/* Mel HQ. Light and dark follow the phone. Sage accent; one tint per feed. */
:root {
  color-scheme: light dark;
  --bg: #f3f2ec; --card: #fffefa; --ink: #1f2423; --muted: #6d726e; --line: rgba(31, 36, 35, .09);
  --accent: #c8db8a; --accent-ink: #2d3a12; --btn: #1f2423; --btn-ink: #fff;
  --bad: #c2362b; --bad-bg: #fbe7e4; --warn: #9a6400; --warn-bg: #fcefd2; --ok: #3f7a2c; --ok-bg: #e5f1d6;
  --blue: #2f6fb3; --blue-bg: #e2edf8; --violet: #6b4fb5; --violet-bg: #ece6f8;
  --bar: rgba(255, 254, 250, .72); --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 6px 20px rgba(0, 0, 0, .05);
  --sys: #fff6dc; --r: 22px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141716; --card: #1e2221; --ink: #eef0ea; --muted: #9aa19b; --line: rgba(255, 255, 255, .08);
    --accent: #c8db8a; --accent-ink: #1b230b; --btn: #eef0ea; --btn-ink: #141716;
    --bad: #ff8a7e; --bad-bg: #3d1f1c; --warn: #f2c14e; --warn-bg: #3a2f12; --ok: #a9d488; --ok-bg: #22321a;
    --blue: #8cbcf0; --blue-bg: #1b2a3a; --violet: #b9a3f2; --violet-bg: #2a2340;
    --bar: rgba(30, 34, 33, .72); --shadow: 0 1px 2px rgba(0, 0, 0, .3); --sys: #34301f;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 -apple-system, system-ui, sans-serif; overflow-x: hidden; -webkit-text-size-adjust: 100%; }
a { color: var(--blue); }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* header */
.top { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 0 12px; padding: calc(env(safe-area-inset-top) + 18px) 20px 6px; max-width: 640px; margin: 0 auto; }
.eyebrow { color: var(--muted); font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; min-height: 18px; }
.top h1 { grid-column: 1 / -1; font-size: 32px; line-height: 1.2; letter-spacing: -.02em; margin: 2px 0 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-bottom: 2px; }
[data-view=chat] .top h1, [data-view=project] .top h1 { font-size: 21px; line-height: 1.25; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.pc { background: var(--card); box-shadow: var(--shadow); border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.pc:empty { display: none; }
.pc::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: #a0a4a0; vertical-align: 1px; }
.pc.on::before { background: #5cb85c; box-shadow: 0 0 0 3px rgba(92, 184, 92, .2); }

main { padding: 0 16px calc(110px + env(safe-area-inset-bottom)); max-width: 640px; margin: 0 auto; }
.summary { margin: 4px 4px 14px; color: var(--muted); font-size: 15px; }
.summary strong { color: var(--ink); }

/* cards */
.card { display: block; background: var(--card); border-radius: var(--r); padding: 16px; margin: 12px 0; box-shadow: var(--shadow); border: 1px solid var(--line); color: inherit; text-decoration: none; }
.card h2 { font-size: 17px; margin: 0; letter-spacing: -.01em; }
.card.list { padding-top: 4px; padding-bottom: 4px; }
.cardhead { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.ico { width: 34px; height: 34px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; background: var(--ok-bg); color: var(--ok); flex: none; }
.ico svg { width: 19px; height: 19px; }
.f-golive .ico { background: var(--warn-bg); color: var(--warn); }
.f-tasks .ico { background: var(--blue-bg); color: var(--blue); }
.f-hobitrade .ico { background: var(--violet-bg); color: var(--violet); }
.more { font-size: 15px; text-decoration: none; padding: 10px 4px; }
.big { font-size: 34px; font-weight: 700; letter-spacing: -.02em; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.err { color: var(--bad); }
.late { color: var(--bad); font-weight: 600; }
.path { overflow-wrap: anywhere; }
h3.group { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 22px 6px -4px; }

.row { display: flex; gap: 12px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); color: inherit; text-decoration: none; min-height: 44px; }
.cardhead + .row, .list > .row:first-child, .feedbody > .row:first-of-type { border-top: 0; }
.row .grow, .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.row.idea { align-items: flex-start; }
.chev { color: var(--muted); display: inline-flex; transition: transform .25s ease; }
.chev svg { width: 18px; height: 18px; }

/* chat cards on Home */
.chatcard { position: relative; }
.chatcard.busy { box-shadow: var(--shadow), inset 0 0 0 2px var(--accent); }
.chatcard-top { display: flex; align-items: center; gap: 8px; }
.meta { color: var(--muted); font-size: 13px; }
.chatcard-title { font-size: 17px; font-weight: 600; margin: 4px 0 8px; }
.link { display: inline-flex; align-items: center; gap: 2px; color: var(--blue); font-weight: 600; font-size: 15px; }
.link svg { width: 16px; height: 16px; }

.dot { width: 9px; height: 9px; border-radius: 50%; background: #a0a4a0; flex: none; }
.dot.s-running, .dot.s-queued { background: #5cb85c; animation: breathe 1.6s ease-in-out infinite; }
.dot.s-waiting { background: var(--blue); }
.dot.s-error { background: var(--bad); }
.dot.s-ok { background: #5cb85c; }
@keyframes breathe { 50% { opacity: .35; transform: scale(.8); } }

/* feeds */
details > summary { list-style: none; cursor: pointer; display: flex; gap: 10px; align-items: center; min-height: 44px; font-weight: 600; }
details > summary::-webkit-details-marker { display: none; }
details[open] > summary .chev { transform: rotate(90deg); }
.feed { padding: 10px 16px; }
.feedbody { padding: 4px 0 6px; animation: drop .25s ease; }
@keyframes drop { from { opacity: 0; transform: translateY(-4px); } }
.badge { font-size: 13px; font-weight: 700; border-radius: 999px; padding: 3px 10px; background: var(--line); color: var(--muted); font-variant-numeric: tabular-nums; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }

/* tasks */
.tick { width: 30px; height: 30px; min-height: 30px; padding: 0; border-radius: 50%; border: 2px solid var(--muted); background: transparent; color: transparent; flex: none; position: relative; }
.tick::after { content: ''; position: absolute; inset: -8px; } /* 46 px touch target */
.tick svg { width: 18px; height: 18px; stroke-width: 2.6; }
.tick:active, .tick.ticked { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.quick { display: grid; gap: 8px; margin-top: 10px; }
.dated { display: flex; gap: 8px; align-items: center; }
.dated input { flex: 1; min-width: 0; }

/* controls */
button, .btn { min-height: 44px; padding: 0 18px; border-radius: 999px; border: 0; background: var(--btn); color: var(--btn-ink); font: inherit; font-size: 15px; font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer; transition: transform .1s ease-out, opacity .15s; }
button:active, .btn:active, .card[href]:active, a.row:active { transform: scale(.97); }
a.row:active { transform: none; opacity: .6; }
button.light, .btn.light { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
button.wide { width: 100%; }
button:disabled { opacity: .35; }
[hidden] { display: none !important; }
input, textarea, select { width: 100%; font: inherit; font-size: 16px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--bg); color: var(--ink); min-height: 44px; -webkit-appearance: none; appearance: none; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; }
textarea { min-height: 88px; resize: vertical; }
form.stack, .stack { display: grid; gap: 8px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.quick .actions { margin-top: 0; }
.quick .actions button { flex: 1; }

/* sign in */
.signin { text-align: center; padding: 28px 20px 20px; }
.signin .lock { width: 56px; height: 56px; border-radius: 18px; background: var(--accent); color: var(--accent-ink); display: inline-flex; align-items: center; justify-content: center; margin-bottom: 10px; }
.signin p { margin: 6px 0 16px; }

/* tab bar: a translucent layer the page scrolls under */
.tabs { position: fixed; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom)); display: flex; background: var(--bar); -webkit-backdrop-filter: blur(20px) saturate(180%); backdrop-filter: blur(20px) saturate(180%); border: 1px solid var(--line); border-radius: 26px; padding: 6px; max-width: 616px; margin: 0 auto; box-shadow: 0 8px 30px rgba(0, 0, 0, .12); z-index: 5; }
.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted); text-decoration: none; padding: 7px 0 6px; border-radius: 20px; font-size: 11px; font-weight: 600; transition: background .2s, color .2s; }
.tabs a svg { width: 23px; height: 23px; }
.tabs a.on { background: var(--accent); color: var(--accent-ink); }

/* chat */
.msg { margin: 10px 0; padding: 11px 15px; border-radius: 20px; overflow-wrap: anywhere; max-width: 92%; }
.msg.me { background: var(--btn); color: var(--btn-ink); margin-left: auto; border-bottom-right-radius: 6px; white-space: pre-wrap; width: fit-content; }
.msg.claude { background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 6px; box-shadow: var(--shadow); }
.msg.claude > :first-child { margin-top: 0; }
.msg.claude > :last-child { margin-bottom: 0; }
.msg.claude p { margin: 0 0 8px; }
.msg.claude h4 { margin: 12px 0 6px; font-size: 16px; }
.msg.claude ul, .msg.claude ol { margin: 4px 0 8px; padding-left: 22px; }
.msg.claude li { margin: 2px 0; }
.msg.claude code { font: 13.5px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--bg); padding: 1px 5px; border-radius: 6px; }
.msg.claude pre { background: var(--bg); padding: 10px 12px; border-radius: 12px; overflow-x: auto; margin: 6px 0 8px; }
.msg.claude pre code { padding: 0; background: none; }
.msg.claude hr { border: 0; border-top: 1px solid var(--line); margin: 10px 0; }
.tbl { overflow-x: auto; margin: 6px 0 8px; }
.tbl table { border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { text-align: left; padding: 5px 10px 5px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.msg.progress { color: var(--muted); font-size: 14px; padding: 2px 6px; margin: 4px 0; display: flex; gap: 8px; align-items: center; }
details.msg.progress { display: block; }
details.steps > summary { font-weight: 400; min-height: 32px; }
details.steps > div { padding: 2px 0 2px 16px; border-left: 2px solid var(--line); margin-left: 4px; }
.msg.system { background: var(--sys); font-size: 14px; }
.spin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--ok); animation: spin .8s linear infinite; flex: none; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.status { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; margin: 14px 6px 0; }
.composer { margin-top: 10px; }

/* toast, dialog, pull */
.toast { position: fixed; left: 16px; right: 16px; bottom: calc(92px + env(safe-area-inset-bottom)); background: var(--btn); color: var(--btn-ink); border-radius: 18px; padding: 8px 8px 8px 18px; display: flex; justify-content: space-between; align-items: center; gap: 8px; max-width: 608px; margin: 0 auto; z-index: 10; min-height: 56px; box-shadow: 0 10px 30px rgba(0, 0, 0, .2); opacity: 0; transform: translateY(16px); transition: opacity .2s ease, transform .3s cubic-bezier(.2, .9, .3, 1); }
.toast.in { opacity: 1; transform: none; }
.toast button { background: var(--accent); color: var(--accent-ink); }
dialog { border: 0; border-radius: 24px; padding: 20px; width: min(92vw, 420px); background: var(--card); color: var(--ink); box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
dialog h2 { margin: 0 0 12px; font-size: 19px; }
dialog::backdrop { background: rgba(0, 0, 0, .35); }
dialog[open] { animation: rise .3s cubic-bezier(.2, .9, .3, 1); }
@keyframes rise { from { opacity: 0; transform: translateY(12px) scale(.98); } }
.pull { position: fixed; top: calc(env(safe-area-inset-top) + 8px); left: 50%; transform: translate(-50%, -40px); opacity: 0; z-index: 20; width: 36px; height: 36px; border-radius: 50%; background: var(--card); box-shadow: var(--shadow); display: flex; align-items: center; justify-content: center; transition: transform .35s cubic-bezier(.2, .9, .3, 1), opacity .25s; pointer-events: none; }
.pull svg { width: 18px; height: 18px; }
.pull.going { opacity: 1 !important; transform: translate(-50%, 20px) !important; }
.pull.going svg { animation: spin .7s linear infinite; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
@media (prefers-reduced-transparency: reduce) { .tabs { background: var(--card); -webkit-backdrop-filter: none; backdrop-filter: none; } }
