:root {
  --page: #f5f6fa;
  --surface: #ffffff;
  --surface-soft: #f8f9fc;
  --line: #e2e5ec;
  --line-strong: #cfd4de;
  --text: #202634;
  --muted: #727b8d;
  --accent: #5870d8;
  --accent-soft: #eef1ff;
  --red: #b8473e;
  --red-soft: #fff1f0;
  --orange: #9b650f;
  --orange-soft: #fff6e7;
  --hover: #fbfcff;
  --free-cell: #fcfcfd;
  --shadow-soft: rgba(24, 32, 52, .10);
  --modal-backdrop: rgba(28, 34, 48, .42);
  --radius: 12px;
  color-scheme: light;
}

html[data-resolved-theme="dark"] {
  --page: #11141a;
  --surface: #181c23;
  --surface-soft: #1f242d;
  --line: #2b323d;
  --line-strong: #3a4350;
  --text: #edf1f7;
  --muted: #9aa5b4;
  --accent: #8192ff;
  --accent-soft: #272d4e;
  --red: #e67870;
  --red-soft: #34201f;
  --orange: #e0aa54;
  --orange-soft: #33291c;
  --hover: #202630;
  --free-cell: #161a20;
  --shadow-soft: rgba(0, 0, 0, .28);
  --modal-backdrop: rgba(0, 0, 0, .62);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--page);
  color: var(--text);
}

body {
  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Arial,
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.app-shell {
  width: 100%;
  min-height: 100vh;
  background: var(--page);
}

/* Header */
.app-header {
  min-height: 58px;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.brand-button {
  padding: 2px 4px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.brand-button:hover {
  background: var(--surface-soft);
}

.brand strong {
  font-size: 19px;
  letter-spacing: -0.02em;
}

.header-subtitle {
  color: var(--muted);
  font-size: 11px;
}

.user-area {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-name {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

/* Login */
.login-panel {
  width: min(460px, calc(100% - 28px));
  margin: 44px auto;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}

.login-panel h1 {
  margin: 0 0 6px;
  font-size: 24px;
}

.login-intro {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 13px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 12px;
}

.form-field > span {
  font-size: 13px;
  font-weight: 650;
}

.form-field input,
.setting-row select {
  min-height: 38px;
  width: 100%;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  outline: none;
}

.form-field input:focus,
.setting-row select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.form-field small,
.security-note {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.manual-toggle,
.link-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
}

.manual-toggle {
  margin: -2px 0 12px;
  font-size: 12px;
}

.manual-fields {
  margin-bottom: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.primary-button {
  min-height: 38px;
  padding: 0 15px;
  border: 0;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-weight: 650;
}

.primary-button:disabled {
  opacity: .55;
}

.full-button {
  width: 100%;
}

.login-error {
  margin: 0 0 10px;
  padding: 10px;
  border: 1px solid #efc3bf;
  border-radius: 9px;
  background: var(--red-soft);
  color: #792d27;
  font-size: 12px;
}

.security-note {
  margin: 10px 0 0;
  text-align: center;
}

/* Main toolbar */
.toolbar {
  margin: 10px 12px 8px;
  padding: 7px;
  display: flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

.segmented {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border-radius: 10px;
  background: var(--surface-soft);
}

.segment {
  height: 31px;
  padding: 0 11px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.segment.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 3px var(--shadow-soft);
}

.date-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.square-button,
.text-button {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
}

.square-button {
  width: 34px;
  font-size: 19px;
}

.text-button {
  padding: 0 10px;
  font-size: 12px;
  font-weight: 600;
}

.settings-button {
  color: var(--accent);
}

.notice {
  margin: 8px 12px;
  padding: 9px 11px;
  border: 1px solid #e7d09d;
  border-radius: 10px;
  background: #fff9eb;
  font-size: 12px;
}

/* Schedule */
.schedule-frame {
  margin: 0 12px 12px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

.week-grid {
  display: grid;
  grid-template-columns: 56px repeat(5, minmax(0, 1fr));
  width: 100%;
  min-width: 700px;
}

.week-grid > * {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.week-grid > *:nth-child(6n) {
  border-right: 0;
}

.week-corner,
.day-column-header {
  height: 38px;
  background: var(--surface-soft);
}

.week-corner {
  display: flex;
  align-items: center;
  justify-content: center;
}

.day-column-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 3px;
}

.day-column-header strong {
  font-size: 11px;
}

.day-column-header span {
  color: var(--muted);
  font-size: 9px;
}

.time-cell {
  min-height: 50px;
  padding: 3px 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--surface-soft);
}

.time-cell strong {
  font-size: 10px;
}

.time-cell span {
  color: var(--muted);
  font-size: 8px;
}

.period-number {
  margin-bottom: 1px;
  color: var(--accent) !important;
  font-size: 8px !important;
  font-weight: 700;
}

.plan-cell {
  position: relative;
  min-height: 50px;
  padding: 2px;
  background: var(--surface);
}

.plan-cell.free {
  background: var(--free-cell);
}

.lesson {
  margin-bottom: 2px;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-left: 3px solid #758095;
  border-radius: 7px;
  background: var(--surface);
  line-height: 1.1;
}

.lesson:last-child {
  margin-bottom: 0;
}

.lesson.subject-color-0 { border-left-color: #5870d8; }
.lesson.subject-color-1 { border-left-color: #4d9072; }
.lesson.subject-color-2 { border-left-color: #b17a2e; }
.lesson.subject-color-3 { border-left-color: #8b67b4; }
.lesson.subject-color-4 { border-left-color: #b75d58; }
.lesson.subject-color-5 { border-left-color: #4c8b96; }
.lesson.subject-color-6 { border-left-color: #808548; }
.lesson.subject-color-7 { border-left-color: #8c6a54; }

.lesson.cancelled {
  border-color: #efc3bf;
  border-left-color: var(--red) !important;
  background: var(--red-soft);
  text-decoration: line-through;
}

.lesson.changed {
  border-color: #ead3a4;
  border-left-color: var(--orange) !important;
  background: var(--orange-soft);
}

.lesson-title {
  font-size: 10px;
  font-weight: 700;
}

.lesson-course {
  margin-top: 1px;
  color: var(--accent);
  font-size: 9px;
  font-weight: 650;
}

.lesson-meta {
  margin-top: 2px;
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 8px;
}

.lesson-status {
  display: inline-block;
  margin-top: 2px;
  font-size: 8px;
  font-weight: 700;
  text-transform: uppercase;
}

/* Merged double/triple lessons */
.plan-cell.single > .lesson:not(.merged) {
  min-height: 45px;
}

.lesson.merged {
  position: absolute;
  top: 2px;
  left: 2px;
  right: 2px;
  z-index: 5;
  margin: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.week-grid .lesson.merged-span-2 { height: 97px; }
.week-grid .lesson.merged-span-3 { height: 148px; }
.week-grid .lesson.merged-span-4 { height: 199px; }
.week-grid .lesson.merged-span-5 { height: 250px; }
.week-grid .lesson.merged-span-6 { height: 301px; }

.plan-cell.merged-covered {
  background: var(--surface);
}

/* Day view */
.day-grid {
  width: min(760px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 78px 1fr;
}

.day-grid > * {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.day-grid > *:nth-child(even) {
  border-right: 0;
}

.day-view-header {
  grid-column: 1 / -1;
  height: 40px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-soft);
}

.day-view-header strong {
  font-size: 14px;
}

.day-view-header span {
  color: var(--muted);
  font-size: 11px;
}

.day-grid .time-cell,
.day-grid .plan-cell {
  min-height: 54px;
}

.day-grid .lesson.merged-span-2 { height: 105px; }
.day-grid .lesson.merged-span-3 { height: 160px; }
.day-grid .lesson.merged-span-4 { height: 215px; }
.day-grid .lesson.merged-span-5 { height: 270px; }
.day-grid .lesson.merged-span-6 { height: 325px; }

/* Settings */
.settings-page {
  min-height: calc(100vh - 58px);
  padding: 12px;
  background: var(--page);
}

.settings-header {
  max-width: 900px;
  margin: 0 auto 10px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.settings-header h2 {
  margin: 0 0 2px;
  font-size: 21px;
}

.settings-header p,
.section-title-row p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.settings-section {
  max-width: 900px;
  margin: 0 auto 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

.section-title-row {
  margin-bottom: 10px;
}

.section-title-row h3 {
  margin: 0 0 2px;
  font-size: 15px;
}

.settings-tools {
  display: flex;
  gap: 7px;
  margin-bottom: 10px;
}

.settings-tools input {
  flex: 1;
  min-width: 0;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: var(--surface);
  outline: none;
}

.settings-tools input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

/* Only one chip per SUBJECT */
.course-index {
  position: sticky;
  top: 0;
  z-index: 9;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 0 10px;
  margin-bottom: 8px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.course-index-button {
  min-width: 42px;
  min-height: 31px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
}

.course-index-button:hover,
.course-index-button:focus {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  outline: none;
}

.course-groups {
  display: block;
}

.subject-group {
  margin-bottom: 12px;
  scroll-margin-top: 72px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.subject-group-header {
  position: sticky;
  top: 50px;
  z-index: 6;
  padding: 8px 10px;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--line);
}

.subject-group-header > div {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.subject-group-header strong {
  font-size: 13px;
}

.subject-group-header span {
  color: var(--muted);
  font-size: 10px;
}

.subject-course-list {
  display: block;
}

.course-option {
  min-height: 36px;
  padding: 5px 10px;
  display: flex;
  align-items: center;
  gap: 9px;
  border-bottom: 1px solid #edf0f4;
  cursor: pointer;
}

.course-option:last-child {
  border-bottom: 0;
}

.course-option:hover {
  background: var(--hover);
}

.course-option:has(input:checked) {
  background: var(--accent-soft);
}

.course-option input {
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
}

.course-option-text {
  min-width: 0;
  flex: 1;
}

.course-option-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.course-option strong {
  font-size: 12px;
}

.course-teacher {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.empty-course-result {
  padding: 16px;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
}

.compact-settings {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.setting-row {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.setting-row span {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.setting-row strong {
  font-size: 12px;
}

.setting-row small {
  color: var(--muted);
  font-size: 10px;
}

.setting-row select {
  min-width: 115px;
  min-height: 34px;
}

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

.account-settings > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.account-settings strong {
  font-size: 12px;
}

.account-settings small {
  color: var(--muted);
  font-size: 11px;
}

.danger-text-button {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid #efc3bf;
  border-radius: 9px;
  background: var(--surface);
  color: var(--red);
}

.settings-save {
  max-width: 900px;
  margin: 0 auto;
  padding: 3px 0 20px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
}

#saveStatus {
  color: var(--muted);
  font-size: 11px;
}

/* Onboarding */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  padding: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--modal-backdrop);
}

.modal {
  width: min(500px, 100%);
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 18px 50px rgba(25, 31, 46, .18);
}

.modal h2 {
  margin: 0 0 12px;
  font-size: 21px;
}

.modal p,
.onboarding-steps {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.onboarding-steps {
  padding-left: 20px;
}

.onboarding-steps li {
  margin-bottom: 6px;
}

.example-box {
  margin: 12px 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft);
  font-size: 11px;
}

.example-box code {
  display: block;
  margin-top: 5px;
  overflow-wrap: anywhere;
  color: var(--text);
}

/* iPad: whole week fits */
@media (min-width: 768px) and (max-width: 1180px) {
  .week-grid {
    min-width: 0;
    grid-template-columns: 52px repeat(5, minmax(0, 1fr));
  }

  .toolbar {
    margin-left: 8px;
    margin-right: 8px;
  }

  .schedule-frame {
    margin-left: 8px;
    margin-right: 8px;
  }

  .lesson {
    padding: 3px 4px;
  }

  .lesson-title {
    font-size: 9px;
  }

  .lesson-course {
    font-size: 8px;
  }

  .lesson-meta {
    font-size: 7px;
  }
}

@media (max-width: 767px) {
  .toolbar {
    flex-wrap: wrap;
    margin: 7px;
  }

  .date-controls {
    order: 3;
    width: 100%;
    margin-left: 0;
    justify-content: center;
  }

  .settings-button {
    margin-left: auto;
  }

  .schedule-frame {
    margin: 0 7px 8px;
  }

  .week-grid {
    min-width: 800px;
  }

  .settings-page {
    padding: 8px;
  }

  .compact-settings {
    grid-template-columns: 1fr;
  }

  .settings-tools {
    flex-direction: column;
  }

  .course-index {
    gap: 5px;
  }

  .course-option-title {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }

  .course-teacher {
    white-space: normal;
  }
}


/* Theme polish */
html[data-resolved-theme="dark"] input,
html[data-resolved-theme="dark"] select,
html[data-resolved-theme="dark"] button {
  color-scheme: dark;
}

html[data-resolved-theme="dark"] .example-box code {
  color: var(--text);
}

html[data-resolved-theme="dark"] .lesson,
html[data-resolved-theme="dark"] .subject-group,
html[data-resolved-theme="dark"] .settings-section,
html[data-resolved-theme="dark"] .login-panel,
html[data-resolved-theme="dark"] .toolbar,
html[data-resolved-theme="dark"] .schedule-frame,
html[data-resolved-theme="dark"] .modal {
  box-shadow: none;
}

html[data-resolved-theme="dark"] .course-option:has(input:checked) {
  background: var(--accent-soft);
}

html[data-resolved-theme="dark"] .notice {
  background: #332b19;
  border-color: #574923;
  color: #f3dfad;
}

html[data-resolved-theme="dark"] .login-error {
  color: #f3b8b3;
  border-color: #57302d;
}

html[data-resolved-theme="dark"] .danger-text-button {
  background: var(--surface);
  border-color: #57302d;
  color: #ef837b;
}


/* ===== Yountis 0.8 header ===== */
.app-header {
  height: 56px;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-button {
  padding: 5px 7px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.035em;
}

.brand-button:hover {
  background: var(--surface-soft);
}

.top-settings-button {
  width: 38px;
  height: 38px;
  padding: 9px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-soft);
  color: var(--muted);
}

.top-settings-button:hover {
  color: var(--text);
  border-color: var(--line-strong);
}

.top-settings-button svg {
  width: 19px;
  height: 19px;
  fill: currentColor;
}

/* No date below Yountis */
.header-subtitle,
.user-area {
  display: none !important;
}

/* ===== Settings rebuilt: no sticky headers, no blank gaps ===== */
.settings-page {
  min-height: calc(100vh - 56px);
  padding: 14px 12px 28px;
  background: var(--page);
}

.settings-shell {
  width: min(920px, 100%);
  margin: 0 auto;
}

.settings-header {
  max-width: none;
  margin: 0 0 11px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.settings-header h2 {
  margin: 0 0 2px;
  font-size: 22px;
  letter-spacing: -0.02em;
}

.settings-header p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.icon-close-button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--muted);
  font-size: 23px;
  line-height: 1;
}

.settings-card {
  margin: 0 0 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
}

.settings-card-heading {
  margin-bottom: 10px;
}

.settings-card h3 {
  margin: 0 0 2px;
  font-size: 15px;
}

.settings-card p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.settings-tools {
  margin-bottom: 10px;
}

.secondary-button {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-soft);
  color: var(--text);
  font-weight: 600;
}

/* Important fix: nothing in the course list is sticky anymore */
.course-index {
  position: static !important;
  top: auto !important;
  z-index: auto !important;
  margin: 0 0 10px;
  padding: 0 0 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  background: transparent;
  border-bottom: 1px solid var(--line);
}

.subject-group {
  margin: 0 0 8px;
  min-height: 0 !important;
  overflow: hidden;
  scroll-margin-top: 12px;
}

.subject-group-header {
  position: static !important;
  top: auto !important;
  z-index: auto !important;
  min-height: 0 !important;
  padding: 7px 10px;
}

.subject-course-list {
  display: block;
  min-height: 0 !important;
}

.course-option {
  min-height: 34px;
  padding: 5px 10px;
}

.course-groups {
  display: grid;
  gap: 0;
}

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

.setting-tile {
  padding: 11px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-soft);
}

.setting-label {
  font-size: 12px;
  font-weight: 700;
}

.setting-help {
  min-height: 26px;
  color: var(--muted);
  font-size: 10px;
}

.setting-tile select {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 0 8px;
}

.account-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logout-settings-button {
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid color-mix(in srgb, var(--red) 45%, var(--line));
  border-radius: 9px;
  background: var(--surface);
  color: var(--red);
  font-weight: 650;
}

.settings-footer {
  max-width: none;
  margin: 0;
  padding: 2px 0 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

/* ===== First-login course setup ===== */
.course-setup-modal {
  width: min(720px, 100%);
  padding: 0;
  overflow: hidden;
}

.setup-head {
  padding: 20px 20px 12px;
}

.setup-kicker {
  display: block;
  margin-bottom: 4px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.setup-head h2 {
  margin: 0 0 4px;
}

.setup-head p {
  margin: 0;
}

.setup-subject-tabs {
  padding: 9px 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.setup-subject-button {
  min-width: 42px;
  min-height: 31px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
}

.setup-subject-button:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.setup-course-groups {
  max-height: 52vh;
  overflow: auto;
  padding: 12px 20px;
}

.setup-subject-section {
  margin-bottom: 9px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 11px;
  scroll-margin-top: 10px;
}

.setup-subject-title {
  padding: 7px 9px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.setup-subject-title strong {
  font-size: 12px;
}

.setup-subject-title span {
  color: var(--muted);
  font-size: 10px;
}

.setup-course-row {
  min-height: 35px;
  padding: 5px 9px;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.setup-course-row:last-child {
  border-bottom: 0;
}

.setup-course-row:has(input:checked) {
  background: var(--accent-soft);
}

.setup-course-row input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.setup-course-name {
  font-size: 12px;
  font-weight: 650;
}

.setup-course-teacher {
  color: var(--muted);
  font-size: 10px;
}

.setup-footer {
  padding: 12px 20px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-top: 1px solid var(--line);
}

#setupSelectedCount {
  color: var(--muted);
  font-size: 11px;
}

@media (max-width: 767px) {
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .setup-course-row {
    grid-template-columns: 18px minmax(0, 1fr);
  }

  .setup-course-teacher {
    grid-column: 2;
  }

  .setup-footer {
    align-items: stretch;
    flex-direction: column;
  }
}


/* ============================================================
   YOUNTIS 0.9 – exact timetable geometry
   ============================================================ */

:root {
  --week-slot-height: 56px;
  --day-slot-height: 60px;
}

/* One normal lesson row has one exact fixed height. */
.week-grid .time-cell,
.week-grid .plan-cell.single,
.week-grid .plan-cell.free,
.week-grid .plan-cell.merged-covered {
  height: var(--week-slot-height);
  min-height: var(--week-slot-height);
}

.day-grid .time-cell,
.day-grid .plan-cell.single,
.day-grid .plan-cell.free,
.day-grid .plan-cell.merged-covered {
  height: var(--day-slot-height);
  min-height: var(--day-slot-height);
}

/* Rows with parallel lessons may grow; merge logic already avoids spanning them. */
.week-grid .plan-cell.multiple {
  min-height: var(--week-slot-height);
}

.day-grid .plan-cell.multiple {
  min-height: var(--day-slot-height);
}

/*
  top:2px + bottom:2px = 4px.
  Therefore a merged block is exactly N complete timetable rows high,
  minus the 4px internal inset.
*/
.week-grid .lesson.merged-span-2 { height: calc(var(--week-slot-height) * 2 - 4px); }
.week-grid .lesson.merged-span-3 { height: calc(var(--week-slot-height) * 3 - 4px); }
.week-grid .lesson.merged-span-4 { height: calc(var(--week-slot-height) * 4 - 4px); }
.week-grid .lesson.merged-span-5 { height: calc(var(--week-slot-height) * 5 - 4px); }
.week-grid .lesson.merged-span-6 { height: calc(var(--week-slot-height) * 6 - 4px); }

.day-grid .lesson.merged-span-2 { height: calc(var(--day-slot-height) * 2 - 4px); }
.day-grid .lesson.merged-span-3 { height: calc(var(--day-slot-height) * 3 - 4px); }
.day-grid .lesson.merged-span-4 { height: calc(var(--day-slot-height) * 4 - 4px); }
.day-grid .lesson.merged-span-5 { height: calc(var(--day-slot-height) * 5 - 4px); }
.day-grid .lesson.merged-span-6 { height: calc(var(--day-slot-height) * 6 - 4px); }

/* ============================================================
   SETTINGS: own screen, top-left back button
   ============================================================ */

.settings-back-button {
  min-height: 38px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}

.settings-back-button:hover {
  background: var(--surface-soft);
}

.settings-back-button > span:first-child {
  color: var(--accent);
  font-size: 19px;
  line-height: 1;
}

.settings-title {
  margin-bottom: 12px;
}

.settings-title h2 {
  margin: 0 0 2px;
  font-size: 22px;
  letter-spacing: -.02em;
}

.settings-title p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

/* Theme is the first setting and has only Hell / Dunkel. */
.appearance-card {
  padding: 12px 14px;
}

.compact-heading {
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.theme-switch {
  flex: 0 0 auto;
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border-radius: 11px;
  background: var(--surface-soft);
}

.theme-choice {
  min-width: 72px;
  min-height: 33px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.theme-choice.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .12);
}

/* Course editing is collapsed until the user explicitly opens it. */
.course-editor {
  padding: 0;
}

.course-editor-summary {
  min-height: 62px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  list-style: none;
  cursor: pointer;
  user-select: none;
}

.course-editor-summary::-webkit-details-marker {
  display: none;
}

.course-editor-summary > span:first-child {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.course-editor-summary strong {
  font-size: 14px;
}

.course-editor-summary small {
  color: var(--muted);
  font-size: 10px;
}

.summary-chevron {
  color: var(--muted);
  font-size: 18px;
  transition: transform .15s ease;
}

.course-editor[open] .summary-chevron {
  transform: rotate(180deg);
}

.course-editor-body {
  padding: 0 14px 14px;
  border-top: 1px solid var(--line);
}

.course-editor-body .settings-tools {
  margin-top: 12px;
}

/* Settings deliberately do not inherit timetable toolbar spacing. */
.settings-page + .toolbar,
.settings-page .toolbar {
  display: none !important;
}

/* ============================================================
   FIRST OPEN / LOGIN EXPLANATION
   ============================================================ */

.onboarding-steps strong {
  color: var(--text);
}

/* ============================================================
   MOBILE
   ============================================================ */

@media (max-width: 767px) {
  .compact-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .theme-switch {
    width: 100%;
  }

  .theme-choice {
    flex: 1;
  }
}
