/* ==========================================================================
   Hido Coach — member app
   Same lavender/plum system as the site, re-cut for a working dashboard:
   quieter surfaces, tighter rhythm, everything reachable in one screen.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600&family=Inter:wght@300;400;500;600&display=swap');

:root {
  --plum-950: #1B0C27;
  --plum-900: #2A1338;
  --plum-800: #3B1B52;
  --purple-700: #4B2270;
  --purple-600: #572C87;
  --violet-500: #7A4FC0;
  --lavender-500: #9B7FE0;
  --lavender-400: #B39DE8;
  --lavender-300: #CFC0F2;
  --lavender-200: #E2D8F7;
  --lavender-100: #EDE7FA;
  --orchid: #8E3E9E;
  --magenta: #A62E8C;

  --mist: #F8F6FD;
  --paper: #FFFFFF;
  --ink: #241832;
  --ink-2: #4A3A5C;
  --ink-3: #71657F;
  --grey: #8A8894;
  --line: #E8E1F4;

  --good: #2F9E6B;
  --good-bg: #E7F6EE;
  --warn: #B4761B;
  --warn-bg: #FBF1DF;
  --bad: #C0453F;
  --bad-bg: #FBEBEA;

  --display: 'Poppins', 'Century Gothic', 'Avenir Next', sans-serif;
  --body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;
  --rail: 260px;

  --shadow-sm: 0 2px 10px rgba(59, 27, 82, .05);
  --shadow: 0 14px 40px -18px rgba(59, 27, 82, .22);
  --shadow-lg: 0 30px 70px -34px rgba(59, 27, 82, .4);

  --ease: cubic-bezier(.22, .61, .36, 1);
}

/* ------------------------------------------------------------------ reset */

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--body);
  font-size: 15.5px;
  line-height: 1.65;
  color: var(--ink-2);
  background: var(--mist);
  -webkit-font-smoothing: antialiased;
}

img, svg { max-width: 100%; display: block; }

/* Flex/grid display values would otherwise beat the [hidden] attribute. */
[hidden] { display: none !important; }

/* Every icon from App.icon() carries .ico — buttons override the size below. */
.ico { width: 18px; height: 18px; flex: none; }
a { color: var(--purple-600); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 {
  font-family: var(--display);
  color: var(--ink);
  line-height: 1.2;
  margin: 0 0 .5em;
  font-weight: 500;
  letter-spacing: -.015em;
}
h1 { font-size: clamp(1.7rem, 3vw, 2.3rem); }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.08rem; font-weight: 600; }
h4 { font-size: .95rem; font-weight: 600; }
p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }

::selection { background: var(--lavender-300); color: var(--plum-900); }
:focus-visible { outline: 3px solid var(--lavender-500); outline-offset: 2px; border-radius: 6px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ------------------------------------------------------------------ shell */

.app {
  display: grid;
  grid-template-columns: var(--rail) 1fr;
  min-height: 100vh;
}

.rail {
  background: linear-gradient(170deg, var(--plum-900) 0%, var(--plum-800) 55%, var(--purple-700) 100%);
  color: var(--lavender-200);
  padding: 24px 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.rail-logo { padding: 0 6px; }
.rail-logo img { width: 150px; }

.rail-nav { display: flex; flex-direction: column; gap: 2px; }
.rail-group {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .16em;
  color: var(--lavender-400);
  opacity: .75;
  padding: 16px 12px 6px;
}

.rail-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: 11px;
  color: var(--lavender-200);
  font-size: .93rem;
  font-weight: 500;
  border: 0;
  background: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  transition: background .18s var(--ease), color .18s var(--ease);
}
.rail-link:hover { background: rgba(255, 255, 255, .08); color: #fff; text-decoration: none; }
.rail-link.active { background: rgba(255, 255, 255, .14); color: #fff; }
.rail-link svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.rail-link.active svg { opacity: 1; }

.rail-badge {
  margin-left: auto;
  background: var(--lavender-500);
  color: var(--plum-950);
  font-size: .7rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 1px 7px;
  min-width: 20px;
  text-align: center;
}

.rail-foot {
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, .12);
  padding-top: 16px;
  font-size: .8rem;
  color: var(--lavender-300);
}
.rail-foot strong { color: #fff; display: block; font-weight: 600; }
.rail-foot .crisis {
  margin-top: 12px;
  font-size: .74rem;
  line-height: 1.5;
  opacity: .8;
}
.rail-foot .crisis a { color: var(--lavender-200); text-decoration: underline; }

/* ------------------------------------------------------------------- main */

.main { min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px clamp(18px, 3vw, 40px);
  background: rgba(255, 255, 255, .82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar h1 { margin: 0; font-size: 1.25rem; }
.topbar .sub { color: var(--ink-3); font-size: .85rem; margin-left: 2px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.rail-toggle { display: none; }

.view { padding: clamp(20px, 3vw, 34px) clamp(18px, 3vw, 40px) 64px; }
.view > header { margin-bottom: 22px; max-width: 62ch; }
.view > header p { color: var(--ink-3); }

/* ------------------------------------------------------------------ cards */

.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.g4 { grid-template-columns: repeat(auto-fit, minmax(136px, 1fr)); }
.split { display: grid; gap: 18px; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow-sm);
}
.card.pad-lg { padding: 26px 28px; }
.card.flush { padding: 0; overflow: hidden; }
.card-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
}
.card-head h3 { flex: none; }
.card-head h3 { margin: 0; }
.card-head .card-action { margin-left: auto; }

.card-deep {
  background: linear-gradient(150deg, var(--plum-800), var(--purple-700) 70%, var(--violet-500));
  color: var(--lavender-100);
  border: 0;
}
.card-deep h2, .card-deep h3 { color: #fff; }
.card-deep .muted { color: var(--lavender-300); }

.muted { color: var(--ink-3); }
.tiny { font-size: .8rem; }
.mt { margin-top: 14px; }
.mt-lg { margin-top: 26px; }

/* -------------------------------------------------------------- stat tiles */

.stat {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.stat .label {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--ink-3);
  font-weight: 600;
}
.stat .value {
  font-family: var(--display);
  font-size: 1.9rem;
  font-weight: 500;
  color: var(--purple-600);
  line-height: 1.15;
  margin-top: 4px;
}
.stat .value small { font-size: .95rem; color: var(--ink-3); font-weight: 400; }
.stat .foot { font-size: .78rem; color: var(--ink-3); margin-top: 2px; }

/* ---------------------------------------------------------------- controls */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 9px 20px;
  font: 500 .9rem/1.3 var(--body);
  cursor: pointer;
  background: var(--purple-600);
  color: #fff;
  transition: transform .16s var(--ease), box-shadow .16s var(--ease), background .16s var(--ease);
  white-space: nowrap;
}
.btn:hover { background: var(--purple-700); transform: translateY(-1px); box-shadow: var(--shadow); text-decoration: none; }
.btn:active { transform: none; }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn svg { width: 16px; height: 16px; }

.btn-ghost { background: transparent; color: var(--purple-600); border-color: var(--lavender-300); }
.btn-ghost:hover { background: var(--lavender-100); color: var(--purple-700); }
.btn-quiet { background: var(--lavender-100); color: var(--purple-700); }
.btn-quiet:hover { background: var(--lavender-200); }
.btn-sm { padding: 6px 14px; font-size: .82rem; }
.btn-block { width: 100%; }
.btn-danger { background: var(--bad-bg); color: var(--bad); }
.btn-danger:hover { background: #f5d9d7; color: var(--bad); }
.btn-rec { background: var(--bad); color: #fff; }
.btn-rec:hover { background: #a83a35; }

.icon-btn {
  border: 0; background: none; cursor: pointer; color: var(--ink-3);
  padding: 5px; border-radius: 8px; line-height: 0;
}
.icon-btn:hover { background: var(--lavender-100); color: var(--purple-600); }
.icon-btn svg { width: 16px; height: 16px; }

label { display: block; font-weight: 600; font-size: .84rem; color: var(--ink); margin-bottom: 5px; }
label .opt { font-weight: 400; color: var(--ink-3); }

input[type=text], input[type=email], input[type=tel], input[type=password],
input[type=date], input[type=number], select, textarea {
  width: 100%;
  font: 400 .93rem/1.5 var(--body);
  color: var(--ink);
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease);
}
textarea { resize: vertical; min-height: 92px; }
input:focus, select:focus, textarea:focus {
  outline: 0;
  border-color: var(--lavender-500);
  box-shadow: 0 0 0 4px rgba(155, 127, 224, .16);
}
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%2371657F' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  background-size: 11px;
  padding-right: 34px;
}
.field { margin-bottom: 15px; }
.field-row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.err { color: var(--bad); font-size: .8rem; margin-top: 4px; }

.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; font-size: .9rem; color: var(--ink-2); }
.check input { width: 17px; height: 17px; margin: 3px 0 0; accent-color: var(--purple-600); flex: none; }

/* ------------------------------------------------------------------ pills */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: .74rem;
  font-weight: 600;
  letter-spacing: .02em;
  padding: 3px 11px;
  border-radius: 999px;
  background: var(--lavender-100);
  color: var(--purple-700);
  white-space: nowrap;
}
.pill-good { background: var(--good-bg); color: var(--good); }
.pill-warn { background: var(--warn-bg); color: var(--warn); }
.pill-bad { background: var(--bad-bg); color: var(--bad); }
.pill-grey { background: #F0EEF4; color: var(--grey); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1.5px solid var(--line);
  background: var(--paper);
  border-radius: 999px;
  padding: 6px 15px;
  font: 500 .84rem var(--body);
  color: var(--ink-2);
  cursor: pointer;
  transition: all .15s var(--ease);
}
.chip:hover { border-color: var(--lavender-400); color: var(--purple-600); }
.chip.on { background: var(--purple-600); border-color: var(--purple-600); color: #fff; }

/* ------------------------------------------------------------------ lists */

.list { list-style: none; margin: 0; padding: 0; }
.list li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}
.list li:last-child { border-bottom: 0; padding-bottom: 0; }
.list li:first-child { padding-top: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 600; color: var(--ink); display: block; }
.list .meta { font-size: .8rem; color: var(--ink-3); display: block; line-height: 1.5; }

.rows { width: 100%; border-collapse: collapse; font-size: .9rem; }
.rows th {
  text-align: left;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--ink-3);
  padding: 12px 16px;
  background: var(--mist);
  border-bottom: 1px solid var(--line);
  font-weight: 600;
  white-space: nowrap;
}
.rows td { padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.rows tr:last-child td { border-bottom: 0; }
.rows tbody tr:hover { background: var(--mist); }
.table-wrap { overflow-x: auto; }
/* Scroll rather than squash — cramped columns are worse than a scrollbar. */
.table-wrap .rows { min-width: 620px; }

.empty {
  text-align: center;
  padding: 34px 20px;
  color: var(--ink-3);
}
.empty svg { width: 34px; height: 34px; margin: 0 auto 10px; opacity: .35; }

/* ------------------------------------------------------------- goal cards */

.goal { border-left: 4px solid var(--lavender-400); }
.goal.done { border-left-color: var(--good); opacity: .82; }
.goal.paused { border-left-color: var(--grey); opacity: .78; }

.bar {
  height: 8px;
  background: var(--lavender-100);
  border-radius: 999px;
  overflow: hidden;
}
.bar span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--violet-500), var(--lavender-400));
  transition: width .5s var(--ease);
}
.bar.thin { height: 5px; }

.steps { list-style: none; margin: 14px 0 0; padding: 0; }
.steps li {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 6px 0;
  border: 0;
  font-size: .9rem;
}
.steps input { margin-top: 3px; accent-color: var(--purple-600); width: 16px; height: 16px; flex: none; }
.steps .ticked { text-decoration: line-through; color: var(--ink-3); }

/* ------------------------------------------------------------------ board */

.board { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); align-items: start; }
.col {
  background: rgba(255, 255, 255, .6);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}
.col > h4 {
  display: flex; align-items: center; gap: 8px;
  margin: 0 0 12px; font-size: .78rem; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-3);
}
.col > h4 .n { background: var(--lavender-100); color: var(--purple-700); border-radius: 999px; padding: 0 8px; font-size: .74rem; }

.task {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
}
.task:last-child { margin-bottom: 0; }
.task .t { font-weight: 600; color: var(--ink); font-size: .92rem; }
.task .t.done { text-decoration: line-through; color: var(--ink-3); font-weight: 500; }
.task .foot { display: flex; align-items: center; gap: 8px; margin-top: 9px; flex-wrap: wrap; }
.task .foot .btns { margin-left: auto; display: flex; gap: 2px; }
.task.high { border-left: 3px solid var(--bad); }
.task.overdue .due { color: var(--bad); font-weight: 600; }

/* --------------------------------------------------------------- calendar */

.cal-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.cal-head h3 { margin: 0; min-width: 190px; }

.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal .dow {
  text-align: center; font-size: .7rem; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ink-3); padding-bottom: 6px;
}
.day {
  aspect-ratio: 1 / .92;
  border: 1.5px solid var(--line);
  background: var(--paper);
  border-radius: var(--radius-sm);
  padding: 6px;
  font: 500 .82rem var(--body);
  color: var(--ink-3);
  cursor: default;
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: all .15s var(--ease);
}
.day.blank { border: 0; background: none; }
.day.free { cursor: pointer; color: var(--ink); border-color: var(--lavender-300); }
.day.free:hover { border-color: var(--purple-600); background: var(--lavender-100); transform: translateY(-1px); }
.day.sel { background: var(--purple-600); border-color: var(--purple-600); color: #fff; }
.day.sel .dot { background: #fff; }
.day.today { box-shadow: inset 0 0 0 2px var(--lavender-400); }
.day .n { font-weight: 600; }
.day .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--violet-500); }
.day .booked { font-size: .64rem; color: var(--purple-600); font-weight: 600; margin-top: auto; }
.day.sel .booked { color: #fff; }

.slots { display: flex; flex-wrap: wrap; gap: 8px; }

/* ----------------------------------------------------------------- status */

.chart { width: 100%; height: 230px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 12px; font-size: .8rem; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-3); }
.chart-legend i { width: 12px; height: 3px; border-radius: 2px; display: block; }

.scale { display: flex; gap: 4px; }
.scale button {
  flex: 1 1 0;
  min-width: 0;
  padding-inline: 0;
  border: 1.5px solid var(--line);
  background: var(--paper);
  border-radius: 9px;
  padding: 9px 0;
  font: 600 .88rem var(--body);
  color: var(--ink-3);
  cursor: pointer;
  transition: all .14s var(--ease);
}
.scale button:hover { border-color: var(--lavender-400); color: var(--purple-600); }
.scale button.on { background: var(--purple-600); border-color: var(--purple-600); color: #fff; }
.scale-row { margin-bottom: 16px; }
.scale-row .lbl { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.scale-row .lbl b { font-size: .86rem; color: var(--ink); }
.scale-row .lbl .hint { font-size: .76rem; color: var(--ink-3); }

.streak-dots { display: flex; gap: 3px; flex-wrap: wrap; }
.streak-dots i {
  width: 12px; height: 12px; border-radius: 3px; background: var(--lavender-100); display: block;
}
.streak-dots i.l1 { background: var(--lavender-200); }
.streak-dots i.l2 { background: var(--lavender-400); }
.streak-dots i.l3 { background: var(--violet-500); }
.streak-dots i.l4 { background: var(--purple-600); }

/* ------------------------------------------------------------------ notes */

.note-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
}
.note-card .thumb { background: var(--lavender-100); }
.note-card .thumb img { width: 100%; height: 168px; object-fit: cover; }
.note-card .body { padding: 16px 18px; flex: 1; display: flex; flex-direction: column; }
.note-card .body p { font-size: .9rem; }
.note-card .foot { display: flex; align-items: center; gap: 8px; margin-top: auto; padding-top: 12px; }
.note-card audio { width: 100%; margin: 10px 0 4px; height: 38px; }
.transcript {
  background: var(--mist);
  border-left: 3px solid var(--lavender-400);
  border-radius: 0 8px 8px 0;
  padding: 10px 13px;
  font-size: .87rem;
  color: var(--ink-2);
  margin: 10px 0 0;
}

.recorder {
  border: 2px dashed var(--lavender-300);
  border-radius: var(--radius);
  padding: 22px;
  text-align: center;
  background: var(--mist);
  transition: all .2s var(--ease);
}
.recorder.live { border-color: var(--magenta); border-style: solid; background: #fdf4fb; }
.rec-dot {
  width: 12px; height: 12px; border-radius: 50%; background: var(--magenta);
  display: inline-block; margin-right: 8px; animation: pulse 1.3s infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .4; transform: scale(.8); } }
.rec-time { font-family: var(--display); font-size: 1.5rem; color: var(--purple-600); font-weight: 500; }
.wave { display: flex; align-items: center; justify-content: center; gap: 3px; height: 34px; margin: 10px 0; }
.wave i {
  width: 3px; background: var(--lavender-400); border-radius: 2px; height: 6px; display: block;
  transition: height .1s linear;
}

.drop {
  border: 2px dashed var(--lavender-300);
  border-radius: var(--radius);
  padding: 26px;
  text-align: center;
  background: var(--mist);
  cursor: pointer;
  transition: all .18s var(--ease);
}
.drop:hover, .drop.over { border-color: var(--purple-600); background: var(--lavender-100); }
.drop svg { width: 30px; height: 30px; margin: 0 auto 8px; color: var(--lavender-500); }

/* -------------------------------------------------------------- checklist */

.chk-section { margin-bottom: 24px; }
.chk-section > h3 { display: flex; align-items: center; gap: 10px; }
.chk-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
  margin-bottom: 8px;
  transition: all .15s var(--ease);
}
.chk-item:hover { border-color: var(--lavender-300); }
.chk-item.on { background: var(--mist); border-color: var(--lavender-200); }
.chk-item.on .lbl { color: var(--ink-3); text-decoration: line-through; }
.chk-item input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--purple-600); flex: none; cursor: pointer; }
.chk-item .lbl { flex: 1; font-size: .92rem; color: var(--ink); }
.chk-item .when { font-size: .75rem; color: var(--ink-3); white-space: nowrap; }

/* ----------------------------------------------------------------- thread */

.thread { display: flex; flex-direction: column; gap: 12px; max-height: 480px; overflow-y: auto; padding-right: 4px; }
.msg { max-width: 78%; }
.msg .bubble {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: .92rem;
  background: var(--lavender-100);
  color: var(--ink);
  border-bottom-left-radius: 5px;
}
.msg .who { font-size: .74rem; color: var(--ink-3); margin: 4px 0 0 4px; }
.msg.me { align-self: flex-end; }
.msg.me .bubble {
  background: var(--purple-600);
  color: #fff;
  border-bottom-left-radius: 16px;
  border-bottom-right-radius: 5px;
}
.msg.me .who { text-align: right; margin-right: 4px; }

/* ------------------------------------------------------------------ misc */

.timeline { position: relative; padding-left: 26px; }
.timeline::before {
  content: ''; position: absolute; left: 6px; top: 6px; bottom: 6px;
  width: 2px; background: var(--lavender-200);
}
.timeline .ev { position: relative; padding-bottom: 22px; }
.timeline .ev:last-child { padding-bottom: 0; }
.timeline .ev::before {
  content: ''; position: absolute; left: -26px; top: 5px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--paper); border: 2.5px solid var(--lavender-500);
}
.timeline .ev.now::before { background: var(--purple-600); border-color: var(--purple-600); }
.timeline .when { font-size: .76rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: .07em; font-weight: 600; }

.ai-out {
  background: linear-gradient(135deg, var(--lavender-100), var(--mist));
  border: 1px solid var(--lavender-200);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-top: 14px;
}
.ai-out h4 { margin-bottom: 6px; }
.ai-tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .7rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  color: var(--violet-500); margin-bottom: 8px;
}

.avatar {
  width: 42px; height: 42px; border-radius: 50%; flex: none;
  background: linear-gradient(140deg, var(--violet-500), var(--lavender-400));
  color: #fff; display: grid; place-items: center;
  font: 600 .95rem var(--display); letter-spacing: .02em;
}
.avatar.lg { width: 62px; height: 62px; font-size: 1.3rem; }

/* ------------------------------------------------------------------ modal */

.modal-bg {
  position: fixed; inset: 0; background: rgba(27, 12, 39, .55);
  backdrop-filter: blur(4px); z-index: 90;
  display: grid; place-items: center; padding: 20px;
  animation: fade .2s var(--ease);
}
.modal {
  background: var(--paper); border-radius: var(--radius-lg);
  width: min(100%, 560px); max-height: 88vh; overflow-y: auto;
  box-shadow: var(--shadow-lg); animation: rise .26s var(--ease);
}
.modal.wide { width: min(100%, 820px); }
.modal-head {
  display: flex; align-items: center; gap: 14px;
  padding: 20px 24px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--paper); z-index: 2;
}
.modal-head h3 { margin: 0; }
.modal-head .icon-btn { margin-left: auto; }
.modal-body { padding: 22px 24px; }
.modal-foot {
  display: flex; gap: 10px; justify-content: flex-end;
  padding: 16px 24px; border-top: 1px solid var(--line);
  background: var(--mist);
}
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.985); } }

.toast-wrap { position: fixed; bottom: 22px; right: 22px; z-index: 120; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--plum-900); color: #fff;
  padding: 12px 18px; border-radius: 12px;
  box-shadow: var(--shadow-lg); font-size: .9rem;
  animation: rise .24s var(--ease);
  max-width: 340px;
}
.toast.bad { background: var(--bad); }
.toast.good { background: var(--good); }

.loading { text-align: center; padding: 60px 20px; color: var(--ink-3); }
.spin {
  width: 26px; height: 26px; margin: 0 auto 12px;
  border: 3px solid var(--lavender-200); border-top-color: var(--purple-600);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ login */

.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.auth-art {
  background: linear-gradient(160deg, var(--plum-950), var(--plum-800) 45%, var(--orchid) 130%);
  color: var(--lavender-100);
  padding: clamp(34px, 5vw, 70px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.auth-art > * { position: relative; z-index: 2; }
.auth-art h2 { color: #fff; font-size: clamp(1.7rem, 3vw, 2.5rem); max-width: 14ch; }
.auth-art .glow {
  position: absolute; border-radius: 50%; filter: blur(80px); opacity: .5; z-index: 1;
}
.auth-art .glow.a { width: 420px; height: 420px; background: var(--magenta); top: -110px; right: -110px; }
.auth-art .glow.b { width: 380px; height: 380px; background: var(--violet-500); bottom: -120px; left: -90px; }
.auth-art img { width: 170px; }
.auth-form {
  display: grid;
  place-items: center;
  padding: clamp(28px, 5vw, 60px);
  background: var(--paper);
}
.auth-form .inner { width: min(100%, 380px); }

.demo-box {
  background: var(--mist);
  border: 1px dashed var(--lavender-300);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: .84rem;
  margin-top: 22px;
}
.demo-box button {
  border: 0; background: none; padding: 0; cursor: pointer;
  color: var(--purple-600); font: 600 .84rem var(--body); text-decoration: underline;
}

/* ------------------------------------------------------------- responsive */

@media (max-width: 1080px) {
  .split { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .rail {
    position: fixed; inset: 0 auto 0 0; width: 268px; z-index: 60;
    transform: translateX(-100%); transition: transform .28s var(--ease);
  }
  body.rail-open .rail { transform: none; box-shadow: var(--shadow-lg); }
  body.rail-open::after {
    content: ''; position: fixed; inset: 0; background: rgba(27, 12, 39, .5); z-index: 50;
  }
  .rail-toggle { display: inline-flex; }
  .auth { grid-template-columns: 1fr; }
  .auth-art { display: none; }
}

@media (max-width: 560px) {
  .topbar h1 { font-size: 1.05rem; }
  .topbar .sub { display: none; }
  .card { padding: 16px 17px; }
  .modal-foot { flex-direction: column-reverse; }
  .modal-foot .btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

@media print {
  .rail, .topbar-actions, .btn, .icon-btn { display: none !important; }
  .app { grid-template-columns: 1fr; }
  .card { break-inside: avoid; box-shadow: none; }
}
