:root {
  --bg: #e6dfd2;
  --paper: #f7f3ea;
  --card: #fffdf8;
  --ink: #241f1b;
  --muted: #74685c;
  --line: #e4d9c8;
  --pine: #1e4d45;
  --pine-soft: #e7f1ee;
  --clay: #b55233;
  --clay-soft: #f8e7e0;
  --gold: #8a5a12;
  --gold-soft: #f8efd8;
  --shadow: 0 16px 40px rgba(48, 36, 22, 0.08);
  --nav-h: 62px;
  color-scheme: light;
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  color: var(--ink);
  font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at 0 0, rgba(198, 161, 91, 0.35), transparent 28%),
    radial-gradient(circle at 100% 0, rgba(30, 77, 69, 0.18), transparent 26%),
    var(--bg);
}

body.sheet-open { overflow: hidden; }

button, input, select, textarea { font: inherit; color: inherit; }

button {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

a { color: var(--pine); }

img, svg { max-width: 100%; }

[hidden] { display: none !important; }

:focus-visible {
  outline: 3px solid rgba(30, 77, 69, 0.35);
  outline-offset: 2px;
}

.shell {
  width: min(100%, 480px);
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--paper);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.7), var(--shadow);
}

.frame { min-height: 100dvh; }

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: calc(18px + env(safe-area-inset-top)) 20px 8px;
}

.eyebrow {
  margin: 0;
  color: var(--pine);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: lowercase;
}

h1, h2 { font-weight: 650; }

h1 {
  margin: 2px 0 0;
  font-family: "Iowan Old Style", "Palatino Linotype", "Songti SC", "Noto Serif SC", serif;
  font-size: 34px;
  line-height: 1.15;
  letter-spacing: 0.02em;
}

h2 { margin: 0; font-size: 16px; }

.sub, .hint, .note, .sheet-text {
  color: var(--muted);
  line-height: 1.55;
}

.sub { margin: 6px 0 0; font-size: 14px; }

.content { padding: 8px 20px 28px; }

.has-nav .content { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 24px); }

.has-composer .content { padding-bottom: calc(var(--nav-h) + 230px + env(safe-area-inset-bottom)); }

.stack { display: grid; gap: 14px; }

.field { display: grid; gap: 6px; }

.field > span, .search { color: var(--muted); font-size: 13px; }

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 14px;
  padding: 12px 14px;
  min-height: 48px;
  font-size: 16px;
}

textarea { resize: vertical; line-height: 1.5; }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 16px;
  border-radius: 14px;
  background: var(--pine);
  color: #f6f1e7;
  font-weight: 650;
  text-decoration: none;
}

.btn.ghost {
  background: transparent;
  color: var(--pine);
  border: 1px solid var(--line);
}

.btn.danger { background: var(--clay); color: #fff; }

.btn:disabled { opacity: 0.55; }

.text-btn {
  color: var(--pine);
  font-size: 14px;
  text-decoration: none;
  min-height: 32px;
}

.danger-text { color: var(--clay); }

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.check input { width: 18px; height: 18px; min-height: 0; }

.foot-link { text-align: center; margin: 4px 0 0; }

.note {
  margin: 0;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.7);
}

.search input { background: #fff; }

.group { margin-top: 18px; }

.group header, .panel-head, .result-head, .place-row, .space-row, .item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.group header span {
  color: var(--muted);
  font-size: 13px;
}

.item {
  width: 100%;
  margin-top: 10px;
  padding: 14px;
  text-align: left;
  border-radius: 16px;
  background: var(--card);
  border: 1px solid var(--line);
}

.item-main, .item-side { display: grid; gap: 4px; }

.item-main strong { font-size: 17px; }

.item-main em {
  color: var(--muted);
  font-style: normal;
  font-size: 13px;
}

.item-side { justify-items: end; }

.item-side small { color: var(--muted); font-size: 12px; }

.pill {
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  white-space: nowrap;
}

.pill.bad { background: var(--clay-soft); color: var(--clay); }
.pill.soon { background: var(--gold-soft); color: var(--gold); }
.pill.ok { background: var(--pine-soft); color: var(--pine); }
.pill.none { background: #eeeae3; color: var(--muted); }

.empty {
  display: grid;
  gap: 14px;
  margin-top: 28px;
  text-align: center;
}

.empty p { margin: 0; color: var(--muted); }

.panel {
  display: grid;
  gap: 12px;
  margin-top: 16px;
  padding: 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid var(--line);
}

.inline-form { display: flex; gap: 8px; }

.inline-form input { flex: 1; }

.inline-form .btn { flex: 0 0 auto; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--pine-soft);
  color: var(--pine);
}

.space-row, .place-row {
  padding: 12px 0;
  border-top: 1px solid var(--line);
  text-decoration: none;
  color: inherit;
}

.space-row span, .place-row span { color: var(--muted); font-size: 13px; }

.place-row span { display: flex; gap: 10px; }

.result-card {
  padding: 14px;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(30, 77, 69, 0.06), transparent 42%),
    var(--card);
  border: 1px solid var(--line);
}

.result-head { color: var(--muted); font-size: 13px; margin-bottom: 8px; }

pre {
  margin: 0 0 14px;
  padding: 12px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
  border-radius: 12px;
  background: #241f1b;
  color: #f6f1e7;
  font-family: ui-monospace, "Sarasa Mono SC", Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
}

.notes {
  margin: 0;
  padding-left: 18px;
  color: var(--clay);
  font-size: 13px;
}

.notes li { margin: 4px 0; }

.composer, .tabbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  width: min(100%, 480px);
  z-index: 20;
}

.composer {
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
  z-index: 19;
  display: grid;
  gap: 8px;
  padding: 10px 16px 12px;
  background: rgba(247, 243, 234, 0.96);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.composer-actions { display: flex; gap: 8px; }

.composer-actions .btn { flex: 1; }

.tabbar {
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(247, 243, 234, 0.96);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.tab {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 2px;
  color: var(--muted);
  text-decoration: none;
  font-size: 12px;
}

.tab svg { width: 22px; height: 22px; }

.tab.active { color: var(--pine); font-weight: 650; }

.mask {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(36, 31, 27, 0.38);
}

.sheet {
  width: min(100%, 480px);
  max-height: min(88dvh, 720px);
  overflow: auto;
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
  border-radius: 22px 22px 0 0;
  background: var(--paper);
}

.sheet h2 { font-family: "Iowan Old Style", "Palatino Linotype", "Songti SC", serif; font-size: 26px; }

.sheet-actions { display: flex; gap: 8px; }

.sheet-actions .btn { flex: 1; }

.sheet-actions.column { flex-direction: column; }

.pick {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.pick input { width: 18px; min-height: 18px; margin-top: 3px; }

.pick span { display: grid; gap: 4px; }

.pick small { color: var(--muted); }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(92px + env(safe-area-inset-bottom));
  z-index: 50;
  width: min(calc(100% - 32px), 420px);
  transform: translateX(-50%) translateY(8px);
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--ink);
  color: #f6f1e7;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show { opacity: 1; transform: translateX(-50%); }

@media (min-width: 840px) {
  body { padding: 24px 0; }
  .shell { min-height: calc(100dvh - 48px); border-radius: 28px; overflow: hidden; }
  .tabbar, .composer { width: min(100%, 480px); }
}
