:root {
  --bg: #f7f5f1; --surface: #ffffff; --text: #1f2937; --muted: #6b7280; --border: #e5e1d8;
  --accent: #4f46e5; --accent-text: #ffffff; --user: #e0e7ff; --bot: #f1efe9; --error: #b91c1c;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1320; --surface: #181d2e; --text: #e5e7eb; --muted: #9ca3af; --border: #2a3147;
    --accent: #818cf8; --accent-text: #0f1320; --user: #2a3170; --bot: #212840; --error: #f87171;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-text-size-adjust: 100%; }
h1, h2 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.4rem; } h2 { font-size: 1.05rem; margin-bottom: 8px; }
.muted { color: var(--muted); margin: 2px 0 0; font-size: .9rem; }
.error { color: var(--error); min-height: 1.2em; margin: 0; font-size: .9rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.screen { min-height: 100dvh; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin: 12px 16px; }
.login-card { max-width: 380px; margin: 12vh auto 0; display: grid; gap: 14px; }
label { display: grid; gap: 4px; font-size: .9rem; color: var(--muted); }
input, textarea, select { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
button { font: inherit; cursor: pointer; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 9px 14px; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; font-weight: 600; }
button.ghost { background: transparent; color: var(--muted); }
button:disabled { opacity: .55; cursor: default; }
.topbar { display: flex; justify-content: space-between; align-items: flex-start; padding: calc(12px + env(safe-area-inset-top)) 16px 4px; position: sticky; top: 0; background: var(--bg); z-index: 5; }
#main { padding-bottom: calc(var(--dock-h, 170px) + 24px); }
.thread { display: grid; gap: 8px; padding: 4px 16px; }
:root { --companion-avatar: url('/avatars/bryn.svg'); }
.bubble { position: relative; max-width: 85%; padding: 10px 14px; border-radius: 18px; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble.user { justify-self: end; background: var(--user); }
.bubble.user.last { border-bottom-right-radius: 6px; }
.bubble.assistant { justify-self: start; background: var(--bot); margin-left: 38px; }
.bubble.assistant.last { border-bottom-left-radius: 6px; }
.bubble.assistant.last::before { content: ""; position: absolute; left: -38px; bottom: 0; width: 28px; height: 28px; border-radius: 50%; background: var(--companion-avatar) center / cover; }
.bubble.cont { margin-top: -6px; }
.bubble.has-reaction { margin-bottom: 14px; }
.bubble .reaction { position: absolute; bottom: -13px; right: 8px; font-size: .95rem; line-height: 1; padding: 2px 5px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); box-shadow: 0 1px 3px rgba(0, 0, 0, .2); }
.bubble.assistant .reaction { right: auto; left: 8px; }
.time-sep { justify-self: center; font-size: .74rem; color: var(--muted); margin: 8px 0 2px; }
.bubble.typing { display: inline-flex; gap: 5px; align-items: center; padding: 14px 16px; }
.bubble.typing .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: typing-dot 1.2s infinite ease-in-out; }
.bubble.typing .dot:nth-child(2) { animation-delay: .15s; }
.bubble.typing .dot:nth-child(3) { animation-delay: .3s; }
@keyframes typing-dot { 0%, 60%, 100% { opacity: .35; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .bubble.typing .dot { animation: none; opacity: .7; } }
.title-row { display: flex; align-items: center; gap: 12px; min-width: 0; }
.title-avatar { width: 40px; height: 40px; border-radius: 50%; flex: none; }
.companion-id { display: flex; align-items: flex-end; gap: 14px; }
.companion-id label { flex: 1; }
.companion-avatar { width: 56px; height: 56px; border-radius: 50%; flex: none; }
.bubble.pending { opacity: .6; }
.bubble img { display: block; max-width: 100%; border-radius: 10px; }
.notice { margin: 8px 16px; padding: 10px 14px; border-radius: 10px; background: var(--bot); font-size: .9rem; }
.photos { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.photos img { width: 96px; height: 96px; object-fit: cover; border-radius: 10px; }
#entry-body { white-space: pre-wrap; }
.dock { position: fixed; left: 0; right: 0; bottom: 0; background: var(--bg); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom); z-index: 10; }
.composer { display: flex; align-items: flex-end; gap: 8px; padding: 8px 10px; }
.composer textarea { flex: 1; min-width: 0; resize: none; min-height: 44px; max-height: 140px; border-radius: 22px; padding: 10px 16px; background: var(--surface); line-height: 1.4; }
.plus-wrap { position: relative; flex: none; }
.plus { position: relative; width: 44px; height: 44px; padding: 0; border-radius: 50%; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--border); color: var(--muted); }
.plus svg { transition: transform .15s ease; }
.plus:hover { color: var(--text); }
.plus[aria-expanded="true"] { color: var(--accent); }
.plus[aria-expanded="true"] svg { transform: rotate(45deg); }
.plus-dot { position: absolute; top: 0; right: 0; width: 11px; height: 11px; border-radius: 50%; background: var(--accent); border: 2px solid var(--bg); }
.plus-menu { position: absolute; left: 0; bottom: calc(100% + 10px); width: max-content; min-width: 244px; padding: 6px; display: grid; gap: 2px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: 0 10px 32px rgba(0, 0, 0, .35); z-index: 30; }
#composer .menu-item { display: flex; align-items: center; justify-content: flex-start; gap: 12px; width: 100%; padding: 10px 12px; border: 0; border-radius: 12px; background: transparent; color: var(--text); font-size: .95rem; text-align: left; cursor: pointer; }
#composer .menu-item[hidden] { display: none; }
#composer .menu-item:hover, #composer .menu-item:focus-visible { background: var(--hover); }
.menu-item .ms, .menu-label .ms { color: var(--accent); font-size: 1.4rem; }
.menu-mood { padding: 8px 6px 4px; border-block: 1px solid var(--border); }
.menu-label { display: flex; align-items: center; gap: 12px; padding: 0 6px 4px; font-size: .95rem; }
.mood-faces { display: flex; justify-content: space-between; }
.mood-faces button { font-size: 1.5rem; padding: 6px 8px; background: transparent; border: 0; border-radius: 10px; line-height: 1; }
.mood-faces button:hover, .mood-faces button:focus-visible { background: var(--hover); }

#mood-btn { display: none; }

/* picking the companion's face */
.faces { display: grid; gap: 8px; }
.faces-title { font-size: .9rem; color: var(--muted); }
.face-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; }
.face { display: grid; justify-items: center; align-content: start; gap: 4px; padding: 8px 4px; border: 2px solid transparent; border-radius: 14px; background: transparent; }
.face:hover { background: var(--hover); }
.face img { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; }
.face small { font-size: .78rem; color: var(--muted); }
.face[aria-checked="true"] { border-color: var(--accent); background: var(--accent-soft); }
.face[aria-checked="true"] small { color: var(--text); font-weight: 600; }
.face-add { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; border: 2px dashed var(--border); font-size: 1.6rem; color: var(--muted); }
#face-msg:empty { display: none; }
.tabs { display: flex; border-top: 1px solid var(--border); }
.tabs button { flex: 1; border: 0; border-radius: 0; background: transparent; color: var(--muted); padding: 12px; }
.tabs button.active { color: var(--accent); font-weight: 600; }
body:not(.on-today) #composer { display: none; }
.row { display: flex; justify-content: space-between; align-items: center; }
.stats { list-style: none; padding: 0; margin: 12px 0 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
.stats li { background: var(--bg); border-radius: 10px; padding: 10px; font-size: .85rem; color: var(--muted); }
.stats strong { display: block; font-size: 1.2rem; color: var(--text); }
.list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.list li { display: flex; justify-content: space-between; gap: 12px; font-size: .92rem; }
#mood-chart svg { width: 100%; height: auto; display: block; }
.axis { stroke: var(--border); stroke-width: 1; } .axis-label { fill: var(--muted); font-size: 10px; }
.line { fill: none; stroke: var(--accent); stroke-width: 2; } .dot { fill: var(--accent); }
@media (min-width: 720px) { #main, .login-card { max-width: 720px; margin-left: auto; margin-right: auto; } .dock { left: 50%; right: auto; width: 720px; transform: translateX(-50%); border: 1px solid var(--border); border-bottom: 0; border-radius: 14px 14px 0 0; } }

.stack { display: grid; gap: 12px; }
.row.gap { gap: 12px; } .row.gap > label { flex: 1; } .row.wrap { flex-wrap: wrap; justify-content: flex-start; }
.card textarea { width: 100%; }
.entries li { display: block; cursor: pointer; padding: 10px 0; border-bottom: 1px solid var(--border); }
.entries li:last-child { border-bottom: 0; }
.entries .head { display: flex; justify-content: space-between; gap: 12px; font-weight: 600; }
.entries .preview { color: var(--muted); font-size: .88rem; margin-top: 2px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.tabs button { font-size: .9rem; padding: 12px 4px; }

.danger-zone { border-color: #7a2e2e; }
button.danger { background: #c0392b; color: #fff; }
button.danger:disabled { opacity: .45; cursor: not-allowed; }

/* icons: Material Symbols Rounded, self-hosted subset */
@font-face { font-family: 'Material Symbols Rounded'; font-style: normal; font-weight: 400; font-display: block; src: url(/fonts/material-symbols.woff2) format('woff2'); }
.ms { font-family: 'Material Symbols Rounded'; font-weight: normal; font-style: normal; font-size: 1.35em; line-height: 1; letter-spacing: normal; text-transform: none; display: inline-block; white-space: nowrap; direction: ltr; -webkit-font-feature-settings: 'liga'; font-feature-settings: 'liga'; -webkit-font-smoothing: antialiased; flex: none; user-select: none; overflow: hidden; width: 1em; height: 1em; font-variation-settings: 'FILL' 0; }
button:has(> .ms):not(.icon-btn):not(.send-btn) { display: inline-flex; align-items: center; gap: 6px; }
.icon-btn { background: transparent; border-color: transparent; color: var(--muted); padding: 6px; display: inline-flex; align-items: center; justify-content: center; }
.icon-btn .ms { font-size: 1.7rem; }
.icon-btn:hover, .icon-btn:focus-visible { color: var(--text); background: var(--bot); }
.send-btn { width: 44px; height: 44px; padding: 0; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; }
.send-btn .ms { font-size: 1.6rem; }
.tabs button { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .72rem; padding: 8px 4px 10px; }
.tabs button .ms { font-size: 1.7rem; }
.tabs button.active { font-weight: 600; }
.tabs button.active .ms { font-variation-settings: 'FILL' 1; }
.login-card .row.wrap { justify-content: space-between; }
.login-card .ghost { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; padding: 8px 10px; }
#delete-btn.danger { justify-self: start; }

.reflection p { margin: 8px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.reflection .row h2 { margin-bottom: 0; }
.tabs button { min-width: 0; }
.reflection > .row:last-child { margin-top: 6px; }
.reflection .icon-btn .ms { font-size: 1.4rem; }
.reflection textarea { margin-top: 8px; }
#refl-custom input { width: 100%; }
button.linklike { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; font: inherit; }
#refl-form .row.gap > button { flex: 0 0 auto; }
#refl-form .row.gap { justify-content: space-between; }
#refl-dated { margin: 0; }

.login-card a { color: var(--accent); }
.login-card .center { text-align: center; }
.login-card .hint { margin: -6px 0 0; }
.login-card .stack > button { width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.login-card .stack > .row { width: 100%; }

/* Keep the hidden attribute working on elements that set their own display. */
[hidden] { display: none !important; }

/* Sign-in cards stay narrow on wide screens (the shared 720px rule above is for the journal itself). */
@media (min-width: 720px) { .login-card { max-width: 420px; } }
#code { font-size: 1.4rem; letter-spacing: .4em; text-align: center; }
#email[readonly] { opacity: .7; }

/* ================= Wide screens: a real desktop layout =================
   The phone layout above is untouched. From 900px up the tab bar becomes a left sidebar
   (navigation on top, the account with Settings and Sign out at the bottom) and the
   composer floats in the content column. */
:root {
  --sidebar-bg: color-mix(in srgb, var(--surface) 55%, var(--bg));
  --hover: color-mix(in srgb, var(--text) 7%, transparent);
  --accent-soft: color-mix(in srgb, var(--accent) 14%, transparent);
  --shadow: 0 1px 2px rgba(15, 19, 32, .05), 0 8px 24px rgba(15, 19, 32, .07);
}
@media (prefers-color-scheme: dark) { :root { --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35); } }
.sidebar { display: none; }

@media (min-width: 900px) {
  :root { --sidebar-w: 264px; --col: 820px; }
  html { scrollbar-gutter: stable; } /* the column must not shift between tabs when a scrollbar appears */

  .sidebar {
    display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 20;
    padding: 22px 14px 14px; background: var(--sidebar-bg); border-right: 1px solid var(--border); overflow-y: auto;
  }
  .side-brand { display: flex; align-items: center; gap: 11px; padding: 2px 10px 22px; font-size: 1.12rem; font-weight: 650; letter-spacing: -.015em; }
  .side-brand img { border-radius: 9px; box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 35%, transparent); }
  .side-nav { display: grid; gap: 3px; }

  #sidebar .side-nav button, #sidebar .side-actions button {
    display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border: 0; border-radius: 10px;
    background: transparent; color: var(--muted); font-size: .95rem; text-align: left; position: relative;
    transition: background-color .15s ease, color .15s ease;
  }
  #sidebar .side-nav button .ms { font-size: 1.45rem; }
  #sidebar .side-nav button:hover, #sidebar .side-actions button:hover { background: var(--hover); color: var(--text); }
  #sidebar button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
  #sidebar .side-nav button.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
  #sidebar .side-nav button.active::before { content: ""; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
  #sidebar button.active .ms { font-variation-settings: 'FILL' 1; }

  .side-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); display: grid; gap: 10px; }
  .side-user { display: flex; align-items: center; gap: 11px; padding: 4px 8px; min-width: 0; }
  .avatar {
    flex: none; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 1rem;
    color: var(--accent-text); background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 50%, #ec4899));
    box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 30%, transparent);
  }
  .who { display: grid; min-width: 0; line-height: 1.25; }
  .who strong { font-size: .93rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .who small { font-size: .78rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .side-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  #sidebar .side-actions button { justify-content: center; gap: 7px; padding: 8px 10px; font-size: .85rem; border: 1px solid var(--border); background: var(--surface); }
  #sidebar .side-actions button .ms { font-size: 1.2rem; }
  #sidebar .side-actions button.active { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); background: var(--accent-soft); }

  /* the content column, to the right of the sidebar */
  #main { margin: 0 0 0 var(--sidebar-w); max-width: none; padding-bottom: calc(var(--dock-h, 170px) + 32px); }
  .tabs, #signout { display: none; }
  .topbar { max-width: var(--col); margin: 0 auto; padding: 30px 32px 10px; background: color-mix(in srgb, var(--bg) 86%, transparent); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
  .topbar h1 { font-size: 1.8rem; letter-spacing: -.025em; }
  .topbar .muted { font-size: .95rem; margin-top: 4px; }
  .tab { max-width: var(--col); margin: 0 auto; padding: 4px 32px 0; animation: tab-in .2s ease-out; }
  .tab .card, .tab .notice { margin-inline: 0; }
  .card { border-radius: 16px; box-shadow: var(--shadow); }
  .thread { padding-inline: 0; gap: 10px; }
  .bubble { max-width: 75%; }

  /* the composer floats above the content */
  body:not(.on-today) .dock { display: none; }
  body:not(.on-today) #main { padding-bottom: 40px; }
  .dock { left: var(--sidebar-w); right: 0; width: auto; transform: none; border: 0; border-radius: 0; pointer-events: none; padding-top: 34px; background: linear-gradient(to top, var(--bg) 55%, transparent); }
  .dock #composer-wrap { pointer-events: auto; width: min(calc(100% - 64px), calc(var(--col) - 64px)); margin: 0 auto 22px; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow); overflow: visible; }
  .dock #composer-wrap:focus-within { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); }
  .dock .composer { flex-wrap: wrap; align-items: center; gap: 6px; padding: 10px 12px; }
  .dock .composer textarea { order: 1; flex: 1 0 100%; background: transparent; border-color: transparent; border-radius: 12px; padding-inline: 6px; }
  .dock .composer textarea:focus { outline: none; }
  .dock .plus-wrap { order: 2; flex: 1; }
  .dock .send-btn { order: 3; }
  /* the extras as a toolbar under the box */
  .dock .plus { display: none; }
  .dock .plus-menu { position: static; display: flex; align-items: center; gap: 6px; width: auto; min-width: 0; padding: 0; background: transparent; border: 0; box-shadow: none; }
  .dock #composer .menu-item { width: auto; gap: 6px; padding: 6px 12px; border-radius: 999px; font-size: .88rem; }
  .dock #composer #attach-item { width: 38px; height: 38px; padding: 0; justify-content: center; }
  .dock #attach-item .menu-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .dock #attach-item .ms { color: var(--muted); font-size: 1.6rem; }
  .dock #composer #attach-item:hover .ms { color: var(--text); }
  .dock .menu-mood { position: relative; padding: 0; border: 0; }
  .dock .menu-label { display: none; }
  .dock #mood-btn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: transparent; border: 1px solid var(--border); color: var(--muted); font-size: .88rem; }
  .dock #mood-btn:hover, .dock #mood-btn[aria-expanded="true"] { color: var(--text); background: var(--hover); }
  .dock #mood-btn .ms { font-size: 1.2rem; }
  .dock .mood-faces { display: none; position: absolute; left: 0; bottom: calc(100% + 8px); gap: 2px; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: 0 8px 28px rgba(0, 0, 0, .35); z-index: 30; }
  .dock .menu-mood.open .mood-faces { display: flex; }
  .dock #composer #make-entry { border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border)); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
  .dock #composer #make-entry[hidden] { display: none; }
  .dock #make-entry .ms { font-size: 1.2rem; }
}
@keyframes tab-in { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .tab { animation: none !important; } #sidebar * { transition: none !important; } }

/* settings switches */
.toggle { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 0; color: var(--text); font-size: 1rem; cursor: pointer; }
.toggle + .toggle { border-top: 1px solid var(--border); }
.toggle-text { display: grid; gap: 2px; min-width: 0; }
.toggle-text strong { font-weight: 600; font-size: .98rem; }
.toggle-text small { color: var(--muted); font-size: .82rem; line-height: 1.35; }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch { position: relative; flex: none; width: 44px; height: 26px; border-radius: 999px; background: color-mix(in srgb, var(--muted) 45%, var(--border)); transition: background-color .18s ease; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .18s ease; }
.toggle input:checked + .switch { background: var(--accent); }
.toggle input:checked + .switch::after { transform: translateX(18px); }
.toggle input:focus-visible + .switch { outline: 2px solid var(--accent); outline-offset: 2px; }
.toggle:has(input:disabled) { opacity: .55; cursor: default; }
@media (prefers-reduced-motion: reduce) { .switch, .switch::after { transition: none; } }

/* notifications */
.sub { margin: 14px 0 -2px; font-size: .78rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 600; }
.channels { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.channel { display: grid; grid-template-columns: 40px 1fr; gap: 4px 12px; align-items: center; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); }
.ch-icon { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-size: 1.4rem; }
.ch-main { display: grid; min-width: 0; line-height: 1.3; }
.ch-main strong { font-size: .98rem; }
.ch-main small { color: var(--muted); font-size: .84rem; overflow-wrap: anywhere; }
.ch-actions { grid-column: 2; display: flex; flex-wrap: wrap; gap: 8px; }
.ch-actions:empty, .ch-actions:not(:has(button:not([hidden]))) { display: none; }
.ch-wide { grid-column: 2; margin: 0; }
.verify-box { display: grid; gap: 8px; }
.verify-box .row { gap: 8px; }
.verify-box input { flex: 1; min-width: 0; letter-spacing: .25em; text-align: center; }
.channel.soon { opacity: .6; }
.channel.soon .ch-icon { background: var(--hover); color: var(--muted); }
.badge { margin-left: 8px; padding: 2px 8px; border-radius: 999px; background: var(--hover); color: var(--muted); font-size: .7rem; font-weight: 600; letter-spacing: .02em; vertical-align: 1px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; background: var(--muted); vertical-align: 1px; }
.dot.on { background: #22c55e; }
.dot.warn { background: #f59e0b; }
.msg-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 14px; align-items: center; padding: 14px 0; border-top: 1px solid var(--border); }
.msg-row:first-child { border-top: 0; }
.msg-row strong { font-size: .98rem; }
.msg-row .desc { color: var(--muted); font-size: .82rem; line-height: 1.35; margin-top: 2px; }
.picks { display: flex; flex-direction: column; gap: 8px; }
.pick { display: flex; align-items: center; gap: 8px; font-size: .92rem; cursor: pointer; }
.pick input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent, #6366f1); }
.pick.unavailable { opacity: .55; cursor: not-allowed; }
.msg-row .warn { grid-column: 1 / -1; color: #b45309; font-size: .82rem; }
@media (prefers-color-scheme: dark) { .msg-row .warn { color: #fbbf24; } }

/* settings sections */
.settings-nav { display: flex; gap: 6px; overflow-x: auto; padding: 4px 16px 10px; margin: 0; scrollbar-width: none; background: var(--bg); position: sticky; top: var(--topbar-h, 57px); z-index: 4; }
.settings-nav::-webkit-scrollbar { display: none; }
.settings-nav button { flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: .9rem; white-space: nowrap; }
.settings-nav button .ms { font-size: 1.2rem; }
.settings-nav button.active { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); font-weight: 600; }
.settings-nav button.active .ms { font-variation-settings: 'FILL' 1; }
.settings-nav button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (min-width: 900px) {
  #tab-settings { max-width: 1040px; }
  .settings-layout { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 28px; align-items: start; }
  .settings-nav { position: sticky; top: 96px; flex-direction: column; overflow: visible; padding: 0; gap: 3px; background: transparent; }
  .settings-nav button { width: 100%; border: 0; border-radius: 10px; background: transparent; padding: 10px 12px; gap: 11px; font-size: .95rem; }
  .settings-nav button:hover { background: var(--hover); color: var(--text); }
  .settings-nav button.active { background: var(--accent-soft); }
  .settings-nav button .ms { font-size: 1.35rem; }
}
.channel .error:empty { display: none; }

/* chat about any day */
/* the day picker, in the header of the Chat tab */
.topbar { flex-wrap: wrap; }
.daybar { display: flex; align-items: center; justify-content: center; gap: 2px; order: 3; flex: 1 0 100%; padding: 2px 0 6px; }
.daypick { position: relative; display: inline-flex; }
.daypick > button { display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px; border-radius: 999px; font-weight: 600; font-size: .95rem; background: var(--bg); border: 1px solid var(--border); color: var(--text); }
.daypick > button:hover, .daypick > button:focus-visible { background: var(--hover); }
.daypick > button svg { color: var(--accent); flex: none; }
.daypick input { position: absolute; left: 0; bottom: 0; width: 100%; height: 1px; opacity: 0; pointer-events: none; border: 0; padding: 0; }
.daybar .icon-btn:disabled { opacity: .3; cursor: default; }
.daybar .ghost { font-size: .85rem; padding: 6px 10px; }
@media (min-width: 900px) { .daybar { order: 0; flex: 0 0 auto; margin-left: auto; padding: 0; } }



dialog.draft { box-sizing: border-box; width: min(640px, calc(100vw - 24px)); max-width: calc(100vw - 24px); max-height: calc(100dvh - 24px); margin: auto; overflow-y: auto; padding: 18px; border: 1px solid var(--border); border-radius: 16px; background: var(--surface); color: var(--text); box-shadow: var(--shadow, 0 10px 40px rgba(0,0,0,.4)); }
dialog.draft::backdrop { background: rgba(8, 10, 18, .6); }
dialog.draft textarea { width: 100%; }
.draft-regen { display: flex; gap: 8px; }
.draft-regen input { flex: 1; min-width: 0; }

.versions { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.versions li { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); }
.versions .preview { color: var(--muted); font-size: .85rem; margin-top: 4px; overflow-wrap: anywhere; }
dialog.draft *, dialog.draft { min-width: 0; box-sizing: border-box; }
dialog.draft .row { flex-wrap: wrap; }
dialog.draft .row label { flex: 1 1 140px; }
dialog.draft input, dialog.draft select { width: 100%; }
.draft-regen input { width: auto; }

/* an entry, shown inside the conversation where it was made */
.entry-inline { align-self: stretch; margin: 8px 0; padding: 12px 14px; border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 12px; background: var(--surface); }
.entry-head { display: flex; align-items: center; gap: 8px; }
.entry-head .ms { color: var(--accent); font-size: 1.2rem; }
.entry-head .muted { margin-left: auto; font-size: .85rem; }
.entry-label { margin: 6px 0 0; font-weight: 600; }
.entry-meta { margin: 2px 0 0; font-size: .82rem; }
.entry-text { margin-top: 8px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; }
.entry-text.clamp { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
button.link { background: transparent; border: 0; padding: 4px 0; color: var(--accent); font-size: .85rem; }
.entry-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.entry-actions button { font-size: .85rem; padding: 6px 10px; }
.entry-msg { margin: 6px 0 0; font-size: .85rem; min-height: 0; }
.entry-msg:empty { display: none; }
#draft-target-label[hidden] { display: none; }
.entry-inline { justify-self: stretch; }

/* settings save themselves; this says so, in view wherever the page is */
.set-toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--dock-h, 70px) + 14px); z-index: 40; max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); box-shadow: 0 8px 28px rgba(0, 0, 0, .35); font-size: .9rem; font-weight: 600; text-align: center; pointer-events: none; }
.set-toast[hidden] { display: none; }
.set-toast.ok { border-color: color-mix(in srgb, #22c55e 60%, var(--border)); }
.set-toast.bad { border-color: var(--error); color: var(--error); border-radius: 14px; }
@media (min-width: 900px) { .set-toast { bottom: 24px; left: calc(50% + var(--sidebar-w) / 2); } }
.autosave-note { font-size: .82rem; margin: 0; }
