:root {
  --bg: #f6f3ef; --card: #ffffff; --text: #241c1a; --muted: #6f6461; --line: #e4ddd6;
  --accent: #7a2340; --accent-ink: #ffffff; --soon: #8a5200; --soon-bg: #fff1d6;
  --bad: #b3261e; --bad-bg: #fde4e1; --ok-bg: #edf3ec; --ok: #2f6b3a;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17120f; --card: #241d1a; --text: #f2ebe6; --muted: #b3a7a1; --line: #3a302c;
    --accent: #e08aa6; --accent-ink: #1b0b11; --soon: #ffc56b; --soon-bg: #3b2a0f;
    --bad: #ff8a80; --bad-bg: #3d1714; --ok-bg: #1d2b1f; --ok: #9fd3a8;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif; -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px; padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); background: var(--bg); border-bottom: 1px solid var(--line); }
.top h1 { font-size: 17px; margin: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top .sub { font-size: 13px; color: var(--muted); }
main { max-width: 640px; margin: 0 auto; padding: 12px 16px calc(80px + env(safe-area-inset-bottom)); }

/* 下部タブ: 文字だけ。選択中は上の線と太字で示す */
.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 5; display: flex; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs button { flex: 1; border: 0; border-top: 2px solid transparent; background: none; padding: 0; min-height: 56px; font-size: 14px; letter-spacing: .04em; color: var(--muted); display: flex; align-items: center; justify-content: center; gap: 4px; }
.tabs button[aria-selected="true"] { color: var(--accent); font-weight: 700; border-top-color: var(--accent); }
.tabs .count { min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 11px; line-height: 18px; font-weight: 700; letter-spacing: 0; }

.row { display: flex; gap: 8px; align-items: center; }
.grow { flex: 1; min-width: 0; }
.search { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.chips { display: flex; gap: 6px; margin: 0 0 12px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 12px; font-size: 14px; }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.list.tight { margin-top: 0; }
.item { display: block; width: 100%; text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
button.item { cursor: pointer; }
.item .title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .meta { font-size: 13px; color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; }
.badge { flex: none; font-size: 12px; font-weight: 700; border-radius: 6px; padding: 2px 8px; background: var(--ok-bg); color: var(--ok); white-space: nowrap; }
.badge.soon { background: var(--soon-bg); color: var(--soon); }
.badge.expired { background: var(--bad-bg); color: var(--bad); }
.badge.muted { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.group { margin-top: 20px; }
.group h2 { font-size: 15px; margin: 0 0 6px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.group h2 span { color: var(--muted); font-weight: 400; font-size: 13px; }
.empty { color: var(--muted); text-align: center; padding: 32px 0; }
.btn { border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 10px 14px; min-height: 44px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 700; }
.btn.danger { color: var(--bad); }
.btn.block { width: 100%; }
.btn.small { min-height: 36px; padding: 6px 10px; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: default; }
.actions { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.btns { margin-top: 10px; }
.capacity { font-size: 13px; color: var(--muted); margin: 0 0 8px; }
.capacity.over { color: var(--bad); font-weight: 700; }
.hint { font-size: 12px; color: var(--muted); margin: 6px 0 0; }
.warn { white-space: pre-line; color: var(--bad); font-weight: 700; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; overflow-wrap: anywhere; }

dialog { width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); border: 0; border-radius: 16px; padding: 0; background: var(--card); color: var(--text); }
dialog::backdrop { background: rgba(0, 0, 0, .45); }
.dlg { padding: 18px 16px 16px; outline: none; }
.dlg h2 { margin: 0 0 4px; font-size: 18px; }
.dlg .meta { color: var(--muted); font-size: 14px; margin: 0; }
label { display: block; font-size: 13px; color: var(--muted); margin-top: 12px; }
label input, label select, label textarea { display: block; width: 100%; margin-top: 4px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); font-size: 16px; }
textarea { min-height: 150px; resize: vertical; }
textarea.short { min-height: 80px; }
.dlg > textarea { display: block; width: 100%; margin-top: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }

.login { max-width: 420px; margin: 12vh auto 0; text-align: center; }
.login h1 { font-size: 24px; margin: 0 0 8px; letter-spacing: .08em; }
.login p { color: var(--muted); }
.login .actions { margin-top: 24px; }

#toast { position: fixed; left: 50%; bottom: calc(72px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 20; width: max-content; max-width: calc(100vw - 32px); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; white-space: pre-line; }
#toast.show { opacity: 1; }
#toast.error { background: var(--bad); color: #fff; }
.loading { color: var(--muted); text-align: center; padding: 40px 0; }
