/* Layout: one narrow letter-paper column (max 460px) with a sticky top bar and a bottom tab bar, like a phone app.
   Brand: Jesse's Instagram cards — paper white, ink, and the red of the beanie; handwriting reserved for Jesse's voice. */
:root {
  --paper: #fbfbf9;
  --sheet: #ffffff;
  --ink: #24272b;
  --ink-soft: #5d636b;
  --line: #e4e6e9;
  --beanie: #d2412c;
  --beanie-soft: #fbe9e5;
  --leaf: #3f7d5a;
  --leaf-soft: #e6f1ea;
  --alert: #b3261e;
  --alert-soft: #fdecea;
  --shadow: 0 1px 2px rgba(36, 39, 43, .06), 0 4px 16px rgba(36, 39, 43, .05);
  --font-body: "Gowun Dodum", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  --font-hand: "Nanum Pen Script", "Gowun Dodum", "Apple SD Gothic Neo", cursive;
  --font-letter: "Gowun Batang", "AppleMyungjo", "Batang", serif;
  --r: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #16181b; --sheet: #1e2125; --ink: #ecebe7; --ink-soft: #a5abb3; --line: #2f3338;
    --beanie: #f0735f; --beanie-soft: #3a2420; --leaf: #7cc49b; --leaf-soft: #1f3128;
    --alert: #ff8a80; --alert-soft: #3b1f1d; --shadow: 0 1px 2px rgba(0,0,0,.3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #16181b; --sheet: #1e2125; --ink: #ecebe7; --ink-soft: #a5abb3; --line: #2f3338;
  --beanie: #f0735f; --beanie-soft: #3a2420; --leaf: #7cc49b; --leaf-soft: #1f3128;
  --alert: #ff8a80; --alert-soft: #3b1f1d; --shadow: 0 1px 2px rgba(0,0,0,.3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--font-body); font-size: 15px; line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--paper); }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--beanie); outline-offset: 2px; border-radius: 6px; }

.app { max-width: 460px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--paper);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding-block: 12px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; flex-direction: column; line-height: 1.15; text-decoration: none; }
.brand b { font-family: var(--font-hand); font-size: 25px; font-weight: 400; }
.brand small { font-size: 11px; letter-spacing: .12em; color: var(--beanie); }
.who { font-size: 12px; color: var(--ink-soft); background: none; border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; cursor: pointer; }

main { flex: 1; display: flex; flex-direction: column; gap: 16px;
  padding-block: 16px 96px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }

.demo-note { font-size: 12px; color: var(--ink-soft); background: var(--sheet); border: 1px dashed var(--line); border-radius: 10px; padding: 8px 12px; }
.intro h1 { font-family: var(--font-hand); font-weight: 400; font-size: 32px; line-height: 1.2; margin: 4px 0 6px; text-wrap: balance; }
.intro p { margin: 0; color: var(--ink-soft); }
.intro .promise { margin-top: 10px; font-size: 13px; }

.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--sheet); border-radius: 999px; padding: 5px 12px; font-size: 13px; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.card { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow); text-decoration: none; cursor: pointer; }
.card:hover { border-color: var(--ink-soft); }
.cat { font-size: 11px; letter-spacing: .08em; color: var(--ink-soft); }
.clip2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin: 0; }
.reply-peek { border-left: 2px solid var(--beanie); padding-left: 10px; font-family: var(--font-letter); font-size: 14px; }
.meta { display: flex; gap: 12px; font-size: 12px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }

.letter { background: var(--sheet); border: 1px solid var(--line); border-radius: var(--r); padding: 20px 18px; display: flex; flex-direction: column; gap: 10px; }
.letter .from { font-size: 12px; color: var(--ink-soft); }
.letter p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.letter.jesse { background: var(--sheet); border-color: var(--beanie); }
.letter.jesse p { font-family: var(--font-letter); font-size: 15px; line-height: 1.9; }
.sign { align-self: flex-end; font-family: var(--font-hand); font-size: 22px; color: var(--beanie); }

.reactions { display: flex; gap: 8px; flex-wrap: wrap; }
.react { border: 1px solid var(--line); background: var(--sheet); border-radius: 999px; padding: 6px 12px; font-size: 13px; cursor: pointer; font-variant-numeric: tabular-nums; }
.react[aria-pressed="true"] { border-color: var(--beanie); background: var(--beanie-soft); }

.btn { text-decoration: none; text-align: center; border: 0; border-radius: 12px; padding: 12px 16px; font-size: 15px; cursor: pointer; background: var(--ink); color: var(--paper); }
.btn.primary { background: var(--beanie); color: #fff; }
.btn.ghost { background: none; color: var(--ink); border: 1px solid var(--line); }
.btn.small { padding: 6px 10px; font-size: 13px; border-radius: 9px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--ink-soft); text-decoration: underline; font-size: 13px; cursor: pointer; }

form, .stack { display: flex; flex-direction: column; gap: 14px; }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.field small, .hint { font-size: 12px; color: var(--ink-soft); }
select, textarea, input[type="text"] { width: 100%; border: 1px solid var(--line); border-radius: 12px; background: var(--sheet); padding: 10px 12px; }
textarea { min-height: 180px; resize: vertical; line-height: 1.7; }
fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin: 0; display: flex; flex-direction: column; gap: 6px; }
legend { font-size: 14px; padding: 0 4px; }
.opt { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; }
.opt input { margin-top: 5px; }
.notice { background: var(--leaf-soft); border-radius: 12px; padding: 12px 14px; font-size: 13px; }
.notice.alert { background: var(--alert-soft); }
.notice strong { display: block; margin-bottom: 2px; }

.status { font-size: 12px; border-radius: 999px; padding: 2px 9px; white-space: nowrap; }
.s-received { background: var(--line); }
.s-read { background: var(--leaf-soft); color: var(--leaf); }
.s-replied, .s-published { background: var(--beanie-soft); color: var(--beanie); }
.s-hidden { background: var(--line); color: var(--ink-soft); }
.risk { background: var(--alert-soft); color: var(--alert); }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; background: var(--paper); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px); padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px); }
.tabs nav { max-width: 460px; margin: 0 auto; display: flex; }
.tabs a { flex: 1; text-align: center; padding: 10px 4px 12px; font-size: 12px; text-decoration: none; color: var(--ink-soft); display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tabs a[aria-current="page"] { color: var(--beanie); }
.tabs .ico { font-size: 18px; line-height: 1; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stat { background: var(--sheet); border: 1px solid var(--line); border-radius: 12px; padding: 10px; text-align: center; }
.stat b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 11px; color: var(--ink-soft); }
h2 { font-size: 17px; margin: 8px 0 0; }
.empty { text-align: center; color: var(--ink-soft); padding: 32px 0; font-size: 14px; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(76px + env(safe-area-inset-bottom, 0px)); background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 999px; font-size: 13px; z-index: 20; }
@media (prefers-reduced-motion: no-preference) { .card { transition: border-color .15s; } }
