.timetable-page .hero { padding-bottom: 24px; }
.timetable-main { padding-top: 24px; padding-bottom: 48px; }
.tool-settings { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.tool-panel, .tool-promotion { padding: 24px; border: 1px solid var(--border); border-radius: 18px; background: var(--surface); margin-bottom: 20px; }
.timetable-page label { display: block; margin: 12px 0; }
.timetable-page input:not([type=checkbox]):not([type=color]), .timetable-page select { display: block; width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: 8px; color: var(--text); background: var(--bg); font: inherit; }
.timetable-page input[type=color] { width: 60px; height: 36px; }
.timetable-page .inline { display: inline-flex; align-items: center; gap: 8px; margin-right: 14px; }
.timetable-page button { cursor: pointer; padding: 9px 14px; border: 1px solid var(--border); border-radius: 9px; color: var(--text); background: var(--bg); font: inherit; }
.timetable-page button[aria-pressed=true] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.timetable-page button.primary { color: white; background: var(--accent); }
.timetable-page :focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
.timetable-page [hidden] { display: none !important; }
.timetable-page fieldset { border: 1px solid var(--border); border-radius: 8px; }
.timetable-page summary { cursor: pointer; padding: 12px 0; font-weight: 600; }
.time-row { display: grid; grid-template-columns: 70px 1fr 1fr; gap: 12px; align-items: center; }
#subject-list { padding: 0; list-style: none; }
#subject-list li { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
#subject-list li span { flex: 1; overflow-wrap: anywhere; }
.subject-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 8px; border: 1px solid #777; }
.editor-toolbar, .dialog-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.subject-tray { margin: 16px 0; }
.subject-tray h2 { margin: 0; font-size: 18px; }
.subject-tray-hint { margin: 8px 0 12px; color: var(--muted); font-size: 14px; }
.timetable-page .quick-subject-chip { padding: 4px 12px; min-height: 32px; border-radius: 24px; color: #171717; font-size: 14px; max-width: 100%; overflow-wrap: anywhere; cursor: grab; }
.timetable-page .quick-subject-chip:active { cursor: grabbing; }
.quick-subject-chip.dragging { opacity: .5; }
.placement-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 12px; font-size: 14px; }
.placement-controls:has(button[hidden]) { display: none; }
.timetable-page #stop-placement { padding: 4px 10px; background: transparent; color: var(--accent); }
.placing-subject .lesson-cell { cursor: crosshair; }
.timetable-grid .lesson-cell.drop-target { outline: 3px solid var(--accent); outline-offset: -3px; box-shadow: inset 0 0 0 4px var(--surface); }
.mobile-day { display: none !important; }
.timetable-grid { border-collapse: collapse; table-layout: fixed; width: 100%; }
.timetable-grid th, .timetable-grid td { padding: 5px; border: 1px solid var(--border); overflow-wrap: anywhere; }
.timetable-grid th { font-size: 13px; }
.timetable-grid th:first-child { width: 90px; }
.timetable-grid small { display: block; font-weight: normal; }
.timetable-grid .lesson-cell { width: 100%; min-height: 86px; padding: 8px 5px; font-size: 13px; border-radius: 5px; }
.lesson-content { display: block; color: #171717; }
.lesson-content strong, .lesson-content span { display: block; }
.export-actions { margin: 24px 0; }
.export-actions > button { margin: 0 8px 8px 0; }
.tool-promotion { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.tool-promotion img { background: white; flex-shrink: 0; }
.tool-help { max-width: 800px; }
.tool-help li { margin: 12px 0; }
#time-error { color: #d33939; }
#lesson-dialog { width: min(680px, calc(100% - 32px)); max-height: calc(100dvh - 32px); overflow-y: auto; padding: 24px; border: 1px solid var(--border); border-radius: 18px; background: var(--bg); color: var(--text); }
#lesson-dialog::backdrop { background: #0008; }
#lesson-dialog .dialog-actions { margin-top: 20px; }
#lesson-dialog .dialog-actions .primary { background: var(--accent); color: white; border-color: var(--accent); font-weight: 650; }
#lesson-dialog .dialog-actions .primary:hover { filter: brightness(.92); }
#lesson-dialog .dialog-actions .secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
#lesson-dialog .dialog-actions .secondary:hover { border-color: var(--accent); }
#lesson-dialog .dialog-actions .tertiary { background: transparent; color: var(--muted); border-color: transparent; margin-left: auto; }
#lesson-dialog .dialog-actions .tertiary:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

#lesson-dialog .lesson-subject-fieldset { border: 0; padding: 0; margin: 16px 0; min-width: 0; }
.lesson-subject-fieldset legend { margin-bottom: 10px; }
.subject-chips { display: flex; flex-wrap: wrap; gap: 8px; }
#lesson-dialog .subject-chip { position: relative; display: inline-flex; align-items: center; gap: 8px; margin: 0; padding: 4px 12px; min-height: 32px; border: 2px solid transparent; border-radius: 24px; color: #171717; font-size: 14px; cursor: pointer; overflow-wrap: anywhere; max-width: 100%; }
#lesson-dialog .subject-chip input { position: absolute; width: 1px; height: 1px; margin: 0; padding: 0; border: 0; clip-path: inset(50%); overflow: hidden; }
#lesson-dialog .subject-chip:has(input:checked) { border-color: #1769c2; box-shadow: 0 0 0 1px #1769c2; font-weight: 650; }
#lesson-dialog .subject-chip:focus-within { outline: 3px solid var(--accent); outline-offset: 3px; }
#lesson-dialog .subject-chip:hover { border-color: #1769c2; }
.chip-check { visibility: hidden; flex-shrink: 0; }
.subject-chip input:checked ~ .chip-check { visibility: visible; }
#print-view { display: none; }
@media (max-width: 700px) {
    .tool-settings { grid-template-columns: 1fr; gap: 0; }
    .tool-panel { padding: 16px; }
    .mobile-day { display: block !important; }
    #editor-grid .day-hidden { display: none; }
    .timetable-page .nav-right { flex-wrap: wrap; justify-content: flex-end; }
    .timetable-grid .lesson-cell { min-height: 65px; }
    .tool-promotion { gap: 12px; padding: 16px; }
}
@page { size: A4 landscape; margin: 10mm; }
@media print {
    html, body.timetable-page { height: auto; margin: 0; background: white; color: #18263e; }
    .timetable-page > :not(#print-view) { display: none !important; }
    #print-view { display: block; }
    .print-sheet { break-after: page; page-break-after: always; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
    .print-sheet:last-child { break-after: auto; page-break-after: auto; }
    .print-heading { display: flex; align-items: center; justify-content: space-between; gap: 5mm; margin-bottom: 3mm; border-top: 1.5mm solid #b4d5ff; padding-top: 2mm; }
    .print-heading > div { flex: 1; min-width: 0; }
    .print-eyebrow { margin: 0 0 1mm; font-size: 7pt; font-weight: 700; letter-spacing: .12em; color: #46668c; }
    .print-sheet h1 { font-size: 17pt; font-weight: 800; margin: 0; line-height: 1.1; letter-spacing: -.025em; overflow-wrap: anywhere; }
    .print-week-badge { flex-shrink: 0; border: .3mm solid #a8c9f5; border-radius: 3mm; background: #eaf3ff; padding: 2mm 4mm; font-size: 10pt; font-weight: 700; color: #254e80; }
    .print-grid { width: 100%; table-layout: fixed; border-collapse: separate; border-spacing: 1mm .4mm; font-size: 9pt; }
    .print-grid th, .print-grid td { border: .2mm solid #e2e8f0; border-radius: 1.5mm; padding: .4mm 1.5mm; overflow-wrap: anywhere; line-height: 1.15; }
    .print-grid th:first-child { width: 22mm; }
    .print-grid thead tr { height: 8mm; }
    .print-grid thead th { background: var(--day-color, #edf2f8); border-color: transparent; font-weight: 750; }
    .print-grid tbody tr { height: var(--print-row-height); break-inside: avoid; }
    .print-grid tbody th { background: #edf2f8; color: #36516f; font-size: 10pt; }
    .print-grid small { display: block; margin-top: .5mm; font-size: 7pt; font-weight: normal; color: #52647a; }
    .print-grid td { font-size: var(--lesson-print-font, 9pt); vertical-align: middle; background: #f8fafc; }
    .print-grid .print-lesson { border-left: .8mm solid var(--subject-accent); }
    .print-grid .lesson-content strong { font-size: inherit; font-weight: 750; color: #18263e; }
    .print-grid .lesson-content span { color: #35445a; }
    .print-promotion { display: flex; justify-content: space-between; align-items: center; gap: 5mm; margin-top: 3mm; padding-top: 1mm; border-top: .3mm solid #dce6f2; height: 23mm; font-size: 8pt; break-inside: avoid; }
    .print-promotion strong { color: #254e80; }
    .print-promotion img { width: 22mm; height: 22mm; background: white; flex-shrink: 0; }
    .print-promotion a { color: #254e80; text-decoration: none; }
    .print-compact .print-grid th { font-size: 8pt; }
    .print-compact .print-heading { padding-top: 1mm; border-top-width: 1mm; margin-bottom: 2mm; }
    .print-sheet.print-compact h1 { font-size: 13.5pt; }
    .print-compact .print-grid { border-spacing: .7mm .25mm; }
    .print-compact .print-grid th, .print-compact .print-grid td { padding: .25mm .6mm; }
    .print-compact .print-promotion { margin-top: 2mm; }
}
