/* Lumi — a quiet, grown-up messenger. Warm paper, ink, muted sage. Light & dark. */
:root {
  color-scheme: light;
  --bg: #f3f1ec;
  --bg-2: #ebe8e1;
  --surface: #ffffff;
  --surface-2: #f8f6f2;
  --border: #e3dfd6;
  --hair: rgba(40, 34, 24, .08);
  --text: #1d1c1a;
  --text-2: #57544d;
  --muted: #8d897f;
  --accent: #3e6b63;
  --accent-ink: #ffffff;
  --accent-soft: #e2ebe7;
  --chat-bg: #ece8e1;
  --in: #ffffff;
  --out: #d6e6dd;
  --out-ink: #1d1c1a;
  --stamp: #8d897f;
  --read: #3d86b3;
  --ok: #2f7a4b; --ok-soft: #e1f0e6;
  --warn: #9a6512; --warn-soft: #f6ead3;
  --err: #b4372f; --err-soft: #f7e1de;
  --shadow: 0 1px 1px rgba(40, 34, 24, .06);
  --shadow-2: 0 10px 30px rgba(30, 25, 15, .12);
  --radius: 14px;
  --grid: #e9e5dd;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #151515; --bg-2: #1c1c1b; --surface: #1f1f1e; --surface-2: #252524; --border: #2f2f2d; --hair: rgba(255, 255, 255, .06);
    --text: #ecebe7; --text-2: #b8b5ad; --muted: #8a877f;
    --accent: #7fb3a7; --accent-ink: #10201d; --accent-soft: #233631;
    --chat-bg: #111110; --in: #232322; --out: #2b4741; --out-ink: #ecebe7; --stamp: #8f8c84; --read: #6fb3dd;
    --ok: #6cc08a; --ok-soft: #1c3124; --warn: #e0b061; --warn-soft: #3a2f1a; --err: #ef8a80; --err-soft: #3c201d;
    --shadow: 0 1px 1px rgba(0, 0, 0, .3); --shadow-2: 0 12px 34px rgba(0, 0, 0, .45); --grid: #2a2a28;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #151515; --bg-2: #1c1c1b; --surface: #1f1f1e; --surface-2: #252524; --border: #2f2f2d; --hair: rgba(255, 255, 255, .06);
  --text: #ecebe7; --text-2: #b8b5ad; --muted: #8a877f;
  --accent: #7fb3a7; --accent-ink: #10201d; --accent-soft: #233631;
  --chat-bg: #111110; --in: #232322; --out: #2b4741; --out-ink: #ecebe7; --stamp: #8f8c84; --read: #6fb3dd;
  --ok: #6cc08a; --ok-soft: #1c3124; --warn: #e0b061; --warn-soft: #3a2f1a; --err: #ef8a80; --err-soft: #3c201d;
  --shadow: 0 1px 1px rgba(0, 0, 0, .3); --shadow-2: 0 12px 34px rgba(0, 0, 0, .45); --grid: #2a2a28;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; overflow: hidden; }
a { color: var(--accent); text-decoration: none; }
button { font: inherit; color: inherit; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 0; border-color: transparent; }
input[type="checkbox"] { width: auto; accent-color: var(--accent); }
input[type="range"] { padding: 0; accent-color: var(--accent); background: none; border: 0; }
input[type="color"] { padding: 2px; width: 44px; height: 32px; }
textarea { resize: vertical; }
code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .88em; background: var(--bg-2); padding: 1px 5px; border-radius: 6px; word-break: break-all; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.err { color: var(--err); min-height: 1.4em; margin: 0; }
.note { background: var(--warn-soft); color: var(--warn); padding: 8px 12px; border-radius: 10px; }
.spacer { flex: 1; }
.empty-note { color: var(--muted); text-align: center; padding: 40px 10px; }

/* ---------- avatar ---------- */
.avatar { border-radius: 50%; object-fit: cover; flex: none; background: var(--bg-2); display: block; }
.avatar.xl { width: 88px; height: 88px; }
.avatar.xxl { width: 132px; height: 132px; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); padding: 8px 14px; border-radius: 10px; cursor: pointer; font-weight: 600; white-space: nowrap; transition: background .15s; }
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--err); border-color: var(--err); color: #fff; }
.btn.danger.ghost { background: transparent; color: var(--err); border-color: color-mix(in srgb, var(--err) 35%, transparent); }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 9px; }
.icon-btn { border: 0; background: transparent; width: 38px; height: 38px; border-radius: 50%; display: inline-grid; place-items: center; cursor: pointer; color: var(--text-2); position: relative; flex: none; }
.icon-btn:hover { background: var(--hair); }
.link { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 0; font-weight: 600; }
.badge { display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 999px; background: var(--bg-2); color: var(--text-2); font-weight: 600; }
.badge.s-stated { background: var(--ok-soft); color: var(--ok); }
.badge.s-inferred { background: var(--warn-soft); color: var(--warn); }
.badge.s-shared { background: var(--accent-soft); color: var(--accent); }
.badge.pin { background: var(--accent-soft); color: var(--accent); }
.badge-count { font-style: normal; background: var(--accent); color: var(--accent-ink); border-radius: 999px; font-size: 11px; font-weight: 700; min-width: 19px; height: 19px; padding: 0 6px; display: inline-grid; place-items: center; line-height: 1; }
.badge-count.warn { background: var(--warn); color: #fff; }

/* ---------- shell ---------- */
#app { display: grid; grid-template-columns: 340px 1fr; height: 100dvh; }
#side { background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; overflow-y: auto; }
.side-head { padding: 16px 18px 10px; padding-top: max(16px, env(safe-area-inset-top)); }
.app-name { font-weight: 700; font-size: 20px; letter-spacing: -.01em; }
.chat-row { display: flex; gap: 12px; align-items: center; padding: 10px 16px; color: var(--text); margin: 0 8px; border-radius: 12px; }
.chat-row:hover { background: var(--surface-2); }
.chat-row.active { background: var(--accent-soft); }
.chat-row .avatar { width: 50px; height: 50px; }
.cr-main { flex: 1; min-width: 0; }
.cr-top, .cr-bottom { display: flex; align-items: center; gap: 8px; }
.cr-top b { flex: 1; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cr-top time { font-size: 12px; color: var(--muted); }
.cr-bottom span { flex: 1; color: var(--text-2); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.typing-text { color: var(--accent) !important; font-style: italic; }
.side-label { font-size: 12px; font-weight: 650; color: var(--muted); letter-spacing: .03em; text-transform: uppercase; padding: 18px 24px 6px; }
.side-links { display: flex; flex-direction: column; }
.side-link { display: flex; align-items: center; gap: 14px; padding: 9px 16px; margin: 0 8px; border-radius: 10px; color: var(--text-2); border: 0; background: none; cursor: pointer; text-align: left; font-size: 15px; }
.side-link span { flex: 1; }
.side-link:hover { background: var(--surface-2); color: var(--text); }
.side-link.active { background: var(--accent-soft); color: var(--accent); }
.side-foot { margin-top: auto; padding: 10px 0 14px; padding-bottom: max(14px, env(safe-area-inset-bottom)); border-top: 1px solid var(--border); display: flex; flex-direction: column; }
.install-link { display: none; }
body.can-install .install-link { display: flex; }
@media (display-mode: standalone) { body.can-install .install-link { display: none; } }

#main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
#topbar { display: flex; align-items: center; gap: 6px; padding: 8px 14px; padding-top: max(8px, env(safe-area-inset-top)); min-height: 56px; background: var(--surface); border-bottom: 1px solid var(--border); flex: none; }
#topbar h1 { font-size: 17px; font-weight: 650; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#topbar .back { display: none; color: var(--accent); width: auto; padding: 0 4px; border-radius: 10px; gap: 2px; grid-auto-flow: column; }
#topbar .back .badge-count { margin-left: 2px; }
body[data-view="chat"] #topbar { display: none; }
#view { flex: 1; overflow-y: auto; min-height: 0; outline: none; }
body[data-view="chat"] #view { overflow: hidden; }

.page { max-width: 1040px; margin: 0 auto; padding: 18px 20px 48px; display: flex; flex-direction: column; gap: 14px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; min-width: 0; }
.card h3 { margin: 0; font-size: 15px; font-weight: 650; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.sub-head { font-size: 12px; font-weight: 650; color: var(--muted); margin: 14px 0 8px; text-transform: uppercase; letter-spacing: .04em; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar h2 { font-size: 17px; margin: 0; }
.toolbar select { width: auto; }
.seg { display: inline-flex; background: var(--bg-2); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: none; padding: 5px 12px; border-radius: 8px; cursor: pointer; color: var(--text-2); font-weight: 600; font-size: 13px; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
details > summary { cursor: pointer; color: var(--text-2); font-weight: 600; padding: 4px 0; }
.plain { list-style: none; padding: 0; margin: 6px 0; }
.plain li { padding: 3px 0; }

/* ---------- login ---------- */
#login { min-height: 100dvh; display: grid; place-items: center; padding: 20px; background: var(--bg); }
.login-card { width: min(340px, 100%); display: flex; flex-direction: column; gap: 12px; align-items: center; text-align: center; }
.login-card h2 { margin: 4px 0 0; font-weight: 650; }
.login-card p { margin: 0 0 6px; }
.login-card input { text-align: center; border-radius: 12px; padding: 11px 14px; }
.login-card .btn { width: 100%; padding: 11px; border-radius: 12px; }

/* ---------- conversation ---------- */
.im { display: flex; flex-direction: column; height: 100%; min-height: 0; background: var(--chat-bg); }
.im-head { display: flex; align-items: center; gap: 6px; padding: 8px 10px 8px 14px; padding-top: max(8px, env(safe-area-inset-top)); background: var(--surface); border-bottom: 1px solid var(--border); flex: none; min-height: 60px; z-index: 2; }
.im-peer { display: flex; align-items: center; gap: 11px; flex: 1; min-width: 0; color: var(--text); padding: 2px 4px; border-radius: 10px; }
.im-peer .avatar { width: 40px; height: 40px; }
.im-peer-text { display: flex; flex-direction: column; min-width: 0; }
.im-peer-text b { font-weight: 650; font-size: 16px; line-height: 1.2; }
.im-peer-text small { color: var(--muted); font-size: 13px; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pins { flex: none; background: var(--surface); }
.pins:empty { display: none; }
.pin { display: flex; align-items: center; gap: 10px; padding: 7px 14px; border-bottom: 1px solid var(--border); font-size: 14px; }
.pin::before { content: ''; width: 3px; align-self: stretch; border-radius: 2px; background: var(--accent); }
.pin.attention::before { background: var(--warn); }
.pin-ic { font-size: 18px; }
.pin-main { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.3; }
.pin-main b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pin-main small { color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pin-btn { border: 0; background: none; color: var(--accent); font-weight: 600; font-size: 14px; cursor: pointer; padding: 6px 6px; border-radius: 8px; }
.pin-btn:hover { background: var(--hair); }
.im-scroll { flex: 1; overflow-y: auto; min-height: 0; overscroll-behavior: contain; }
.im-inner { max-width: 820px; margin: 0 auto; padding: 10px 14px 14px; display: flex; flex-direction: column; }
#list { display: flex; flex-direction: column; }
.load-more { align-self: center; border: 0; background: var(--surface); color: var(--text-2); font-size: 13px; padding: 4px 12px; border-radius: 999px; margin: 6px 0; cursor: pointer; box-shadow: var(--shadow); }
.day, .unread-div { display: flex; justify-content: center; margin: 12px 0 8px; position: sticky; top: 6px; z-index: 1; }
.day span { background: color-mix(in srgb, var(--surface) 88%, transparent); color: var(--text-2); font-size: 12.5px; padding: 3px 11px; border-radius: 8px; box-shadow: var(--shadow); backdrop-filter: blur(6px); }
.unread-div { position: static; }
.unread-div span { background: var(--surface); color: var(--accent); font-size: 12.5px; font-weight: 600; padding: 3px 14px; border-radius: 8px; width: 100%; text-align: center; }
.sys { display: flex; justify-content: center; margin: 8px 0; }
.sys span { background: color-mix(in srgb, var(--surface) 80%, transparent); color: var(--text-2); font-size: 12.5px; padding: 4px 12px; border-radius: 8px; text-align: center; max-width: 88%; }
.sys.intro span { background: color-mix(in srgb, var(--warn-soft) 70%, var(--surface)); color: var(--text-2); }

.row { display: flex; flex-direction: column; max-width: min(78%, 560px); margin-top: 2px; }
.row.first { margin-top: 8px; }
.row.in { align-self: flex-start; align-items: flex-start; }
.row.out { align-self: flex-end; align-items: flex-end; }
.bubble { position: relative; padding: 6px 9px 6px 10px; border-radius: 12px; box-shadow: var(--shadow); overflow-wrap: anywhere; word-break: break-word; font-size: 15.5px; line-height: 1.42; }
.row.in .bubble { background: var(--in); color: var(--text); }
.row.out .bubble { background: var(--out); color: var(--out-ink); }
.row.in.first .bubble { border-top-left-radius: 3px; }
.row.out.first .bubble { border-top-right-radius: 3px; }
.row.in.first .bubble::before, .row.out.first .bubble::before { content: ''; position: absolute; top: 0; width: 10px; height: 12px; }
.row.in.first .bubble::before { left: -7px; background: linear-gradient(to bottom left, var(--in) 50%, transparent 50%); }
.row.out.first .bubble::before { right: -7px; background: linear-gradient(to bottom right, var(--out) 50%, transparent 50%); }
.bubble .text { display: inline; white-space: normal; }
.bubble .text p { margin: 0 0 .35em; }
.bubble .text p:last-child { display: inline; margin: 0; }
.bubble .text ul, .bubble .text ol { margin: .2em 0 .35em; padding-left: 1.3em; }
.bubble .text blockquote { margin: .2em 0; padding-left: 8px; border-left: 3px solid var(--border); color: var(--text-2); }
.bubble .text pre { background: var(--bg-2); padding: 6px 8px; border-radius: 8px; overflow-x: auto; font-size: 13px; }
.bubble .text .md-h { font-weight: 650; }
.stamp { float: right; position: relative; top: 7px; margin-left: 10px; font-size: 11.5px; color: var(--stamp); display: inline-flex; align-items: center; gap: 3px; line-height: 1; white-space: nowrap; }
.stamp-space { display: block; clear: both; height: 0; }
.tick { color: var(--stamp); }
.tick.read { color: var(--read); }
.row.typing .bubble { padding: 11px 14px; }
.dots { display: inline-flex; gap: 4px; align-items: center; }
.dots i { width: 7px; height: 7px; background: var(--muted); border-radius: 50%; animation: dot 1.3s infinite ease-in-out; }
.dots i:nth-child(2) { animation-delay: .18s; } .dots i:nth-child(3) { animation-delay: .36s; }
@keyframes dot { 0%, 60%, 100% { opacity: .35; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
.cards { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; width: 100%; min-width: 220px; }
.cards .card { display: flex; gap: 10px; align-items: center; padding: 8px 12px 8px 10px; border-radius: 12px; background: var(--in); color: var(--text); box-shadow: var(--shadow); border: 0; border-left: 3px solid var(--accent); min-width: 0; }
.cards .card.fail { border-left-color: var(--err); }
.cards .card.fail .ci { color: var(--err); font-weight: 800; }
.cards .card .ci { font-size: 19px; width: 26px; text-align: center; flex: none; }
.cards .card .cb { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.cards .card .cb b { font-weight: 600; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cards .card .cb small { color: var(--text-2); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cards a.card:hover { background: var(--surface-2); }
.undelivered { border: 0; background: none; color: var(--err); font-size: 12.5px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; padding: 3px 2px; }
.undelivered i { font-style: normal; width: 16px; height: 16px; border-radius: 50%; background: var(--err); color: #fff; display: inline-grid; place-items: center; font-weight: 800; font-size: 11px; }
.fallback-note { font-size: 12.5px; color: var(--text-2); }
.im-compose { display: flex; gap: 8px; align-items: flex-end; padding: 8px 10px; padding-bottom: max(8px, env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--border); flex: none; }
.im-compose textarea { flex: 1; resize: none; border-radius: 21px; padding: 9px 15px; max-height: 150px; line-height: 1.4; font-size: 16px; background: var(--surface-2); border-color: var(--border); }
.send { width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; cursor: pointer; flex: none; transition: opacity .15s, transform .1s; }
.send:disabled { opacity: .35; cursor: default; }
.send:not(:disabled):active { transform: scale(.94); }

/* ---------- profile ---------- */
.profile { max-width: 560px; }
.profile-hero { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 18px 0 6px; }
.profile-hero h2 { margin: 12px 0 2px; font-weight: 650; }
.profile-hero p { margin: 0; }
.profile-hero .about { margin-top: 10px; color: var(--text-2); font-size: 14px; }
.list-group { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.list-row { display: flex; align-items: center; gap: 14px; padding: 13px 16px; color: var(--text); border: 0; background: none; width: 100%; cursor: pointer; text-align: left; font-size: 15.5px; }
.list-row + .list-row { border-top: 1px solid var(--border); }
.list-row svg:first-child { color: var(--accent); }
.list-row span { flex: 1; }
.list-row em { font-style: normal; color: var(--muted); font-size: 14px; }
.list-row em.warn { color: #fff; background: var(--warn); border-radius: 999px; padding: 0 7px; font-size: 12px; font-weight: 700; }
.list-row .chev { color: var(--muted); }
.list-row:hover { background: var(--surface-2); }

/* ---------- notices ---------- */
.notice-list { display: flex; flex-direction: column; gap: 10px; }
.notice { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--warn); border-radius: 12px; padding: 12px 14px; }
.notice.error { border-left-color: var(--err); }
.notice.info { border-left-color: var(--accent); }
.notice.closed { opacity: .6; }
.notice-head { display: flex; gap: 10px; align-items: baseline; }
.notice-head .sev { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--warn); }
.notice.error .sev { color: var(--err); }
.notice.info .sev { color: var(--accent); }
.notice-detail { white-space: pre-wrap; font-size: 12.5px; color: var(--text-2); background: var(--surface-2); padding: 8px 10px; border-radius: 8px; margin: 8px 0; max-height: 220px; overflow: auto; font-family: ui-monospace, Menlo, monospace; }
.notice-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 6px; }

/* ---------- today / lists ---------- */
.date-nav { display: flex; align-items: center; gap: 8px; }
.date-nav h2 { margin: 0; font-size: 19px; font-weight: 650; }
.date-nav h2 small { color: var(--muted); font-size: 13px; font-weight: 500; margin-left: 6px; }
.open-list { display: flex; flex-direction: column; gap: 8px; }
.open-card { display: flex; align-items: center; gap: 10px; background: var(--surface-2); border: 1px solid var(--border); border-left: 4px solid var(--c); border-radius: 12px; padding: 10px 12px; }
.open-card .oc-emoji { font-size: 20px; }
.open-card .oc-main { flex: 1; min-width: 0; }
.open-card .oc-main b { display: block; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.open-card .oc-main small { color: var(--muted); font-size: 12px; }
.oc-timer { font-variant-numeric: tabular-nums; font-weight: 650; font-size: 18px; }
.oc-timer.paused { color: var(--muted); }
.oc-btns { display: flex; gap: 6px; }
.kind-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 8px; }
.kind-btn { border: 1px solid var(--border); background: var(--surface-2); border-radius: 12px; padding: 8px 4px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 13px; color: var(--text-2); border-bottom: 3px solid var(--c, var(--border)); }
.kind-btn span { font-size: 19px; }
.kind-btn:hover { background: var(--accent-soft); }
.kind-btn.more { border-bottom-color: var(--border); justify-content: center; }
.timeline { margin: 4px 0 12px; }
.tl-track { position: relative; height: 22px; background: var(--bg-2); border-radius: 7px; overflow: hidden; }
.tl-track.plan { height: 8px; margin-top: 4px; background: transparent; }
.tl-seg { position: absolute; top: 0; bottom: 0; background: var(--c); border-radius: 4px; box-shadow: 0 0 0 1px var(--surface); }
.tl-plan { position: absolute; top: 0; bottom: 0; border: 1.5px dashed var(--accent); border-radius: 4px; }
.tl-plan.done { background: var(--accent-soft); border-style: solid; }
.tl-now { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--err); }
.tl-ticks { position: relative; height: 16px; font-size: 10px; color: var(--muted); }
.tl-ticks span { position: absolute; transform: translateX(-50%); top: 2px; }
.tl-ticks span:first-child { transform: none; } .tl-ticks span:last-child { transform: translateX(-100%); }
.kind-totals { display: flex; flex-direction: column; gap: 6px; }
.kt { display: grid; grid-template-columns: 10px 1fr auto auto; gap: 10px; align-items: center; font-size: 14px; }
.kt i, .dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.dot { margin-right: 6px; vertical-align: -1px; }
.kt small { color: var(--muted); width: 36px; text-align: right; }
.act-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; }
.act-list li { display: grid; grid-template-columns: 6px 92px 1fr auto; gap: 10px; align-items: center; padding: 7px 4px; border-bottom: 1px solid var(--border); cursor: pointer; font-size: 14px; }
.act-list li:last-child { border-bottom: 0; }
.act-list li:hover { background: var(--surface-2); }
.act-list li i { width: 6px; height: 22px; border-radius: 3px; }
.act-list li span { font-variant-numeric: tabular-nums; color: var(--text-2); font-size: 13px; }
.act-list li b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.act-list li small { color: var(--muted); }
.act-list li p { grid-column: 3 / -1; margin: 0; }
details.acts { margin-top: 10px; }
.plan-list, .event-list, .rem-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.plan-item { display: flex; align-items: center; gap: 10px; padding: 6px 4px; border-radius: 10px; }
.plan-item:hover { background: var(--surface-2); }
.plan-item .pi-main { flex: 1; min-width: 0; cursor: pointer; }
.plan-item b { display: block; font-weight: 600; }
.plan-item small { color: var(--muted); font-size: 12px; }
.plan-item.done b { text-decoration: line-through; color: var(--muted); }
.plan-item.skipped b { color: var(--muted); }
.check-btn { width: 22px; height: 22px; border-radius: 50%; border: 1.6px solid var(--accent); background: transparent; cursor: pointer; color: var(--accent-ink); font-size: 12px; font-weight: 800; flex: none; display: grid; place-items: center; }
.plan-item.done .check-btn { background: var(--accent); border-color: var(--accent); }
.plan-item.skipped .check-btn { border-color: var(--muted); color: var(--muted); }
.event-list li, .rem-list li { display: flex; gap: 12px; align-items: center; padding: 8px 6px; border-radius: 10px; cursor: pointer; }
.event-list li:hover, .rem-list li:hover { background: var(--surface-2); }
.event-list li > div, .rem-list li > div { flex: 1; min-width: 0; }
.event-list b, .rem-list b { display: block; font-weight: 600; }
.event-list small, .rem-list small { color: var(--muted); font-size: 12px; }
.ev-time { font-variant-numeric: tabular-nums; font-weight: 650; width: 46px; font-size: 14px; line-height: 1.2; }
.ev-time small { font-weight: 500; }
.sync { color: var(--muted); }
.sync.ok { color: var(--accent); }
.rem-list li.delivered b::after { content: ' ●'; color: var(--warn); }
.goal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.goal-card { border: 1px solid var(--border); border-radius: 12px; padding: 12px; cursor: pointer; display: flex; flex-direction: column; gap: 6px; background: var(--surface-2); margin-bottom: 8px; }
.goal-grid .goal-card { margin: 0; }
.goal-card:hover { border-color: var(--accent); }
.goal-card.done, .goal-card.dropped { opacity: .65; }
.gc-head { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.goal-card p { margin: 0; }
.progress { height: 6px; background: var(--bg-2); border-radius: 999px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.day-block { padding: 8px 0; border-bottom: 1px solid var(--border); }
.day-block:last-child { border-bottom: 0; }
.day-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }

/* ---------- charts ---------- */
.stat-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; min-width: 0; }
.tile small { color: var(--text-2); font-size: 12px; display: block; }
.tile b { font-size: 19px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stack-chart { display: grid; grid-template-columns: 34px 1fr; height: 220px; gap: 6px; }
.sc-y { position: relative; font-size: 11px; color: var(--muted); }
.sc-y span { position: absolute; right: 0; transform: translateY(50%); }
.sc-plot { position: relative; display: flex; align-items: stretch; gap: 6px; padding-bottom: 18px; border-bottom: 1px solid var(--border); }
.sc-plot.dense { gap: 2px; }
.sc-grid i { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--grid); }
.sc-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; position: relative; min-width: 0; }
.sc-stack { display: flex; flex-direction: column; justify-content: flex-end; height: 100%; gap: 2px; }
.sc-stack i { display: block; width: 100%; min-height: 2px; }
.sc-stack i:first-child { border-radius: 4px 4px 0 0; }
.sc-stack i:hover { filter: brightness(1.08); outline: 2px solid var(--surface); }
.sc-x { position: absolute; bottom: -18px; left: 50%; transform: translateX(-50%); font-size: 10px; color: var(--muted); white-space: nowrap; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 26px; font-size: 13px; color: var(--text-2); }
.lg i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.viz-tip { position: fixed; z-index: 100; pointer-events: none; background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow-2); border-radius: 10px; padding: 6px 10px; font-size: 12px; max-width: 240px; }
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 6px; border-bottom: 1px solid var(--border); }
.tbl td { padding: 7px 6px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.minibar { display: inline-block; width: 60px; height: 6px; background: var(--bg-2); border-radius: 3px; overflow: hidden; margin-right: 6px; vertical-align: middle; }
.minibar i { display: block; height: 100%; background: var(--accent); }
.kinds-tbl input { padding: 4px 6px; }

/* ---------- calendar ---------- */
.sync-line { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); flex-wrap: wrap; }
.sync-line.connected span::before { content: '● '; color: var(--ok); }
.sync-line:not(.connected) span::before { content: '● '; color: var(--muted); }
.cal-card { padding: 0; overflow: hidden; }
.week-grid { display: grid; grid-template-rows: auto auto 1fr; height: min(70vh, 720px); }
.wg-head, .wg-allday { display: grid; grid-template-columns: 52px repeat(7, 1fr); border-bottom: 1px solid var(--border); }
.wg-head div { text-align: center; padding: 8px 0 6px; }
.wg-head small { display: block; color: var(--muted); font-size: 12px; }
.wg-head b { font-size: 17px; }
.wg-head .today b { background: var(--accent); color: var(--accent-ink); border-radius: 50%; display: inline-grid; place-items: center; width: 30px; height: 30px; }
.wg-allday > div { padding: 3px; border-left: 1px solid var(--border); min-height: 24px; display: flex; flex-direction: column; gap: 2px; }
.wg-allday > div:first-child { border-left: 0; color: var(--muted); font-size: 11px; display: grid; place-items: center; }
.wg-body { display: grid; grid-template-columns: 52px repeat(7, 1fr); overflow-y: auto; position: relative; }
.wg-hours { display: flex; flex-direction: column; }
.wg-hours span { height: 48px; font-size: 11px; color: var(--muted); text-align: right; padding-right: 6px; transform: translateY(-7px); }
.wg-day { position: relative; border-left: 1px solid var(--border); height: calc(48px * 24); background: repeating-linear-gradient(to bottom, transparent 0 47px, var(--grid) 47px 48px); cursor: cell; }
.wg-day.today { background-color: color-mix(in srgb, var(--accent-soft) 45%, transparent); }
.wg-ev { position: absolute; left: 3px; right: 3px; background: var(--accent-soft); border: 0; border-left: 3px solid var(--accent); border-radius: 6px; padding: 2px 5px; text-align: left; font-size: 12px; overflow: hidden; cursor: pointer; color: var(--text); display: flex; flex-direction: column; }
.wg-ev b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wg-ev small { color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wg-ev.local { border-left-style: dashed; }
.wg-ev.invited { border-left-color: var(--read); background: color-mix(in srgb, var(--read) 14%, var(--surface)); }
.wg-ev.allday { position: static; }
.wg-now { position: absolute; left: 0; right: 0; height: 2px; background: var(--err); }
.agenda { display: none; padding: 8px 14px; }
.ag-day { padding: 8px 0; border-bottom: 1px solid var(--border); }
.ag-day.today .ag-date b { color: var(--accent); }
.ag-ev { display: grid; grid-template-columns: 92px 1fr; gap: 2px 10px; width: 100%; text-align: left; border: 0; background: var(--accent-soft); border-left: 3px solid var(--accent); border-radius: 8px; padding: 6px 10px; margin-top: 6px; cursor: pointer; color: var(--text); }
.ag-ev.local { border-left-style: dashed; }
.ag-ev span { font-variant-numeric: tabular-nums; color: var(--text-2); font-size: 13px; }
.ag-ev small { grid-column: 2; color: var(--muted); }
.warn-card { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.pending-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 6px 0; }
.pending-row p { margin: 0; }
.pending-row div { display: flex; gap: 6px; }

/* ---------- memory ---------- */
.mem-top { display: flex; gap: 10px; align-items: center; }
.mem-top input { flex: 1; }
.mem-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.mem-card { text-align: left; border: 1px solid var(--border); background: var(--surface); border-radius: 12px; padding: 12px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; color: var(--text); }
.mem-card:hover { border-color: var(--accent); }
.mem-card p { margin: 0; color: var(--text-2); font-size: 13px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.mem-card.tier-fading { opacity: .85; }
.mem-card.tier-faded { opacity: .6; }
.mem-card.tier-outdated b { text-decoration: line-through; }
.mc-top { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.imp { margin-left: auto; color: var(--warn); font-size: 11px; letter-spacing: 1px; }
.mem-detail .md { margin: 12px 0; font-size: 15px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; font-size: 13px; margin: 8px 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.evidence { padding-left: 1.1em; font-size: 14px; }
.conv-results { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.conv-results li { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 8px 12px; }
.conv-results p { margin: 2px 0 0; }
.md p { margin: 0 0 .5em; }
.md p:last-child { margin-bottom: 0; }
.md ul, .md ol { margin: .3em 0 .5em; padding-left: 1.3em; }
.md .md-h { font-weight: 650; margin-top: .4em; }
.md blockquote { margin: .4em 0; padding-left: 10px; border-left: 3px solid var(--border); color: var(--text-2); }

/* ---------- reviews ---------- */
.review-layout { display: grid; grid-template-columns: 220px 1fr; gap: 16px; align-items: start; }
.review-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; max-height: 70vh; overflow-y: auto; }
.review-list button { width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 10px; cursor: pointer; display: flex; flex-direction: column; }
.review-list button.on { background: var(--accent-soft); }
.review-list small { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.review-body h2 { margin-top: 0; font-size: 18px; }
.review-body h4 { margin: 18px 0 6px; color: var(--text-2); }
.review-body textarea { margin-bottom: 8px; }
.facts p { margin: 6px 0; }

/* ---------- settings ---------- */
.settings { max-width: 820px; }
.settings-nav { display: flex; gap: 6px; flex-wrap: wrap; position: sticky; top: -18px; z-index: 2; background: var(--bg); padding: 10px 0 6px; }
.settings-nav a { font-size: 13px; padding: 4px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); color: var(--text-2); }
.settings .card { scroll-margin-top: 60px; }
.settings .card > h3 { margin-bottom: 10px; }
.form { display: flex; flex-direction: column; gap: 10px; margin: 8px 0; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text-2); font-weight: 600; }
.form label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 500; color: var(--text); font-size: 14px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.weekdays { display: flex; flex-wrap: wrap; gap: 8px 14px; }
.sliders { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 24px; }
.slider span { display: flex; justify-content: space-between; }
.slider em { font-style: normal; color: var(--accent); font-weight: 700; }
.slider small { display: flex; justify-content: space-between; color: var(--muted); font-weight: 500; font-size: 11px; }
.avatar-edit { display: flex; gap: 14px; align-items: center; margin-bottom: 8px; }
.avatar-edit p { margin: 2px 0 8px; }
.login-code { background: var(--accent-soft); border-radius: 12px; padding: 10px 14px; margin: 10px 0; }
.login-code p { margin: 4px 0; }
.code { font-family: ui-monospace, Menlo, monospace; font-size: 20px; letter-spacing: 2px; background: var(--surface); padding: 2px 10px; border-radius: 8px; user-select: all; }
.log li { padding: 3px 0; border-bottom: 1px solid var(--border); }
.log b.error { color: var(--err); } .log b.warn { color: var(--warn); }
.log code { display: block; margin-top: 2px; }

/* ---------- modal / toast ---------- */
.modal-wrap { position: fixed; inset: 0; background: rgba(20, 18, 14, .4); display: grid; place-items: center; z-index: 50; padding: 16px; animation: fade .15s; }
.modal-wrap.out { opacity: 0; transition: opacity .18s; }
.modal { background: var(--surface); border-radius: 16px; width: min(480px, 100%); max-height: calc(100dvh - 32px); display: flex; flex-direction: column; box-shadow: var(--shadow-2); animation: pop .18s; }
.modal.wide { width: min(720px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px 6px; gap: 10px; }
.modal-head h3 { margin: 0; font-size: 17px; overflow-wrap: anywhere; }
.modal-body { padding: 6px 18px 12px; overflow-y: auto; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; padding: 10px 18px 16px; flex-wrap: wrap; border-top: 1px solid var(--border); }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }
#toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center; width: min(92vw, 440px); pointer-events: none; }
.toast { background: var(--text); color: var(--bg); padding: 9px 16px; border-radius: 10px; font-size: 14px; box-shadow: var(--shadow-2); animation: pop .2s; max-width: 100%; }
.toast-error { background: var(--err); color: #fff; }
.toast-ok { background: var(--text); color: var(--bg); }
.toast.out { opacity: 0; transition: opacity .3s; }

@media (prefers-reduced-motion: reduce) { .dots i { animation: none; } }

/* ---------- phone ---------- */
@media (max-width: 900px) {
  #app { grid-template-columns: 1fr; }
  #side { display: none; }
  #topbar .back { display: inline-grid; }
  .page { padding: 14px 14px 36px; gap: 12px; }
  .grid2 { grid-template-columns: 1fr; }
  .row { max-width: 84%; }
  .im-inner { padding: 8px 10px 12px; }
  .week-grid { display: none; }
  .agenda { display: block; }
  .stat-tiles { grid-template-columns: 1fr 1fr; }
  .stat-tiles .tile:last-child { grid-column: 1 / -1; }
  .review-layout { grid-template-columns: 1fr; }
  .review-list { flex-direction: row; overflow-x: auto; max-height: none; }
  .review-list li { flex: none; }
  .row3, .sliders { grid-template-columns: 1fr 1fr; }
  .act-list li { grid-template-columns: 6px 82px 1fr; }
  .act-list li small { grid-column: 3; }
  .stack-chart { height: 180px; }
  .settings-nav { top: -14px; }
  .modal-wrap { place-items: end center; padding: 0; }
  .modal { width: 100%; border-radius: 16px 16px 0 0; max-height: 92dvh; padding-bottom: env(safe-area-inset-bottom); }
  .modal.wide { width: 100%; }
}
@media (max-width: 480px) {
  .row2, .row3, .sliders { grid-template-columns: 1fr; }
  .kind-grid { grid-template-columns: repeat(4, 1fr); }
  .date-nav h2 { font-size: 17px; }
  .toolbar h2 { font-size: 15px; }
}
