:root {
  --main: #A8573D;      /* terracotta */
  --main-dark: #7E3F2B;
  --clay: #D9A679;
  --cream: #F5ECE0;
  --olive: #6B7A5A;
  --ink: #3A2A22;
  --soft: #7A6A60;
  --line: #E6D9C8;
  --card: #FFFCF7;
  --bg: #F5ECE0;
  --ok: #4E6B3F;
  --tabs-h: 64px;
}
@media (prefers-color-scheme: dark) {
  :root { --ink: #F2E8DC; --soft: #BBA999; --line: #4A3A31; --card: #2E241F; --bg: #221A16; --cream: #2E241F; --main-dark: #E39A7E; --ok: #A5C08F; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: "Heebo", Arial, sans-serif; font-size: 16px; line-height: 1.55; -webkit-tap-highlight-color: transparent; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
a { color: var(--main-dark); }

.err { color: #B3261E; margin-top: 10px; font-size: 14px; }

/* frame */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px; padding: calc(10px + env(safe-area-inset-top)) 12px 10px; background: var(--main); color: #FFF7EE; }
.top h1 { flex: 1; margin: 0; font-size: 19px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { width: 40px; height: 40px; border: 0; border-radius: 12px; background: transparent; color: inherit; font-size: 22px; }
.icon-btn:active { background: rgba(255,255,255,.15); }
main { max-width: 680px; margin: 0 auto; padding: 14px 16px calc(var(--tabs-h) + 90px + env(safe-area-inset-bottom)); }
.hero { margin: 0 0 16px; padding: 14px 16px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); }
.hero-t { font-size: 18px; font-weight: 700; color: var(--main-dark); line-height: 1.4; margin-bottom: 6px; }
.hero-s { font-size: 14.5px; color: var(--soft); }
.intro { margin: 0 0 14px; color: var(--soft); font-size: 15px; }
.small { color: var(--soft); font-size: 13px; }

.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 6; display: flex; height: calc(var(--tabs-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: var(--card); border-top: 1px solid var(--line); }
.tabs button { position: relative; flex: 1; border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; font-size: 13px; color: var(--soft); }
.tabs .ti { font-size: 19px; line-height: 1.2; }
.tabs button.on { color: var(--main-dark); font-weight: 500; }
.badge { position: absolute; top: 7px; right: calc(50% - 22px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--main); color: #fff; font-size: 11px; line-height: 18px; }
.fab { position: fixed; z-index: 6; left: 18px; bottom: calc(var(--tabs-h) + 18px + env(safe-area-inset-bottom)); width: 58px; height: 58px; border: 0; border-radius: 50%; background: var(--main); color: #fff; font-size: 32px; line-height: 1; box-shadow: 0 4px 14px rgba(58,42,34,.28); }

/* buttons */
.primary { padding: 12px 22px; border: 0; border-radius: 12px; background: var(--main); color: #fff; font-weight: 500; font-size: 16px; }
.primary:disabled { opacity: .55; }
.ghost-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 11px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); font-size: 15px; cursor: pointer; }
.ghost-btn.wide { width: 100%; margin-top: 14px; }
.link-btn { border: 0; background: none; color: var(--soft); text-decoration: underline; font-size: 14px; padding: 8px; }

/* question list */
.card { display: block; width: 100%; text-align: right; margin-bottom: 10px; padding: 13px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); }
.card.unread { border-color: var(--main); box-shadow: inset -4px 0 0 var(--main); }
.card .t { font-weight: 500; font-size: 16px; }
.card .meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 6px; font-size: 13px; color: var(--soft); }
.chip { padding: 2px 10px; border-radius: 10px; font-size: 12px; white-space: nowrap; }
.chip.waiting { background: rgba(217,166,121,.28); color: var(--main-dark); }
.chip.new { background: var(--main); color: #fff; }
.chip.answered { background: rgba(107,122,90,.18); color: var(--ok); }
.empty { text-align: center; padding: 36px 12px; color: var(--soft); }
.show-archived { display: block; margin-top: 18px; font-size: 14px; color: var(--soft); }

/* thread */
.msg { margin: 0 0 14px; padding: 12px 14px; border-radius: 16px; max-width: 92%; white-space: normal; overflow-wrap: anywhere; }
.msg.rivka { margin-right: 0; margin-left: auto; background: var(--card); border: 1px solid var(--line); border-top-right-radius: 4px; }
.msg.claude { margin-left: 0; margin-right: auto; background: rgba(107,122,90,.12); border: 1px solid rgba(107,122,90,.3); border-top-left-radius: 4px; }
.msg .who { font-size: 12px; color: var(--soft); margin-bottom: 4px; display: flex; gap: 8px; flex-wrap: wrap; }
.msg .basis { color: var(--ok); }
.msg p { margin: 0 0 8px; }
.msg p:last-child, .msg ul:last-child { margin-bottom: 0; }
.msg ul { margin: 0 0 8px; padding-right: 20px; }
.msg .src { margin-top: 10px; padding-top: 8px; border-top: 1px dashed rgba(107,122,90,.4); font-size: 13px; }
.msg .src a { display: block; margin-top: 2px; }
.thumbs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.thumbs img { width: 84px; height: 84px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); cursor: zoom-in; }
.waiting-note { text-align: center; color: var(--soft); font-size: 14px; padding: 6px 0 4px; }
.item-actions { text-align: center; margin-top: 8px; }

/* compose */
textarea { width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); resize: vertical; font-size: 16px; }
.compose-row { display: flex; justify-content: space-between; gap: 10px; margin-top: 12px; }
.previews { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.previews .pv { position: relative; }
.previews img { width: 76px; height: 76px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
.previews button { position: absolute; top: -6px; left: -6px; width: 22px; height: 22px; border: 0; border-radius: 50%; background: var(--ink); color: var(--bg); font-size: 13px; line-height: 22px; padding: 0; }

/* checklist */
.sec { margin-bottom: 20px; }
.sec h2 { display: flex; justify-content: space-between; align-items: baseline; margin: 0 0 8px; font-size: 17px; font-weight: 500; color: var(--main-dark); }
.sec h2 span { font-size: 13px; color: var(--soft); font-weight: 400; }
.chk { display: flex; gap: 12px; padding: 11px 12px; margin-bottom: 6px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.chk input { flex: none; width: 22px; height: 22px; margin: 2px 0 0; accent-color: var(--olive); }
.chk .how { font-size: 13px; color: var(--soft); margin-top: 2px; }
.chk.done .tx { text-decoration: line-through; color: var(--soft); }
.progress { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; margin: 0 0 18px; }
.progress div { height: 100%; background: var(--olive); }

/* deadlines */
.dl { display: flex; gap: 12px; padding: 11px 12px; margin-bottom: 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.dl .date { flex: none; width: 56px; text-align: center; border-radius: 10px; background: rgba(168,87,61,.1); color: var(--main-dark); padding: 4px 0; }
.dl .date b { display: block; font-size: 21px; line-height: 1.1; }
.dl .date small { font-size: 12px; }
.dl.soon { border-color: var(--main); }
.dl .t { font-weight: 500; }
.dl .note { font-size: 13px; color: var(--soft); }
.dl .when { font-size: 12px; color: var(--soft); }
.verify { display: inline-block; margin-right: 6px; padding: 0 8px; border-radius: 8px; font-size: 11px; background: rgba(217,166,121,.3); color: var(--main-dark); font-weight: 400; }

.viewer { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.88); display: flex; align-items: center; justify-content: center; padding: 16px; }
.viewer img { max-width: 100%; max-height: 100%; border-radius: 8px; }
