/* BAN年間予定 ── 見た目。BANeと並べて違和感が出ないよう、同系の落ち着いた配色にする */
:root {
  color-scheme: light;
  --ink:#252722; --muted:#6f716a; --paper:#f6f3ec; --card:#fffdf8; --line:#dedbd2;
  --green:#345c48; --green-soft:#e3ede6; --danger:#9b3f35; --gold:#b78636;
  --shadow:0 12px 34px rgb(45 43 36 / 8%);
  --wide:1080px;     /* 画面の横幅。⚠️ 1か所で持つ。各所に数字を散らすと必ずずれる */
  --today:#d0342c;   /* 今日を囲む赤。⚠️ 失敗を示す --danger とは別に持つ（意味が違う） */
  --f-title:26px; --f-section:17px; --f-body:15px; --f-meta:13px; --f-small:11px;
  font-family:Inter,"Noto Sans JP",system-ui,-apple-system,sans-serif;
}
* { box-sizing:border-box; }
/* ⚠️ hidden より display:flex/grid の方が強い。これが無いと、隠したはずの物が全部出たままになる
   （モーダルが開きっぱなし・終日なのに時刻欄が出る、を実際に起こした） */
[hidden] { display:none !important; }
body { margin:0; min-width:320px; min-height:100vh; padding:0 0 48px; color:var(--ink); background:var(--paper); font-size:var(--f-body); }
body.modal-open { overflow:hidden; }
h1 { margin:0; font-size:var(--f-title); }
h2 { margin:0; font-size:var(--f-section); }
p { margin:0; }
button { min-height:44px; padding:0 16px; border:0; border-radius:11px; color:#fff; background:var(--green); font:inherit; font-weight:700; cursor:pointer; }
button.ghost { color:var(--ink); background:transparent; border:1px solid var(--line); }
button.danger { color:var(--danger); border-color:#e3b8af; }
button:disabled { opacity:.5; cursor:default; }
input, textarea, select { width:100%; min-height:46px; padding:10px 12px; border:1px solid var(--line); border-radius:11px; background:var(--card); font:inherit; color:var(--ink); }
textarea { min-height:110px; resize:vertical; }
label { display:grid; gap:6px; color:var(--muted); font-size:var(--f-meta); font-weight:700; }
.eyebrow { color:var(--muted); font-size:var(--f-small); font-weight:800; letter-spacing:.14em; }

/* ログイン */
.login-wrap { display:grid; place-items:center; min-height:100vh; padding:20px; }
.login-card { width:min(420px,100%); padding:28px; border-radius:20px; background:var(--card); box-shadow:var(--shadow); }
.login-card h1 { margin:2px 0 10px; }
.lead { margin-bottom:18px; color:var(--muted); font-size:var(--f-meta); }
#login-form { display:grid; gap:14px; }
.form-error { color:var(--danger); font-size:var(--f-meta); font-weight:700; }

/* 本体 */
.app-head { display:flex; align-items:flex-end; justify-content:space-between; gap:12px; flex-wrap:wrap; max-width:var(--wide); margin:0 auto; padding:22px 20px 8px; }
.head-right { display:flex; align-items:center; gap:10px; }
.who { color:var(--muted); font-size:var(--f-meta); font-weight:700; }
.note, .alert, .readonly-note, .toolbar, .pane { max-width:var(--wide); margin-inline:auto; padding-inline:20px; }
.note { margin-top:6px; color:var(--muted); font-size:var(--f-meta); }
.alert { margin-top:12px; padding:10px 14px; border:1px solid #e3b8af; border-radius:13px; color:var(--danger); background:#fff4f1; font-size:var(--f-meta); font-weight:700; }
.readonly-note { margin-top:12px; padding:10px 14px; border:1px solid var(--line); border-radius:13px; color:var(--muted); background:var(--card); font-size:var(--f-meta); }
.toolbar { display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap; margin:16px auto 10px; }
.toolbar-right { display:flex; align-items:center; gap:12px; }
.segmented { display:flex; gap:2px; padding:3px; border-radius:12px; background:var(--green-soft); }
.segmented button { min-height:38px; color:var(--muted); background:transparent; font-size:var(--f-meta); }
.segmented button[aria-selected="true"] { color:var(--ink); background:var(--card); }
.check { display:flex; flex-direction:row; align-items:center; gap:7px; min-height:44px; color:var(--muted); font-size:var(--f-meta); white-space:nowrap; cursor:pointer; }
.check input { flex:0 0 auto; width:18px; height:18px; min-height:18px; margin:0; accent-color:var(--green); }
#search { margin-bottom:14px; }

/* 一覧 */
.month-label { margin:22px 0 8px; color:var(--muted); font-size:var(--f-meta); font-weight:800; }
.card { display:flex; gap:11px; width:100%; min-height:0; margin-bottom:8px; padding:13px 15px; border:1px solid var(--line); border-radius:14px; background:var(--card); text-align:left; color:var(--ink); font-weight:400; }
button.card { cursor:pointer; }
button.card:hover { border-color:var(--green); }
.dot { flex:0 0 auto; width:10px; height:10px; margin-top:6px; border-radius:50%; }
.card-main { display:grid; gap:3px; min-width:0; }
.title { font-size:var(--f-body); font-weight:700; overflow-wrap:anywhere; }
.meta { display:flex; align-items:center; gap:7px; flex-wrap:wrap; color:var(--muted); font-size:var(--f-meta); }
.why { color:var(--danger); font-size:var(--f-meta); overflow-wrap:anywhere; }
.badge { padding:2px 8px; border-radius:999px; font-size:var(--f-small); font-weight:800; }
.badge.s-pending { color:var(--gold); background:#fbf3e4; }
.badge.s-synced { color:var(--muted); background:transparent; padding-inline:0; }
.badge.s-failed { color:var(--danger); background:#fff4f1; }
.empty { display:grid; gap:5px; padding:38px 20px; border:1px dashed var(--line); border-radius:14px; color:var(--muted); text-align:center; font-size:var(--f-meta); }
.empty strong { color:var(--ink); font-size:var(--f-body); }

/* 月カレンダー */
.month-head { display:flex; align-items:center; justify-content:center; gap:14px; margin-bottom:10px; }
.month-head button { min-width:44px; }
.weekdays, .month-grid { display:grid; grid-template-columns:repeat(7,1fr); gap:6px; }
.weekdays span { padding-bottom:5px; color:var(--muted); text-align:center; font-size:var(--f-small); font-weight:800; }
.day { display:flex; flex-direction:column; gap:3px; min-height:104px; padding:6px; border:1px solid var(--line); border-radius:11px; background:var(--card); overflow:hidden; }
.day.blank { border:0; background:transparent; }
.day.is-today { border:2px solid var(--today); background:#fff; }
.day.is-today b { color:var(--today); font-weight:800; }
.day.is-holiday { background:#fbeff0; }
.day.is-holiday b { color:var(--danger); }
.day-holiday { color:var(--danger); font-size:var(--f-small); font-weight:700; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.day b { color:var(--muted); font-size:var(--f-meta); }
.chip { display:block; width:100%; min-height:0; padding:3px 6px; border:0; border-left:3px solid var(--c); border-radius:5px; background:#f2efe7; color:var(--ink); text-align:left; font-size:var(--f-small); font-weight:600; line-height:1.35; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
button.chip { cursor:pointer; }
button.chip:hover { background:#e8e4d9; }
.chip.is-unsynced { font-style:italic; opacity:.75; }

/* 年間（4月〜翌3月を横に12列）── 紙の年間表と同じ見え方にする */
.year-head { display:flex; align-items:center; justify-content:center; gap:14px; margin-bottom:6px; }
.year-head button { min-width:44px; }
.year-note { margin-bottom:10px; color:var(--muted); font-size:var(--f-meta); }
.year-grid { display:flex; gap:8px; overflow-x:auto; padding-bottom:12px; -webkit-overflow-scrolling:touch; }
.year-col { flex:0 0 320px; border:1px solid var(--line); border-radius:12px; background:var(--card); overflow:hidden; }
.year-col-head { position:sticky; top:0; z-index:1; display:flex; align-items:baseline; gap:7px; padding:8px 10px; border-bottom:1px solid var(--line); background:var(--green-soft); }
.year-col-head b { font-size:var(--f-section); }
.year-col-head span { color:var(--muted); font-size:var(--f-small); font-weight:700; }
.year-row { display:flex; align-items:flex-start; gap:6px; min-height:26px; padding:2px 8px; border-bottom:1px solid #efece4; }
.year-row:last-child { border-bottom:0; }
/* ⚠️ 土日は色だけでなく濃さも変える（色覚に依らず区別できるように） */
.year-row.is-sat { background:#eef3f8; }
/* 日曜と祝日は同じ扱い。⚠️ 背景だけでなく日付の文字も赤にする（色の濃さだけでは伝わらない） */
.year-row.is-off { background:#fbeff0; }
.year-row.is-off .year-day { color:var(--danger); }
/* 今日は赤で囲む。⚠️ 高さを変えないよう外枠ではなく内側の影で描く（行がずれると年間表が読みにくい） */
.year-row.is-today { box-shadow:inset 0 0 0 2px var(--today); background:#fff; }
.year-row.is-today .year-day { color:var(--today); font-weight:800; }
.year-day { flex:0 0 46px; padding-top:3px; color:var(--muted); font-size:var(--f-small); font-weight:700; font-variant-numeric:tabular-nums; }
/* 同じ日に3つまで横に並べる。4つ目からは折り返して下に出る＝隠さない。
   列の数はその日の件数に合わせて app.js が入れる（1つなら幅いっぱい） */
.year-slot { display:grid; gap:2px; min-width:0; flex:1; padding:1px 0; }
/* ⚠️ min-height:0 は必須。共通のbuttonが44pxを持っているので、消さないと1件で3行分の高さになる */
.year-chip, .year-holiday { display:block; min-width:0; min-height:0; padding:2px 5px; border:0; border-radius:4px; text-align:left; font-size:var(--f-small); font-weight:700; line-height:1.4; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.year-holiday { color:var(--danger); background:transparent; padding-inline:0; }
button.year-chip { cursor:pointer; }
button.year-chip:hover { filter:brightness(0.94); }
.year-chip.is-unsynced { font-style:italic; box-shadow:inset 0 0 0 1px rgb(0 0 0 / 25%); }

/* 入力 */
.modal-backdrop { position:fixed; z-index:60; inset:0; display:grid; place-items:center; padding:18px; background:rgb(22 27 23 / 48%); }
.modal-panel { width:min(560px,100%); max-height:92vh; overflow:auto; border-radius:20px; background:var(--card); box-shadow:var(--shadow); }
.modal-head { position:sticky; top:0; display:flex; align-items:center; justify-content:space-between; padding:16px 18px; border-bottom:1px solid var(--line); background:var(--card); }
.modal-head button { min-width:44px; font-size:20px; }
#form { display:grid; gap:14px; padding:18px; }
#form .row { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
#form label.check.inline { color:var(--ink); }
.sync-line { padding:9px 12px; border-radius:10px; font-size:var(--f-meta); font-weight:700; }
.sync-line.s-pending { color:var(--gold); background:#fbf3e4; }
.sync-line.s-synced { color:var(--muted); background:#f2efe7; }
.sync-line.s-failed { color:var(--danger); background:#fff4f1; }
.modal-actions { display:flex; align-items:center; justify-content:flex-end; gap:10px; padding-top:2px; }
#f-delete { margin-right:auto; }

/* 知らせ */
.toast { position:fixed; left:50%; bottom:22px; z-index:80; max-width:min(560px,calc(100% - 32px)); transform:translateX(-50%); padding:13px 18px; border-radius:13px; color:#fff; background:#252722; box-shadow:var(--shadow); font-size:var(--f-meta); font-weight:700; }

/* パソコン・タブレット。⚠️ 年間表は「一度に何か月見えるか」がそのまま使い勝手になる */
@media (min-width:900px) {
  :root { --wide:1180px; }
  .day { min-height:116px; }
}
@media (min-width:1280px) {
  :root { --wide:1440px; }
  .day { min-height:128px; }
  .year-col { flex-basis:340px; }
}
@media (min-width:1680px) {
  :root { --wide:1760px; }
  .day { min-height:140px; }
  .year-col { flex-basis:360px; }
}
/* タブレットの縦持ち。列は少し細くして2か月を見えるようにする */
@media (min-width:641px) and (max-width:899px) {
  .year-col { flex-basis:300px; }
}

@media (max-width:640px) {
  .toolbar { align-items:stretch; }
  .toolbar-right { justify-content:space-between; }
  #form .row { grid-template-columns:1fr; }
  .day { min-height:76px; }
  .year-col { flex-basis:280px; }
  .chip { font-size:10px; }
}
