:root {
  color-scheme: dark;
  --bg: #151617;
  --panel: #1c1d1f;
  --line: #2a2b2e;
  --text: #e9e7e1;
  --muted: #b5b1a6;
  --cell: #1a1b1d;
  --change: #5c3a3a;
  --holiday: #242526;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "IBM Plex Sans", "Noto Sans", sans-serif;
}

.page {
  max-width: 1320px;
  margin: 0 auto;
  padding: 24px;
}

.layout {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.page-title {
  font-size: 1.02rem;
  font-weight: 600;
}

.page-subtitle {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.9rem;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  background: #191a1c;
  color: var(--text);
  text-decoration: none;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 0.84rem;
  white-space: nowrap;
}

.back-link:hover {
  background: #1f2022;
}

.week-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.week-label {
  font-size: 0.86rem;
  color: var(--muted);
}

.week-button {
  border: 1px solid var(--line);
  background: #191a1c;
  color: var(--text);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.84rem;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease;
}

.week-button:hover,
.week-button:focus-visible,
.week-button.is-active {
  background: #232427;
  border-color: #3a3b3f;
  outline: none;
}

.homework-panel {
  border-bottom: 1px solid var(--line);
  padding: 14px 18px 18px;
}

.homework-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.homework-title {
  font-size: 0.94rem;
  font-weight: 600;
}

.homework-note {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.82rem;
}

.homework-toggle {
  border: 1px solid var(--line);
  background: #191a1c;
  color: var(--text);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.84rem;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease;
}

.homework-toggle:hover,
.homework-toggle:focus-visible {
  background: #232427;
  border-color: #3a3b3f;
  outline: none;
}

.homework-body {
  display: none;
  margin-top: 12px;
}

.homework-panel.is-open .homework-body {
  display: block;
}

.homework-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.homework-field {
  display: grid;
  gap: 6px;
}

.homework-label {
  font-size: 0.82rem;
  color: var(--muted);
}

.homework-input,
.homework-select {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #151618;
  color: var(--text);
  padding: 7px 9px;
  font-size: 0.88rem;
}

.homework-input:focus,
.homework-select:focus {
  outline: 2px solid #3b3c40;
  outline-offset: 1px;
}

.homework-actions {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.homework-button {
  border: 1px solid var(--line);
  background: #222326;
  color: var(--text);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease;
}

.homework-button.secondary {
  background: #1b1c1f;
}

.homework-button:hover,
.homework-button:focus-visible {
  background: #2a2b2f;
  border-color: #3a3b3f;
  outline: none;
}

.is-hidden {
  display: none;
}

.homework-error {
  margin-top: 8px;
  min-height: 18px;
  color: #e4a4a4;
  font-size: 0.82rem;
}

.auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(12, 12, 12, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 10;
}

.auth-panel {
  width: min(420px, 100%);
  background: #1b1c1e;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}

.auth-title {
  font-size: 1rem;
  font-weight: 600;
}

.auth-form {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.auth-label {
  font-size: 0.84rem;
  color: var(--muted);
}

.auth-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #151618;
  color: var(--text);
  padding: 8px 10px;
  font-size: 0.9rem;
}

.auth-input:focus {
  outline: 2px solid #3b3c40;
  outline-offset: 1px;
}

.auth-error {
  min-height: 18px;
  color: #e4a4a4;
  font-size: 0.82rem;
}

.auth-submit {
  border: 1px solid var(--line);
  background: #222326;
  color: var(--text);
  border-radius: 6px;
  padding: 9px 12px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease;
}

.auth-submit:hover,
.auth-submit:focus-visible {
  background: #2a2b2f;
  border-color: #3a3b3f;
  outline: none;
}

.nav-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 16px 18px 20px;
}

.nav-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #1a1b1e;
  color: var(--text);
  padding: 16px;
  text-align: left;
  cursor: pointer;
  min-height: 120px;
  transition: background 0.16s ease, border-color 0.16s ease;
}

.nav-card:hover,
.nav-card:focus-visible {
  background: #202124;
  border-color: #3a3b3f;
  outline: none;
}

.nav-title {
  font-size: 1rem;
  font-weight: 600;
}

.nav-note {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.placeholder-layout {
  max-width: 900px;
}

.placeholder-content {
  padding: 28px 16px;
  color: var(--muted);
}

.marks-overall {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px 0;
}

.marks-overall-label {
  color: var(--muted);
  font-size: 0.86rem;
}

.marks-overall-value {
  font-size: 1.1rem;
  font-weight: 700;
}

.marks-overall-value.is-predicted {
  color: #e4d6c2;
}

.predictor-panel {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 14px 18px 18px;
}

.predictor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.predictor-title {
  font-size: 0.94rem;
  font-weight: 600;
}

.predictor-note {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.82rem;
}

.predictor-toggle {
  border: 1px solid var(--line);
  background: #191a1c;
  color: var(--text);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.84rem;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease;
}

.predictor-toggle:hover,
.predictor-toggle:focus-visible {
  background: #232427;
  border-color: #3a3b3f;
  outline: none;
}

.predictor-body {
  display: none;
  margin-top: 12px;
}

.predictor-panel.is-open .predictor-body {
  display: block;
}

.predictor-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.predictor-field {
  display: grid;
  gap: 6px;
}

.predictor-label {
  font-size: 0.82rem;
  color: var(--muted);
}

.predictor-input,
.predictor-select {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #151618;
  color: var(--text);
  padding: 7px 9px;
  font-size: 0.88rem;
}

.predictor-input:focus,
.predictor-select:focus {
  outline: 2px solid #3b3c40;
  outline-offset: 1px;
}

.predictor-actions {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.predictor-button {
  border: 1px solid var(--line);
  background: #222326;
  color: var(--text);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease;
}

.predictor-button.secondary {
  background: #1b1c1f;
}

.predictor-button:hover,
.predictor-button:focus-visible {
  background: #2a2b2f;
  border-color: #3a3b3f;
  outline: none;
}

.predictor-error {
  margin-top: 8px;
  min-height: 18px;
  color: #e4a4a4;
  font-size: 0.82rem;
}

.predictor-list {
  margin-top: 8px;
  display: grid;
  gap: 6px;
}

.predictor-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #191a1c;
  font-size: 0.82rem;
}

.predictor-item-label {
  color: var(--text);
}

.predictor-item-actions {
  display: flex;
  gap: 6px;
}

.predictor-action {
  border: 1px solid var(--line);
  background: #1a1b1d;
  color: var(--muted);
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 0.68rem;
  cursor: pointer;
}

.predictor-action:hover,
.predictor-action:focus-visible {
  background: #232427;
  color: var(--text);
  outline: none;
}


.marks-table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
}

.compact-marks-table {
  min-width: 980px;
}

.marks-table th,
.marks-table td {
  border: 1px solid var(--line);
  vertical-align: top;
}

.marks-table th {
  background: #191a1c;
  padding: 8px;
  text-align: left;
  font-weight: 600;
}

.marks-table td {
  background: var(--cell);
  padding: 8px;
}

.compact-marks-table th,
.compact-marks-table td {
  padding: 5px 6px;
  font-size: 0.8rem;
}

.marks-subject-cell {
  width: 180px;
  min-width: 180px;
}

.marks-subject-title {
  font-weight: 700;
}

.marks-subject-note {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.8rem;
}

.marks-average-cell,
.marks-report-cell {
  width: 84px;
  min-width: 84px;
}

.marks-average-cell {
  width: 72px;
  min-width: 72px;
}

.marks-report-cell {
  text-align: center;
}

.marks-report-cell.is-predicted,
.marks-average-cell.is-predicted {
  color: #e4d6c2;
}

.report-grade {
  display: block;
  font-weight: 700;
  font-size: 0.95rem;
}

.report-hint {
  color: var(--muted);
  font-size: 0.68rem;
}

.severity-orange {
  background: #5a4823 !important;
}

.severity-red {
  background: #5a2c2c !important;
}

.severity-ok {
  background: #24282b !important;
}

.marks-temp-note {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.8rem;
}

.marks-list-cell {
  min-width: 560px;
}

.marks-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mark-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  width: auto;
  min-width: 46px;
  border: 1px solid #303134;
  background: #1f2023;
  border-radius: 6px;
  padding: 1px 4px 1px 3px;
  font-weight: 600;
  font-size: 0.72rem;
  line-height: 1.2;
}

.mark-chip.is-new {
  border-color: #5b5a52;
  box-shadow: 0 0 0 1px rgba(91, 90, 82, 0.2) inset;
}

.mark-chip.is-predicted {
  border-color: #6a5840;
  background: #262320;
}

.compact-marks-list {
  gap: 4px;
}

.chip-grade {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 18px;
  border-radius: 4px;
  background: #2e2f32;
  color: #f0ede5;
  font-weight: 700;
  font-size: 0.72rem;
}

.chip-weight {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 14px;
  border-radius: 4px;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: #242527;
  color: var(--muted);
}

.grade-1 {
  background: #2f5c3a;
  color: #e7f2ea;
}

.grade-2 {
  background: #6f6026;
  color: #f3edcf;
}

.grade-3 {
  background: #6a4b2a;
  color: #f2e3d1;
}

.grade-4 {
  background: #6a2f2f;
  color: #f3d6d6;
}

.grade-5 {
  background: #4a2020;
  color: #f0d5d5;
}

.grade-unknown {
  background: #2e2f32;
  color: var(--muted);
}

.marks-empty {
  color: var(--muted);
  font-size: 0.84rem;
}

.table-wrap {
  overflow-x: auto;
  padding: 10px;
}

.timetable {
  width: 100%;
  min-width: 1080px;
  border-collapse: collapse;
  table-layout: fixed;
}

.timetable th,
.timetable td {
  border: 1px solid var(--line);
  vertical-align: top;
}

.timetable th {
  background: #191a1c;
  padding: 8px;
  text-align: left;
  font-weight: 600;
}

.day-col-header {
  width: 100px;
  min-width: 100px;
}

.h-num {
  font-size: 0.86rem;
}

.h-time {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.75rem;
}

.timetable td {
  background: var(--cell);
  height: 140px;
  padding: 6px;
}

.day-cell {
  width: 100px;
  min-width: 100px;
  background: #171a1f;
}

.day-name {
  font-weight: 600;
  font-size: 0.86rem;
}

.day-note {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.75rem;
}

.cell-title {
  font-weight: 700;
  font-size: 0.95rem;
}

.cell-content {
  position: relative;
  height: 126px;
  overflow: visible;
  padding-bottom: 20px;
}

.cell-subject {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
}

.cell-theme {
  margin-top: 6px;
  font-size: 0.78rem;
  line-height: 1.25;
  overflow: hidden;
  display: -webkit-box;
  line-clamp: 3;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  word-break: break-word;
}

.cell-room,
.cell-teacher {
  position: absolute;
  bottom: 0;
  color: var(--muted);
  font-size: 0.74rem;
}

.cell-room {
  left: 0;
}

.cell-teacher {
  right: 0;
}

.cell-note {
  margin-top: 6px;
  font-size: 0.78rem;
  color: var(--muted);
}

.homework-present {
  box-shadow: inset 0 0 0 1px var(--change);
}

.homework-indicator {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 30;
}

.homework-icon {
  border: 1px solid var(--line);
  background: var(--change);
  color: #f2dede;
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
}

.homework-icon:hover,
.homework-icon:focus-visible {
  background: #6a3a3a;
  outline: none;
}

.homework-menu {
  display: none;
  position: absolute;
  top: 22px;
  right: 0;
  min-width: 64px;
  background: #1b1c1e;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px;
  z-index: 40;
}

.homework-indicator.is-open .homework-menu {
  display: grid;
  gap: 6px;
}

.homework-item {
  display: grid;
  gap: 6px;
}

.homework-text {
  color: var(--text);
  font-size: 0.76rem;
}

.homework-item-actions {
  display: flex;
  gap: 6px;
}

.homework-action {
  border: 1px solid var(--line);
  background: #1a1b1d;
  color: var(--muted);
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 0.68rem;
  cursor: pointer;
}

.homework-action:hover,
.homework-action:focus-visible {
  background: #232427;
  color: var(--text);
  outline: none;
}

td.empty {
  background: #17181a;
}

td.canceled-empty {
  background: var(--change);
}

td.change {
  background: var(--change);
}

td.holiday {
  background: var(--holiday);
}

.holiday-label {
  height: 100%;
  min-height: 106px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 600;
  color: #e6e2d8;
  padding: 6px;
  overflow: hidden;
}

.holiday-span-cell {
  background: var(--holiday);
  padding: 0;
}

.holiday-row-label {
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 700;
  color: #e6e2d8;
  padding: 8px 14px;
}

.state {
  padding: 24px;
  color: var(--muted);
}

.state.error {
  color: #e4a4a4;
}

@media (max-width: 900px) {
  .page {
    padding: 10px;
  }

  .section-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .back-link {
    width: 100%;
  }

  .nav-list {
    grid-template-columns: 1fr;
    padding: 12px 14px 16px;
  }

  .week-controls {
    width: 100%;
    justify-content: flex-start;
  }

  .homework-form {
    grid-template-columns: 1fr;
  }

  .homework-actions {
    justify-content: flex-start;
  }

  .marks-overall {
    padding: 10px 12px 0;
  }

  .predictor-form {
    grid-template-columns: 1fr;
  }

  .marks-table {
    min-width: 680px;
  }

  .marks-subject-cell {
    min-width: 150px;
  }

  .marks-list-cell {
    min-width: 320px;
  }

  .mark-chip {
    font-size: 0.7rem;
  }

  .table-wrap {
    padding: 6px;
  }

  .timetable td {
    height: 150px;
  }
}
