:root {
  --primary: #0B1B26; --accent: #B39C84; --accent-bg: #F7F3EE; --text: #1A1A1A; --grey: #5F6670;
  --line: #DADDE1; --head: #EDEFF1; --bg: #FAFAF8; --card: #FFFFFF; --ok: #2E6B3F; --warn: #9A6A12; --bad: #8B1E1E;
  --r: 12px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: Heebo, Arial, sans-serif; background: var(--bg); color: var(--text); font-size: 16px;
       padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
button, input, textarea, select { font: inherit; }
a { color: var(--primary); }
[hidden] { display: none !important; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
       padding: 10px 16px; background: var(--primary); color: #fff; }
.brand { display: flex; align-items: baseline; gap: 10px; }
.brand .mark { font-weight: 700; letter-spacing: .3px; }
.brand .proj { color: var(--accent); font-size: 14px; }

main { max-width: 760px; margin: 0 auto; padding: 16px; }
h1 { font-size: 21px; margin: 4px 0 12px; color: var(--primary); }
h2 { font-size: 16px; margin: 18px 0 8px; color: var(--primary); }
.muted { color: var(--grey); font-size: 14px; }
.small { font-size: 13px; }

.tabs { position: fixed; bottom: 0; inset-inline: 0; z-index: 5; display: flex; background: #fff;
        border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs a { flex: 1; text-align: center; padding: 12px 4px; text-decoration: none; color: var(--grey); font-size: 14px;
          position: relative; }
.tabs a.on { color: var(--primary); font-weight: 700; box-shadow: inset 0 3px 0 var(--accent); }
.badge { background: var(--bad); color: #fff; border-radius: 9px; font-size: 11px; padding: 0 6px; margin-inline-start: 4px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin-bottom: 10px; }
.card.link { display: block; text-decoration: none; color: inherit; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.num { font-weight: 700; color: var(--primary); direction: ltr; unicode-bidi: isolate; }
.pill { display: inline-block; border-radius: 999px; padding: 2px 10px; font-size: 13px; background: var(--head); color: var(--grey); white-space: nowrap; }
.pill.ok { background: #E3F0E6; color: var(--ok); }
.pill.warn { background: #FBF0DA; color: var(--warn); }
.pill.bad { background: #F5E1E1; color: var(--bad); }
.pill.draft { background: var(--accent-bg); color: #7A6550; }

button { border: 0; border-radius: 10px; padding: 11px 16px; background: var(--primary); color: #fff; cursor: pointer; }
button.accent { background: var(--accent); color: var(--primary); font-weight: 700; }
button.ghost { background: transparent; color: var(--primary); border: 1px solid var(--line); }
.top button.ghost { color: #fff; border-color: rgba(255,255,255,.35); }
button.small { padding: 6px 12px; font-size: 14px; }
button.wa { background: #1F8A4C; }
button:disabled { opacity: .5; cursor: default; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.actions > * { flex: 1 1 auto; }

input, textarea, select { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fff; }
textarea { resize: vertical; min-height: 44px; }
label { display: block; font-size: 14px; color: var(--grey); margin: 10px 0 4px; }
.err { color: var(--bad); font-size: 14px; margin-top: 8px; }

/* chat */
.chat { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.msg { max-width: 88%; padding: 10px 12px; border-radius: 14px; white-space: pre-wrap; line-height: 1.45; }
.msg.user { align-self: flex-start; background: var(--primary); color: #fff; border-end-start-radius: 4px; }
.msg.assistant { align-self: flex-end; background: #fff; border: 1px solid var(--line); border-end-end-radius: 4px; }
.msg .who { font-size: 12px; opacity: .7; margin-bottom: 2px; }
.msg .files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.msg .files a { color: inherit; font-size: 13px; background: rgba(255,255,255,.15); padding: 2px 8px; border-radius: 6px; text-decoration: none; }
.msg.assistant .tag { font-size: 12px; color: var(--accent); font-weight: 700; }
.composer { position: sticky; bottom: calc(56px + env(safe-area-inset-bottom)); background: var(--bg); padding: 8px 0;
            display: flex; gap: 8px; align-items: flex-end; }
.composer textarea { flex: 1; }
.composer .attach { background: var(--head); color: var(--primary); padding: 11px 13px; }
.pending-files { display: flex; flex-wrap: wrap; gap: 6px; }
.pending-files span { background: var(--accent-bg); border-radius: 8px; padding: 3px 8px; font-size: 13px; }
.thinking { align-self: flex-end; color: var(--grey); font-size: 14px; }

/* form summary */
.form-sum table { width: 100%; border-collapse: collapse; font-size: 14px; }
.form-sum th, .form-sum td { border: 1px solid var(--line); padding: 6px 8px; text-align: start; vertical-align: top; }
.form-sum th { background: var(--head); color: var(--primary); font-weight: 500; width: 26%; }
.form-sum td.rec { background: var(--accent-bg); }
.form-sum .scroll { overflow-x: auto; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 4px 10px; font-size: 14px; }
.kv dt { color: var(--grey); }
.kv dd { margin: 0; }
.fixed { color: var(--grey); font-size: 13px; background: var(--head); border-radius: 8px; padding: 8px 10px; }

.modal { position: fixed; inset: 0; background: rgba(11,27,38,.45); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: #fff; width: 100%; max-width: 640px; max-height: 92vh; overflow: auto; border-radius: 16px 16px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
@media (min-width: 700px) { .modal { align-items: center; } .sheet { border-radius: 16px; } }
.toast { position: fixed; bottom: calc(76px + env(safe-area-inset-bottom)); inset-inline: 16px; margin: auto; max-width: 480px;
         background: var(--primary); color: #fff; padding: 12px 14px; border-radius: 10px; z-index: 30; text-align: center; }
.empty { text-align: center; color: var(--grey); padding: 30px 10px; }
.login { max-width: 360px; margin: 40px auto; }
.notice { background: #FBF0DA; color: #6A4A0E; border-radius: 10px; padding: 10px 12px; font-size: 14px; margin-bottom: 12px; }

/* viewer */
.viewer { position: fixed; inset: 0; z-index: 40; background: #2B2F33; display: flex; flex-direction: column; }
.vbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; background: var(--primary); color: #fff; }
.vbar .ghost { color: #fff; border-color: rgba(255,255,255,.35); }
.vbar a { color: var(--accent); }
.vname { flex: 1; text-align: center; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vbody { flex: 1; overflow: auto; padding: 10px; -webkit-overflow-scrolling: touch; }
.vbody img { display: block; width: 100%; max-width: 900px; margin: 0 auto; background: #fff; border-radius: 4px; min-height: 140px; }
.vpage { text-align: center; color: #C9CDD2; font-size: 12px; margin: 6px 0 14px; }
.vtext { overflow-wrap: anywhere; font-family: inherit; background: #fff; padding: 14px; border-radius: 8px; white-space: pre-wrap; max-width: 900px; margin: 0 auto; }
