:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-2: #eef2f0;
  --text: #1c2b27;
  --muted: #6b7d77;
  --border: #dce4e0;
  --primary: #0f6e56;
  --primary-soft: #e1f5ee;
  --danger: #b42318;
  --warning: #b54708;
  --shadow: 0 1px 3px rgba(16, 40, 33, 0.08), 0 8px 24px rgba(16, 40, 33, 0.06);
  --r: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--danger); font-size: 13px; min-height: 20px; }

.app-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: var(--primary); color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 16px; letter-spacing: .2px; }
.brand-mark {
  display: inline-grid; place-items: center; width: 28px; height: 28px;
  border-radius: 8px; background: rgba(255,255,255,.18); font-size: 12px; font-weight: 700;
}
.icon-btn {
  border: 0; background: transparent; color: inherit; cursor: pointer;
  font-size: 22px; line-height: 1; padding: 6px 10px; border-radius: 10px;
}
.icon-btn:active { background: rgba(255,255,255,.18); }

.tabs { display: flex; gap: 6px; padding: 12px 16px 4px; }
.tab {
  flex: 1; border: 1px solid var(--border); background: var(--surface);
  color: var(--muted); padding: 9px 0; border-radius: 10px; font-size: 14px;
  font-family: inherit; cursor: pointer; transition: .15s;
}
.tab.active { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); font-weight: 600; }

.view { padding: 14px 16px; }
.list-head { display: flex; align-items: center; justify-content: space-between; margin: 4px 2px 12px; }
.list-head h2 { font-size: 15px; margin: 0; font-weight: 600; }
.count { color: var(--muted); font-size: 13px; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
  padding: 14px; margin-bottom: 10px; box-shadow: var(--shadow); cursor: pointer;
  transition: transform .12s, box-shadow .12s;
}
.card:active { transform: scale(.99); }
.card-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-weight: 600; }
.badge.proposal { background: #e6f1fb; color: #185fa5; }
.badge.decision { background: #eaf3de; color: #3b6d11; }
.badge.review { background: #faeeda; color: #854f0b; }
.badge.handoff { background: #fbeaf0; color: #993556; }
.badge.status { background: var(--primary-soft); color: var(--primary); }
.card-key { font-weight: 600; font-size: 15px; word-break: break-all; }
.card-meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.card-preview { color: var(--text); font-size: 13px; margin-top: 8px; white-space: pre-wrap; word-break: break-word; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.empty { text-align: center; color: var(--muted); padding: 60px 20px; }
.empty-mark { font-size: 40px; color: var(--border); }

.detail { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow); }
.detail h2 { margin: 0 0 4px; font-size: 18px; word-break: break-all; }
.kv { display: grid; grid-template-columns: 72px 1fr; gap: 4px 10px; font-size: 13px; margin: 14px 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }
.content {
  white-space: pre-wrap; word-break: break-word; background: var(--surface-2);
  padding: 14px; border-radius: 10px; font-size: 14px; margin: 14px 0 0;
}
.detail-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }

.btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 10px 16px; border-radius: 10px; font-size: 14px; font-family: inherit;
  cursor: pointer; transition: .12s;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.btn.block { width: 100%; }
.btn.danger { color: var(--danger); }

.back { border: 0; background: transparent; color: var(--primary); padding: 0 0 10px; font-size: 14px; cursor: pointer; font-family: inherit; }

.fab-wrap { position: fixed; right: 18px; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 30; }
.fab {
  width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--primary);
  color: #fff; font-size: 30px; line-height: 1; cursor: pointer;
  box-shadow: 0 6px 20px rgba(15, 110, 86, .38);
}
.fab-menu {
  position: absolute; right: 0; bottom: 66px; display: flex; flex-direction: column; gap: 8px;
  align-items: flex-end; opacity: 0; pointer-events: none; transform: translateY(8px); transition: .18s;
}
.fab-menu.open { opacity: 1; pointer-events: auto; transform: none; }
.fab-item {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 9px 14px; border-radius: 10px; font-size: 14px; font-family: inherit;
  box-shadow: var(--shadow); cursor: pointer; white-space: nowrap;
}

.modal { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(16, 32, 27, .4); }
.modal-sheet {
  position: relative; background: var(--surface); width: 100%; max-width: 520px;
  border-radius: 20px 20px 0 0; padding: 18px 18px calc(20px + env(safe-area-inset-bottom));
  max-height: 88vh; overflow-y: auto;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-head .icon-btn { color: var(--muted); }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
  font-size: 15px; font-family: inherit; background: var(--surface); color: var(--text);
}
.field textarea { min-height: 140px; resize: vertical; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }

.gate { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; background: var(--bg); padding: 20px; }
.gate-card { width: 100%; max-width: 380px; background: var(--surface); border-radius: 20px; padding: 28px; box-shadow: var(--shadow); text-align: center; }
.gate-logo { display: grid; place-items: center; width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 16px; background: var(--primary); color: #fff; font-weight: 700; }
.gate-card h1 { margin: 0 0 4px; font-size: 20px; }
.gate-card p { margin: 0 0 18px; }
.gate-card input { width: 100%; border: 1px solid var(--border); border-radius: 10px; padding: 12px; font-size: 15px; margin-bottom: 12px; font-family: inherit; }

.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: #1c2b27; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 14px;
  z-index: 80; max-width: 86vw; text-align: center;
}

@media (min-width: 600px) {
  body { max-width: 620px; margin: 0 auto; }
  .modal { align-items: center; }
  .modal-sheet { border-radius: 20px; }
}
