:root {
  --accent: #2E7D4A;
  --accent-ink: #FFFFFF;
  --ground: #F3F3F1;
  --card: #FFFFFF;
  --ink: #1A1A1A;
  --muted: #6B6B6B;
  --line: #E6E6E2;
  --danger: #B42318;
  --radius: 22px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--ground); color: var(--ink); font-family: 'Figtree', system-ui, -apple-system, sans-serif; -webkit-font-smoothing: antialiased; overscroll-behavior: none; }
body { overflow: hidden; }
#app { height: 100%; display: flex; flex-direction: column; }
button, input, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); text-decoration: none; }
.screen { flex: 1; display: flex; flex-direction: column; min-height: 0; animation: fade .18s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.topbar { display: flex; align-items: center; gap: 8px; padding: calc(14px + var(--safe-top)) 12px 12px; }
.topbar .title { flex: 1; text-align: center; font-size: 22px; font-weight: 800; color: var(--accent); letter-spacing: -0.3px; }
.topbar .title.ink { color: var(--ink); font-size: 19px; font-weight: 700; }
.topbar .sub { display: block; font-size: 12px; font-weight: 500; color: var(--accent); margin-top: 2px; }
.iconbtn { width: 44px; height: 44px; border: 0; background: transparent; border-radius: 22px; display: flex; align-items: center; justify-content: center; color: var(--accent); }
.iconbtn:active { background: rgba(0,0,0,.05); }
.iconbtn svg { width: 24px; height: 24px; }
.content { flex: 1; overflow-y: auto; padding: 0 16px calc(24px + var(--safe-bottom)); -webkit-overflow-scrolling: touch; }
.hero { padding: 40px 28px 28px; }
.wordmark { font-size: 44px; font-weight: 800; color: var(--accent); letter-spacing: -1px; line-height: 1; }
.tagline { font-size: 18px; color: var(--muted); margin-top: 10px; }
.card { background: var(--card); border-radius: var(--radius); padding: 20px; margin-bottom: 14px; }
.label { font-size: 12px; font-weight: 700; letter-spacing: 2px; color: var(--muted); text-transform: uppercase; margin-bottom: 12px; }
h2 { font-size: 24px; font-weight: 700; margin: 0 0 8px; }
p { line-height: 1.5; margin: 0 0 14px; }
p.muted, .muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 10px; align-items: center; }
.field { width: 100%; height: 56px; border: 1.5px solid #D9D9D4; border-radius: 14px; padding: 0 16px; font-size: 20px; background: #fff; outline: none; }
.field:focus { border-color: var(--accent); }
.field.cc { width: 92px; text-align: center; flex: none; }
.field.code { font-size: 32px; letter-spacing: 10px; text-align: center; height: 72px; font-weight: 600; }
.btn { width: 100%; height: 56px; border: 0; border-radius: 16px; background: var(--accent); color: var(--accent-ink); font-size: 17px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; display: flex; align-items: center; justify-content: center; gap: 8px; }
.btn:disabled { opacity: .5; }
.btn.ghost { background: transparent; color: var(--accent); border: 1.5px solid var(--line); }
.btn.danger { background: transparent; color: var(--danger); border: 1.5px solid var(--line); }
.stack { display: flex; flex-direction: column; gap: 14px; }
.trust { display: flex; align-items: center; gap: 12px; font-size: 14px; margin-top: 10px; }
.trust svg { width: 22px; height: 22px; flex: none; color: var(--accent); }
.section { font-size: 12px; font-weight: 700; letter-spacing: 2px; color: var(--muted); padding: 14px 4px 8px; }
.list { background: var(--card); border-radius: var(--radius); overflow: hidden; }
.item { display: flex; align-items: center; gap: 14px; padding: 15px 18px; border-bottom: 1px solid var(--line); width: 100%; text-align: left; background: transparent; border-left: 0; border-right: 0; border-top: 0; }
.item:last-child { border-bottom: 0; }
.item:active { background: var(--ground); }
.avatar { width: 46px; height: 46px; border-radius: 23px; flex: none; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px; color: #fff; background: var(--accent); }
.avatar.small { width: 40px; height: 40px; font-size: 14px; }
.avatar.group { background: #1A1A1A; }
.item .main { flex: 1; min-width: 0; }
.item .name { font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .meta { font-size: 13px; color: var(--muted); margin-top: 3px; display: flex; gap: 4px; align-items: center; }
.bars { display: flex; gap: 4px; margin-top: 6px; }
.bars i { display: block; height: 9px; border-radius: 5px; background: var(--accent); opacity: .3; }
.item .right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; font-size: 12px; color: var(--muted); }
.dot { width: 12px; height: 12px; border-radius: 6px; background: var(--accent); }
.empty { text-align: center; color: var(--muted); padding: 60px 24px; line-height: 1.5; }
.empty .big { font-size: 40px; margin-bottom: 10px; }
.tabbar { display: flex; justify-content: space-around; border-top: 1px solid var(--line); padding: 10px 0 calc(12px + var(--safe-bottom)); background: var(--ground); }
.tab { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 12px; font-weight: 600; color: var(--muted); border: 0; background: transparent; padding: 4px 20px; }
.tab.on { color: var(--accent); }
.tab svg { width: 26px; height: 26px; }

/* Conversation */
.thread { flex: 1; overflow-y: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 14px; }
.day { align-self: center; font-size: 12px; color: var(--muted); }
.msg { max-width: 86%; display: flex; flex-direction: column; gap: 6px; }
.msg.mine { align-self: flex-end; align-items: flex-end; }
.msg.theirs { align-self: flex-start; align-items: flex-start; }
.msg .who { font-size: 12px; color: var(--muted); font-weight: 600; }
.bubble { background: var(--card); border: 1px solid var(--line); border-radius: 4px 18px 18px 18px; padding: 10px 14px; font-size: 16px; line-height: 1.4; }
.msg.mine .bubble { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); border-radius: 18px 18px 4px 18px; }
.status { font-size: 11px; color: var(--muted); }
.sealed { display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: var(--card); border: 1.5px solid var(--accent); border-radius: 4px 18px 18px 18px; width: 100%; text-align: left; }
.sealed .t { font-size: 15px; font-weight: 600; }
.sealed .s { font-size: 12px; color: var(--muted); }
.sealed svg { width: 24px; height: 24px; color: var(--accent); flex: none; }
.lines { display: flex; flex-direction: column; gap: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 4px 18px 18px 18px; padding: 8px 12px; min-width: 200px; touch-action: none; user-select: none; -webkit-user-select: none; }
.msg.mine .lines { background: #fff; border-color: var(--accent); border-radius: 18px 18px 4px 18px; }
.line { min-height: 34px; display: flex; align-items: center; border: 0; background: transparent; padding: 4px 2px; text-align: left; font-size: 16px; line-height: 1.3; width: 100%; color: var(--ink); }
.line .cover { height: 15px; border-radius: 8px; background: var(--accent); opacity: .35; display: block; transition: opacity .15s; }
.line.open .cover { display: none; }
.line .txt { display: none; }
.line.open .txt { display: block; animation: reveal .12s ease-out; }
@keyframes reveal { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
.hint { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.hint svg { width: 14px; height: 14px; }
.actions { display: flex; gap: 8px; }
.chip { border: 1.5px solid var(--line); background: var(--card); color: var(--ink); border-radius: 20px; padding: 8px 14px; font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.chip.accent { color: var(--accent); border-color: var(--accent); }
.chip svg { width: 16px; height: 16px; }
.composer { display: flex; align-items: flex-end; gap: 10px; padding: 10px 14px calc(14px + var(--safe-bottom)); border-top: 1px solid var(--line); background: var(--ground); }
.composer textarea { flex: 1; min-height: 44px; max-height: 120px; border: 1.5px solid #D9D9D4; border-radius: 22px; padding: 11px 16px; font-size: 16px; resize: none; background: #fff; outline: none; line-height: 1.3; }
.composer textarea:focus { border-color: var(--accent); }
.round { width: 44px; height: 44px; border-radius: 22px; border: 0; display: flex; align-items: center; justify-content: center; flex: none; }
.round.send { background: var(--accent); color: var(--accent-ink); }
.round.attach { background: var(--card); color: var(--accent); }
.round svg { width: 20px; height: 20px; }
.peek { position: relative; border-radius: 16px; overflow: hidden; background: #111; touch-action: none; }
.peek img { display: block; width: 100%; max-height: 60vh; object-fit: contain; }
.peek .shade { position: absolute; inset: 0; background: var(--ink); pointer-events: none; }
.peek .shade.hole { background: transparent; }
.peek .caption { position: absolute; bottom: 8px; left: 0; right: 0; text-align: center; color: #fff; font-size: 12px; text-shadow: 0 1px 2px #000; }
.filecard { display: flex; align-items: center; gap: 12px; }
.filecard svg { width: 28px; height: 28px; color: var(--accent); flex: none; }

/* Reader */
.reader { background: #fff; animation: none; }
.rbar { background: var(--accent); color: var(--accent-ink); display: flex; align-items: center; justify-content: space-between; padding: calc(10px + var(--safe-top)) 8px 10px; }
.rclose { border: 0; background: transparent; color: var(--accent-ink); font-size: 19px; font-weight: 600; padding: 10px 12px; min-width: 64px; text-align: left; }
.rfrom { font-size: 15px; font-weight: 600; opacity: .9; }
.rbody { flex: 1; overflow-y: auto; padding: 28px 24px 24px; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; cursor: grab; }
.rline { display: flex; flex-wrap: nowrap; gap: 6px; padding: 9px 0; min-height: 52px; align-items: center; }
.w { font-size: 25px; line-height: 34px; font-weight: 500; color: transparent; background: var(--accent); border-radius: 5px; padding: 0 3px; white-space: nowrap; }
.rline.seen .w { background: #E4E4E0; }
.rline.open .w { background: transparent; color: var(--ink); }
.gap { display: block; height: 20px; }
.rhint { text-align: center; font-size: 13px; color: var(--muted); padding: 12px 20px calc(16px + var(--safe-bottom)); }
.peek.big { border-radius: 12px; }
.peek.big img { max-height: none; }
.filecard.big { flex-direction: column; align-items: flex-start; gap: 14px; padding: 8px 0; }
.filecard.big svg { width: 44px; height: 44px; }
.dust { position: fixed; inset: 0; pointer-events: none; z-index: 100; overflow: hidden; }
.dust i { position: absolute; display: block; will-change: transform, opacity; }

/* Settings */
.swatches { display: flex; justify-content: space-between; }
.swatch { width: 52px; height: 52px; border-radius: 26px; border: 4px solid #fff; padding: 0; }
.swatch.on { border-color: var(--ink); }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 0; border-bottom: 1px solid var(--line); }
.setting:last-child { border-bottom: 0; }
.setting .t { font-size: 16px; font-weight: 600; }
.setting .d { font-size: 13px; color: var(--muted); margin-top: 2px; }
.setting .v { font-size: 15px; font-weight: 600; color: var(--accent); }
.toggle { width: 52px; height: 32px; border-radius: 16px; background: #CFCFC9; border: 0; padding: 3px; display: flex; justify-content: flex-start; transition: background .2s; flex: none; }
.toggle.on { background: var(--accent); justify-content: flex-end; }
.toggle i { width: 26px; height: 26px; border-radius: 13px; background: #fff; display: block; }
.picked { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.picked .chip { padding: 6px 10px 6px 12px; }
.picked .chip button { border: 0; background: transparent; color: var(--muted); font-size: 16px; line-height: 1; padding: 0 2px; }
#toast { position: fixed; left: 16px; right: 16px; bottom: calc(24px + var(--safe-bottom)); background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 14px; font-size: 14px; font-weight: 500; opacity: 0; transform: translateY(10px); transition: all .2s; pointer-events: none; z-index: 50; text-align: center; }
#toast.show { opacity: 1; transform: none; }
.devcode { background: #FFF4D6; color: #7A4F00; border-radius: 12px; padding: 10px 14px; font-size: 14px; }
.center { text-align: center; }
.spacer { flex: 1; }
.spin { width: 18px; height: 18px; border: 2.5px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (min-width: 720px) { #app { max-width: 480px; margin: 0 auto; box-shadow: 0 0 0 1px var(--line); background: var(--ground); } }
