:root {
  color-scheme: light;
  --navy: #16324f;
  --navy-2: #24496e;
  --navy-tint: #eaf0f6;
  --accent: #2f7de1;
  --accent-dark: #1f63bd;
  --accent-tint: #e8f1fd;
  --bg: #f4f6f9;
  --paper: #ffffff;
  --ink: #1b2733;
  --muted: #5d6b79;
  --faint: #8a97a4;
  --line: #dde3ea;
  --line-strong: #c3ccd6;
  --ok: #1d7a4f;
  --ok-tint: #e7f5ee;
  --warn: #9a5b00;
  --warn-tint: #fff4e0;
  --danger: #b3261e;
  --danger-tint: #fdecea;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(22, 50, 79, .06), 0 8px 24px rgba(22, 50, 79, .06);
  --font: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Yu Gothic", "Meiryo", "Noto Sans JP", system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.7;
}
button, input, select { font: inherit; color: inherit; }
svg { width: 1em; height: 1em; flex: none; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
code { padding: 1px 5px; border-radius: 5px; background: var(--navy-tint); font-size: .92em; }
:focus-visible { outline: 3px solid rgba(47, 125, 225, .45); outline-offset: 2px; }

.skip-link { position: absolute; left: 12px; top: -60px; z-index: 10; padding: 8px 14px; border-radius: 8px; background: var(--navy); color: #fff; }
.skip-link:focus { top: 12px; }

/* ---------- header ---------- */
.topbar { background: var(--navy); color: #fff; }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 16px 0; }
.brand { display: flex; align-items: center; gap: 14px; color: inherit; text-decoration: none; }
.brand-text { display: grid; }
.brand-text strong { font-size: 18px; line-height: 1.35; letter-spacing: .02em; }
.brand-text small { color: #b8c8da; font-size: 12px; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 11px; background: rgba(255, 255, 255, .1); font-size: 24px; color: #cfe2ff; }
.brand h1 { margin: 0; font-size: 18px; line-height: 1.35; letter-spacing: .02em; }
.brand p { margin: 0; color: #b8c8da; font-size: 12px; }
.local-badge { text-decoration: none; display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid rgba(255, 255, 255, .22); border-radius: 999px; color: #dce8f5; font-size: 12px; white-space: nowrap; }
.local-badge svg { font-size: 15px; }
.top-links { display: flex; align-items: center; gap: 8px; }
.guide-link { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 999px; background: #fff; color: var(--navy); font-size: 13px; font-weight: 700; text-decoration: none; white-space: nowrap; }
.guide-link svg { font-size: 15px; }
.guide-link:hover { background: var(--accent-tint); }
.local-badge:hover { background: rgba(255, 255, 255, .08); }

.shell { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 28px 0 48px; }

/* ---------- stepper ---------- */
.stepper { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0 0 22px; padding: 0; list-style: none; }
.step { position: relative; display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--paper); border: 1px solid var(--line); color: var(--faint); font-size: 14px; font-weight: 600; }
.step-num { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--bg); border: 1px solid var(--line-strong); font-size: 13px; }
.step.is-current { border-color: var(--accent); color: var(--navy); box-shadow: 0 0 0 3px var(--accent-tint); }
.step.is-current .step-num { background: var(--accent); border-color: var(--accent); color: #fff; }
.step.is-done { color: var(--navy); }
.step.is-done .step-num { background: var(--navy); border-color: var(--navy); color: #fff; }

/* ---------- cards ---------- */
.workspace { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(320px, 1fr); gap: 18px; align-items: start; }
.card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); box-shadow: var(--shadow); padding: 22px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-head h2 { display: flex; align-items: center; gap: 10px; margin: 0; color: var(--navy); font-size: 18px; }
.card-head p { margin: 0; color: var(--muted); font-size: 13px; }
.head-num { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 7px; background: var(--navy); color: #fff; font-size: 13px; }

.segmented { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; border-radius: 11px; background: var(--bg); border: 1px solid var(--line); }
.segment { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-weight: 700; font-size: 14px; cursor: pointer; }
.segment svg { font-size: 18px; }
.segment:hover { color: var(--navy); }
.segment.is-active { background: var(--paper); color: var(--navy); box-shadow: 0 1px 3px rgba(22, 50, 79, .14); }
.source-content { padding-top: 16px; }
.label-short { display: none; }

.dropzone { display: flex; min-height: 220px; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 20px; border: 2px dashed var(--line-strong); border-radius: 12px; background: #fafbfd; color: var(--muted); cursor: pointer; text-align: center; transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone.is-dragging { border-color: var(--accent); background: var(--accent-tint); }
.dropzone strong { color: var(--navy); font-size: 16px; }
.dropzone u { color: var(--accent-dark); text-underline-offset: 3px; }
.dropzone small { margin-top: 8px; color: var(--faint); font-size: 12px; }
.drop-icon { display: grid; place-items: center; width: 52px; height: 52px; margin-bottom: 10px; border-radius: 50%; background: var(--accent-tint); color: var(--accent-dark); font-size: 26px; }
.dropzone.has-file { min-height: 120px; }
.dropzone.has-file .drop-icon { display: none; }

.file-chip { display: flex; align-items: center; gap: 12px; margin-top: 12px; padding: 12px 12px 12px 14px; border: 1px solid #b9d3f5; border-radius: 11px; background: var(--accent-tint); }
.file-chip-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 9px; background: #fff; color: var(--ok); font-size: 22px; }
.file-chip-body { display: grid; min-width: 0; flex: 1; }
.file-chip-body strong { overflow: hidden; color: var(--navy); font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.file-chip-body small { color: var(--muted); font-size: 12px; }
.icon-button { display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 18px; cursor: pointer; }
.icon-button:hover { background: rgba(22, 50, 79, .08); color: var(--navy); }

.field-label { display: block; margin-bottom: 6px; color: var(--navy); font-size: 14px; font-weight: 700; }
.text-input { width: 100%; min-height: 48px; padding: 10px 14px; border: 1px solid var(--line-strong); border-radius: 10px; background: #fff; outline: none; }
.text-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
.text-input.is-invalid { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-tint); }
.text-input.is-valid { border-color: var(--ok); }
.field-msg { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.field-msg.is-invalid { color: var(--danger); }
.field-msg.is-valid { color: var(--ok); }
.google-status { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 16px; padding: 10px 12px; border-radius: 10px; background: var(--bg); color: var(--muted); font-size: 13px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); }
.google-status.is-connected .status-dot { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-tint); }
.text-link { margin-left: auto; color: var(--accent-dark); font-weight: 700; text-decoration: none; }
.text-link:hover { text-decoration: underline; }
.note { margin: 12px 0 0; color: var(--muted); font-size: 12px; }

.mode-list { display: grid; gap: 8px; }
.mode-option { position: relative; display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 11px; cursor: pointer; transition: border-color .15s, background .15s; }
.mode-option:hover { border-color: var(--line-strong); background: #fafbfd; }
.mode-option input { position: absolute; opacity: 0; pointer-events: none; }
.mode-option:has(input:focus-visible) { outline: 3px solid rgba(47, 125, 225, .45); outline-offset: 2px; }
.mode-option.is-selected { border-color: var(--accent); background: var(--accent-tint); }
.mode-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 9px; background: var(--bg); color: var(--muted); font-size: 20px; }
.mode-option.is-selected .mode-icon { background: var(--accent); color: #fff; }
.mode-text { display: grid; }
.mode-text strong { color: var(--navy); font-size: 15px; line-height: 1.4; }
.mode-text small { color: var(--muted); font-size: 12px; }

.primary-button { position: relative; display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 52px; margin-top: 18px; padding: 12px 20px; border: 0; border-radius: 11px; background: var(--navy); color: #fff; font-size: 16px; font-weight: 700; letter-spacing: .03em; cursor: pointer; transition: background .15s, transform .05s; }
.primary-button:hover:not(:disabled) { background: var(--navy-2); }
.primary-button:active:not(:disabled) { transform: translateY(1px); }
.primary-button:disabled { background: #9aa8b6; cursor: not-allowed; }
.primary-button.is-busy { background: var(--navy-2); cursor: progress; }
.spinner { display: none; width: 18px; height: 18px; border: 2.5px solid rgba(255, 255, 255, .35); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
.primary-button.is-busy .spinner { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }
.run-hint { margin: 8px 0 0; color: var(--muted); font-size: 12px; text-align: center; }
.run-hint.is-ready { color: var(--ok); }
.privacy-note { display: flex; gap: 6px; margin: 16px 0 0; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; line-height: 1.6; }
.privacy-note svg { margin-top: 3px; font-size: 13px; }

/* ---------- result ---------- */
.result { margin-top: 22px; }
.result-banner { display: flex; gap: 14px; padding: 18px 20px; border: 1px solid var(--line); border-left-width: 5px; border-radius: var(--radius); background: var(--paper); box-shadow: var(--shadow); }
.banner-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--navy-tint); color: var(--navy); font-size: 22px; flex: none; }
.banner-body { flex: 1; min-width: 0; }
.banner-body h2 { margin: 0; color: var(--navy); font-size: 18px; line-height: 1.5; outline: none; }
.banner-body p { margin: 2px 0 0; overflow-wrap: anywhere; color: var(--muted); font-size: 14px; }
.result-banner.is-busy { border-left-color: var(--accent); }
.result-banner.is-busy .banner-icon { background: var(--accent-tint); color: var(--accent-dark); }
.result-banner.is-ok { border-left-color: var(--ok); }
.result-banner.is-ok .banner-icon { background: var(--ok-tint); color: var(--ok); }
.result-banner.is-warn { border-left-color: #e0a030; }
.result-banner.is-warn .banner-icon { background: var(--warn-tint); color: var(--warn); }
.result-banner.is-error { border-left-color: var(--danger); }
.result-banner.is-error .banner-icon { background: var(--danger-tint); color: var(--danger); }
.result-banner.is-error h2 { color: var(--danger); }
.progress { position: relative; height: 4px; margin-top: 12px; overflow: hidden; border-radius: 4px; background: var(--accent-tint); }
.progress span { position: absolute; inset: 0 auto 0 0; width: 35%; border-radius: 4px; background: var(--accent); animation: indeterminate 1.3s ease-in-out infinite; }
@keyframes indeterminate { from { left: -35%; } to { left: 100%; } }

.result-body:empty { display: none; }
.result-body { margin-top: 14px; }
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.metrics-1 { grid-template-columns: minmax(0, 260px); }
.metrics-2 { grid-template-columns: repeat(2, minmax(0, 260px)); }
.metric { padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); }
.metric span { display: block; color: var(--muted); font-size: 12px; font-weight: 600; }
.metric strong { display: block; color: var(--navy); font-size: 28px; line-height: 1.3; font-variant-numeric: tabular-nums; }
.metric small { color: var(--faint); font-size: 12px; }
.metric.is-warn { border-color: #f1d29a; background: var(--warn-tint); }
.metric.is-warn strong { color: var(--warn); }
.metric.is-danger { border-color: #f1b8b3; background: var(--danger-tint); }
.metric.is-danger strong { color: var(--danger); }
.metric.is-ok strong { color: var(--ok); }

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.button { display: inline-flex; align-items: center; gap: 8px; min-height: 42px; padding: 9px 16px; border: 1px solid var(--navy); border-radius: 10px; background: var(--navy); color: #fff; font-size: 14px; font-weight: 700; text-decoration: none; cursor: pointer; }
.button:hover { background: var(--navy-2); }
.button svg { font-size: 18px; }
.button.secondary { background: #fff; color: var(--navy); border-color: var(--line-strong); }
.button.secondary:hover { background: var(--bg); }
.actions .spacer { flex: 1; }

.panel { margin-top: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); box-shadow: var(--shadow); overflow: hidden; }
.tabs { display: flex; gap: 2px; padding: 0 12px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: thin; }
.tab { position: relative; display: inline-flex; align-items: center; gap: 6px; min-height: 48px; padding: 0 14px; border: 0; background: none; color: var(--muted); font-size: 14px; font-weight: 700; white-space: nowrap; cursor: pointer; }
.tab:hover { color: var(--navy); }
.tab.is-active { color: var(--navy); }
.tab.is-active::after { content: ""; position: absolute; right: 10px; bottom: -1px; left: 10px; height: 3px; border-radius: 3px 3px 0 0; background: var(--accent); }
.count { min-width: 22px; padding: 0 7px; border-radius: 999px; background: var(--bg); color: var(--muted); font-size: 12px; line-height: 20px; text-align: center; }
.count.is-warn { background: var(--warn-tint); color: var(--warn); }
.count.is-danger { background: var(--danger-tint); color: var(--danger); }
.tab-body { padding: 16px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 14px; }
.toolbar select, .toolbar input { min-height: 38px; padding: 6px 10px; border: 1px solid var(--line-strong); border-radius: 9px; background: #fff; font-size: 14px; }
.toolbar input { min-width: 180px; }
.toolbar .legend { display: flex; flex-wrap: wrap; gap: 12px; margin-left: auto; color: var(--muted); font-size: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 4px; }
.legend svg { font-size: 13px; }

/* timetable */
.tt-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 11px; }
.timetable { width: 100%; min-width: 760px; border-collapse: separate; border-spacing: 0; table-layout: fixed; }
.timetable th, .timetable td { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); vertical-align: top; }
.timetable tr > :last-child { border-right: 0; }
.timetable tbody tr:last-child > * { border-bottom: 0; }
.timetable thead th { position: sticky; top: 0; padding: 10px 8px; background: var(--navy-tint); color: var(--navy); font-size: 14px; text-align: center; }
.timetable thead th small { display: block; color: var(--muted); font-size: 11px; font-weight: 500; }
.timetable thead th.is-weekend { color: #9b2c2c; }
.timetable .slot-col { width: 108px; }
.timetable tbody th { padding: 10px; background: #fafbfd; color: var(--navy); font-size: 13px; text-align: left; }
.timetable tbody th small { display: block; color: var(--muted); font-size: 11px; font-weight: 500; font-variant-numeric: tabular-nums; }
.timetable td { padding: 6px; }
.cell { display: grid; gap: 5px; }
.cell-empty { display: block; padding: 8px 0; color: #c1c9d2; font-size: 12px; text-align: center; }
.lesson { position: relative; padding: 6px 8px 6px 10px; border: 1px solid transparent; border-left: 4px solid var(--sub, var(--navy)); border-radius: 7px; background: var(--sub-bg, var(--navy-tint)); font-size: 12px; line-height: 1.45; }
.lesson-top { display: flex; align-items: center; gap: 6px; }
.lesson-student { overflow: hidden; color: var(--ink); font-size: 13px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.lesson-subject { margin-left: auto; padding: 0 6px; border-radius: 5px; background: rgba(255, 255, 255, .8); color: var(--sub, var(--navy)); font-size: 11px; font-weight: 700; white-space: nowrap; }
.lesson-meta { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.lesson-meta .pref { margin-left: auto; font-weight: 700; }
.lesson.is-fixed { border-style: dashed; border-color: var(--line-strong); border-left-style: solid; }
.lesson .fixed-mark { display: inline-flex; color: var(--navy); font-size: 12px; }
.lesson-capacity { margin-top: 2px; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.lesson-capacity.is-shared { color: var(--accent-dark); font-weight: 700; }
.button.small { min-height: 34px; margin-top: 8px; padding: 5px 12px; font-size: 13px; }
.version-badge { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px; background: rgba(255, 255, 255, .14); color: #dce8f5; font-size: 11px; font-weight: 700; vertical-align: 2px; }
.lesson.is-dim { opacity: .22; }
.lesson.is-hit { box-shadow: 0 0 0 2px var(--accent); }

/* subject palette (muted, AA contrast on tint) */
.sub-0 { --sub: #1f5fa8; --sub-bg: #eaf2fc; }
.sub-1 { --sub: #1d7a4f; --sub-bg: #e8f5ee; }
.sub-2 { --sub: #a4441a; --sub-bg: #fcefe7; }
.sub-3 { --sub: #6c3fa3; --sub-bg: #f2ecfa; }
.sub-4 { --sub: #0d7582; --sub-bg: #e5f5f6; }
.sub-5 { --sub: #9a5b00; --sub-bg: #fdf3e2; }
.sub-6 { --sub: #a3284f; --sub-bg: #fcebf1; }
.sub-7 { --sub: #4a5a6b; --sub-bg: #eef1f4; }

/* tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 11px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { position: sticky; top: 0; padding: 9px 12px; background: var(--navy-tint); color: var(--navy); font-size: 12px; text-align: left; white-space: nowrap; }
.data-table td { padding: 9px 12px; border-top: 1px solid var(--line); vertical-align: top; }
.data-table tbody tr:hover { background: #fafbfd; }
.data-table .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--bg); color: var(--muted); font-size: 11px; font-weight: 700; white-space: nowrap; }
.tag.fixed { background: var(--navy-tint); color: var(--navy); }
.tag.danger { background: var(--danger-tint); color: var(--danger); }
.tag.warn { background: var(--warn-tint); color: var(--warn); }

/* unassigned */
.issue-list { display: grid; gap: 10px; }
.issue { display: grid; grid-template-columns: minmax(180px, 240px) 1fr; gap: 16px; padding: 14px 16px; border: 1px solid #f1d29a; border-left: 4px solid #e0a030; border-radius: 11px; background: #fffdf8; }
.issue-who strong { display: block; color: var(--navy); font-size: 15px; }
.issue-who small { color: var(--muted); font-size: 12px; }
.issue-reason { display: flex; align-items: center; gap: 6px; margin: 0; color: var(--warn); font-size: 14px; font-weight: 700; }
.issue-hint { display: flex; gap: 6px; margin: 6px 0 0; color: var(--ink); font-size: 13px; }
.issue-hint svg { margin-top: 3px; color: var(--accent-dark); }

.empty-state { padding: 28px 16px; color: var(--muted); text-align: center; }
.empty-state strong { display: block; color: var(--ok); font-size: 15px; }
.muted { color: var(--muted); font-size: 12px; }
.error-text { color: var(--danger); }

/* guide */
.guide { margin-top: 28px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); }
.guide summary { padding: 14px 18px; color: var(--navy); font-weight: 700; cursor: pointer; }
.guide-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; padding: 0 18px 18px; }
.guide article { display: flex; gap: 12px; padding: 14px; border-radius: 11px; background: var(--bg); }
.guide article > span { display: grid; place-items: center; flex: 0 0 26px; height: 26px; border-radius: 50%; background: var(--navy); color: #fff; font-size: 12px; font-weight: 700; }
.guide strong { color: var(--navy); font-size: 14px; }
.guide p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.footer { padding: 20px 16px; border-top: 1px solid var(--line); color: var(--faint); font-size: 12px; text-align: center; }
.footer p { margin: 2px 0; }
.footer a { color: var(--muted); }


/* ---------- source picker ---------- */
.source-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.source-option { display: flex; align-items: center; gap: 10px; min-height: 64px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--paper); color: var(--ink); text-align: left; cursor: pointer; transition: border-color .15s, background .15s; }
.source-option:hover { border-color: var(--line-strong); background: #fafbfd; }
.source-option.is-active { border-color: var(--accent); background: var(--accent-tint); box-shadow: 0 0 0 1px var(--accent) inset; }
.source-option > span:last-child { display: grid; min-width: 0; }
.source-option strong { color: var(--navy); font-size: 14px; line-height: 1.4; }
.source-option small { color: var(--muted); font-size: 11px; line-height: 1.45; }
.source-icon { display: grid; place-items: center; flex: none; width: 36px; height: 36px; border-radius: 9px; background: var(--bg); color: var(--muted); font-size: 20px; }
.source-option.is-active .source-icon { background: var(--accent); color: #fff; }

.helper-links { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-top: 14px; color: var(--muted); font-size: 13px; }
.link-button { display: inline-flex; align-items: center; gap: 5px; padding: 4px 0; border: 0; background: none; color: var(--accent-dark); font-size: 13px; font-weight: 700; cursor: pointer; }
.link-button:hover { text-decoration: underline; }
.link-button svg { font-size: 15px; }
.manual-steps { padding: 16px 18px; border: 1px solid var(--line); border-radius: 12px; background: #fafbfd; }
.manual-title { margin: 0 0 6px; color: var(--navy); font-weight: 700; }
.manual-steps ol { margin: 0 0 12px; padding-left: 1.3em; color: var(--ink); font-size: 14px; }
.manual-steps li + li { margin-top: 4px; }
.button.wide { width: 100%; justify-content: center; }
.note strong { color: var(--ink); }

/* 画面入力のときは入力欄を横幅いっぱいにする */
.workspace.is-form { grid-template-columns: 1fr; }
.workspace.is-form .action-card { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(280px, 1fr); gap: 0 24px; align-items: start; }
.workspace.is-form .action-card .card-head { grid-column: 1 / -1; }
.workspace.is-form .action-card .mode-list { grid-row: span 3; }
.workspace.is-form .action-card .primary-button { margin-top: 0; }
.mode-option.is-disabled { opacity: .45; cursor: not-allowed; }

/* ---------- form editor ---------- */
.fe-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 14px; }
.fe-toolbar .save-state { margin-left: auto; color: var(--muted); font-size: 12px; }
.fe-toolbar .button { min-height: 36px; padding: 6px 12px; font-size: 13px; }
.fe-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.fe-summary div { padding: 8px 12px; border-radius: 10px; background: var(--bg); }
.fe-summary span { display: block; color: var(--muted); font-size: 11px; font-weight: 600; }
.fe-summary strong { color: var(--navy); font-size: 18px; font-variant-numeric: tabular-nums; }
.fe-tabs { display: flex; gap: 2px; margin: 0 -2px 16px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.fe-tab { position: relative; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px; border: 0; background: none; color: var(--muted); font-size: 14px; font-weight: 700; white-space: nowrap; cursor: pointer; }
.fe-tab .n { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--bg); font-size: 11px; }
.fe-tab.is-active { color: var(--navy); }
.fe-tab.is-active .n { background: var(--navy); color: #fff; }
.fe-tab.is-active::after { content: ""; position: absolute; right: 8px; bottom: -1px; left: 8px; height: 3px; border-radius: 3px 3px 0 0; background: var(--accent); }
.fe-lead { margin: 0 0 14px; color: var(--muted); font-size: 13px; }
.fe-section + .fe-section { margin-top: 20px; }
.fe-section h3 { margin: 0 0 8px; color: var(--navy); font-size: 15px; }
.fe-grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 16px; }
.fe-field { display: grid; gap: 4px; }
.fe-field > span { color: var(--navy); font-size: 13px; font-weight: 700; }
.fe-field small { color: var(--muted); font-size: 12px; }
.fe-input, .fe-select { width: 100%; min-height: 40px; padding: 6px 10px; border: 1px solid var(--line-strong); border-radius: 9px; background: #fff; font-size: 14px; }
.fe-input:focus, .fe-select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-tint); }
.fe-input.small { width: 90px; }
.fe-input.tiny { width: 70px; }
.fe-inline { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.fe-check { display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; background: #fff; font-size: 13px; cursor: pointer; user-select: none; }
.fe-check:has(input:checked) { border-color: var(--accent); background: var(--accent-tint); color: var(--navy); font-weight: 700; }
.fe-check input { accent-color: var(--accent); margin: 0; }
.fe-table-wrap { overflow-x: auto; }
.fe-table { width: 100%; min-width: 640px; border-collapse: collapse; font-size: 14px; }
.fe-section .fe-table { min-width: 360px; }
.fe-table th { padding: 6px 8px; color: var(--muted); font-size: 12px; font-weight: 700; text-align: left; white-space: nowrap; }
.fe-table td { padding: 4px 6px 4px 0; vertical-align: middle; }
.fe-add { display: inline-flex; align-items: center; gap: 6px; margin-top: 10px; padding: 8px 14px; border: 1px dashed var(--line-strong); border-radius: 10px; background: #fff; color: var(--accent-dark); font-size: 14px; font-weight: 700; cursor: pointer; }
.fe-add:hover { border-color: var(--accent); background: var(--accent-tint); }
.fe-add svg { font-size: 16px; }
.fe-del { display: grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 8px; background: none; color: var(--faint); font-size: 18px; cursor: pointer; }
.fe-del:hover { background: var(--danger-tint); color: var(--danger); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 4px 6px 4px 12px; border-radius: 999px; background: var(--navy-tint); color: var(--navy); font-size: 14px; font-weight: 700; }
.chip button { display: grid; place-items: center; width: 24px; height: 24px; border: 0; border-radius: 50%; background: none; color: var(--muted); font-size: 14px; cursor: pointer; }
.chip button:hover { background: rgba(22, 50, 79, .1); color: var(--danger); }

.fe-search { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.fe-search .fe-input { max-width: 260px; }
.person-list { display: grid; gap: 10px; }
.person { border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.person[open] { border-color: var(--line-strong); box-shadow: var(--shadow); }
.person > summary { display: flex; align-items: center; gap: 10px; padding: 10px 14px; cursor: pointer; list-style: none; }
.person > summary::-webkit-details-marker { display: none; }
.person > summary::before { content: ""; width: 8px; height: 8px; border-right: 2px solid var(--faint); border-bottom: 2px solid var(--faint); transform: rotate(-45deg); transition: transform .15s; flex: none; }
.person[open] > summary::before { transform: rotate(45deg); }
.person-id { color: var(--faint); font-size: 12px; font-variant-numeric: tabular-nums; }
.person-name { color: var(--navy); font-weight: 700; }
.person-name.is-empty { color: var(--danger); font-weight: 500; }
.person-meta { overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.person-badge { margin-left: auto; flex: none; }
.person-body { display: grid; gap: 14px; padding: 4px 14px 16px 32px; }
.person-body h4 { margin: 0 0 6px; color: var(--navy); font-size: 13px; }
.person.is-inactive .person-name { color: var(--faint); text-decoration: line-through; }

.avail { border-collapse: separate; border-spacing: 4px; margin-left: -4px; }
.avail th { color: var(--muted); font-size: 12px; font-weight: 700; text-align: center; }
.avail th.row { padding-right: 6px; text-align: left; white-space: nowrap; }
.avail th.row small { display: block; color: var(--faint); font-size: 10px; font-weight: 500; }
.av { width: 52px; height: 38px; border: 1px solid var(--line); border-radius: 8px; background: #f3f5f8; color: var(--faint); font-size: 16px; font-weight: 700; cursor: pointer; }
.av:hover { border-color: var(--line-strong); }
.av.p-best { border-color: #1f63bd; background: #1f63bd; color: #fff; }
.av.p-ok { border-color: #7fb0ec; background: #e3eefc; color: #1f4f8f; }
.av.p-maybe { border-color: #e7c27a; background: #fff6e2; color: #8a5a00; }
.av.t-on { border-color: #86c5a4; background: #e7f5ee; color: var(--ok); }
.av.t-off { background: #f3f5f8; color: #b8c1cb; }
.avail-tools { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.mini { padding: 3px 10px; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: var(--muted); font-size: 12px; cursor: pointer; }
.mini:hover { border-color: var(--accent); color: var(--accent-dark); }
.legend-line { display: flex; flex-wrap: wrap; gap: 12px; margin: 0 0 10px; color: var(--muted); font-size: 12px; }
.legend-line span { display: inline-flex; align-items: center; gap: 5px; }
.legend-line i { display: inline-grid; place-items: center; width: 22px; height: 18px; border-radius: 5px; font-size: 11px; font-style: normal; font-weight: 700; }
.fe-empty { padding: 22px; border: 1px dashed var(--line-strong); border-radius: 12px; color: var(--muted); text-align: center; }
.fe-empty strong { display: block; color: var(--navy); }
.fe-nav { display: flex; justify-content: space-between; gap: 8px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.fe-warn { margin: 6px 0 0; color: var(--warn); font-size: 12px; }
.loc-link { padding: 0; border: 0; background: none; color: var(--accent-dark); font-size: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; }
.person.is-flash { box-shadow: 0 0 0 3px var(--accent); }

.toast { position: fixed; left: 50%; bottom: 24px; z-index: 20; max-width: calc(100% - 32px); padding: 10px 18px; border-radius: 10px; background: var(--navy); color: #fff; font-size: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .2); transform: translate(-50%, 0); }
.toast.is-error { background: var(--danger); }

/* ---------- document page ---------- */
.doc { max-width: 820px; }
.doc h1 { margin: 8px 0 10px; color: var(--navy); font-size: 26px; }
.doc-lead { margin: 0 0 20px; color: var(--ink); }
.doc-card { margin-top: 14px; }
.doc-card h2 { margin: 0 0 8px; color: var(--navy); font-size: 17px; }
.doc-card ul { margin: 0; padding-left: 1.2em; }
.doc-card li + li { margin-top: 6px; }
.doc-foot { margin-top: 22px; color: var(--muted); font-size: 13px; }
.brand-mark svg { width: 1em; height: 1em; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .workspace.is-form .action-card { display: block; }
  .source-picker { grid-template-columns: 1fr; }
  .fe-summary { grid-template-columns: repeat(2, 1fr); }
  .guide-grid { grid-template-columns: 1fr; }
  .issue { grid-template-columns: 1fr; gap: 6px; }
}
@media (max-width: 600px) {
  body { font-size: 14px; }
  .topbar-inner, .shell { width: calc(100% - 32px); }
  .brand-text small { display: none; }
  .local-badge span { display: none; }
  .person-body { padding-left: 14px; }
  .av { width: 44px; }
  .fe-toolbar .save-state { width: 100%; margin-left: 0; }
  .stepper { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .step { justify-content: center; padding: 8px; }
  .step-text { display: none; }
  .step.is-current .step-text { display: inline; font-size: 12px; }
  .card { padding: 16px; }
  .card-head { flex-direction: column; gap: 2px; }
  .segment { font-size: 13px; }
  .segment svg { display: none; }
  .label-long { display: none; }
  .label-short { display: inline; }
  .timetable { min-width: 640px; }
  .timetable .slot-col { width: 76px; }
  .timetable tbody th { padding: 8px 6px; font-size: 12px; }
  .dropzone { min-height: 170px; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .metrics-1 { grid-template-columns: 1fr; }
  .toolbar .legend { margin-left: 0; }
  .toolbar select, .toolbar input { flex: 1 1 140px; min-width: 0; }
  .actions .button { flex: 1 1 auto; justify-content: center; }
  .actions .spacer { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}

/* ---------- print: 時間割だけを印刷 ---------- */
@media print {
  @page { size: A4 landscape; margin: 10mm; }
  body { background: #fff; font-size: 11px; }
  .topbar, .stepper, .workspace, .guide, .footer, .toast, .skip-link, .actions, .tabs, .toolbar, .metrics, .result-banner .banner-icon, .progress { display: none !important; }
  .shell { width: 100%; padding: 0; }
  .result-banner { padding: 0 0 8px; border: 0; box-shadow: none; }
  .panel { border: 0; box-shadow: none; }
  .tab-body { padding: 0; }
  .tab-body[hidden] { display: none !important; }
  .tt-wrap { overflow: visible; }
  .timetable { min-width: 0; }
  .lesson { break-inside: avoid; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .lesson.is-dim { opacity: 1; }
}
