/* All Talk. Mobile-first, light and dark follow the phone's setting. */
:root {
  --bg: #FBF6EC; --surface: #FFFFFF; --ink: #1A1613; --muted: #6F665C; --line: #E6DDCD;
  --doubt: #D63A1F; --believe: #177A4F; --pop: #FFD84D; --pop-ink: #1A1613;
  --edge: #1A1613; --shadow: 3px 3px 0 var(--edge);
  --good-bg: #DDF3E6; --bad-bg: #FBE0D9; --vote-bg: #FFF0B3;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12100E; --surface: #1F1B18; --ink: #F7F1E6; --muted: #A69D92; --line: #3A342E;
    --doubt: #FF7A5C; --believe: #5AD19B; --pop: #FFD84D; --pop-ink: #1A1613;
    --edge: #000000; --shadow: 3px 3px 0 var(--edge);
    --good-bg: #173527; --bad-bg: #40201A; --vote-bg: #3D3410;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); overscroll-behavior-y: contain;
  font: 17px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, sans-serif;
  padding: 0 env(safe-area-inset-right) 0 env(safe-area-inset-left);
}
body.sheet-open { overflow: hidden; }
[hidden] { display: none !important; }
a { color: inherit; }
h1, h2, p { margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; }

/* top bar */
#top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px; background: var(--bg);
}
.wordmark {
  font-weight: 900; font-size: 22px; letter-spacing: -.5px; text-decoration: none;
  background: var(--pop); color: var(--pop-ink); padding: 4px 12px 5px; border: 2px solid var(--edge);
  border-radius: 14px 14px 14px 3px; box-shadow: 2px 2px 0 var(--edge);
}
.wordmark span { font-weight: 500; font-style: italic; }
.icon-btn { background: none; border: 0; padding: 10px; min-width: 44px; min-height: 44px; border-radius: 50%; cursor: pointer; }
.icon-btn.spin svg { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#pull {
  position: fixed; top: calc(env(safe-area-inset-top) + 58px); left: 50%; transform: translate(-50%, -20px); opacity: 0; z-index: 6;
  background: var(--ink); color: var(--bg); padding: 6px 14px; border-radius: 99px; font-size: 14px; transition: .15s; pointer-events: none;
}
#pull.show { opacity: 1; transform: translate(-50%, 0); }

/* layout */
#view { max-width: 560px; margin: 0 auto; padding: 4px 16px 32px; outline: none; }
body.with-tabs #view { padding-bottom: calc(env(safe-area-inset-bottom) + 96px); }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 8px 0 14px; }
.page-head h1 { font-size: 30px; font-weight: 800; letter-spacing: -.6px; overflow-wrap: anywhere; }
.section { margin-top: 22px; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 0 4px 8px; font-weight: 700; }
.muted { color: var(--muted); } .small { font-size: 14px; } .pad { padding: 0 4px; margin-top: 8px; }
.d { color: var(--doubt); } .b { color: var(--believe); }
.loading { text-align: center; color: var(--muted); padding: 80px 0; }
.back { display: inline-block; padding: 10px 4px; text-decoration: none; font-weight: 600; }

/* cards */
.card {
  display: block; background: var(--surface); border: 2px solid var(--edge); border-radius: 18px;
  box-shadow: var(--shadow); padding: 16px; text-decoration: none; margin-bottom: 14px;
}
@media (prefers-color-scheme: dark) { .card { border-color: var(--line); } }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.who { font-weight: 700; font-size: 15px; overflow-wrap: anywhere; }
.quote { font-size: 22px; font-weight: 800; line-height: 1.2; letter-spacing: -.3px; margin: 8px 0 12px; overflow-wrap: anywhere; }
.quote::before { content: "\201C"; } .quote::after { content: "\201D"; }
.claim.big .quote { font-size: 28px; }
.quote.small { font-size: 18px; margin: 0 0 14px; }
.pot b { font-size: 20px; background: var(--pop); color: var(--pop-ink); padding: 1px 8px; border-radius: 8px; margin-left: 4px; }
.chip { display: inline-block; font-size: 13px; font-weight: 700; padding: 3px 10px; border-radius: 99px; border: 1.5px solid var(--line); white-space: nowrap; }
.chip.good { background: var(--good-bg); border-color: transparent; color: var(--believe); }
.chip.bad { background: var(--bad-bg); border-color: transparent; color: var(--doubt); }
.chip.vote { background: var(--vote-bg); border-color: transparent; }
.split { margin-top: 12px; }
.bar { display: flex; height: 10px; border-radius: 99px; overflow: hidden; background: var(--line); }
.bar .d { background: var(--doubt); } .bar .b { background: var(--believe); }
.split-text { display: flex; justify-content: space-between; font-size: 14px; font-weight: 700; margin-top: 5px; }

.banner { display: block; background: var(--vote-bg); border-radius: 14px; padding: 12px 14px; margin-bottom: 14px; font-size: 15px; text-decoration: none; }
.result { border-radius: 18px; padding: 16px; margin-bottom: 14px; }
.result strong { font-size: 22px; font-weight: 800; }
.result.good { background: var(--good-bg); } .result.bad { background: var(--bad-bg); }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty strong { display: block; color: var(--ink); font-size: 19px; margin: 12px 0 4px; }
.bubble { display: inline-block; background: var(--pop); color: var(--pop-ink); font-size: 34px; font-weight: 900; line-height: 1; padding: 6px 22px 18px; border: 2px solid var(--edge); border-radius: 22px 22px 22px 4px; }

/* lists */
.list { list-style: none; padding: 4px 16px; }
.list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 0; border-top: 1px solid var(--line); min-height: 48px; }
.list li:first-child { border-top: 0; }
.list li > :first-child { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.debt > div, .member { display: flex; flex-direction: column; align-items: flex-start !important; gap: 3px; }
.debt { flex-direction: row; } .debt > div { flex: 1; min-width: 0; }
.records { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 14px; color: var(--muted); }
.records b { color: var(--ink); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stats div { background: var(--surface); border: 2px solid var(--edge); border-radius: 16px; padding: 12px 6px; text-align: center; box-shadow: var(--shadow); }
@media (prefers-color-scheme: dark) { .stats div { border-color: var(--line); } }
.stats b { display: block; font-size: 24px; font-weight: 800; } .stats span { font-size: 13px; color: var(--muted); }
.plain { padding-left: 18px; margin: 0; } .plain li { margin: 6px 0; }
.terms p { margin-top: 10px; }
.defbox { background: var(--bg); border-radius: 12px; padding: 10px 12px; margin: 0 0 4px; overflow-wrap: anywhere; }
.proof-img { display: block; width: 100%; max-height: 70vh; object-fit: contain; border-radius: 12px; background: var(--bg); min-height: 120px; margin-bottom: 12px; }
.note { font-style: italic; margin-bottom: 12px; overflow-wrap: anywhere; }
.vote-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0 4px; }
.tally { list-style: none; padding: 0; margin: 12px 0 0; font-size: 15px; } .tally li { margin-top: 6px; overflow-wrap: anywhere; }

/* buttons and forms */
.btn {
  display: inline-flex; align-items: center; justify-content: center; min-height: 46px; padding: 10px 18px; cursor: pointer;
  background: var(--surface); color: var(--ink); border: 2px solid var(--edge); border-radius: 14px; font-weight: 700; text-decoration: none;
  box-shadow: 2px 2px 0 var(--edge); transition: transform .1s, box-shadow .1s; text-align: center;
}
@media (prefers-color-scheme: dark) { .btn { border-color: var(--line); } }
.btn:active { transform: translate(2px, 2px); box-shadow: none; }
.btn:disabled { opacity: .5; }
.btn.primary { background: var(--pop); color: var(--pop-ink); border-color: var(--edge); }
.btn.believe { background: var(--good-bg); color: var(--believe); } .btn.doubt { background: var(--bad-bg); color: var(--doubt); }
.btn.picked { outline: 3px solid currentColor; outline-offset: 2px; }
.btn.ghost { background: none; border-color: transparent; box-shadow: none; }
.btn.danger { color: var(--doubt); }
.btn.small { min-height: 44px; padding: 6px 14px; font-size: 15px; white-space: nowrap; }
.btn.wide { display: flex; width: 100%; margin-bottom: 14px; }
.form { display: flex; flex-direction: column; gap: 14px; }
.form h2 { font-size: 22px; font-weight: 800; }
.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-size: 14px; font-weight: 700; display: block; }
.hint { font-size: 13px; color: var(--muted); }
input[type=text], input[type=date], textarea, select {
  width: 100%; min-height: 48px; padding: 10px 12px; background: var(--surface); border: 2px solid var(--line); border-radius: 12px; resize: none;
}
input[type=file] { width: 100%; font-size: 15px; }
input:focus, textarea:focus, select:focus { outline: 0; border-color: var(--ink); }
input[type=range] { width: 100%; accent-color: var(--doubt); height: 36px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; }
.check input { width: 24px; height: 24px; flex: none; accent-color: var(--believe); margin: 0; }
.live-line { background: var(--vote-bg); border-radius: 12px; padding: 10px 12px; font-size: 15px; font-weight: 600; margin: 14px 0; }
.form .live-line { margin: 0; }
.linkbox { background: var(--bg); border: 2px dashed var(--line); border-radius: 12px; padding: 10px 12px; font-size: 14px; word-break: break-all; user-select: all; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.seg button { min-height: 52px; border-radius: 14px; border: 2px solid var(--line); background: var(--surface); font-weight: 800; cursor: pointer; }
.seg .doubt.on { background: var(--bad-bg); border-color: var(--doubt); color: var(--doubt); }
.seg .believe.on { background: var(--good-bg); border-color: var(--believe); color: var(--believe); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip-btn { min-height: 44px; padding: 6px 16px; border-radius: 99px; border: 2px solid var(--line); background: var(--surface); font-weight: 700; cursor: pointer; }
.chip-btn.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
details summary { font-weight: 700; cursor: pointer; min-height: 28px; }
details .card { border: 0; box-shadow: none; padding: 14px 0 0; margin: 0; }

/* welcome */
.welcome { padding-top: 8px; }
.hero h1 { font-size: 40px; line-height: 1.02; font-weight: 900; letter-spacing: -1.2px; margin: 14px 0 12px; overflow-wrap: anywhere; }
.hero em { font-style: normal; background: var(--pop); color: var(--pop-ink); padding: 0 8px; border-radius: 10px; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.hero p { font-size: 18px; color: var(--muted); margin-bottom: 18px; }
.steps { padding-left: 22px; margin: 0 0 22px; } .steps li { margin: 6px 0; }
.fine { font-size: 14px; color: var(--muted); text-align: center; }

/* tab bar */
#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; justify-content: space-around;
  background: var(--surface); border-top: 2px solid var(--edge); padding: 6px 8px calc(env(safe-area-inset-bottom) + 6px);
}
@media (prefers-color-scheme: dark) { #tabs { border-top-color: var(--line); } }
#tabs a { position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 48px; padding-top: 4px; text-decoration: none; font-size: 11px; font-weight: 700; color: var(--muted); }
#tabs svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#tabs a.on { color: var(--ink); } #tabs a.on svg { fill: var(--pop); }
#settle-dot { position: absolute; top: 0; left: calc(50% + 8px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: var(--doubt); color: #fff; font-size: 11px; font-style: normal; line-height: 18px; text-align: center; }

/* sheets */
.sheet-wrap { position: fixed; inset: 0; z-index: 10; background: rgba(0, 0, 0, .5); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto; background: var(--surface); border-radius: 22px 22px 0 0;
  padding: 8px 16px calc(env(safe-area-inset-bottom) + 20px); animation: up .22s ease-out;
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; position: sticky; top: -8px; background: var(--surface); padding: 6px 0; z-index: 1; }
.sheet-head h2 { font-size: 22px; font-weight: 800; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }

#toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 96px); transform: translate(-50%, 20px); z-index: 20; opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 14px; font-size: 15px; font-weight: 600; max-width: min(90vw, 480px); text-align: center; transition: .2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
