:root {
  --bg: #f3f0e8;
  --paper: #fffdf8;
  --ink: #1f2933;
  --muted: #6b7280;
  --line: #e3ddd0;
  --accent: #2f5d50;
  --accent-soft: #e6efe9;
  --gold: #b07a1e;
  --gold-soft: #f6ecd8;
  --red: #b6402f;
  --red-soft: #f8e4df;
  --blue: #3d5a80;
  --blue-soft: #e4ecf5;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(31, 41, 51, .06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.6 "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: 72px;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: .01em; }
h1 { font-size: 21px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 0 0 8px; }
small { color: var(--muted); }

.top {
  position: sticky; top: 0; z-index: 20;
  background: rgba(243, 240, 232, .94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.top-inner {
  max-width: 1080px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { display: flex; align-items: baseline; gap: 8px; }
.brand b { font-size: 17px; letter-spacing: .08em; }
.brand span { color: var(--muted); font-size: 12px; }
.tabs { display: none; gap: 4px; }
.tab {
  border: 0; background: transparent; padding: 8px 12px; border-radius: 999px;
  color: var(--muted); cursor: pointer;
}
.tab.on { background: var(--ink); color: #fff; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 16px; }
.grid { display: grid; gap: 14px; }
@media (min-width: 860px) {
  .tabs { display: flex; }
  .bottom { display: none; }
  body { padding-bottom: 0; }
  .grid.two { grid-template-columns: 1.15fr .85fr; align-items: start; }
}

.bottom {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(255, 253, 248, .96);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom button {
  border: 0; background: transparent; padding: 9px 0 8px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--muted); font-size: 11px; cursor: pointer;
}
.bottom button .ico { font-size: 18px; line-height: 1; }
.bottom button.on { color: var(--accent); }

.card {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
}
.card + .card { margin-top: 14px; }
.card h3 { margin-bottom: 10px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-variant-numeric: tabular-nums; }

.hero {
  background: linear-gradient(135deg, #24483d, #2f5d50 60%, #3c6b5b);
  color: #f7f3e8; border-radius: 18px; padding: 18px 18px 16px;
  box-shadow: 0 10px 30px rgba(36, 72, 61, .18);
}
.hero .topline { display: flex; justify-content: space-between; font-size: 12px; opacity: .85; }
.hero .main { font-size: 26px; font-weight: 700; margin: 8px 0 2px; letter-spacing: .02em; }
.hero .sub { font-size: 13px; opacity: .9; }
.hero .stage { display: inline-block; margin-top: 10px; padding: 3px 10px; border-radius: 999px; background: rgba(255,255,255,.14); font-size: 12px; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; border: 1px solid var(--line); background: #fff; }
.badge.p0 { background: var(--red-soft); color: var(--red); border-color: #efc7be; }
.badge.p1 { background: var(--gold-soft); color: var(--gold); border-color: #ead6ad; }
.badge.p2 { background: var(--blue-soft); color: var(--blue); border-color: #c9d7e8; }
.badge.p3 { background: #f1f1f1; color: #666; }
.badge.ok { background: var(--accent-soft); color: var(--accent); border-color: #c9ddd2; }
.badge.warn { background: var(--gold-soft); color: var(--gold); }
.badge.danger { background: var(--red-soft); color: var(--red); }

.btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 7px 13px; border-radius: 999px; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: #c9c1b1; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); border-color: #eccac2; background: #fff; }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn.block { width: 100%; text-align: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.seg { display: inline-flex; background: #efece3; border-radius: 999px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 5px 12px; border-radius: 999px; cursor: pointer; color: var(--muted); font-size: 13px; }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

.progress { height: 8px; background: #ece7da; border-radius: 999px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s; }

.quick { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.quick .btn { font-size: 12px; padding: 5px 10px; }

.block { padding: 10px 0; border-top: 1px dashed var(--line); }
.block:first-of-type { border-top: 0; }
.block-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.block-head b { font-size: 13px; }
.block-head span { font-size: 11px; color: var(--muted); }
.item { display: flex; gap: 8px; align-items: flex-start; padding: 5px 0; }
.item input[type=checkbox] { margin-top: 4px; width: 16px; height: 16px; accent-color: var(--accent); }
.item .id { font-size: 11px; color: var(--muted); min-width: 42px; padding-top: 2px; }
.item .body { flex: 1; }
.item .title { font-size: 14px; }
.item .next { font-size: 12px; color: var(--muted); }
.item .meta { font-size: 11px; color: var(--muted); margin-top: 2px; }
.item.done .title { text-decoration: line-through; color: var(--muted); }

.fixed { display: flex; gap: 10px; padding: 6px 0; font-size: 13px; border-top: 1px dashed var(--line); }
.fixed:first-child { border-top: 0; }
.fixed .t { color: var(--muted); min-width: 46px; font-variant-numeric: tabular-nums; }
.fixed.cancelled { opacity: .45; text-decoration: line-through; }

.first {
  border-left: 4px solid var(--gold);
  background: linear-gradient(180deg, #fffaf0, #fffdf8);
}
.first .step { font-size: 17px; font-weight: 650; margin: 6px 0 4px; }

.decision { border-left: 4px solid var(--red); background: #fff8f6; }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar input[type=search], .toolbar select, .field input, .field select, .field textarea {
  border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 8px 10px;
}
.toolbar input[type=search] { flex: 1; min-width: 140px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
table { border-collapse: collapse; width: 100%; min-width: 860px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid #eee8db; vertical-align: top; font-size: 13px; }
th { background: #faf7ef; color: var(--muted); font-weight: 600; font-size: 12px; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td .title { font-weight: 600; }
td .sub { font-size: 11px; color: var(--muted); }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }

.chat { display: flex; flex-direction: column; height: calc(100vh - 210px); min-height: 420px; }
.chat-log { flex: 1; overflow-y: auto; padding: 4px 2px 12px; }
.msg { display: flex; margin: 10px 0; }
.msg.user { justify-content: flex-end; }
.bubble {
  max-width: 84%; padding: 10px 13px; border-radius: 14px;
  background: #fff; border: 1px solid var(--line); white-space: pre-wrap; word-break: break-word;
}
.msg.user .bubble { background: var(--accent); color: #fff; border-color: var(--accent); }
.msg.system .bubble { background: #f6f2e7; border-style: dashed; color: var(--muted); font-size: 12px; }
.chat-input { display: flex; gap: 8px; align-items: flex-end; padding-top: 10px; border-top: 1px solid var(--line); }
.chat-input textarea { flex: 1; resize: none; min-height: 44px; max-height: 120px; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: #fff; }

.field { display: grid; gap: 4px; margin-bottom: 10px; }
.field label { font-size: 12px; color: var(--muted); }
.field input, .field select, .field textarea { width: 100%; }
.field textarea { min-height: 72px; resize: vertical; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 620px) { .two-col { grid-template-columns: 1fr; } }

.modal-bg {
  position: fixed; inset: 0; background: rgba(20, 24, 28, .45); z-index: 60;
  display: flex; align-items: flex-end; justify-content: center; padding: 0;
}
.modal {
  background: var(--paper); width: 100%; max-width: 620px; max-height: 92vh; overflow-y: auto;
  border-radius: 18px 18px 0 0; padding: 18px;
}
@media (min-width: 700px) {
  .modal-bg { align-items: center; padding: 20px; }
  .modal { border-radius: 18px; }
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }

.empty { color: var(--muted); font-size: 13px; padding: 12px 0; }
.hint { font-size: 12px; color: var(--muted); line-height: 1.7; }
.divider { height: 1px; background: var(--line); margin: 14px 0; }
.toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 9px 14px; border-radius: 999px;
  font-size: 13px; z-index: 80; box-shadow: var(--shadow); opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.toast.show { opacity: 1; }
