/* エマ ファミリー（LINE の中で開く親のアプリ）。生成り色の地・紺の文字・赤茶（期限）・琥珀（確認待ち）。リッチメニューとそろえる */
:root {
  --bg: #F6F4EE;
  --card: #FFFFFF;
  --ink: #0C447C;
  --ink-soft: #4F6F93;
  --line: #E6E1D5;
  --navy-bg: #E7EEF6;
  --coral: #993C1D;
  --coral-bg: #FAECE7;
  --amber: #854F0B;
  --amber-bg: #FAEEDA;
  --done: #6F7F8F;
  --done-bg: #EEF0F2;
  --radius: 14px;
  --tabbar-h: 64px;
  --shadow: 0 1px 2px rgba(12, 68, 124, .06);
  /* 余白の決まり。どの画面もこの段だけを使う（4 の倍数） */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --gutter: var(--sp-4);   /* 画面の左右 */
  --stack: var(--sp-4);    /* カードとカードの間 */
  --card-py: var(--sp-4);  /* カードの上下の内側 */
  --card-px: var(--sp-4);  /* カードの左右の内側（390px 以上で 18px） */
  --row-py: var(--sp-3);   /* 行の上下の内側 */
  /* 44px の押せる範囲を持つ最後の行は、文字の下に自然な余白があるぶんだけカードの下を詰める */
  --tap-slack: var(--sp-2);
  color-scheme: light;
}
@media (min-width: 390px) { :root { --card-px: 18px; } }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  overflow-wrap: anywhere;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid #5B8FD0; outline-offset: 2px; }

.app { min-height: 100vh; }
.boot { margin: 0; padding: 64px var(--gutter); text-align: center; color: var(--ink-soft); }
.page { max-width: 560px; margin: 0 auto; padding: var(--sp-3) var(--gutter) calc(var(--tabbar-h) + var(--sp-6) + env(safe-area-inset-bottom)); }
.view { display: flex; flex-direction: column; gap: var(--stack); }

/* 見出し */
.head { display: flex; align-items: flex-start; gap: var(--sp-1); padding: var(--sp-2) 0 var(--sp-1); }
.head-text { flex: 1; min-width: 0; }
.head-sub { margin: 0 0 2px; font-size: 13px; color: var(--ink-soft); }
.head-title { margin: 0; font-size: 24px; line-height: 1.3; font-weight: 700; text-wrap: balance; }
.head-action, .head-back { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 50%; }
.head-back { margin-left: -10px; }
.head-action:active, .head-back:active { background: var(--navy-bg); }

/* カード */
.card { margin: 0; padding: var(--card-py) var(--card-px); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-link { display: block; }
.card-link:active { filter: brightness(.97); }
.card-coral { background: var(--coral-bg); border-color: transparent; color: var(--coral); }
.card-amber { background: var(--amber-bg); border-color: transparent; color: var(--amber); }
.card-heading { margin: 0; font-size: 17px; font-weight: 700; }
.card-text { margin: var(--sp-1) 0 0; font-size: 15px; }
.card-heading + .card-text { margin-top: var(--sp-2); }
.card-more { display: flex; align-items: center; min-height: 44px; margin-top: var(--sp-1); font-size: 14px; font-weight: 700; }
.section-title { margin: 0 0 var(--sp-2); font-size: 13px; font-weight: 700; letter-spacing: .02em; color: var(--ink-soft); }
.section-gap { margin-top: var(--sp-2); }
/* カードの外の見出しは、下のカードに近づける（上 24px・下 12px） */
.view > .section-title { margin-bottom: calc(var(--sp-1) * -1); }
.card-coral .section-title, .card-amber .section-title { color: inherit; }

/* 点の並び（明日の準備） */
.list { list-style: none; margin: 0; padding: 0; }
.list-item { position: relative; padding: var(--sp-2) 0 var(--sp-2) 18px; border-top: 1px solid var(--line); }
.list-item:first-child { border-top: 0; }
.list-item::before { content: ""; position: absolute; left: 2px; top: 16px; width: 7px; height: 7px; border-radius: 50%; background: var(--ink); }
.card-change .list-item::before { background: transparent; border: 2px solid var(--ink); }

/* 行の並び（提出物・資料） */
.rows { list-style: none; margin: 0; padding: 0; }
.rows > li { border-top: 1px solid var(--line); }
.rows > li:first-child { border-top: 0; }
/* .rows の padding: 0 が .card の左右の余白を消していたので、左右も明示する */
.card.rows { padding: var(--sp-1) var(--card-px); }
.card-coral .rows > li { border-top-color: rgba(153, 60, 29, .15); }
.card-coral .rows > li:first-child { border-top: 0; }
.row { display: flex; align-items: center; gap: var(--sp-3); padding: var(--row-py) 0; min-height: 56px; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.row-title { font-weight: 600; }
.row-sub { font-size: 13px; line-height: 1.5; color: var(--ink-soft); }
.card-coral .row-sub { color: inherit; opacity: .85; }
.row-side { flex: none; display: flex; align-items: center; gap: var(--sp-2); }
.row.is-done .row-title { color: var(--done); text-decoration: line-through; }
.chev { flex: none; color: var(--ink-soft); font-size: 20px; }
@media (max-width: 480px) {
  .row-deadline { flex-wrap: wrap; }
  .row-deadline .row-main { flex-basis: 100%; }
  .row-deadline .row-side { width: 100%; justify-content: flex-end; }
}

/* 期限の札 */
.due { flex: none; padding: 2px var(--sp-3); border-radius: 999px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.due-urgent { background: var(--coral); color: #fff; }
.due-soon { background: #fff; color: var(--coral); box-shadow: inset 0 0 0 1px rgba(153, 60, 29, .35); }
.due-later { background: var(--navy-bg); color: var(--ink); }

/* ボタン */
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 16px; border: 1px solid var(--ink); border-radius: 999px; background: var(--card); font-size: 14px; font-weight: 700; white-space: nowrap; cursor: pointer; }
.btn-primary { background: var(--ink); color: #fff; }
.btn-ghost { background: transparent; }
.btn:disabled { opacity: .55; cursor: default; }
.row-side .btn { min-height: 44px; padding: 0 var(--sp-4); }

/* 今週 */
.tags { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.tag { display: inline-block; max-width: 100%; padding: 2px var(--sp-3); border-radius: 999px; background: var(--navy-bg); font-size: 13px; }
.tag-change { background: transparent; box-shadow: inset 0 0 0 1px var(--ink); }
.tag-due { background: var(--coral-bg); color: var(--coral); font-weight: 700; }
.tag-due.is-done { background: var(--done-bg); color: var(--done); font-weight: 400; text-decoration: line-through; }
.day { padding: var(--card-py) var(--card-px); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.day.is-today { border: 2px solid var(--ink); }
.day-head { display: flex; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-1); font-weight: 700; }
.pill { padding: 1px var(--sp-2); border-radius: 999px; background: var(--ink); color: #fff; font-size: 12px; }
.day-none { margin: 0; font-size: 14px; color: var(--ink-soft); }
.day-lines { margin: var(--sp-1) 0 0; padding: 0; list-style: none; font-size: 14px; }
.weeknav { display: flex; gap: var(--sp-2); }
.weeknav .btn { flex: 1 1 0; min-width: 0; padding: 0 var(--sp-2); }

/* 提出物の済み */
.details-done summary { display: flex; align-items: center; min-height: 44px; font-weight: 700; cursor: pointer; list-style: none; }
.details-done summary::-webkit-details-marker { display: none; }
.details-done summary::after { content: "›"; margin-left: auto; font-size: 20px; transition: transform .2s; }
.details-done[open] summary::after { transform: rotate(90deg); }

/* 資料 */
.doc-kind { flex: none; display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; border-radius: 10px; background: var(--navy-bg); font-size: 12px; font-weight: 700; }
.items { display: flex; flex-direction: column; gap: var(--sp-3); margin: 0; padding: 0; list-style: none; }
.item-head { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin: 0; font-size: 13px; color: var(--ink-soft); }
.item-kind { font-weight: 700; color: var(--ink); }
.item-title { margin: var(--sp-1) 0 0; font-weight: 700; }
.item-detail { margin: var(--sp-1) 0 0; font-size: 14px; }
.quote { margin: var(--sp-3) 0 0; padding: var(--sp-2) var(--sp-3); border-left: 3px solid var(--line); font-size: 13px; color: var(--ink-soft); }
/* 項目の行から、その項目が書かれた資料を開く */
.list-item:has(> .list-link) { padding-top: 0; padding-bottom: 0; }
.list-item:has(> .list-link)::before { top: 18px; }
.list-link { display: flex; align-items: center; gap: var(--sp-2); min-height: 44px; padding: var(--sp-2) 0; }
.list-link::after { content: "›"; flex: none; margin-left: auto; color: var(--ink-soft); font-size: 18px; }
.day-lines .list-link { min-height: 44px; padding: 4px 0; }
/* 今週のタグの当たり判定を 44px にする。見た目の丸は上下の透明な枠の内側だけに塗る */
.tag-link { display: inline-flex; align-items: center; min-height: 44px; border-block: 10px solid transparent; }
/* 色の指定（background）で塗る範囲が戻らないよう、.tag-due.is-done より後ろ・同じ強さで指定する */
.tags .tag-link { background-clip: padding-box; }
.tags:has(.tag-link) { row-gap: 0; }
/* 札の透明な枠と行の押せる範囲が重なって広く見えるので、札の次の予定の行は少し上げる */
.tags:has(.tag-link) + .day-lines { margin-top: calc(var(--sp-2) * -1); }
.merged-note .card-text + .card-text { margin-top: var(--sp-2); }
.row-tap { align-self: stretch; justify-content: center; }
.list-link:active, .row-tap:active, .tag-link:active { opacity: .7; }
.item.is-focus { border-color: var(--ink); box-shadow: 0 0 0 2px var(--ink); scroll-margin: 16px; }
.same-docs .rows { margin-top: var(--sp-1); }
.viewer { display: flex; flex-direction: column; gap: var(--sp-2); }
.viewer-img { display: block; width: 100%; height: auto; border: 1px solid var(--line); border-radius: 10px; }
.viewer-pdf { display: block; width: 100%; height: 70vh; border: 1px solid var(--line); border-radius: 10px; background: #fff; }

/* 確認待ち */
.choices { display: grid; gap: var(--sp-2); margin-top: var(--sp-4); }
.choice { display: flex; flex-direction: column; align-items: flex-start; width: 100%; min-height: 56px; padding: var(--sp-3) var(--sp-4); border: 1px solid rgba(133, 79, 11, .35); border-radius: 12px; background: #fff; color: var(--ink); text-align: left; cursor: pointer; }
.choice:disabled { opacity: .6; cursor: default; }
.choice-value { font-weight: 700; }
.choice-src { margin-top: 2px; font-size: 13px; line-height: 1.5; color: var(--ink-soft); }
.answer-note { margin: var(--sp-3) 0 0; font-weight: 700; }

/* 設定 */
.settings { margin: 0; }
.setting { display: flex; justify-content: space-between; gap: var(--sp-4); padding: var(--row-py) 0; border-top: 1px solid var(--line); }
.setting:first-child { border-top: 0; }
.setting:first-child { padding-top: var(--sp-1); }
.setting:last-child { padding-bottom: 0; }
.setting dt { flex: none; max-width: 50%; font-size: 14px; color: var(--ink-soft); }
.setting dd { margin: 0; min-width: 0; text-align: right; font-weight: 600; }
.setting-note { display: block; margin-top: 2px; font-size: 12px; line-height: 1.5; font-weight: 400; color: var(--ink-soft); }

/* 状態（読み込み中・空・失敗）と知らせ */
.state { display: flex; flex-direction: column; align-items: center; gap: var(--sp-3); padding: 48px var(--gutter); text-align: center; color: var(--ink-soft); }
.state-error { color: var(--ink); }
.state-title { margin: 0; font-size: 17px; font-weight: 700; }
.state-body { margin: 0; font-size: 14px; color: var(--ink-soft); }
.spinner { width: 28px; height: 28px; border: 3px solid var(--navy-bg); border-top-color: var(--ink); border-radius: 50%; animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.5s; } }
.empty p { margin: 0; padding: var(--sp-2) 0; text-align: center; color: var(--ink-soft); }
.toast { position: fixed; left: var(--gutter); right: var(--gutter); bottom: calc(var(--tabbar-h) + var(--sp-4) + env(safe-area-inset-bottom)); z-index: 20; max-width: 528px; margin: 0 auto; padding: var(--sp-3) var(--sp-4); border-radius: 12px; background: var(--ink); color: #fff; font-size: 14px; text-align: center; }

/* 下のタブ */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: grid; grid-template-columns: repeat(4, 1fr); height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: rgba(255, 255, 255, .96); border-top: 1px solid var(--line); }
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--sp-1); min-width: 0; font-size: 11px; color: var(--ink-soft); }
.tab[aria-current="page"] { color: var(--ink); font-weight: 700; }

/* 最後が 44px の押せる行（リンク・札・ボタン）だと、文字の下に押せる範囲の余白が足されて下だけ広く見える。
   押せる範囲は残したまま、その分だけカードの下を詰めて上下の見た目をそろえる */
.card > :last-child:is(.card-more, .rows, .list:has(> li:last-child > .list-link)),
.day > :last-child:is(.tags:has(.tag-link), .day-lines:has(> li:last-child > .list-link)) { margin-bottom: calc(var(--tap-slack) * -1); }
/* 済みの欄は見出し（44px）で始まるので、上下を少し詰める */
.details-done { padding-block: var(--sp-2); }
.details-done > .rows:last-child { margin-bottom: 0; }

/* 見出しの最後の 1 文字だけが折り返さないようにする */
h1, h2, .state-title { text-wrap: balance; }
