/* ------------------------------------------------------------------
   見た目の土台（全画面で共通）
   方眼紙の机に付箋を貼った感じ。画面ごとの見た目は board.css / list.css / plan.css。
------------------------------------------------------------------ */
:root {
  --bg: #f2f4f6;
  --surface: #ffffff;
  --sunken: #e8ecf0;
  --ink: #1e2833;
  --muted: #5b6672;
  --line: #d5dce3;
  --grid: rgba(35, 73, 122, .07);
  --accent: #23497a;
  --accent-soft: #e2eaf4;
  --red: #b8322a;
  --red-soft: #fbe5e2;
  --ok: #2c7548;
  --ok-soft: #e0f1e6;
  --warn: #8f5a07;
  --warn-soft: #fbf0d4;
  --st-blue: #b3d1ef;
  --st-green: #c2e5ad;
  --st-yellow: #f7eb93;
  --st-pink: #f5c0cf;
  --st-ink: #1b232c;
  --st-red: #b3261e;
  --shadow: 0 1px 2px rgba(20, 30, 40, .14), 0 4px 10px rgba(20, 30, 40, .06);
  --f-head: "Zen Kaku Gothic New", "Hiragino Sans", "Yu Gothic", "Meiryo", sans-serif;
  --f-note: "Klee One", "Hiragino Maru Gothic ProN", "Yu Gothic", sans-serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --header-h: 54px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12171c; --surface: #1a2027; --sunken: #222a33; --ink: #e3e8ed; --muted: #9ca8b4;
    --line: #313c47; --grid: rgba(143, 180, 255, .05); --accent: #8fb4ff; --accent-soft: #1f2d42;
    --red: #ff8b7e; --red-soft: #3b201d; --ok: #7fd3a0; --ok-soft: #163225; --warn: #f0c063; --warn-soft: #3a2e14;
    --st-blue: #9fbfe2; --st-green: #abd497; --st-yellow: #e6d979; --st-pink: #e6aabb;
    --st-ink: #161d24; --st-red: #a3231b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 4px 12px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px;
  color: var(--ink);
  font-family: var(--f-head);
  font-size: 14px;
  line-height: 1.6;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.35; text-wrap: balance; }
p { margin: 0; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---- 上の帯 ---- */
.app-header {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 20px; height: var(--header-h);
  padding: 0 max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px));
  background: var(--sunken); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: 6px; text-decoration: none; color: var(--ink); white-space: nowrap; }
.brand-mark { font-weight: 700; font-size: 13px; background: var(--ink); color: var(--bg); border-radius: 3px; padding: 0 6px; }
.brand-name { font-weight: 700; font-size: 16px; }
.tabs { display: flex; gap: 2px; height: 100%; }
.tabs a {
  display: flex; align-items: center; padding: 0 14px; font-size: 14px; color: var(--muted);
  text-decoration: none; border-bottom: 3px solid transparent; white-space: nowrap;
}
.tabs a.is-on { color: var(--ink); font-weight: 700; border-bottom-color: var(--accent); }
.tabs a:hover { color: var(--ink); }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.save-state { font-size: 12px; min-width: 5em; text-align: right; color: var(--muted); }
.save-state.is-saving { color: var(--warn); }
.save-state.is-saved { color: var(--ok); }
.save-state.is-error { color: var(--red); font-weight: 700; }

.page {
  padding: 18px max(16px, env(safe-area-inset-right, 0px)) 48px max(16px, env(safe-area-inset-left, 0px));
  max-width: 1440px; margin: 0 auto;
}
.banner { background: var(--red-soft); color: var(--red); padding: 10px 16px; font-size: 13px; font-weight: 700; }
.empty { padding: 48px 16px; text-align: center; color: var(--muted); }

/* ---- 白い面（画面の中の区切り） ---- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.panel-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.panel-head h2 { font-size: 16px; }
.page-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 14px; flex-wrap: wrap; }
.page-head h1 { font-size: 20px; }
.page-head p { color: var(--muted); font-size: 13px; }

/* ---- ボタン ---- */
.btn {
  font: inherit; font-size: 13px; font-weight: 700; border-radius: 6px; padding: 6px 14px; cursor: pointer;
  border: 1px solid var(--accent); background: var(--accent); color: var(--surface);
  text-decoration: none; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; line-height: 1.6;
}
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: var(--surface); color: var(--accent); }
.btn.plain { background: transparent; border-color: transparent; color: var(--muted); font-weight: 500; }
.btn.plain:hover { color: var(--ink); }
.btn.danger { background: var(--surface); color: var(--red); border-color: var(--red); }
.btn.sm { font-size: 12px; padding: 3px 10px; }

/* ---- 表示の切り替えボタン（種類） ---- */
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar .lbl { font-size: 12px; color: var(--muted); margin-right: 2px; }
.toolbar .hint { font-size: 12px; color: var(--muted); margin-left: auto; }
.chip {
  font: inherit; font-size: 13px; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 999px; padding: 3px 12px 3px 8px; display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
}
.chip .dot { width: 12px; height: 12px; border-radius: 2px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); }
.chip[aria-pressed="false"] { opacity: .45; }
.chip .cnt { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12px; }

/* ---- 付箋 ---- */
.note {
  all: unset; box-sizing: border-box; cursor: grab; position: relative;
  padding: 7px 8px 6px; border-radius: 2px; box-shadow: var(--shadow); color: var(--st-ink);
  display: flex; flex-direction: column; gap: 2px; min-height: 74px;
  transform: rotate(var(--tilt, 0deg)); transition: transform .12s ease;
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.note:hover { transform: rotate(0deg) translateY(-1px); }
.note:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.note.is-sel { outline: 3px solid var(--accent); outline-offset: 2px; transform: none; }
.note.is-drag { opacity: .35; }
.note .n-title { font-family: var(--f-note); font-size: 13.5px; line-height: 1.35; font-weight: 600; }
.note .n-id { font-family: var(--f-mono); font-size: 10.5px; opacity: .85; word-break: break-all; }
.note .n-foot { margin-top: auto; display: flex; align-items: flex-end; justify-content: space-between; gap: 4px; font-size: 11px; }
.note .n-reason { font-family: var(--f-note); color: var(--st-red); line-height: 1.3; }
.note .n-days { font-variant-numeric: tabular-nums; white-space: nowrap; background: rgba(255, 255, 255, .55); border-radius: 3px; padding: 0 4px; }
.note .n-badge {
  position: absolute; top: -7px; right: -5px; font-size: 10.5px; font-weight: 700; letter-spacing: .04em;
  background: var(--st-red); color: #fff; border-radius: 3px; padding: 0 5px; line-height: 1.6;
}
.note .n-karte { font-size: 10.5px; }
.note .n-karte.no { color: var(--st-red); }
/* 付箋の色。.note の all: unset より後ろに置く（前にあると色が消える） */
.bg-blue { background: var(--st-blue); }
.bg-green { background: var(--st-green); }
.bg-yellow { background: var(--st-yellow); }
.bg-pink { background: var(--st-pink); }

/* つかんで動かしている間の影 */
.drag-ghost {
  position: fixed !important; z-index: 1000; pointer-events: none; margin: 0 !important; flex: none !important; max-width: none !important;
  transform: rotate(2.5deg) scale(1.04) !important; box-shadow: 0 12px 28px rgba(20, 30, 40, .28) !important; opacity: .95;
}
body.dragging, body.dragging * { cursor: grabbing !important; user-select: none; -webkit-user-select: none; }
.is-over { border-color: var(--accent) !important; background: var(--accent-soft) !important; }

/* ---- 小さな印 ---- */
.pill { display: inline-block; font-size: 11.5px; border-radius: 4px; padding: 0 6px; margin: 0 4px 4px 0; line-height: 1.7; white-space: nowrap; }
.pill.red { background: var(--red-soft); color: var(--red); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.plain { background: var(--sunken); color: var(--ink); }
.pill.accent { background: var(--accent-soft); color: var(--accent); }
.mono { font-family: var(--f-mono); font-size: 12.5px; }
.sub { font-size: 11.5px; color: var(--muted); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* 工程のチップ（済み・今・これから） */
.steps { display: flex; flex-wrap: wrap; gap: 4px; }
.steps span { font-size: 11px; border-radius: 3px; padding: 0 5px; background: var(--sunken); color: var(--muted); line-height: 1.7; }
.steps span.done { background: var(--ok-soft); color: var(--ok); }
.steps span.cur { background: var(--accent); color: var(--surface); font-weight: 700; }
/* 工程の細い棒 */
.prog { display: flex; gap: 2px; margin-bottom: 3px; }
.prog i { width: 16px; height: 6px; border-radius: 2px; background: var(--sunken); }
.prog i.done { background: var(--ok); }
.prog i.cur { background: var(--accent); }
/* 進み具合の棒 */
.bar { height: 8px; border-radius: 4px; background: var(--sunken); overflow: hidden; margin-top: 4px; }
.bar i { display: block; height: 100%; background: var(--ok); }
.bar.over i { background: var(--red); }

/* ---- 数字のまとめ ---- */
.sumrow { display: flex; gap: 10px; flex-wrap: wrap; }
.sum { border: 1px solid var(--line); border-radius: 8px; padding: 6px 14px; display: flex; align-items: baseline; gap: 8px; font-size: 13px; background: var(--surface); }
.sum b { font-size: 20px; font-variant-numeric: tabular-nums; }
.sum.warn { border-color: transparent; background: var(--warn-soft); color: var(--warn); }
.sum.red { border-color: transparent; background: var(--red-soft); color: var(--red); }

/* ---- 入力欄 ---- */
.fld { display: flex; flex-direction: column; gap: 4px; min-width: 0; font-size: 12px; color: var(--muted); }
.fld.wide { grid-column: 1 / -1; }
.input,
.fld input:not([type="checkbox"]):not([type="radio"]),
.fld select, .fld textarea {
  font: inherit; font-size: 14px; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; width: 100%; min-width: 0;
}
.fld textarea { resize: vertical; }
.fld input.mono-in { font-family: var(--f-mono); }
.fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 14px; }
.inline { display: flex; gap: 8px; align-items: center; font-size: 13px; flex-wrap: wrap; cursor: pointer; }
.inline small { color: var(--muted); font-size: 12px; }
.help { font-size: 12px; color: var(--muted); }
.form-error { color: var(--red); font-size: 13px; margin-top: 8px; }
/* 押して選ぶ丸いチップ（チェックボックス・ラジオ） */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chk { position: relative; cursor: pointer; }
.chk input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.chk span { display: inline-block; font-size: 13px; border: 1px solid var(--line); border-radius: 999px; padding: 2px 12px; background: var(--surface); color: var(--ink); }
.chk input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--surface); }
.chk.red input:checked + span { background: var(--red); border-color: var(--red); color: var(--surface); }
.chk input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- お知らせ ---- */
.toast {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 200;
  background: var(--ink); color: var(--bg); border-radius: 8px; padding: 8px 16px; font-size: 13px; box-shadow: var(--shadow);
}
.toast.error { background: var(--red); color: #fff; }

/* ---- ログイン ---- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 24px; display: flex; flex-direction: column; gap: 12px; }
.login-brand { font-size: 18px; font-weight: 700; display: flex; align-items: baseline; gap: 6px; }
.login-lead { color: var(--muted); font-size: 13px; }

@media (max-width: 900px) {
  .app-header { gap: 10px; overflow-x: auto; }
  .brand-name { display: none; }
  .tabs a { padding: 0 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .note { transition: none; }
}
