/* ============================================================
   CATO — Messages
   An iMessage-shaped client for the tool server. Light and dark,
   iOS on a phone, macOS Messages on a desktop.
   ============================================================ */

:root {
  /* --- surfaces --- */
  --bg:            #FFFFFF;
  --sidebar:       #F7F7F7;
  --sidebar-hover: #EDEDED;
  --raised:        #F2F2F7;
  --line:          #D8D8DC;
  --line-soft:     #E5E5EA;

  /* --- text --- */
  --text:          #000000;
  --muted:         #8E8E93;
  --faint:         #AEAEB2;

  /* --- bubbles --- */
  --sent:          #248BF5;
  --sent-text:     #FFFFFF;
  --received:      #E9E9EB;
  --received-text: #000000;

  /* --- system --- */
  --blue:          #007AFF;
  --green:         #34C759;
  --amber:         #FF9F0A;
  --red:           #FF3B30;
  --selected:      #007AFF;
  --selected-text: #FFFFFF;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

  --r-bubble:  18px;
  --r-card:    14px;
  --r-field:   17px;
  --sidebar-w: 302px;
  --info-w:    268px;
  --ease:      220ms cubic-bezier(.32, .72, 0, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg:            #000000;
    --sidebar:       #1C1C1E;
    --sidebar-hover: #2C2C2E;
    --raised:        #1C1C1E;
    --line:          #38383A;
    --line-soft:     #2C2C2E;
    --text:          #FFFFFF;
    --muted:         #98989F;
    --faint:         #636366;
    --received:      #26262A;
    --received-text: #FFFFFF;
    --blue:          #0A84FF;
    --green:         #30D158;
    --amber:         #FF9F0A;
    --red:           #FF453A;
    --selected:      #0A84FF;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
button { font-family: inherit; }
.sr {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
:where(button, a, input, textarea):focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

/* ============================================================
   SHELL
   ============================================================ */

.app { display: flex; height: 100dvh; }

/* --- conversation list ------------------------------------- */
.list {
  flex: 0 0 var(--sidebar-w);
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.list__top {
  padding: 12px 14px 8px;
  border-bottom: 1px solid var(--line-soft);
}
.list__title {
  font-size: 24px; font-weight: 700; letter-spacing: -.4px;
  margin: 2px 0 10px;
}
.search {
  width: 100%; border: 0; border-radius: 9px;
  background: rgba(120, 120, 128, .12);
  color: var(--text); font: inherit; font-size: 13px;
  padding: 7px 10px 7px 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238E8E93' stroke-width='2.4' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.6-3.6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 8px center;
  background-size: 14px 14px;
}
.search::placeholder { color: var(--muted); }
.search:focus { outline: none; background-color: rgba(120, 120, 128, .18); }

.rows { flex: 1; overflow-y: auto; padding: 4px 8px; }

.row {
  display: flex; gap: 10px; align-items: flex-start;
  width: 100%; text-align: left;
  padding: 9px 8px; border: 0; border-radius: 10px;
  background: transparent; color: inherit; cursor: pointer;
  min-height: 60px;
}
.row:hover { background: var(--sidebar-hover); }
.row[aria-current="page"] { background: var(--selected); }
.row[aria-current="page"] .row__name,
.row[aria-current="page"] .row__preview,
.row[aria-current="page"] .row__time { color: var(--selected-text); }
.row[aria-current="page"] .row__preview { opacity: .85; }

.avatar {
  flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 15px; font-weight: 500; color: #fff;
  background: linear-gradient(180deg, #B0B3B8, #8E9196);
  user-select: none;
}
.avatar--sm { width: 26px; height: 26px; font-size: 11px; }

.row__body { flex: 1; min-width: 0; }
.row__line { display: flex; align-items: baseline; gap: 6px; }
.row__name { font-size: 14px; font-weight: 600; letter-spacing: -.1px; flex: 1;
             overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row__time { font-size: 11.5px; color: var(--muted); flex: 0 0 auto; }
.row__preview {
  font-size: 13px; color: var(--muted); margin-top: 1px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.row__dot {
  flex: 0 0 auto; width: 9px; height: 9px; border-radius: 50%;
  background: var(--blue); align-self: center;
}

/* --- list footer: the meter and the clocks ------------------ */
.list__foot { border-top: 1px solid var(--line-soft); padding: 10px 14px 12px; }
.clock { margin-bottom: 9px; }
.clock__line {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 11px; margin-bottom: 4px;
}
.clock__name { font-weight: 600; letter-spacing: .04em; }
.clock__cap { color: var(--muted); font-family: var(--font-mono);
              font-variant-numeric: tabular-nums; font-size: 10.5px; }
.track { height: 4px; border-radius: 999px; background: rgba(120,120,128,.2); overflow: hidden; }
.track__fill { height: 100%; width: 0; background: var(--blue); border-radius: 999px;
               transition: width var(--ease); }
.clock--starved .track__fill { background: var(--amber); }
.meter__fill--warn { background: var(--amber) !important; }
.meter__fill--bad  { background: var(--red) !important; }

/* ============================================================
   THREAD
   ============================================================ */

.thread-pane { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg); }

.navbar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 14px; min-height: 52px;
  border-bottom: 1px solid var(--line-soft);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  position: sticky; top: 0; z-index: 5;
}
.navbar__back {
  display: none; align-items: center; gap: 2px;
  background: none; border: 0; color: var(--blue); cursor: pointer;
  font-size: 17px; padding: 4px 6px 4px 0; margin-left: -6px;
}
.navbar__id { flex: 1; min-width: 0; display: flex; align-items: center; gap: 9px; }
.navbar__name { font-size: 15px; font-weight: 600; letter-spacing: -.2px; }
.navbar__sub {
  font-size: 12px; color: var(--muted); font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.iconbtn {
  flex: 0 0 auto; width: 30px; height: 30px; border-radius: 50%;
  border: 0; background: transparent; color: var(--blue);
  display: grid; place-items: center; cursor: pointer;
}
.iconbtn:hover { background: rgba(120,120,128,.14); }
.iconbtn[aria-pressed="true"] { background: rgba(120,120,128,.2); }

.thread {
  flex: 1; overflow-y: auto; overscroll-behavior: contain;
  padding: 14px 16px 8px;
  display: flex; flex-direction: column;
}
.thread > * { flex: 0 0 auto; }   /* nothing in a thread is allowed to squash */

/* --- separators and system notices -------------------------- */
.sep {
  align-self: center; margin: 14px 0 8px;
  font-size: 11px; color: var(--muted);
}
.sep b { font-weight: 600; color: var(--muted); }
.sys { align-self: center; margin: 6px 0; font-size: 12px; color: var(--muted); text-align: center; }

/* --- message groups ----------------------------------------- */
.group { display: flex; flex-direction: column; margin-top: 8px; }
.group + .group { margin-top: 10px; }
.group--out { align-items: flex-end; }
.group--in  { align-items: flex-start; }
.group--tight { margin-top: 2px; }

.bubble {
  position: relative;
  max-width: min(65ch, 72%);
  padding: 7px 13px 8px;
  border-radius: var(--r-bubble);
  font-size: 15px; line-height: 1.3;
  white-space: pre-wrap; overflow-wrap: anywhere;
  margin-bottom: 2px;
}
.group--out .bubble { background: var(--sent); color: var(--sent-text); }
.group--in  .bubble { background: var(--received); color: var(--received-text); }

/* the tail, drawn only on the last bubble of a run */
.bubble--tail::before,
.bubble--tail::after { content: ""; position: absolute; bottom: 0; height: 20px; }
.group--out .bubble--tail::before {
  right: -7px; width: 20px;
  background: var(--sent);
  border-bottom-left-radius: 16px;
}
.group--out .bubble--tail::after {
  right: -20px; width: 20px;
  background: var(--bg);
  border-bottom-left-radius: 12px;
}
.group--in .bubble--tail::before {
  left: -7px; width: 20px;
  background: var(--received);
  border-bottom-right-radius: 16px;
}
.group--in .bubble--tail::after {
  left: -20px; width: 20px;
  background: var(--bg);
  border-bottom-right-radius: 12px;
}

.bubble code {
  font-family: var(--font-mono); font-size: 13px;
  background: rgba(120,120,128,.2); padding: 1px 4px; border-radius: 4px;
}
.group--out .bubble code { background: rgba(255,255,255,.22); }

.receipt {
  font-size: 11px; color: var(--muted); margin: 1px 2px 0;
  font-variant-numeric: tabular-nums;
}
.receipt b { font-weight: 600; }

/* --- typing indicator --------------------------------------- */
.typing {
  display: inline-flex; gap: 5px; align-items: center;
  padding: 12px 15px; border-radius: var(--r-bubble);
  background: var(--received);
}
.typing i {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--muted); display: block;
  animation: blip 1.4s infinite ease-in-out;
}
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blip {
  0%, 60%, 100% { opacity: .35; transform: translateY(0); }
  30%           { opacity: 1;   transform: translateY(-3px); }
}

/* --- tool calls: quiet attachment rows ---------------------- */
.tool {
  align-self: flex-start; max-width: 72%;
  display: block; width: auto; text-align: left;
  background: none; border: 0; cursor: pointer;
  color: var(--muted); font-size: 12px;
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  padding: 3px 4px; margin: 1px 0 2px 6px;
}
.tool__glyph { color: var(--blue); }
.tool--ok .tool__glyph { color: var(--green); }
.tool--fail .tool__glyph { color: var(--red); }
.tool__panel {
  align-self: flex-start; max-width: 72%;
  background: var(--raised); border: 1px solid var(--line-soft);
  border-radius: 10px; padding: 9px 11px; margin: 0 0 4px 6px;
  font-family: var(--font-mono); font-size: 11.5px; color: var(--text);
  max-height: 240px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere;
}
.cite {
  align-self: flex-start; margin: 0 0 2px 8px;
  font-size: 11px; color: var(--muted);
}
.mem {
  align-self: flex-start; margin: 1px 0 2px 6px;
  background: none; border: 0; padding: 2px 4px; cursor: pointer;
  font-size: 11.5px; color: var(--muted); text-align: left;
}
.mem:hover { color: var(--blue); }
.cost { align-self: flex-start; margin: 0 0 2px 8px; font-size: 10.5px; color: var(--faint);
        font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.group--out .cost, .group--out .receipt { align-self: flex-end; }

/* --- the confirmation gate, as an app card ------------------ */
.gate {
  align-self: flex-start; width: min(340px, 82%);
  background: var(--raised); border: 1px solid var(--line-soft);
  border-radius: var(--r-card); overflow: hidden; margin: 4px 0 6px;
}
.gate__head {
  padding: 9px 14px; font-size: 11px; font-weight: 600; letter-spacing: .04em;
  color: var(--amber); border-bottom: 1px solid var(--line-soft);
  text-transform: uppercase;
}
.gate__body { padding: 11px 14px 12px; }
.gate__tool { font-size: 16px; font-weight: 600; letter-spacing: -.2px; }
.gate__sum  { font-size: 13px; color: var(--muted); margin-top: 2px; }
.gate__amount { font-size: 26px; font-weight: 600; font-family: var(--font-mono);
                font-variant-numeric: tabular-nums; margin-top: 6px; }
.gate__disclose {
  background: none; border: 0; padding: 8px 0 2px; cursor: pointer;
  color: var(--blue); font-size: 13px; display: block;
}
.gate__row { display: flex; border-top: 1px solid var(--line-soft); }
.gate__row .btn { flex: 1; }
.btn {
  border: 0; background: none; cursor: pointer;
  padding: 12px 10px; font-size: 15px; color: var(--blue);
  min-height: 44px;
}
.btn + .btn { border-left: 1px solid var(--line-soft); }
.btn--go { font-weight: 600; }
.gate__done { padding: 10px 14px; font-size: 12px; color: var(--muted); }

/* --- the briefings, as a plain card ------------------------- */
.brief {
  align-self: stretch; max-width: 100%;
  background: var(--raised); border: 1px solid var(--line-soft);
  border-radius: var(--r-card); padding: 12px 14px; margin: 8px 0;
  font-family: var(--font-mono); font-size: 12px; line-height: 1.55;
  white-space: pre; overflow-x: auto; font-variant-numeric: tabular-nums;
}
.err { border: 1px solid var(--red); background: transparent; color: var(--text); }

/* ============================================================
   COMPOSER
   ============================================================ */

.composer {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 8px 12px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line-soft);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
}
.composer__plus {
  flex: 0 0 auto; width: 30px; height: 30px; border-radius: 50%;
  border: 0; background: rgba(120,120,128,.14); color: var(--muted);
  display: grid; place-items: center; cursor: pointer;
}
.composer__plus:hover { color: var(--blue); }
.field {
  flex: 1; display: flex; align-items: flex-end; gap: 6px;
  border: 1px solid var(--line); border-radius: var(--r-field);
  background: var(--bg); padding: 4px 4px 4px 12px; min-height: 34px;
}
.composer__input {
  flex: 1; border: 0; background: none; color: var(--text);
  font: inherit; font-size: 16px;   /* 16px or iOS zooms on focus */
  line-height: 1.3; resize: none; padding: 5px 0 6px;
  max-height: 140px; overflow-y: auto;
}
.composer__input::placeholder { color: var(--muted); }
.composer__input:focus { outline: none; }
.composer__send {
  flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%;
  border: 0; background: var(--sent); color: #fff;
  display: grid; place-items: center; cursor: pointer;
  transition: opacity var(--ease), transform var(--ease);
}
.composer__send:disabled {
  background: rgba(120,120,128,.28); color: rgba(255,255,255,.75);
  cursor: default; transform: scale(.94);
}
.capnote { padding: 0 16px 6px; font-size: 12px; color: var(--muted); }

/* ============================================================
   INFO PANEL
   ============================================================ */

.info {
  flex: 0 0 var(--info-w);
  border-left: 1px solid var(--line);
  background: var(--sidebar);
  overflow-y: auto; padding: 16px 16px 24px;
}
.info[hidden] { display: none; }
.info__title { font-size: 12px; font-weight: 600; color: var(--muted);
               letter-spacing: .05em; text-transform: uppercase; margin: 18px 0 8px; }
.info__title:first-child { margin-top: 0; }
.info__hero { display: flex; flex-direction: column; align-items: center; gap: 8px;
              padding: 4px 0 14px; border-bottom: 1px solid var(--line-soft); }
.info__hero .avatar { width: 64px; height: 64px; font-size: 24px; }
.info__name { font-size: 17px; font-weight: 600; }
.info__blurb { font-size: 12.5px; color: var(--muted); text-align: center; }

.stat { display: flex; justify-content: space-between; align-items: baseline;
        padding: 7px 0; border-bottom: 1px solid var(--line-soft); }
.stat__label { font-size: 12px; color: var(--muted); }
.stat__value { font-size: 15px; font-weight: 600; font-family: var(--font-mono);
               font-variant-numeric: tabular-nums; }
.stat--ok   .stat__value { color: var(--green); }
.stat--warn .stat__value { color: var(--amber); }
.stat--bad  .stat__value { color: var(--red); }

.fact { display: flex; gap: 8px; align-items: flex-start; padding: 8px 0;
        border-bottom: 1px solid var(--line-soft); font-size: 13px; line-height: 1.35; }
.fact__body { flex: 1; min-width: 0; }
.fact__key { font-size: 11px; color: var(--muted); }
.fact__drop { background: none; border: 0; color: var(--faint); cursor: pointer;
              font-size: 14px; padding: 0 2px; }
.fact__drop:hover { color: var(--red); }
.info__empty { font-size: 13px; color: var(--muted); }

/* ============================================================
   STRIPS, TOASTS, UNLOCK
   ============================================================ */

.strip {
  padding: 6px 14px; font-size: 12px; text-align: center;
  background: var(--amber); color: #000;
}
.strip--bad { background: var(--red); color: #fff; }

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: rgba(60, 60, 67, .92); color: #fff; border-radius: 20px;
  font-size: 13px; padding: 8px 16px; z-index: 30;
  opacity: 0; transition: opacity var(--ease); pointer-events: none;
}
@media (prefers-color-scheme: dark) { .toast { background: rgba(230,230,235,.9); color: #000; } }
.toast--on { opacity: 1; }

.unlock { display: grid; place-items: center; height: 100dvh; padding: 20px; background: var(--bg); }
.unlock form { width: min(300px, 100%); display: flex; flex-direction: column;
               gap: 10px; align-items: stretch; text-align: center; }
.unlock .avatar { width: 64px; height: 64px; font-size: 26px; margin: 0 auto 4px;
                  background: linear-gradient(180deg, #4FB3F9, #1E7EF7); }
.unlock h1 { font-size: 20px; font-weight: 600; margin: 0; }
.unlock p { font-size: 13px; color: var(--muted); margin: -4px 0 6px; }
.unlock input {
  font-size: 16px; padding: 11px 13px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text);
}
.unlock button {
  font-size: 16px; padding: 12px; border-radius: 10px; border: 0;
  background: var(--sent); color: #fff; cursor: pointer; min-height: 44px;
}
.unlock__err { font-size: 13px; color: var(--red); min-height: 18px; }

/* ============================================================
   MOBILE — the list and the thread are two screens
   ============================================================ */

@media (max-width: 768px) {
  :root { --sidebar-w: 100%; }
  .app { position: relative; overflow: hidden; }
  .list {
    position: absolute; inset: 0; z-index: 2; border-right: 0;
    transition: transform var(--ease);
  }
  .thread-pane {
    position: absolute; inset: 0; z-index: 3;
    transform: translateX(100%); transition: transform var(--ease);
  }
  .app[data-view="thread"] .list { transform: translateX(-24%); }
  .app[data-view="thread"] .thread-pane { transform: translateX(0); }
  .navbar__back { display: inline-flex; }
  .info {
    position: absolute; inset: 0; z-index: 4; flex: 1 1 auto;
    border-left: 0;
  }
  .bubble { max-width: 78%; }
  .list__top { padding-top: max(12px, env(safe-area-inset-top)); }
  .navbar { padding-top: max(8px, env(safe-area-inset-top)); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ============================================================
   APP DRAWER — the sheet behind the + button
   Messages puts its apps here; Cato puts the four things that
   would otherwise be a sentence: a mark, homework, the week,
   what is due.
   ============================================================ */

.sheet {
  border-top: 1px solid var(--line-soft);
  background: var(--sidebar);
  max-height: min(62vh, 520px);
  overflow-y: auto;
  padding: 12px 14px 14px;
}
.sheet[hidden] { display: none; }

.sheet__head {
  display: flex; align-items: center; gap: 10px; margin-bottom: 10px;
}
.sheet__title { font-size: 15px; font-weight: 600; flex: 1; }
.sheet__back, .sheet__close {
  background: none; border: 0; color: var(--blue); font-size: 14px;
  cursor: pointer; padding: 6px 4px; min-height: 32px;
}

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 10px; }
.tile {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: var(--bg); border: 1px solid var(--line-soft); border-radius: 14px;
  padding: 12px 8px; cursor: pointer; color: var(--text); font-size: 12px;
  min-height: 76px; justify-content: center;
}
.tile:hover { border-color: var(--blue); }
.tile__glyph {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  color: #fff; font-size: 15px; font-weight: 600;
}

.field-label {
  font-size: 11px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .05em; margin: 12px 0 6px;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line); background: var(--bg); color: var(--text);
  border-radius: 999px; padding: 7px 12px; font-size: 13px; cursor: pointer;
  min-height: 34px;
}
.chip[aria-pressed="true"] { background: var(--sent); border-color: transparent; color: #fff; }

/* the 0–15 pad. Colour carries the same meaning as the number, never alone. */
.pad { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.pad button {
  border: 0; border-radius: 10px; padding: 11px 0; font-size: 15px; font-weight: 600;
  color: #fff; cursor: pointer; font-variant-numeric: tabular-nums; min-height: 40px;
}
.pad button[aria-pressed="true"] { outline: 3px solid var(--text); outline-offset: 1px; }
.pad--0  { background: #D0463C; }
.pad--4  { background: #E07B2F; }
.pad--7  { background: #C9A227; }
.pad--10 { background: #3E9E63; }
.pad--13 { background: #2E8B57; }

.sheet__note {
  font-size: 12.5px; color: var(--muted); margin-top: 10px; line-height: 1.4;
  min-height: 18px;
}
.sheet__input {
  width: 100%; font-size: 16px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text);
}
.sheet__row { display: flex; gap: 8px; margin-top: 12px; }
.sheet__go {
  flex: 1; border: 0; border-radius: 11px; background: var(--sent); color: #fff;
  font-size: 15px; font-weight: 600; padding: 12px; cursor: pointer; min-height: 44px;
}
.sheet__go:disabled { background: rgba(120,120,128,.28); cursor: default; }

/* --- rich cards in the thread ------------------------------------- */
.card {
  align-self: flex-start; width: min(360px, 84%);
  background: var(--raised); border: 1px solid var(--line-soft);
  border-radius: var(--r-card); margin: 4px 0 6px; overflow: hidden;
}
.card--wide { width: min(460px, 92%); }
.card__head {
  display: flex; align-items: baseline; gap: 8px;
  padding: 10px 14px 8px; border-bottom: 1px solid var(--line-soft);
}
.card__title { font-size: 14px; font-weight: 600; flex: 1; }
.card__sub { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.card__body { padding: 4px 0; }
.card__row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px; border-bottom: 1px solid var(--line-soft); font-size: 13.5px;
}
.card__row:last-child { border-bottom: 0; }
.card__row b { font-weight: 600; }
.card__grow { flex: 1; min-width: 0; }
.card__num {
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-size: 15px; font-weight: 600;
}
.card__meta { font-size: 11.5px; color: var(--muted); }
.card__foot { padding: 9px 14px; font-size: 12px; color: var(--muted);
              border-top: 1px solid var(--line-soft); }

.tick {
  width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--muted);
  background: none; cursor: pointer; display: grid; place-items: center;
  color: transparent; font-size: 12px; flex: 0 0 auto;
}
.tick:hover { border-color: var(--blue); }
.tick[aria-pressed="true"] { background: var(--green); border-color: var(--green); color: #fff; }
.done { text-decoration: line-through; color: var(--muted); }

.pill {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: rgba(120,120,128,.16); color: var(--muted);
}
.pill--bad { background: rgba(255,59,48,.16); color: var(--red); }
.pill--warn { background: rgba(255,159,10,.18); color: var(--amber); }
.pill--ok { background: rgba(52,199,89,.16); color: var(--green); }

.sparks { display: inline-flex; gap: 2px; align-items: flex-end; height: 16px; }
.sparks i { width: 4px; border-radius: 1px; background: var(--blue); display: block; }

.grid-week { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.grid-week th {
  text-align: left; font-weight: 600; color: var(--muted); font-size: 11px;
  text-transform: uppercase; letter-spacing: .04em; padding: 6px 14px 4px;
}
.grid-week td { padding: 5px 14px; border-top: 1px solid var(--line-soft); }
.grid-week td.at { font-family: var(--font-mono); color: var(--muted); width: 52px; }

/* ============================================================
   FORMATTED MESSAGES
   The model writes light markdown; a bubble shows it as a list,
   a table or a bold word — never as asterisks.
   ============================================================ */

.bubble--rich { white-space: normal; }
.bubble--rich > :first-child { margin-top: 0; }
.bubble--rich > :last-child { margin-bottom: 0; }

.md-p { margin: 0 0 7px; }
.md-head { font-weight: 600; }
.md-list { margin: 0 0 7px; padding-left: 18px; }
.md-list li { margin: 2px 0; }
.md-list li::marker { color: var(--muted); }
.group--out .md-list li::marker { color: rgba(255,255,255,.65); }

.md-pre {
  margin: 6px 0; padding: 9px 11px; border-radius: 10px;
  background: rgba(120,120,128,.16);
  font-family: var(--font-mono); font-size: 12.5px; line-height: 1.45;
  overflow-x: auto; white-space: pre;
}
.group--out .md-pre { background: rgba(255,255,255,.16); }

.md-quote {
  margin: 6px 0; padding: 2px 0 2px 10px;
  border-left: 2px solid var(--muted); color: var(--muted);
}
.md-rule { border: 0; border-top: 1px solid var(--line); margin: 9px 0; }

.md-table {
  border-collapse: collapse; margin: 6px 0; font-size: 13.5px;
  font-variant-numeric: tabular-nums;
}
.md-table th, .md-table td { padding: 3px 12px 3px 0; text-align: left; }
.md-table th { font-weight: 600; color: var(--muted); font-size: 12px; }
.md-table td:not(:first-child), .md-table th:not(:first-child) {
  font-family: var(--font-mono); font-size: 12.5px;
}
.md-table tr + tr td { border-top: 1px solid var(--line-soft); }
.group--out .md-table tr + tr td { border-top-color: rgba(255,255,255,.2); }

.bubble--rich a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.group--in .bubble--rich a { color: var(--blue); }

/* ============================================================
   AN EMPTY CHAT
   Not "no messages" — what this chat is for, and the two things
   worth trying, as buttons.
   ============================================================ */

.opener {
  align-self: center; max-width: 420px; text-align: center;
  padding: 40px 10px 10px;
}
.opener__line { font-size: 15px; line-height: 1.45; }
.opener__hint { font-size: 12.5px; color: var(--muted); margin: 6px 0 14px; }
.opener .chips { justify-content: center; }
.opener .chip { font-family: var(--font-mono); font-size: 12.5px; }

.unlock__link {
  background: none; border: 0; color: var(--blue); font-size: 13px;
  cursor: pointer; padding: 8px; min-height: 36px;
}
.unlock input[hidden] { display: none; }

/* ============================================================
   WHAT MOVED, AND WHAT IS NEXT
   ============================================================ */

.changed {
  align-self: stretch; display: flex; flex-wrap: wrap; gap: 4px 14px;
  align-items: baseline; margin: 10px 0 4px; padding: 9px 12px;
  border-radius: 12px; background: rgba(120,128,160,.10);
  font-size: 12.5px;
}
.changed__tag {
  font-size: 11px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em;
}
.changed__item { font-variant-numeric: tabular-nums; }
.changed__label { color: var(--muted); }
.changed__from { color: var(--faint); }
.changed__to { font-family: var(--font-mono); }
.changed__to--ok { color: var(--green); }
.changed__to--warn { color: var(--amber); }
.changed__to--bad { color: var(--red); }

.suggest {
  display: flex; gap: 7px; padding: 8px 12px 2px;
  overflow-x: auto; scrollbar-width: none;
}
.suggest::-webkit-scrollbar { display: none; }
.suggest[hidden] { display: none; }
.chip--suggest {
  flex: 0 0 auto; display: inline-flex; align-items: baseline; gap: 6px;
  font-size: 13px; padding: 7px 13px;
}
.chip__why { font-size: 11px; color: var(--muted); }
.chip--suggest:hover { border-color: var(--blue); color: var(--blue); }
.chip--suggest:hover .chip__why { color: var(--blue); opacity: .8; }
