: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 transparent; border-radius: 11px; background: #263c46; color: white; font-size: 11px; font-weight: 700; text-decoration: none; transition: .15s ease; }
.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 { 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(3,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 { width: 100%; min-height: 42px; padding: 10px 12px; border: 1px solid #e1e7e9; border-radius: 10px; outline: none; background: #fff; color: var(--ink); font-size: 12px; }
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); }
.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); }
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)); }
  .card { padding: 16px; }
  .quick-actions { grid-template-columns: repeat(3,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; justify-content: space-between; align-items: center; text-align: left; }
  .review-day { margin: 0; }
  .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; } }
