/* Study planner (only loaded on its page). */
.sp-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.sp-views { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: var(--r-panel); background: var(--mist); }
.sp-views button { display: inline-flex; align-items: center; gap: 7px; padding: 8px 13px; border: 0; border-radius: var(--r-control); background: none; color: var(--slate); font: 600 0.92rem var(--text); cursor: pointer; }
.sp-views button svg { width: 16px; height: 16px; }
.sp-views button[aria-selected="true"] { background: var(--paper); color: var(--ink); box-shadow: var(--shadow-1); }
.sp-views button:focus-visible, .sp-chip:focus-visible, .sp-difficulty button:focus-visible, .sp-cal-cell:focus-visible { outline: 3px solid var(--signal); outline-offset: 2px; }
.sp-setup-tab { display: none !important; }
.sp-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.sp-actions svg { width: 15px; height: 15px; }
.sp-menu-wrap { position: relative; }
.sp-menu { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 220px; padding: 6px; border: 1px solid var(--line); border-radius: var(--r-panel); background: var(--paper); box-shadow: var(--shadow-3); }
.sp-menu button { display: block; width: 100%; padding: 9px 10px; border: 0; border-radius: var(--r-control); background: none; color: var(--ink); font: 500 0.92rem var(--text); text-align: left; cursor: pointer; }
.sp-menu button:hover { background: var(--mist); }
.sp-danger { color: var(--bad) !important; }

.sp-layout { display: grid; grid-template-columns: minmax(0, 360px) minmax(0, 1fr); gap: 22px; align-items: start; }
.sp-setup { position: sticky; top: 80px; max-height: calc(100vh - 100px); overflow: auto; padding: 14px; border: 1px solid var(--line); border-radius: var(--r-panel); background: #FBFCFE; overscroll-behavior: contain; }
.sp-setup .small-heading { margin: 4px 0 10px; }
.sp-setup .small-heading:not(:first-child) { margin-top: 20px; }
.sp-setup .field { margin: 0 0 10px; }
.sp-label { display: block; font-weight: 600; font-size: 0.9rem; color: var(--ink); margin-bottom: 6px; }
.sp-subjects { display: flex; flex-direction: column; gap: 10px; }
.sp-subject { padding: 10px 12px; border: 1px solid var(--line); border-left: 4px solid var(--c); border-radius: 10px; background: var(--paper); }
.sp-subject-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.sp-subject-name { flex: 1; min-width: 0; font-weight: 700; }
.sp-color { position: relative; width: 26px; height: 26px; flex: none; border-radius: 50%; background: var(--c); cursor: pointer; overflow: hidden; box-shadow: 0 0 0 2px #fff, 0 0 0 3px var(--line-strong); }
.sp-color input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.sp-subject-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 8px; }
.sp-subject-grid .field { margin: 0; }
.sp-subject-grid label { font-size: 0.8rem; }
.sp-subject-grid input { padding: 7px 9px; font-size: 0.92rem; }
.sp-span2 { grid-column: 1 / -1; }
.sp-difficulty { display: flex; align-items: center; gap: 4px; margin-top: 8px; font-size: 0.85rem; color: var(--slate); }
.sp-difficulty span { margin-right: 4px; }
.sp-difficulty button { padding: 4px 10px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--paper); color: var(--ink); font: 600 0.8rem var(--text); cursor: pointer; }
.sp-difficulty button[aria-checked="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.sp-topics { margin-top: 8px; }
.sp-topics summary { cursor: pointer; font-size: 0.88rem; font-weight: 600; color: var(--ink); }
.sp-topics summary small { color: var(--slate-2); font-weight: 400; }
.sp-topics textarea { margin-top: 6px; font-size: 0.9rem; }
.sp-add { margin-top: 10px; }
.sp-add svg { width: 15px; height: 15px; }
.sp-hours { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.sp-hours label { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 0.75rem; font-weight: 700; color: var(--slate); }
.sp-hours input { padding: 6px 2px; text-align: center; font-size: 0.9rem; }
.sp-presets { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 12px; }
.sp-chip { padding: 4px 10px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--paper); color: var(--ink); font: 600 0.8rem var(--text); cursor: pointer; }
.sp-chip:hover { border-color: var(--signal); background: var(--signal-soft); }
.sp-two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.sp-two label { font-size: 0.82rem; }
.sp-rest { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.sp-rest-day { display: inline-flex; align-items: center; gap: 2px; padding: 2px 2px 2px 10px; border-radius: 999px; background: var(--mist); font-size: 0.85rem; font-weight: 600; }
.sp-rest input { width: auto; padding: 5px 8px; font-size: 0.85rem; }
.sp-icon-btn { display: inline-grid; place-items: center; width: 30px; height: 30px; padding: 0; border: 0; border-radius: var(--r-control); background: none; color: var(--slate); cursor: pointer; flex: none; }
.sp-icon-btn:hover { background: var(--mist); color: var(--ink); }
.sp-icon-btn svg { width: 16px; height: 16px; }

/* Plan */
.sp-main { min-width: 0; }
.sp-empty { padding: 24px; border: 1px dashed var(--line-strong); border-radius: var(--r-panel); color: var(--slate); text-align: center; }
.sp-plan-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.sp-week { margin-bottom: 18px; }
.sp-week .small-heading { margin: 0 0 8px; color: var(--slate); font-size: 0.9rem; }
.sp-day { margin-bottom: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-panel); background: var(--paper); scroll-margin-top: 90px; }
.sp-day.is-today { border-color: var(--signal); box-shadow: 0 0 0 3px var(--signal-soft); }
.sp-day.is-past { opacity: 0.75; }
.sp-day-head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.sp-day-head span { color: var(--slate); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.sp-exam-row { display: flex; align-items: center; gap: 8px; margin: 4px 0 6px; padding: 8px 10px; border-radius: var(--r-control); background: var(--c); color: #fff; }
.sp-exam-row svg { width: 18px; height: 18px; flex: none; }
.sp-exam-row span:nth-child(2) { flex: 1; }
.sp-good-luck { font-size: 0.82rem; opacity: 0.9; }
.sp-free { margin: 2px 0; color: var(--slate); font-size: 0.9rem; }
.sp-sessions { list-style: none; margin: 0; padding: 0; }
.sp-session { display: flex; align-items: center; gap: 10px; padding: 6px 4px; border-top: 1px solid var(--line); }
.sp-session:first-child { border-top: 0; }
.sp-check input { width: 19px; height: 19px; accent-color: var(--c); cursor: pointer; }
.sp-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--c); flex: none; }
.sp-session-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sp-session-text small { color: var(--slate); font-size: 0.84rem; }
.sp-session-text select { width: auto; max-width: 100%; padding: 4px 28px 4px 8px; font-size: 0.9rem; }
.sp-session.is-done .sp-session-text strong, .sp-session.is-done .sp-session-text small { text-decoration: line-through; color: var(--slate-2); }
.sp-mins { color: var(--slate); font-size: 0.85rem; white-space: nowrap; }

/* Calendar */
.sp-cal-head { display: flex; align-items: center; justify-content: center; gap: 14px; margin-bottom: 10px; }
.sp-cal-head strong { font-family: var(--display); font-size: 1.15rem; min-width: 160px; text-align: center; }
.sp-cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.sp-cal-dow { text-align: center; font-size: 0.78rem; font-weight: 700; color: var(--slate); padding: 4px 0; }
.sp-cal-cell { display: flex; flex-direction: column; align-items: stretch; gap: 3px; min-height: 84px; padding: 5px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); text-align: left; cursor: pointer; font: inherit; }
.sp-cal-cell:hover { border-color: var(--line-strong); }
.sp-cal-cell.is-empty { border: 0; background: none; cursor: default; }
.sp-cal-cell.is-today { border-color: var(--signal); box-shadow: inset 0 0 0 1px var(--signal); }
.sp-cal-num { font-size: 0.82rem; font-weight: 700; color: var(--ink); }
.sp-cal-exam { padding: 1px 5px; border-radius: 4px; background: var(--c); color: #fff; font-size: 0.7rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-cal-rest { font-size: 0.72rem; color: var(--slate); }
.sp-cal-bars { display: flex; gap: 2px; margin-top: auto; height: 6px; }
.sp-cal-bars i { display: block; flex-basis: 0; border-radius: 3px; background: var(--c); }
.sp-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 12px; font-size: 0.85rem; }
.sp-legend span { display: inline-flex; align-items: center; gap: 6px; }
.sp-legend i { width: 12px; height: 12px; border-radius: 3px; background: var(--c); }

/* Exams */
.sp-countdowns { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-bottom: 16px; }
.sp-count { display: flex; flex-direction: column; padding: 14px; border-radius: var(--r-panel); background: var(--c); color: #fff; }
.sp-count-num { font-family: var(--display); font-size: 2.4rem; font-weight: 800; line-height: 1; }
.sp-count span:nth-child(2) { font-size: 0.85rem; opacity: 0.9; }
.sp-count strong { margin-top: 2px; }
.sp-timetable tr.is-past td { color: var(--slate-2); text-decoration: line-through; }

/* Progress */
.sp-overall { display: flex; align-items: center; gap: 18px; margin-bottom: 18px; padding: 16px; border-radius: var(--r-panel); background: var(--mist); }
.sp-overall p { margin: 4px 0 0; color: var(--slate); }
.sp-ring { --p: 0; position: relative; width: 84px; height: 84px; flex: none; border-radius: 50%; background: conic-gradient(var(--signal) calc(var(--p) * 1%), var(--line) 0); display: grid; place-items: center; }
.sp-ring::before { content: ""; position: absolute; inset: 9px; border-radius: 50%; background: var(--mist); }
.sp-ring span { position: relative; font-family: var(--display); font-weight: 800; font-size: 1.15rem; }
.sp-progress-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.sp-prog { padding: 12px 14px; border: 1px solid var(--line); border-top: 4px solid var(--c); border-radius: var(--r-panel); background: var(--paper); }
.sp-prog-head { display: flex; justify-content: space-between; gap: 10px; font-size: 0.92rem; }
.sp-prog-head span { color: var(--slate); }
.sp-bar { height: 8px; margin: 8px 0 10px; border-radius: 99px; background: var(--mist); overflow: hidden; }
.sp-bar span { display: block; height: 100%; border-radius: 99px; background: var(--c); }
.sp-topic-list { list-style: none; margin: 0; padding: 0; font-size: 0.9rem; }
.sp-topic-list li { padding: 2px 0; }
.sp-topic-list input { accent-color: var(--c); margin-right: 6px; }

@media (max-width: 900px) {
    .sp-setup-tab { display: inline-flex !important; }
    .sp-layout { grid-template-columns: minmax(0, 1fr); }
    .sp-setup { position: static; max-height: none; }
    .sp-layout:not([data-view="setup"]) .sp-setup, .sp-layout[data-view="setup"] .sp-main { display: none; }
    .sp-views { width: 100%; }
    .sp-views button { flex: 1 1 auto; justify-content: center; padding: 8px 6px; font-size: 0.82rem; }
    .sp-views button svg { display: none; }
}
@media (max-width: 520px) {
    .sp-cal-cell { min-height: 58px; padding: 3px; }
    .sp-cal-exam { font-size: 0.6rem; padding: 0 3px; }
    .sp-actions { width: 100%; }
}

/* Printing: only the timetable and plan. */
.sp-print { display: none; }
@media print {
    body.sp-printing > * { display: none !important; }
    body.sp-printing > main { display: block !important; }
    body.sp-printing main > * { display: none !important; }
    body.sp-printing main .page-body, body.sp-printing .sp { display: block !important; }
    body.sp-printing .page-body > :not(.sp), body.sp-printing .sp > :not(.sp-print) { display: none !important; }
    body.sp-printing .sp { border: 0; box-shadow: none; padding: 0; }
    body.sp-printing .sp-print { display: block; color: #000; font: 10pt Arial, sans-serif; }
    .sp-print h1 { font-size: 16pt; margin: 0 0 6pt; }
    .sp-print h2 { font-size: 12pt; margin: 12pt 0 4pt; }
    .sp-print table { width: 100%; border-collapse: collapse; }
    .sp-print th, .sp-print td { border: 1px solid #999; padding: 3pt 5pt; text-align: left; vertical-align: top; }
    .sp-print tr { break-inside: avoid; }
}
.sp-timetable th, .sp-timetable td { text-align: left !important; }
