:root {
  color-scheme: light;
  --bg: #f5f6f7;
  --surface: #ffffff;
  --surface-2: #f8f9fa;
  --ink: #202a35;
  --muted: #71808d;
  --line: #e6eaed;
  --accent: #287b80;
  --accent-dark: #1e6268;
  --accent-soft: #e6f2f2;
  --warm: #d89a55;
  --danger: #c65c5c;
  --shadow: 0 12px 35px rgba(31, 48, 63, .055);
  --radius: 18px;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI", Meiryo, sans-serif;
  font-synthesis: none;
}
* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { margin: 0; min-height: 100vh; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
.app-shell { min-height: 100vh; max-width: 1440px; margin: 0 auto; padding: 0 30px 30px; }
.app-header { height: 78px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 13px; background: #253b45; color: white; font: 700 22px Georgia, serif; box-shadow: 0 5px 12px rgba(37,59,69,.18); }
.brand strong { display: block; font-size: 16px; letter-spacing: -.3px; }
.brand small { display: block; margin-top: 2px; color: #83909a; font-size: 8px; font-weight: 700; letter-spacing: 1.7px; }
.header-actions { display: flex; align-items: center; gap: 12px; }
.save-indicator { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; }
.save-indicator i { width: 7px; height: 7px; border-radius: 50%; background: #57a789; }
.save-indicator.saving i { background: var(--warm); }
.icon-button { border: 1px solid var(--line); width: 38px; height: 38px; border-radius: 12px; color: var(--ink); background: var(--surface); font-size: 20px; }
.main-nav { display: flex; gap: 5px; align-items: center; margin: 18px 0 28px; padding: 6px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.72); box-shadow: 0 5px 20px rgba(31,48,63,.025); overflow-x: auto; scrollbar-width: none; }
.main-nav::-webkit-scrollbar { display: none; }
.nav-item { display: inline-flex; align-items: center; justify-content: center; gap: 7px; flex: 1 0 auto; min-width: 100px; padding: 10px 14px; border: 0; border-radius: 11px; background: transparent; color: var(--muted); font-size: 12px; font-weight: 650; white-space: nowrap; transition: .15s ease; }
.nav-item span { font-size: 16px; line-height: 1; }
.nav-item:hover { color: var(--ink); background: var(--surface-2); }
.nav-item.active { background: #263c46; color: white; box-shadow: 0 5px 12px rgba(38,60,70,.13); }
#app-main { min-height: calc(100vh - 190px); outline: none; }
.app-footer { display: flex; justify-content: space-between; padding: 22px 2px 0; color: #99a2a9; font-size: 10px; letter-spacing: .2px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin: 5px 0 24px; }
.eyebrow { display: block; margin-bottom: 7px; color: var(--accent); font-size: 9px; font-weight: 800; letter-spacing: 2px; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 5px; font-size: clamp(25px, 3.1vw, 34px); letter-spacing: -1.2px; line-height: 1.2; }
.page-description { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.7; }
.page-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.card { min-width: 0; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.card.compact { padding: 15px 17px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 15px; }
.card-title { margin: 0; font-size: 13px; font-weight: 760; letter-spacing: -.2px; }
.card-subtitle { margin: 4px 0 0; color: var(--muted); font-size: 10px; line-height: 1.6; }
.metric-label { color: var(--muted); font-size: 11px; font-weight: 600; }
.metric-value { margin: 8px 0 3px; font-size: clamp(26px, 3vw, 36px); font-weight: 760; letter-spacing: -1px; line-height: 1; font-variant-numeric: tabular-nums; }
.metric-foot { color: var(--muted); font-size: 10px; }
.metric-accent { color: var(--accent); }
.metric-icon { width: 34px; height: 34px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 11px; background: var(--accent-soft); color: var(--accent); font-size: 17px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 39px; padding: 9px 14px; border: 1px solid rgba(255,255,255,.42); border-radius: 11px; background: #263c46; color: white; font-size: 11px; font-weight: 700; text-decoration: none; transition: .15s ease; }
.btn:not(.secondary):not(.soft):not(.danger) { border-color: rgba(255,255,255,.42); }
.btn:not(.secondary):not(.soft):not(.danger):hover { border-color: rgba(255,255,255,.58); }
.btn:hover { background: #182e37; transform: translateY(-1px); }
.btn.secondary { border-color: var(--line); background: white; color: var(--ink); }
.btn.secondary:hover { background: #f6f8f9; }
.btn.soft { border-color: #c7dddd; background: var(--accent-soft); color: var(--accent-dark); }
.btn.danger { border-color: #f1dddd; background: #fff7f7; color: var(--danger); }
.btn.small { min-height: 31px; padding: 6px 10px; border-radius: 9px; font-size: 10px; }
.btn.full { width: 100%; }
.text-button { padding: 4px 0; border: 0; background: transparent; color: var(--accent-dark); font-size: 11px; font-weight: 700; }
.quick-actions { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
.quick-action { min-height: 86px; display: flex; flex-direction: column; justify-content: space-between; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink); text-align: left; }
.quick-action:hover { border-color: #c5dada; background: #fbfefe; }
.quick-action .q-icon { color: var(--accent); font-size: 20px; }
.quick-action strong { font-size: 11px; }
.quick-action small { color: var(--muted); font-size: 9px; }
.progress-track { width: 100%; height: 8px; overflow: hidden; border-radius: 99px; background: #edf0f2; }
.progress-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg,#2c777e,#70aaa0); }
.progress-row { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 8px; font-size: 10px; }
.progress-row span:last-child { color: var(--muted); font-variant-numeric: tabular-nums; }
.subject-mini { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid #f0f2f3; }
.subject-mini:last-child { border-bottom: 0; }
.subject-dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.subject-mini-name { flex: 1; font-size: 11px; font-weight: 650; }
.subject-mini-time { color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.empty-state { padding: 28px 18px; border: 1px dashed #dce2e5; border-radius: 15px; color: var(--muted); text-align: center; background: #fbfcfc; }
.empty-state .empty-icon { margin-bottom: 9px; color: #a0afb5; font-size: 24px; }
.empty-state strong { display: block; margin-bottom: 5px; color: var(--ink); font-size: 12px; }
.empty-state p { margin: 0; font-size: 10px; line-height: 1.7; }
.form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; }
.field { min-width: 0; display: flex; flex-direction: column; gap: 7px; }
.field.full-width { grid-column: 1 / -1; }
.field label, .field-label { color: #586774; font-size: 10px; font-weight: 740; }
input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]), select, textarea { display: block; width: 100%; max-width: 100%; min-width: 0; min-inline-size: 0; box-sizing: border-box; min-height: 42px; padding: 10px 12px; border: 1px solid #e1e7e9; border-radius: 10px; outline: none; background: #fff; color: var(--ink); font-size: 12px; }
input[type="date"], input[type="datetime-local"] { width: 100%; max-width: 100%; min-width: 0; min-inline-size: 0; box-sizing: border-box; }
.form-grid, .field { min-width: 0; }
.form-grid { width: 100%; }
/* Safari/iPadOS can let the native datetime control paint outside its grid cell.
   The wrapper owns the visible border and clips the native control to the field width. */
.datetime-input-wrap { display: flex; width: 100%; min-width: 0; max-width: 100%; overflow: hidden; border: 1px solid #e1e7e9; border-radius: 10px; background: #fff; }
.datetime-input-wrap:focus-within { border-color: #81b3b5; box-shadow: 0 0 0 3px rgba(40,123,128,.10); }
.datetime-input-wrap input[type="datetime-local"] { display: block; flex: 1 1 0; width: 100%; min-width: 0; max-width: 100%; min-inline-size: 0; box-sizing: border-box; border: 0 !important; border-radius: inherit; outline: 0; box-shadow: none !important; background: transparent; text-align: center; }
.datetime-input-wrap input[type="datetime-local"]::-webkit-date-and-time-value { min-width: 0; text-align: center; }
.category-segment { display: flex; justify-content: stretch; align-self: stretch; width: 100%; max-width: 100%; }
.category-segment button { flex: 1 1 0; min-width: 0; min-height: 46px; padding: 10px 8px; text-align: center; white-space: nowrap; }
textarea { min-height: 76px; resize: vertical; line-height: 1.6; }
input:focus, select:focus, textarea:focus { border-color: #81b3b5 !important; box-shadow: 0 0 0 3px rgba(40,123,128,.10); }
input[type=range] { width: 100%; accent-color: var(--accent); }
input[type=color] { width: 44px; height: 38px; padding: 3px; border: 1px solid var(--line); border-radius: 9px; background: white; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); vertical-align: middle; }
input[type=number] { font-variant-numeric: tabular-nums; }
.hint { color: var(--muted); font-size: 9px; line-height: 1.6; }
.section-label { display: flex; align-items: center; gap: 9px; margin: 22px 0 12px; color: #65727c; font-size: 10px; font-weight: 800; letter-spacing: .7px; }
.section-label:after { content: ""; height: 1px; flex: 1; background: var(--line); }
.segmented { display: inline-flex; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 11px; background: #f6f8f8; }
.segmented button { padding: 7px 11px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 10px; font-weight: 700; }
.segmented button.active { background: white; color: var(--ink); box-shadow: 0 2px 7px rgba(30,45,55,.08); }
.tag-list { display: flex; flex-wrap: wrap; gap: 7px; }
.tag-choice { display: inline-flex; align-items: center; gap: 6px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: #5e6b75; font-size: 9px; }
.tag-choice:has(input:checked) { border-color: #c2dada; background: #f0f8f7; color: var(--accent-dark); }
.question-card { padding: 15px; border: 1px solid var(--line); border-radius: 15px; background: #fcfdfd; }
.question-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.question-head strong { font-size: 12px; }
.rating-row { display: flex; gap: 6px; }
.rating-option { position: relative; flex: 1; }
.rating-option input { position: absolute; opacity: 0; pointer-events: none; }
.rating-option span { display: grid; place-items: center; min-height: 34px; border: 1px solid var(--line); border-radius: 8px; background: white; color: #71808d; font-size: 13px; font-weight: 800; }
.rating-option input:checked + span { border-color: #8db9b7; background: var(--accent-soft); color: var(--accent-dark); }
.timer-panel { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 13px 15px; border: 1px solid #dce9e9; border-radius: 13px; background: #f1f8f7; }
.timer-time { color: #23434a; font: 650 23px ui-monospace, SFMono-Regular, Menlo, monospace; font-variant-numeric: tabular-nums; letter-spacing: -.8px; }
.timer-status { color: var(--muted); font-size: 9px; }
.timer-controls { display: flex; gap: 6px; flex-wrap: wrap; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 560px; }
th, td { padding: 11px 10px; border-bottom: 1px solid #eef1f2; text-align: left; font-size: 10px; }
th { color: var(--muted); font-weight: 750; background: #fafbfb; }
td strong { font-size: 11px; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 7px; border-radius: 7px; background: #f0f3f4; color: #65737d; font-size: 9px; font-weight: 700; white-space: nowrap; }
.badge.teal { background: #e7f3f1; color: #2d7774; }
.badge.orange { background: #fbf1e5; color: #a06b2f; }
.badge.red { background: #faeeee; color: #ae5555; }
.history-subject, .history-book, .history-chapter { margin: 9px 0; border: 1px solid var(--line); border-radius: 13px; background: white; overflow: hidden; }
.history-subject > summary, .history-book > summary, .history-chapter > summary { display: flex; align-items: center; gap: 9px; min-height: 49px; padding: 12px 14px; cursor: pointer; list-style: none; }
summary::-webkit-details-marker { display: none; }
.history-subject > summary:after, .history-book > summary:after, .history-chapter > summary:after { content: "⌄"; margin-left: auto; color: #9aa5ac; }
.history-subject > summary { background: #fbfcfc; }
.history-subject > summary strong { font-size: 12px; }
.history-book { margin: 8px 10px 10px 19px; }
.history-book > summary strong, .history-chapter > summary strong { font-size: 11px; }
.history-chapter { margin: 8px 10px 10px 18px; }
.history-chapter > summary { min-height: 42px; background: #fcfdfd; }
.history-record { display: flex; justify-content: space-between; gap: 12px; padding: 12px 14px; border-top: 1px solid #f0f2f3; }
.history-record-main { flex: 1; min-width: 0; }
.history-record-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 7px; }
.history-record-title strong { font-size: 10px; }
.problem-line { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; color: #64717b; font-size: 9px; }
.problem-line span:first-child { color: var(--ink); font-weight: 650; }
.row-actions { display: flex; align-items: flex-start; gap: 5px; }
.icon-action { padding: 5px 8px; border: 1px solid var(--line); border-radius: 8px; background: white; color: var(--muted); font-size: 10px; }
.icon-action.delete { color: var(--danger); }

/* Proportional rectangular plan editor (mirrors the original SwiftUI layout). */
.plan-form { gap: 14px; }
.plan-time-layout { display: flex; justify-content: space-between; align-items: end; gap: 18px; }
.plan-time-inputs { display: flex; align-items: end; gap: 7px; }
.plan-time-inputs .field { width: 92px; }
.plan-time-unit { padding-bottom: 12px; color: var(--muted); font-size: 10px; }
.plan-allocation-card { overflow: hidden; }
.plan-visual-legend { display: flex; justify-content: space-between; gap: 12px; margin: 2px 0 8px; color: var(--muted); font-size: 9px; }
.plan-visual-legend span:first-child { color: var(--ink); font-weight: 750; }
.plan-subject-bar { position: relative; height: 58px; overflow: visible; border: 2px solid #1a252a; border-radius: 9px; background: white; touch-action: pan-y; }
.plan-subject-segments { display: flex; width: 100%; height: 100%; overflow: hidden; border-radius: 6px; }
.plan-subject-segment { display: flex; min-width: 0; flex: 0 0 auto; flex-direction: column; justify-content: center; align-items: center; gap: 2px; overflow: hidden; border-right: 1px solid rgba(30,40,45,.45); color: #23323a; text-align: center; white-space: nowrap; }
.plan-subject-segment:last-child { border-right: 0; }
.plan-subject-segment strong { max-width: 100%; overflow: hidden; padding: 0 3px; font-size: 10px; text-overflow: ellipsis; }
.plan-subject-segment small { font-size: 9px; font-variant-numeric: tabular-nums; }
.plan-subject-handle { position: absolute; z-index: 4; top: 50%; width: 24px; height: 100%; padding: 0; border: 0; border-radius: 4px; background: transparent; transform: translate(-50%,-50%); cursor: ew-resize; touch-action: none; }
.plan-subject-handle::after { content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 4px; background: #11191d; border: 1px solid rgba(255,255,255,.8); transform: translateX(-50%); }
.plan-subject-handle:focus-visible, .plan-category-handle:focus-visible { outline: 3px solid #5d9e9b; outline-offset: 1px; }
.plan-visual-legend-lower { margin-top: 17px; }
.plan-treemap { display: flex; width: 100%; height: clamp(300px,52vw,450px); gap: 4px; overflow: visible; }
.plan-subject-column { position: relative; display: flex; min-width: 0; flex-direction: column; border: 2px solid #172126; border-radius: 9px; background: #fff; overflow: visible; }
.plan-category-stack { display: flex; flex: 1 1 auto; min-height: 0; flex-direction: column; overflow: hidden; border-radius: 6px; }
.plan-category-block { display: flex; min-height: 0; min-width: 0; flex-direction: column; justify-content: center; align-items: center; gap: 4px; overflow: hidden; padding: 4px 2px; color: #1e3038; text-align: center; }
.plan-category-block strong { max-width: 100%; overflow: hidden; font-size: clamp(9px,1.25vw,12px); text-overflow: ellipsis; white-space: nowrap; }
.plan-category-block > span { max-width: 100%; overflow: hidden; font-size: clamp(8px,1.1vw,10px); font-variant-numeric: tabular-nums; white-space: nowrap; }
.plan-category-block small { font-size: inherit; }
.plan-category-handle { position: absolute; z-index: 5; left: 0; width: 100%; height: 24px; padding: 0; border: 0; border-radius: 4px; background: transparent; transform: translateY(-50%); cursor: ns-resize; touch-action: none; }
.plan-category-handle::after { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 4px; background: #11191d; border: 1px solid rgba(255,255,255,.8); transform: translateY(-50%); }
.plan-treemap-empty { display: grid; width: 100%; place-items: center; padding: 20px; border: 2px dashed var(--line); border-radius: 10px; color: var(--muted); font-size: 11px; text-align: center; }
.plan-drag-hint { margin: 10px 0 0; }
.plan-details { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.plan-details summary { color: var(--accent-dark); font-size: 10px; font-weight: 750; cursor: pointer; }
.plan-details .table-wrap { margin-top: 10px; }
.plan-save-actions { justify-content: flex-end; }

.review-list { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; align-items: stretch; }
.review-card { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 14px; align-items: center; padding: 16px; border: 1px solid var(--line); border-radius: 15px; background: white; }
.review-card h3 { margin: 0 0 6px; font-size: 13px; }
.review-card p { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.7; }
.review-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.review-side { text-align: right; }
.review-day { margin-bottom: 9px; color: var(--accent-dark); font-size: 11px; font-weight: 800; }
.review-section-title { display: flex; align-items: center; gap: 8px; margin: 20px 0 10px; font-size: 12px; font-weight: 800; }
.review-section-title span { color: var(--muted); font-size: 9px; font-weight: 500; }
.chart-bars { display: flex; align-items: flex-end; gap: 7px; min-height: 140px; padding: 12px 4px 0; }
.chart-bar-wrap { display: flex; flex: 1; min-width: 0; height: 126px; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; }
.chart-bar { width: min(100%,26px); min-height: 2px; border-radius: 6px 6px 2px 2px; background: #6fa5a2; }
.chart-bar-label { color: var(--muted); font-size: 8px; white-space: nowrap; }
.chart-bar-value { color: #62727b; font-size: 8px; font-variant-numeric: tabular-nums; }
.legend-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 9px; }
.legend-item i { width: 8px; height: 8px; border-radius: 3px; }
.heatmap { display: grid; grid-template-columns: repeat(7,minmax(0,1fr)); gap: 5px; }
.heat-cell { min-height: 29px; display: grid; place-items: center; border-radius: 6px; background: #eef1f2; color: #64717b; font-size: 8px; }
.heat-cell.level-1 { background: #dcebea; }
.heat-cell.level-2 { background: #b9d8d5; }
.heat-cell.level-3 { background: #83b9b4; color: #163f40; }
.heat-cell.level-4 { background: #438c89; color: white; }
.bar-list-item { display: grid; grid-template-columns: minmax(65px, 1fr) 2fr auto; align-items: center; gap: 9px; padding: 9px 0; border-bottom: 1px solid #f0f2f3; }
.bar-list-item:last-child { border-bottom: 0; }
.bar-list-label { overflow: hidden; color: #56646e; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.bar-list-track { height: 7px; border-radius: 99px; background: #eef1f2; overflow: hidden; }
.bar-list-fill { height: 100%; border-radius: inherit; background: #79aaa6; }
.bar-list-value { color: var(--muted); font-size: 9px; font-variant-numeric: tabular-nums; }
.setting-group { margin-bottom: 14px; }
.setting-row { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid #f0f2f3; }
.setting-row:last-child { border-bottom: 0; }
.setting-row strong { display: block; font-size: 11px; }
.setting-row small { display: block; margin-top: 3px; color: var(--muted); font-size: 9px; line-height: 1.55; }
.subject-setting { padding: 14px; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.subject-setting + .subject-setting { margin-top: 9px; }
.book-setting { display: flex; align-items: center; justify-content: space-between; gap: 7px; padding: 8px 0 8px 16px; border-bottom: 1px solid #f1f3f4; font-size: 10px; }
.inline-form { display: flex; gap: 7px; margin-top: 9px; }
.inline-form input { flex: 1; min-width: 0; }
.toast-region { position: fixed; z-index: 100; right: 18px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { max-width: min(420px, calc(100vw - 36px)); padding: 12px 15px; border-radius: 12px; background: #263c46; color: white; box-shadow: 0 12px 30px rgba(0,0,0,.18); font-size: 11px; line-height: 1.5; animation: toast-in .2s ease both; }
.toast.error { background: #8f4141; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.loading-state { min-height: 55vh; display: grid; align-content: center; justify-items: center; color: var(--muted); font-size: 11px; }
.loader { width: 24px; height: 24px; border: 2px solid #e0e7e8; border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
dialog { width: min(620px, calc(100vw - 28px)); max-height: min(92vh, 860px); padding: 0; border: 1px solid var(--line); border-radius: 22px; background: var(--bg); color: var(--ink); box-shadow: 0 25px 80px rgba(20,40,50,.25); }

/* 記録入力のストップウォッチは、Swift Playgrounds / iPadでも画面全体を使う。 */
#timer-dialog.timer-fullscreen {
  position: fixed;
  inset: 0;
  width: 100vw;
  max-width: none;
  height: 100vh;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  box-shadow: none;
}
#timer-dialog.timer-fullscreen[open] { display: flex; flex-direction: column; }
#timer-dialog.timer-fullscreen .dialog-head {
  flex: 0 0 auto;
  padding: calc(14px + env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) 14px max(18px, env(safe-area-inset-left));
}
#timer-dialog.timer-fullscreen .dialog-body {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow: auto;
  overscroll-behavior: contain;
  padding: clamp(18px, 4vh, 42px) max(18px, env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
}
#timer-dialog.timer-fullscreen .timer-hero {
  max-width: 900px;
  margin: 0 auto clamp(20px, 4vh, 36px);
  padding: clamp(42px, 10vh, 108px) 16px;
  border-radius: 24px;
}
#timer-dialog.timer-fullscreen .timer-hero .timer-time {
  font-size: clamp(54px, 13vw, 116px);
  letter-spacing: -3px;
}
#timer-dialog.timer-fullscreen .timer-hero p { font-size: 14px; }
#timer-dialog.timer-fullscreen .timer-controls { justify-content: center; gap: 10px; }
#timer-dialog.timer-fullscreen .timer-controls .btn { min-height: 48px; padding: 12px 20px; }
#timer-dialog.timer-fullscreen .card,
#timer-dialog.timer-fullscreen > .btn { max-width: 900px; margin-left: auto; margin-right: auto; }
#timer-dialog.timer-fullscreen > .btn { display: block; width: 100%; }
@media (max-width: 560px) {
  #timer-dialog.timer-fullscreen .timer-hero { padding: 54px 10px; }
  #timer-dialog.timer-fullscreen .timer-hero .timer-time { font-size: clamp(42px, 13vw, 68px); letter-spacing: -2px; }
  #timer-dialog.timer-fullscreen .timer-controls .btn { flex: 1 1 42%; }
}
dialog::backdrop { background: rgba(21,37,45,.42); backdrop-filter: blur(3px); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; padding: 17px 20px; border-bottom: 1px solid var(--line); background: white; }
.dialog-head h2 { margin: 0; font-size: 14px; }
.dialog-body { max-height: calc(92vh - 70px); overflow: auto; padding: 20px; }
.timer-hero { margin: 8px 0 18px; padding: 30px 14px; border-radius: 18px; background: white; text-align: center; }
.timer-hero .timer-time { font-size: clamp(36px,9vw,60px); letter-spacing: -2px; }
.timer-hero p { margin: 8px 0 0; color: var(--muted); font-size: 10px; }
.lap-row { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--line); font: 11px ui-monospace,monospace; }
.notice { padding: 12px 14px; border: 1px solid #eadfc9; border-radius: 12px; background: #fffaf1; color: #80653c; font-size: 10px; line-height: 1.7; }
.notice.info { border-color: #d8e8e7; background: #f1f8f7; color: #3d6b6b; }
.hidden { display: none !important; }
@media (max-width: 900px) {
  .app-shell { padding: 0 18px 26px; }
  .grid-4 { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .nav-item { min-width: 90px; padding-inline: 10px; }
}
@media (max-width: 640px) {
  .app-shell { padding: 0 13px 96px; }
  .app-header { height: 64px; }
  .brand-mark { width: 34px; height: 34px; }
  .brand strong { font-size: 14px; }
  .save-indicator { font-size: 0; }
  .save-indicator i { width: 8px; height: 8px; }
  .main-nav { position: fixed; z-index: 30; left: 10px; right: 10px; bottom: max(8px, env(safe-area-inset-bottom)); margin: 0; padding: 5px; border: 1px solid rgba(210,218,221,.9); border-radius: 17px; background: rgba(255,255,255,.96); box-shadow: 0 10px 32px rgba(25,42,50,.16); backdrop-filter: blur(18px); }
  .nav-item { min-width: 61px; flex: 1 0 auto; flex-direction: column; gap: 3px; padding: 7px 5px; font-size: 8px; }
  .nav-item span { font-size: 17px; }
  .nav-item[data-tab="settings"] { display: none; }
  .page-head { align-items: flex-start; flex-direction: column; margin: 5px 0 18px; gap: 12px; }
  .page-head .page-actions { width: 100%; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .grid-2.mobile-two { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .grid-4.home-metrics { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
  .home-metrics .card.compact { padding: 12px; }
  .home-metrics .metric-value { font-size: 25px; }
  .review-list { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 9px; }
  .review-card { padding: 11px; gap: 9px; }
  .review-card h3 { font-size: 11px; overflow-wrap: anywhere; }
  .review-card p { font-size: 9px; }
  .review-card .btn { width: 100%; padding-inline: 6px; font-size: 9px; }
  .card { padding: 16px; }
  .quick-actions { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px; }
  .quick-action { min-height: 78px; padding: 10px; }
  .quick-action strong { font-size: 9px; }
  .quick-action small { font-size: 8px; }
  .form-grid { grid-template-columns: 1fr; }
  .field.full-width { grid-column: auto; }
  .history-book { margin-left: 9px; }
  .history-chapter { margin-left: 9px; }
  .review-card { grid-template-columns: 1fr; }
  .review-side { display: flex; flex-direction: column; align-items: stretch; gap: 7px; text-align: left; }
  .review-day { margin: 0; }
  .plan-time-layout { align-items: stretch; flex-direction: column; gap: 12px; }
  .plan-time-inputs { justify-content: flex-start; }
  .plan-time-inputs .field { width: min(92px,28vw); }
  .plan-treemap { height: 340px; gap: 3px; }
  .plan-category-block { padding-inline: 1px; gap: 2px; }
  .plan-category-block strong { font-size: 8px; }
  .plan-category-block > span { font-size: 7px; }
  .setting-row { align-items: flex-start; }
  .app-footer { padding-bottom: 2px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
