/* Componenti delle funzioni scolastiche: materie, orario, compiti, verifiche, calendario, dashboard. */
:root {
  --t-homework: #2f6fb0;
  --t-test: #c2412f;
  --t-oral: #b0731a;
  --t-study: #2f8a57;
  --t-lesson: #6f7b80;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --t-homework: #6aa5e0;
    --t-test: #ef8b7c;
    --t-oral: #e4ad4b;
    --t-study: #6fbf89;
    --t-lesson: #8a9a9f;
  }
}
:root[data-theme="dark"] {
  --t-homework: #6aa5e0;
  --t-test: #ef8b7c;
  --t-oral: #e4ad4b;
  --t-study: #6fbf89;
  --t-lesson: #8a9a9f;
}
.sc-red, .sw-red { --sc: #d64545; }
.sc-orange, .sw-orange { --sc: #e07a2e; }
.sc-amber, .sw-amber { --sc: #c99312; }
.sc-lime, .sw-lime { --sc: #6f9e1f; }
.sc-green, .sw-green { --sc: #2f8f55; }
.sc-teal, .sw-teal { --sc: #1f8a83; }
.sc-cyan, .sw-cyan { --sc: #1c94b4; }
.sc-blue, .sw-blue { --sc: #2f6fd1; }
.sc-indigo, .sw-indigo { --sc: #4f56c9; }
.sc-violet, .sw-violet { --sc: #8650c4; }
.sc-pink, .sw-pink { --sc: #cf4f8e; }
.sc-slate, .sw-slate { --sc: #66757c; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.page-head .page-title { margin-bottom: 12px; }
.page-actions { display: flex; gap: 8px; flex: none; padding-top: 8px; }
.icon.tiny { width: 14px; height: 14px; vertical-align: -2px; }
.icon.chev-sm { width: 18px; height: 18px; color: var(--ink-3); flex: none; }

/* ---------- Materie ---------- */
.subj-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--sc); flex: none; }
.subj-icon {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; flex: none;
  color: var(--sc); background: color-mix(in srgb, var(--sc) 15%, var(--surface));
}
.subj-icon.sm { width: 32px; height: 32px; border-radius: 10px; }
.subj-icon.sm .icon { width: 18px; height: 18px; }
.subj-icon.xs { width: 22px; height: 22px; border-radius: 7px; vertical-align: -5px; }
.subj-icon.xs .icon { width: 14px; height: 14px; }
.subj-icon.lg { width: 64px; height: 64px; border-radius: 20px; }
.subj-icon.lg .icon { width: 32px; height: 32px; }
.subject-preview { display: flex; justify-content: center; margin-bottom: 12px; }
.list-row.link { color: var(--ink); }
.list-row.link:hover { background: var(--surface-2); }
.swatch[class*="sw-"] { background: var(--sc); }
.icon-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 8px; }
.icon-choice {
  position: relative; display: grid; place-items: center; height: 44px; border-radius: 12px;
  border: 1.5px solid var(--line); color: var(--ink-2); cursor: pointer;
}
.icon-choice input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.icon-choice.on { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.icon-choice:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.card.catalog { padding: 6px; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 4px; }
.catalog-item { position: relative; display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 6px 10px; border-radius: var(--r-sm); cursor: pointer; }
.catalog-item input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.catalog-item .tick { color: transparent; }
.catalog-item.on { background: var(--primary-soft); }
.catalog-item.on .tick { color: var(--primary); }
.catalog-item:has(input:focus-visible) { outline: 3px solid var(--focus); }
.danger-panel { border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent); background: var(--danger-soft); border-radius: var(--r-md); margin-top: 8px; }
.callout { margin: 8px 0 16px; }
.callout.info { background: var(--primary-soft); color: var(--ink); }
.callout.info > .icon { color: var(--primary); }

/* ---------- Schede di navigazione ---------- */
.segmented.tabs { margin: 0 0 16px; }
.segmented a {
  flex: 1; text-align: center; min-height: 36px; display: grid; place-items: center; border-radius: 999px;
  font-weight: 600; font-size: var(--fs-sm); color: var(--ink-2); padding: 4px 12px;
}
.segmented a.on { background: var(--surface); color: var(--primary); box-shadow: var(--shadow-1); }
.subtabs .segmented { max-width: 420px; }
.segmented button .icon { width: 16px; height: 16px; vertical-align: -3px; }

/* ---------- Orario ---------- */
.day-chips { display: flex; gap: 6px; margin-bottom: 12px; }
.chip {
  flex: 1; display: grid; justify-items: center; min-height: 52px; padding: 6px 0; border-radius: var(--r-md);
  border: 1px solid var(--line); background: var(--surface); font-weight: 600; font-size: var(--fs-sm); color: var(--ink-2);
}
.chip small { font-size: var(--fs-xs); color: var(--ink-3); min-height: 1em; }
.chip.on { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.chip.on small { color: inherit; opacity: 0.85; }
.tt-grid { display: grid; gap: 12px; }
.tt-col { display: none; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 8px; }
.tt-col.selected { display: block; }
.tt-head { display: none; font-weight: 700; padding: 6px 8px 8px; }
.lesson { display: flex; align-items: center; gap: 12px; padding: 10px 8px; border-radius: var(--r-sm); color: var(--ink); min-width: 0; }
a.lesson:hover { background: var(--surface-2); }
.lesson + .lesson { border-top: 1px solid var(--line); }
.lesson strong, .lesson small { display: block; }
.lesson-time { display: grid; font-weight: 700; font-variant-numeric: tabular-nums; font-size: var(--fs-sm); min-width: 46px; }
.lesson-time small { font-weight: 500; color: var(--ink-3); }
.lesson.changed .lesson-time { color: var(--accent); }
.lesson.cancelled { opacity: 0.7; }
.tag-change { color: var(--accent); font-weight: 600; font-size: var(--fs-xs); }
.add-row {
  display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; margin-top: 4px;
  border: 1.5px dashed var(--line-strong); border-radius: var(--r-sm); font-weight: 600; font-size: var(--fs-sm);
}
.add-row .icon { width: 16px; height: 16px; }
.card.list.lessons { padding: 4px 8px; }
@media (min-width: 900px) {
  .day-chips { display: none; }
  .tt-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; }
  .tt-col { display: block; padding: 6px; }
  .tt-col .lesson { flex-direction: column; align-items: stretch; gap: 2px; padding: 8px 6px; border-left: 3px solid var(--sc); border-radius: 4px var(--r-sm) var(--r-sm) 4px; }
  .tt-col .lesson .subj-icon { display: none; }
  .tt-col .lesson-time { display: flex; gap: 4px; font-size: var(--fs-xs); color: var(--ink-2); }
  .tt-col .lesson-time small::before { content: "– "; }
  .tt-col .lesson strong { font-size: var(--fs-sm); overflow-wrap: anywhere; hyphens: auto; }
  .tt-head { display: block; }
}
.date-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 4px 0 12px; }
.date-nav .center { display: grid; }
.date-nav.compact { justify-content: flex-start; margin: 0; }
.date-nav.compact strong { min-width: 0; text-align: center; flex: 1; }
.link-small { font-size: var(--fs-xs); font-weight: 600; }

/* ---------- Filtri ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; align-items: center; }
.filters select {
  min-height: 40px; padding: 6px 10px; border-radius: 999px; border: 1px solid var(--line-strong);
  background: var(--surface); font-size: var(--fs-sm); max-width: 100%;
}
.filters .segmented { flex: 1 1 260px; }
.section-title .count { font-weight: 700; color: var(--ink-3); margin-left: 4px; }

/* ---------- Compiti ---------- */
.task-list { display: grid; gap: 8px; }
.task {
  display: flex; align-items: stretch; gap: 4px; background: var(--surface); border: 1px solid var(--line);
  border-left: 4px solid var(--sc); border-radius: var(--r-md); box-shadow: var(--shadow-1); min-width: 0;
}
.task-check { border: 0; background: none; padding: 0 6px 0 10px; color: var(--ink-3); display: grid; place-items: center; min-width: 44px; }
.task-check .icon { width: 26px; height: 26px; }
.task-check:hover { color: var(--ok); }
.task-body { flex: 1; min-width: 0; display: grid; gap: 2px; padding: 10px 4px; color: var(--ink); }
.task-subject { font-size: var(--fs-xs); font-weight: 700; color: var(--ink-2); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.task-text { font-weight: 550; overflow-wrap: anywhere; }
.task-meta { font-size: var(--fs-sm); color: var(--ink-2); }
.task-due {
  display: grid; align-content: center; justify-items: end; padding: 8px 12px 8px 4px; font-size: var(--fs-xs);
  font-weight: 700; color: var(--ink-2); text-align: right; white-space: nowrap;
}
.task-due b { color: var(--danger); }
.tag { font-style: normal; font-size: 0.7rem; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); }
.tag.hot { background: var(--danger-soft); color: var(--danger); }
.task.u-overdue {
  background: color-mix(in srgb, var(--danger) 6%, var(--surface));
  border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); border-left-color: var(--danger);
}
.task.u-today .task-due, .task.u-tomorrow .task-due { color: var(--accent); }
.task.u-done { opacity: 0.62; box-shadow: none; }
.task.u-done .task-text { text-decoration: line-through; }
.task.u-done .task-check { color: var(--ok); }
.suggest { margin: -6px 0 12px; }
.radio-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.radio-pill { position: relative; }
.radio-pill input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.radio-pill span { display: inline-block; padding: 8px 16px; border-radius: 999px; border: 1.5px solid var(--line-strong); font-weight: 600; font-size: var(--fs-sm); }
.radio-pill input:checked + span { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.radio-pill input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
textarea {
  width: 100%; padding: 10px 14px; border-radius: var(--r-sm); border: 1.5px solid var(--line-strong);
  background: var(--surface); resize: vertical; font: inherit; color: inherit;
}
textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.empty-state { display: grid; justify-items: center; text-align: center; gap: 6px; padding: 40px 16px; color: var(--ink-2); }
.empty-state > .icon { width: 40px; height: 40px; color: var(--ink-3); }
.empty-state p { max-width: 360px; margin: 0; }

/* ---------- Verifiche e interrogazioni ---------- */
.event-list { display: grid; gap: 8px; }
.event-card {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); color: var(--ink); box-shadow: var(--shadow-1); min-width: 0;
}
.event-card .grow { display: grid; gap: 1px; }
.event-date { display: grid; justify-items: center; width: 48px; padding: 6px 0; border-radius: 12px; flex: none; color: #fff; background: var(--t-test); line-height: 1.1; }
.event-card.k-oral .event-date { background: var(--t-oral); }
.event-date b { font-size: 1.2rem; }
.event-date small { font-size: 0.7rem; text-transform: uppercase; font-weight: 600; }
.event-kind { font-size: var(--fs-xs); font-weight: 700; color: var(--t-test); }
.event-card.k-oral .event-kind { color: var(--t-oral); }
.when { font-size: var(--fs-xs); font-weight: 700; color: var(--ink-2); white-space: nowrap; }
.when.soon { color: var(--danger); }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- Calendario ---------- */
.t-homework { --tc: var(--t-homework); }
.t-test { --tc: var(--t-test); }
.t-oral { --tc: var(--t-oral); }
.t-study { --tc: var(--t-study); }
.t-lesson { --tc: var(--t-lesson); }
.cal-toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.cal-toolbar .segmented { margin: 0; }
.cal-toolbar .date-nav { flex: 1 1 280px; }
.card.month { padding: 8px; }
.month-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
.month-grid.head span { text-align: center; font-size: var(--fs-xs); font-weight: 700; color: var(--ink-3); padding: 4px 0; }
.mday { display: grid; justify-items: center; align-content: start; gap: 3px; min-height: 52px; padding: 6px 0; border-radius: 12px; color: var(--ink); }
.mday:hover { background: var(--surface-2); }
.mday.other { color: var(--ink-3); opacity: 0.6; }
.mday .num { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; font-weight: 600; font-variant-numeric: tabular-nums; }
.mday.is-today .num { box-shadow: inset 0 0 0 2px var(--primary); color: var(--primary); }
.mday.selected .num { background: var(--primary); color: var(--primary-ink); box-shadow: none; }
.dots { display: flex; gap: 3px; min-height: 6px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--tc); }
.dots i.overdue { box-shadow: 0 0 0 1.5px var(--danger); }
@media (min-width: 900px) {
  .mday { min-height: 76px; }
}
.card.cal-day { padding: 6px; }
.cal-event { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: var(--r-sm); color: var(--ink); min-width: 0; }
.cal-event:hover { background: var(--surface-2); }
.cal-event + .cal-event { border-top: 1px solid var(--line); }
.cal-event .grow { display: grid; gap: 1px; }
.cal-type { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; color: var(--tc); background: color-mix(in srgb, var(--tc) 15%, var(--surface)); flex: none; }
.cal-type .icon { width: 19px; height: 19px; }
.cal-meta { font-size: var(--fs-xs); font-weight: 700; color: var(--tc); }
.cal-event strong { display: flex; align-items: center; gap: 6px; }
.cal-event.done { opacity: 0.6; }
.cal-event.done strong { text-decoration: line-through; }
.cal-event.overdue .cal-meta::after { content: " · in ritardo"; color: var(--danger); }
.cal-event.t-lesson strong { font-weight: 550; }
.quick-add { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 8px; }
.chip-btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 6px 14px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font-weight: 600; font-size: var(--fs-sm);
}
.chip-btn .icon { width: 17px; height: 17px; color: var(--primary); }
.chip-btn:hover { background: var(--primary-soft); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 16px 0 8px; font-size: var(--fs-xs); color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 9px; height: 9px; border-radius: 50%; background: var(--tc); }
.cal-week { display: grid; gap: 10px; }
.cal-week-day { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 6px; min-width: 0; }
.cal-week-day.is-today { border-color: var(--primary); }
.cal-week-head { display: block; padding: 6px 10px; color: var(--ink); }
.cal-week-day.is-today .cal-week-head { color: var(--primary); }
.cal-week .cal-event { padding: 8px; gap: 8px; }
.cal-week .empty { padding: 4px 10px 8px; text-align: left; }
@media (min-width: 1200px) {
  .cal-week { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
  .cal-week .cal-event { flex-direction: column; align-items: flex-start; gap: 4px; }
  .cal-week .cal-event .chev-sm,
  .cal-week .cal-type { display: none; }
}

/* ---------- Dashboard ---------- */
.dashboard .page-title { margin-bottom: 12px; }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
.stat {
  display: grid; padding: 12px 14px; border-radius: var(--r-md); background: var(--surface);
  border: 1px solid var(--line); color: var(--ink); box-shadow: var(--shadow-1);
}
.stat b { font-size: 1.6rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { font-size: var(--fs-xs); font-weight: 600; color: var(--ink-2); }
.stat.danger:not(.zero) b { color: var(--danger); }
.stat.accent:not(.zero) b { color: var(--accent); }
.stat.violet:not(.zero) b { color: var(--t-test); }
.stat.zero b { color: var(--ink-3); }
@media (min-width: 640px) {
  .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.quick-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 8px; }
@media (min-width: 640px) {
  .quick-actions { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
.quick-actions a.primary { background: var(--primary); color: var(--primary-ink); }
.quick-actions a {
  display: grid; justify-items: center; gap: 6px; padding: 12px 4px; border-radius: var(--r-md); background: var(--primary-soft);
  color: var(--primary); font-size: var(--fs-xs); font-weight: 700; text-align: center; line-height: 1.2;
}
.quick-actions a:hover { background: color-mix(in srgb, var(--primary) 18%, var(--surface)); }
.dash-grid { display: grid; gap: 0 24px; }
@media (min-width: 1100px) {
  .dash-grid { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); }
}
.dash-section { margin-top: 18px; }
.dash-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin: 0 4px 8px; }
.dash-head h2 { font-size: var(--fs-md); margin: 0; display: flex; align-items: center; gap: 6px; }
.dash-head a { font-size: var(--fs-sm); font-weight: 600; }
.dash-section.danger .dash-head h2 { color: var(--danger); }
.dash-section .empty { text-align: left; padding: 10px 4px; }
.more-link { display: inline-block; margin: 8px 4px 0; font-weight: 600; font-size: var(--fs-sm); }
.lessons.compact .lesson { padding: 8px 4px; }
.card.hero .avatar.lg { margin: 0 auto 12px; }
.dashboard { max-width: 1120px; }
