:root {
  --ink: #17202a;
  --deep: #0b1724;
  --blue: #204a6a;
  --blue-soft: #e9f1f6;
  --gold: #c08b35;
  --gold-ink: #906827;
  --gold-soft: #f2dfbd;
  --green: #2f6f65;
  --red: #a3422b;
  --paper: #f8f7f4;
  --white: #ffffff;
  --muted: #657587;
  --line: #d7dee5;
  --shadow: 0 22px 70px rgba(13, 27, 42, 0.14);
  --radius: 8px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: "DM Sans", Arial, sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

:focus-visible {
  outline: 3px solid rgba(192, 139, 53, 0.55);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.portal-shell {
  min-height: 100svh;
}

.suspended-view {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  color: var(--white);
  background:
    radial-gradient(circle at 75% 20%, rgba(192, 139, 53, 0.2), transparent 30%),
    linear-gradient(135deg, #07111c, #173f4d);
}

.suspended-card {
  width: min(620px, 100%);
  padding: 2rem;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.suspended-card h1 {
  margin: 0.7rem 0 0.8rem;
  font-family: "Playfair Display", Georgia, serif;
  font-size: clamp(2.2rem, 6vw, 4rem);
  line-height: 1.02;
}

.suspended-card p {
  color: rgba(255, 255, 255, 0.74);
}

.suspended-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-top: 1.5rem;
}

.login-view {
  min-height: 100svh;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  align-items: center;
  gap: 4rem;
  padding: clamp(1.2rem, 4vw, 4rem);
  color: var(--white);
  background:
    linear-gradient(rgba(255, 255, 255, 0.08) 1px, transparent 1px) 0 38% / 100% 34px,
    radial-gradient(circle at 82% 18%, rgba(192, 139, 53, 0.2), transparent 28%),
    linear-gradient(135deg, #07111c 0%, #102940 58%, #173f4d 100%);
}

.login-brand {
  max-width: 720px;
}

.back-link {
  display: inline-flex;
  margin-bottom: 3rem;
  color: rgba(255, 255, 255, 0.72);
  font-weight: 800;
}

.portal-kicker {
  display: inline-flex;
  color: var(--gold-ink);
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.login-view .portal-kicker,
.suspended-view .portal-kicker {
  color: var(--gold);
}

.login-brand h1,
.portal-topbar h2,
.login-card h2,
.portal-card h3,
.panel-head h3 {
  font-family: "Playfair Display", Georgia, serif;
}

.login-brand h1 {
  margin: 0.9rem 0 1rem;
  font-size: clamp(3rem, 7vw, 5.8rem);
  line-height: 0.98;
}

.login-brand p {
  max-width: 620px;
  color: rgba(255, 255, 255, 0.75);
  font-size: 1.08rem;
}

.login-card {
  width: min(100%, 430px);
  justify-self: end;
  padding: 2rem;
  color: var(--ink);
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.login-card h2 {
  margin: 1.5rem 0 0.3rem;
  color: var(--blue);
  font-size: 2rem;
}

.login-card p {
  margin: 0 0 1.5rem;
  color: var(--muted);
}

.prototype-note {
  display: grid;
  gap: 0.2rem;
  padding: 1rem;
  background: var(--blue-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.prototype-note strong {
  color: var(--blue);
}

.prototype-note span,
.small-note {
  color: var(--muted);
  font-size: 0.86rem;
}

.field-error {
  color: #b3261e;
  font-size: 0.86rem;
  min-height: 1.2em;
}

.field-success {
  color: #1e7a3d;
  font-size: 0.86rem;
  min-height: 1.2em;
}

.danger-zone {
  margin-top: 0.9rem;
  padding-top: 0.8rem;
  border-top: 1px dashed rgba(163, 66, 43, 0.3);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: flex-start;
}

.danger-zone .small-note {
  color: var(--red);
}

.login-label {
  display: block;
  margin: 1.2rem 0 0.35rem;
  color: var(--blue);
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.app-view {
  min-height: 100svh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.side-nav {
  position: sticky;
  top: 0;
  height: 100svh;
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
  padding: 1.25rem;
  color: var(--white);
  background: var(--deep);
}

.side-brand {
  display: inline-flex;
  flex-direction: column;
  color: var(--white);
  font-family: "Playfair Display", Georgia, serif;
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.08;
}

.side-brand span {
  color: var(--gold);
  font-style: italic;
}

.account-box {
  display: grid;
  gap: 0.15rem;
  padding: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.04);
}

.account-box span {
  color: rgba(255, 255, 255, 0.46);
  font-size: 0.73rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.account-box strong {
  color: var(--white);
}

.side-nav nav {
  display: grid;
  gap: 0.35rem;
}

.nav-tab {
  width: 100%;
  min-height: 42px;
  padding: 0.6rem 0.75rem;
  color: rgba(255, 255, 255, 0.68);
  text-align: left;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  cursor: pointer;
}

.nav-tab:hover,
.nav-tab.active {
  color: var(--deep);
  background: var(--gold);
}

.portal-main {
  min-width: 0;
  padding: 1.4rem;
}

.portal-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.2rem;
  padding: 1.25rem;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(13, 27, 42, 0.06);
}

.portal-topbar h2 {
  margin: 0.2rem 0 0;
  color: var(--blue);
  font-size: 1.8rem;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.portal-btn {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.66rem 0.9rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
}

.portal-btn.primary {
  color: var(--deep);
  background: var(--gold);
}

.portal-btn.neutral {
  color: var(--blue);
  background: var(--blue-soft);
  border-color: var(--line);
}

.portal-btn.ghost {
  margin-top: auto;
  color: rgba(255, 255, 255, 0.78);
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
}

.login-card .portal-btn,
.login-card select {
  width: 100%;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin-bottom: 1.2rem;
  background: var(--line);
  border: 1px solid var(--line);
}

.stat-card {
  padding: 1.15rem;
  background: var(--white);
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.stat-card strong {
  display: block;
  margin-top: 0.35rem;
  color: var(--blue);
  font-family: "Playfair Display", Georgia, serif;
  font-size: 2rem;
}

.dashboard-grid,
.panel-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.88fr) minmax(0, 1.12fr);
  gap: 1rem;
}

.portal-card {
  padding: 1.2rem;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 38px rgba(13, 27, 42, 0.06);
}

.wide-card {
  min-width: 0;
}

.portal-card h3,
.panel-head h3 {
  margin: 0 0 0.65rem;
  color: var(--blue);
  font-size: 1.35rem;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 1.2rem;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.panel-head.compact {
  padding: 0;
  margin-bottom: 1rem;
  border: 0;
  background: transparent;
}

.panel-head p,
.portal-card p {
  color: var(--muted);
}

.form-card {
  display: grid;
  gap: 0.9rem;
  align-content: start;
}

.field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
}

.field-row .full-row {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 0.35rem;
  color: var(--blue);
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 0.7rem 0.75rem;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  letter-spacing: 0;
  text-transform: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  outline: none;
  box-shadow: 0 0 0 3px rgba(32, 74, 106, 0.12);
}

input:disabled,
select:disabled,
textarea:disabled {
  color: #8a98a7;
  background: #eef2f5;
  cursor: not-allowed;
}

textarea {
  min-height: 104px;
  resize: vertical;
}

select[multiple] {
  min-height: 112px;
}

.item-list,
.student-list,
.lesson-list,
.material-list,
.request-list,
.review-list {
  display: grid;
  gap: 0.7rem;
}

.list-item {
  display: grid;
  gap: 0.45rem;
  padding: 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
}

.list-item.soft {
  background: var(--paper);
}

.list-line {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.list-title {
  display: block;
  color: var(--ink);
  font-weight: 900;
}

.list-meta {
  display: block;
  color: var(--muted);
  font-size: 0.86rem;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.chip {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  min-height: 24px;
  padding: 0.16rem 0.5rem;
  color: var(--blue);
  background: var(--blue-soft);
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 900;
}

.chip.gold {
  color: var(--deep);
  background: var(--gold-soft);
}

.chip.green {
  color: var(--green);
  background: rgba(47, 111, 101, 0.12);
}

.chip.red {
  color: var(--red);
  background: rgba(163, 66, 43, 0.12);
}

.proposal-box {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-top: 0.6rem;
  padding: 0.7rem 0.85rem;
  background: var(--gold-soft);
  border-left: 3px solid var(--gold-ink);
  border-radius: 4px;
}

.proposal-box .list-meta {
  color: var(--ink);
}

.archive-block {
  margin-top: 1.1rem;
  padding-top: 0.9rem;
  border-top: 1px dashed var(--line);
}

.archive-block summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}

.archive-block .list-item {
  opacity: 0.82;
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.35rem;
}

.mini-btn {
  min-height: 32px;
  padding: 0.35rem 0.55rem;
  color: var(--blue);
  background: var(--blue-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 0.72rem;
  font-weight: 900;
  cursor: pointer;
}

.mini-btn.danger {
  color: var(--red);
  background: rgba(163, 66, 43, 0.08);
}

.student-detail {
  margin-top: 0.8rem;
  padding: 0.9rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.search-label {
  position: relative;
}

.search-results {
  position: absolute;
  inset: calc(100% + 0.3rem) 0 auto;
  z-index: 20;
  display: grid;
  max-height: 260px;
  overflow: auto;
  padding: 0.35rem;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.search-results:empty {
  display: none;
}

.search-result {
  display: grid;
  gap: 0.1rem;
  padding: 0.65rem;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: calc(var(--radius) - 2px);
  cursor: pointer;
}

.search-result:hover {
  background: var(--blue-soft);
}

.search-result strong {
  color: var(--blue);
}

.search-result span,
.search-empty {
  color: var(--muted);
  font-size: 0.82rem;
}

.request-detail,
.material-viewer {
  border-top: 1px solid var(--line);
  padding-top: 0.4rem;
}

.request-detail summary,
.material-viewer summary {
  color: var(--blue);
  font-weight: 900;
  cursor: pointer;
}

.request-detail > * + *,
.material-viewer > * + * {
  margin-top: 0.75rem;
}

.materials-layout {
  display: grid;
  grid-template-columns: minmax(220px, 0.35fr) minmax(0, 1fr);
  gap: 1rem;
}

.materials-workspace {
  display: grid;
  gap: 1rem;
  min-width: 0;
}

.materials-stats {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.mini-stat {
  display: grid;
  gap: 0.2rem;
  padding: 0.9rem;
  background: var(--white);
}

.mini-stat span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.mini-stat strong {
  color: var(--blue);
  font-family: "Playfair Display", Georgia, serif;
  font-size: 1.55rem;
}

.archive-sidebar {
  align-self: start;
  display: grid;
  gap: 1rem;
}

.stacked-actions {
  display: grid;
  gap: 0.55rem;
}

.role-student .teacher-actions {
  display: none;
}

.category-filters,
.chip-picker {
  align-items: center;
}

.chip-button {
  border: 0;
  cursor: pointer;
}

.chip-button.active {
  color: var(--deep);
  background: var(--gold);
}

.category-chip {
  gap: 0.35rem;
}

.category-chip button {
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 999px;
  color: var(--blue);
  background: rgba(255, 255, 255, 0.7);
  cursor: pointer;
}

.material-editor,
.category-settings,
.group-settings {
  max-width: 980px;
}

.lesson-editor {
  min-height: 280px;
  line-height: 1.75;
}

.material-type-panels,
.type-fields,
.assignment-panel,
.rich-editor,
.student-material-sections,
.group-manager {
  display: grid;
  gap: 0.9rem;
}

.rich-editor {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--white);
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.55rem;
  background: var(--blue-soft);
  border-bottom: 1px solid var(--line);
}

.editor-toolbar button {
  min-height: 32px;
  padding: 0.3rem 0.55rem;
  color: var(--blue);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.72rem;
  font-weight: 900;
  cursor: pointer;
}

.editor-surface {
  min-height: 340px;
  padding: 1.1rem;
  color: var(--ink);
  line-height: 1.85;
  outline: none;
}

.editor-surface h2,
.editor-surface h3,
.rich-lesson h2,
.rich-lesson h3 {
  margin: 0.8rem 0 0.45rem;
  color: var(--blue);
  font-family: "Playfair Display", Georgia, serif;
}

.assignment-panel {
  padding: 1rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.assignment-panel h4,
.student-material-sections h4 {
  margin: 0;
  color: var(--blue);
  font-size: 1rem;
}

.assignment-panel p {
  margin: 0.2rem 0 0;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--line);
}

.segmented-control label {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0.55rem;
  color: var(--blue);
  background: var(--white);
  letter-spacing: 0;
  text-align: center;
  text-transform: none;
  cursor: pointer;
}

.segmented-control input {
  width: 16px;
  min-height: 16px;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.choice-grid.compact {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.choice-pill {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.15rem 0.5rem;
  align-items: center;
  padding: 0.65rem;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  letter-spacing: 0;
  text-transform: none;
}

.choice-pill input {
  grid-row: span 2;
  width: 18px;
  min-height: 18px;
}

.choice-pill span {
  font-weight: 900;
}

.choice-pill small {
  color: var(--muted);
}

.group-card {
  display: grid;
  gap: 0.8rem;
  padding: 0.9rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
}

.material-description,
.viewer-note {
  margin: 0;
  color: var(--muted);
}

.assignment-note {
  padding: 0.7rem;
  color: var(--blue);
  background: var(--blue-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 0.88rem;
}

.student-material-sections section {
  display: grid;
  gap: 0.6rem;
}

.student-material-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.student-material-summary div {
  display: grid;
  gap: 0.15rem;
  padding: 0.9rem;
  background: var(--paper);
}

.student-material-summary span,
.material-page-meta span {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.student-material-summary strong,
.material-page-meta strong {
  color: var(--blue);
  font-family: "Playfair Display", Georgia, serif;
  font-size: 1.35rem;
  line-height: 1.1;
}

.material-card {
  position: relative;
  overflow: hidden;
}

.material-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--blue);
}

.material-card-video::before {
  background: var(--red);
}

.material-card-file::before {
  background: var(--gold);
}

.material-card-link::before {
  background: var(--green);
}

.material-card-exercise::before {
  background: var(--blue);
}

.material-card-actions,
.material-page-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.mini-btn.primary {
  color: var(--deep);
  background: var(--gold);
  border-color: var(--gold);
}

.material-page {
  max-width: 1180px;
}

.material-page-head {
  justify-content: space-between;
  margin-bottom: 1rem;
}

.material-page-title {
  margin-bottom: 1rem;
}

.material-page-title h3 {
  margin: 0.35rem 0 0.4rem;
  color: var(--blue);
  font-family: "Playfair Display", Georgia, serif;
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 1.02;
}

.material-page-title p {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
}

.material-page-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 0.28fr);
  gap: 1rem;
  align-items: start;
}

.material-page-main {
  display: grid;
  gap: 0.9rem;
  min-width: 0;
}

.material-page-aside {
  display: grid;
  gap: 0.9rem;
  padding: 1rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.material-page-meta {
  display: grid;
  gap: 0.8rem;
}

.material-page-meta div {
  display: grid;
  gap: 0.2rem;
}

.viewer {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
}

.viewer iframe {
  width: 100%;
  border: 0;
  display: block;
}

.video-viewer iframe {
  aspect-ratio: 16 / 9;
  height: auto;
}

.pdf-viewer iframe {
  min-height: 520px;
}

.lesson-page {
  padding: 1.1rem;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 1rem;
  line-height: 1.85;
}

.star-input {
  display: inline-flex;
  gap: 0.2rem;
}

.star-input button {
  width: 42px;
  height: 42px;
  color: #b4bfca;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-size: 1.25rem;
  cursor: pointer;
}

.star-input button.active {
  color: var(--deep);
  background: var(--gold);
  border-color: var(--gold);
}

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  color: var(--ink);
  letter-spacing: 0;
  text-transform: none;
}

.check-row input {
  width: 18px;
  min-height: 18px;
  margin-top: 0.15rem;
}

.empty-state {
  padding: 1rem;
  color: var(--muted);
  text-align: center;
  background: var(--paper);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
}

.teacher-only,
.student-only {
  display: none !important;
}

.role-teacher .nav-tab.teacher-only,
.role-student .nav-tab.student-only {
  display: block !important;
}

.role-teacher .form-card.teacher-only {
  display: grid !important;
}

.role-teacher .portal-btn.teacher-only,
.role-teacher a.teacher-only {
  display: inline-flex !important;
}

.role-teacher .archive-sidebar.teacher-only,
.role-teacher .materials-stats.teacher-only,
.role-teacher .material-editor.teacher-only,
.role-teacher .category-settings.teacher-only,
.role-teacher .group-settings.teacher-only {
  display: grid !important;
}

.role-teacher [hidden].teacher-only,
.role-student [hidden].student-only,
[hidden] {
  display: none !important;
}

button.teacher-only,
a.teacher-only {
  display: none !important;
}

.role-student .student-only:not(.nav-tab) {
  display: revert !important;
}

.role-student .teacher-only {
  display: none !important;
}

.role-teacher .student-only {
  display: none !important;
}

[hidden] {
  display: none !important;
}

@media (max-width: 980px) {
  .login-view {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .login-card {
    justify-self: stretch;
  }

  .app-view {
    grid-template-columns: 1fr;
  }

  .side-nav {
    position: static;
    height: auto;
  }

  .side-nav nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .portal-main {
    padding: 1rem;
  }

  .dashboard-grid,
  .panel-grid,
  .materials-layout,
  .material-page-grid {
    grid-template-columns: 1fr;
  }

  .materials-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .choice-grid,
  .choice-grid.compact {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .login-view {
    padding: 1rem;
  }

  .login-brand h1 {
    font-size: 3rem;
  }

  .portal-topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .side-nav nav,
  .stats-grid,
  .materials-stats,
  .student-material-summary,
  .segmented-control,
  .choice-grid,
  .choice-grid.compact,
  .field-row {
    grid-template-columns: 1fr;
  }

  .portal-btn,
  .mini-btn {
    width: 100%;
  }

  .suspended-actions {
    flex-direction: column;
  }
}

/* ── Notifiche toast (conferma invio email, avvisi) ── */
[data-toast-host] {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-width: min(360px, calc(100vw - 2.5rem));
  pointer-events: none;
}

.toast {
  padding: 0.75rem 1rem;
  background: var(--deep);
  color: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 0.85rem;
  line-height: 1.5;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast-ok {
  border-left: 3px solid var(--green);
}

.toast-warn {
  border-left: 3px solid var(--gold);
}

.toast-info {
  border-left: 3px solid var(--blue);
}

@media (prefers-reduced-motion: reduce) {
  .toast {
    transition: none;
  }
}
