:root {
  color-scheme: light;
  --bg: #f3ecdf;
  --bg-2: #efe2cf;
  --card: #fffaf3;
  --ink: #2c241c;
  --muted: #6d5f52;
  --line: #eadfce;
  --forest: #2f5d45;
  --forest-ink: #1d4634;
  --amber: #e07a3d;
  --amber-ink: #8a3e12;
  --clay: #a65348;
  --good: #2f7d57;
  --shadow: 0 12px 30px rgba(88, 58, 28, 0.08);
  --radius: 22px;
  --font: "IBM Plex Sans KR", "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
  --display: "Gowun Batang", "Batang", "Song Myung", serif;
  --tab: 76px;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #171410;
  --bg-2: #241c16;
  --card: #262019;
  --ink: #f6efe6;
  --muted: #cbbba8;
  --line: #3c3228;
  --forest: #9dceb4;
  --forest-ink: #d7f3e4;
  --amber: #f0a36a;
  --amber-ink: #ffd7b0;
  --clay: #f0a097;
  --good: #9ad7b5;
  --shadow: 0 14px 34px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 0% -10%, rgba(224, 122, 61, 0.18), transparent 55%),
    radial-gradient(700px 380px at 100% 0%, rgba(47, 93, 69, 0.16), transparent 50%),
    var(--bg);
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--forest-ink); }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; line-height: 1.3; margin: 0; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0; }

#app {
  width: min(1080px, 100%);
  margin: 0 auto;
  padding: 18px 16px calc(var(--tab) + env(safe-area-inset-bottom) + 20px);
}
.loading { padding: 48px 8px; color: var(--muted); }
.foot { margin: 18px 4px 0; color: var(--muted); font-size: 0.92rem; }
.muted { color: var(--muted); }
.center { text-align: center; }
.kicker { margin: 0 0 4px; color: var(--amber-ink); font-size: 0.92rem; letter-spacing: 0.01em; }
.hint { color: var(--muted); font-size: 0.95rem; }

.bento { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.span-2 { grid-column: span 2; }
.card, .sheet, .gate .sheet {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.card-h, .note-top, .greet-top, .toolbar, .row-actions, .adder {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.card-h { margin-bottom: 8px; }
.lead { margin-top: 8px; }

.greet h1 { font-size: 1.65rem; }
.greet-top { align-items: flex-start; justify-content: flex-start; }
.mark { width: 52px; height: 52px; color: var(--forest); flex: none; }
.weather-temp { font-family: var(--display); font-size: 2.4rem; line-height: 1; margin: 4px 0; }
.joke-line { font-size: 1.15rem; margin: 8px 0 12px; }
.weather, .joke { grid-column: span 2; }
@media (min-width: 520px) {
  .weather, .joke { grid-column: span 1; }
}
@media (min-width: 900px) {
  .bento { grid-template-columns: 1.3fr 1fr 1fr; }
  .greet { grid-column: span 2; grid-row: span 2; }
  .favorites, .notes, .agenda { grid-column: span 2; }
}

.btn, .tabbar a, .chip, .star, .icon-x {
  min-height: 44px;
}
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); background: transparent; color: var(--ink);
  border-radius: 999px; padding: 10px 16px; text-decoration: none; min-height: 48px;
}
.btn.primary { background: var(--forest); color: #fffaf3; border-color: transparent; }
:root[data-theme="dark"] .btn.primary { color: #17211b; }
.btn.danger { color: var(--clay); border-color: var(--clay); }
.btn.tiny { min-height: 40px; padding: 6px 12px; font-size: 0.95rem; }
.btn.wide, .wide { width: 100%; }
.btn:disabled { opacity: 0.55; }

.seg { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }
.seg button, .seg a {
  border: 1px solid var(--line); background: transparent; color: var(--ink);
  border-radius: 999px; padding: 8px 12px; min-height: 44px; text-decoration: none;
}
.seg button[aria-pressed="true"], .seg a[aria-selected="true"] { background: var(--forest); color: #fffaf3; border-color: transparent; }
:root[data-theme="dark"] .seg button[aria-pressed="true"],
:root[data-theme="dark"] .seg a[aria-selected="true"] { color: #17211b; }
.seg.wide a { flex: 1; text-align: center; }

.stack { display: flex; flex-direction: column; gap: 8px; }
.link-row, .check-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 16px; background: color-mix(in srgb, var(--bg) 70%, var(--card));
  text-decoration: none; color: inherit;
}
.link-row b, .link-row small, .check-row span { display: block; }
.link-row small { color: var(--muted); }
.link-row .grow, .link-row > span { flex: 1; min-width: 0; }
.link-row b, .note p { overflow-wrap: break-word; word-break: keep-all; }
.ico { font-size: 1.3rem; }
.pill {
  display: inline-flex; align-items: center; border-radius: 999px;
  background: color-mix(in srgb, var(--amber) 18%, var(--card)); color: var(--amber-ink);
  padding: 2px 8px; font-size: 0.85rem; white-space: nowrap;
}
.text-link { color: var(--forest-ink); font-weight: 600; }
.check-row input { width: 22px; height: 22px; accent-color: var(--forest); }
.check-row .done { text-decoration: line-through; color: var(--muted); }
.icon-x { border: 0; background: transparent; color: var(--muted); font-size: 1.4rem; width: 44px; }
.adder { margin-top: 10px; }
.adder .btn { flex: none; white-space: nowrap; }
.adder input, .search input, .sheet input, .sheet textarea, .sheet select {
  width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: 14px;
  padding: 12px 14px; min-height: 48px;
}
.sheet { display: flex; flex-direction: column; gap: 12px; margin: 12px 0; }
.sheet label, .gate label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; }
.sheet textarea { min-height: 96px; resize: vertical; }
.check { flex-direction: row !important; align-items: center; font-weight: 500; }
.check input { width: 22px; height: 22px; }
.form-error { color: var(--clay); }
.search { margin: 8px 0 14px; }

.page-h { margin: 8px 0 14px; }
.page-h p { color: var(--muted); margin-top: 6px; }
.back { display: inline-flex; gap: 6px; align-items: center; color: var(--forest-ink); text-decoration: none; min-height: 44px; font-weight: 600; }
.drawer-grid { display: grid; gap: 10px; }
.drawer {
  display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center;
  padding: 14px; border-radius: 18px; background: var(--card); border: 1px solid var(--line);
  text-decoration: none; color: inherit; box-shadow: var(--shadow);
}
.drawer small, .drawer em { display: block; color: var(--muted); font-style: normal; font-size: 0.92rem; }
.drawer-ic { font-size: 1.6rem; }
.group { margin: 14px 0; }
.group h3 { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.count { color: var(--muted); font-family: var(--font); font-size: 0.9rem; }
.star { border: 0; background: transparent; font-size: 1.4rem; color: var(--amber); width: 44px; }
.star.on { color: var(--amber); }
.page-row.dragging, .group.dragging { opacity: 0.7; }
.sorting { touch-action: none; }
.empty { padding: 28px 8px; text-align: center; }
.empty b { display: block; font-family: var(--display); font-size: 1.25rem; margin-bottom: 6px; }
.toolbar { margin: 8px 0; justify-content: flex-start; flex-wrap: wrap; }

.mic {
  width: 148px; height: 148px; border-radius: 50%; border: 0; margin: 8px auto;
  background: radial-gradient(circle at 40% 30%, #ffb07a, var(--amber) 58%, #c45d28);
  color: #fffaf3; display: flex; flex-direction: column; align-items: center; justify-content: center;
  position: relative; font-weight: 700;
}
.mic[disabled] { filter: grayscale(0.6); }
.mic.on { box-shadow: 0 0 0 10px rgba(224, 122, 61, 0.2); }
.mic-ring { position: absolute; inset: -8px; border-radius: 50%; border: 2px solid rgba(255,255,255,.5); }
.voice-sheet { align-items: stretch; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 14px; }
.chip {
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 999px; padding: 8px 12px; text-decoration: none;
}
.chip.on { background: var(--forest); color: #fffaf3; border-color: transparent; }
:root[data-theme="dark"] .chip.on { color: #17211b; }
.note, .word { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 14px; }
.note p { margin: 8px 0; }
.inline { display: flex; gap: 8px; align-items: center; color: var(--muted); }
.inline select { min-height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); padding: 6px 8px; }
.tally { display: flex; gap: 8px; flex-wrap: wrap; color: var(--muted); margin-bottom: 8px; }
.tally span { background: var(--card); border-radius: 999px; padding: 6px 10px; border: 1px solid var(--line); }
details.sheet summary { cursor: pointer; font-weight: 700; min-height: 44px; }

.gate { max-width: 460px; margin: 24px auto; }
.brand { text-align: center; margin-bottom: 16px; }
.brand .mark { width: 72px; height: 72px; }
.brand p { color: var(--muted); margin-top: 8px; }
.camp-list { list-style: none; padding: 0; margin: 8px 0 0; display: flex; flex-direction: column; gap: 8px; }
.camp-list li { display: flex; flex-direction: column; }
.camp-list span { color: var(--muted); }
code { font-size: 0.86rem; overflow-wrap: anywhere; }

#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: color-mix(in srgb, var(--card) 92%, transparent);
  border-top: 1px solid var(--line);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  backdrop-filter: blur(10px);
}
#tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  text-decoration: none; color: var(--muted); font-size: 0.78rem; min-height: 52px;
}
#tabbar a[aria-current="page"] { color: var(--forest-ink); font-weight: 700; }
#tabbar svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#toast {
  position: fixed; left: 50%; bottom: calc(var(--tab) + 10px); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); border-radius: 999px;
  padding: 10px 16px; z-index: 6; max-width: calc(100% - 32px);
}
#update {
  position: fixed; top: 0; left: 0; right: 0; z-index: 8;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--ink); color: var(--bg);
  padding: 10px 16px calc(10px + env(safe-area-inset-top));
}
#update[hidden] { display: none; }
body:has(#update:not([hidden])) #app { padding-top: 64px; }
#update button { border: 0; background: var(--amber); color: #2c241c; border-radius: 999px; min-height: 40px; padding: 6px 14px; white-space: nowrap; }
@media (max-width: 389px) {
  h1 { font-size: 1.45rem; }
  .weather-temp { font-size: 2rem; }
}
