/* =====================================================================
   Хичээлийн үнэлгээ — "Warm Paper" theme
   Calm, low-glare, WCAG AA. Every text colour below is ≥ 4.5:1 on the
   backgrounds it is used on. Nothing is pure white or pure black.
   ===================================================================== */

:root {
  --bg: #f5f1ea;
  --surface: #fbf9f5;
  --surface-sunken: #efe9df;
  --text: #2a2723;
  --text-secondary: #5c554c;
  --text-muted: #6f675c;
  --border: #e2dbcf;
  --border-control: #8a7f6f;

  --accent: #2f6f6a;
  --accent-hover: #255954;
  --accent-soft: #e3eeeb;
  --accent-ink: #1f4f4b;

  --good: #356b40;
  --good-soft: #e6efe3;
  --mid: #7a5717;
  --mid-soft: #f5ead3;
  --bad: #9a3f35;
  --bad-soft: #f6e3de;
  --star: #9c6a14;

  --radius-control: 10px;
  --radius-card: 14px;
  --radius-modal: 18px;
  --radius-chip: 8px;

  --focus: 0 0 0 3px var(--surface), 0 0 0 5px var(--accent);
  --shadow-modal: 0 20px 40px -16px rgba(60, 45, 30, 0.22), 0 2px 6px rgba(60, 45, 30, 0.06);
  --transition: 0.18s ease;

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC",
    "Noto Sans SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.65;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  padding-top: calc(64px + env(safe-area-inset-top));
  overflow-x: hidden;
}

body.modal-open { overflow: hidden; }

h1, h2, h3, h4 { line-height: 1.3; font-weight: 700; }

.icon { display: inline-block; vertical-align: -0.15em; flex-shrink: 0; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: 16px; top: -60px; z-index: 2000;
  background: var(--accent); color: #fff; padding: 10px 16px; border-radius: var(--radius-control);
  font-weight: 600; text-decoration: none;
}
.skip-link:focus { top: 12px; }

:focus { outline: none; }
:focus-visible { box-shadow: var(--focus); border-radius: var(--radius-control); }

a { color: var(--accent); }

/* ===== Navigation ===== */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}
.nav-inner {
  max-width: 1120px; margin: 0 auto; height: 64px; padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.nav-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--accent); color: #fff; flex-shrink: 0;
}
.brand-text {
  font-weight: 700; font-size: 17px; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.badge {
  font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 2px 8px; border-radius: 6px;
  border: 1px solid var(--border-control); color: var(--text-secondary);
  flex-shrink: 0;
}
.user-area { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.user-info { display: none; align-items: center; gap: 10px; }
.user-name { font-weight: 600; white-space: nowrap; }
.user-role { color: var(--text-secondary); font-size: 15px; white-space: nowrap; }
.user-role:not(:empty)::before { content: "·"; margin-right: 8px; color: var(--text-muted); }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 18px;
  border: 1px solid transparent; border-radius: var(--radius-control);
  font: 600 16px/1.2 var(--font);
  cursor: pointer; text-decoration: none;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
  background: var(--surface); color: var(--text);
}
.btn-sm { min-height: 40px; padding: 8px 14px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); border-color: var(--border-control); color: var(--text); }
.btn-secondary:hover { background: var(--surface-sunken); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--surface-sunken); color: var(--text); }
.btn-ghost-danger { background: transparent; color: var(--bad); }
.btn-ghost-danger:hover { background: var(--bad-soft); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.login-label-short { display: none; }

.btn-spinner, .spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin 0.7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Page header ===== */
.container { max-width: 1120px; margin: 0 auto; padding: 40px 24px 80px; }
.page-head { margin-bottom: 24px; }
.eyebrow { font-size: 15px; font-weight: 600; color: var(--accent-ink); margin-bottom: 6px; }
.page-head h1 { font-size: 32px; letter-spacing: -0.01em; }
.page-sub { color: var(--text-secondary); margin-top: 4px; }

.search-box { position: relative; margin-bottom: 20px; }
.search-icon {
  position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); display: inline-flex; pointer-events: none;
}
.search-box input[type="search"] {
  width: 100%; min-height: 52px; padding: 12px 16px 12px 48px;
  font: 400 16px var(--font); color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-control); border-radius: 12px;
  transition: border-color var(--transition);
}
.search-box input::placeholder { color: var(--text-muted); }
.search-box input:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.category-filter { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.cat-btn {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 40px; padding: 8px 14px; border-radius: var(--radius-control);
  border: 1px solid var(--border-control); background: var(--surface); color: var(--text);
  font: 500 15px var(--font); cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}
.cat-btn:hover { background: var(--surface-sunken); }
.cat-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.cat-count { font-size: 14px; color: var(--text-muted); font-weight: 500; }
.cat-btn[aria-pressed="true"] .cat-count { color: #d7ebe7; }
/* 通识课 + 1 2 3 4 as one joined control */
.cat-group { display: inline-flex; flex-shrink: 0; }
.cat-group .cat-btn { border-radius: 0; margin-left: -1px; }
.cat-group .cat-btn:first-child { border-radius: var(--radius-control) 0 0 var(--radius-control); margin-left: 0; }
.cat-group .cat-btn:last-child { border-radius: 0 var(--radius-control) var(--radius-control) 0; }
.cat-num { min-width: 40px; justify-content: center; padding: 8px 0; font-weight: 600; color: var(--text-secondary); }
.cat-btn[aria-pressed="true"] { position: relative; z-index: 1; }
.cat-main.cat-parent { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); position: relative; z-index: 1; }
.cat-main.cat-parent .cat-count { color: var(--accent-ink); }
@media (max-width: 640px) {
  .category-filter { flex-wrap: nowrap; overflow-x: auto; margin-right: -16px; padding-right: 16px; scrollbar-width: none; }
  .category-filter::-webkit-scrollbar { display: none; }
  .cat-btn { flex-shrink: 0; }
}
.teacher-filter { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.teacher-filter[hidden] { display: none; }
.teacher-filter .cat-btn { min-height: 38px; padding: 6px 12px; }
.teacher-filter .cat-btn .icon { color: currentColor; opacity: 0.8; }
.review-teacher {
  display: inline-flex; align-items: center; gap: 5px; margin-top: 2px;
  font-size: 14px; font-weight: 600; color: var(--accent-ink);
}
#teacherField[hidden] { display: none; }
.list-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 16px;
}
.list-count { color: var(--text-secondary); font-size: 15px; }

/* ===== Course grid ===== */
.course-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px;
}
.course-grid:focus { box-shadow: none; }
.course-card {
  display: flex; flex-direction: column; gap: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card);
  padding: 20px 22px; color: inherit; text-decoration: none;
  transition: border-color var(--transition), background var(--transition);
}
.course-card:hover { border-color: var(--accent); background: #f8f4ec; }
.course-card:focus-visible { border-radius: var(--radius-card); border-color: var(--accent); }
.card-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-height: 28px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 14px; font-weight: 500; line-height: 1.2;
  padding: 4px 10px; border-radius: var(--radius-chip);
  background: var(--surface-sunken); color: var(--text-secondary);
}
.chip-good { background: var(--good-soft); color: var(--good); }
.chip-core { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.chip-gender { background: var(--mid-soft); color: var(--mid); font-weight: 600; }
.teacher-note { font-size: 14px; font-weight: 600; color: var(--mid); background: var(--mid-soft); padding: 1px 6px; border-radius: 6px; }
.cat-btn[aria-pressed="true"] .teacher-note { background: rgba(255,255,255,0.2); color: #fff; }
#coreField[hidden] { display: none; }
.course-name { font-size: 18px; font-weight: 600; line-height: 1.4; color: var(--text); }
.course-meta {
  color: var(--text-secondary); font-size: 15px;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.course-facts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; font-size: 15px; color: var(--text-secondary); }
.fact { display: inline-flex; align-items: center; gap: 5px; }
.fact .icon { color: var(--text-muted); }
.fact-credits {
  font-weight: 600; color: var(--accent-ink); background: var(--accent-soft);
  padding: 2px 9px; border-radius: var(--radius-chip);
}
.fact-credits .icon { color: var(--accent); }
.modal-header .course-facts { margin-top: 6px; }
.course-card-bottom {
  display: flex; align-items: center; gap: 10px;
  margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border);
}
.course-rating { display: flex; align-items: baseline; gap: 6px; color: var(--text-secondary); font-size: 15px; min-width: 0; }
.course-rating .rating-star { color: var(--star); display: inline-flex; align-self: center; }
.course-rating .rating-score { font-size: 20px; font-weight: 700; color: var(--text); }
.course-rating.empty { flex-direction: column; align-items: flex-start; gap: 0; font-size: 14px; color: var(--text-muted); }
.course-rating .first-review { color: var(--accent); font-weight: 600; }
.credits { margin-left: auto; color: var(--text-secondary); font-size: 15px; white-space: nowrap; }
.card-arrow { margin-left: auto; display: inline-flex; color: var(--text-muted); transition: transform var(--transition), color var(--transition); }
.course-card:hover .card-arrow { color: var(--accent); transform: translateX(2px); }

/* ===== Modals ===== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1100;
  background: rgba(42, 39, 35, 0.45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 48px 24px;
  opacity: 0; visibility: hidden;
  transition: opacity var(--transition), visibility var(--transition);
}
.modal-overlay.active { opacity: 1; visibility: visible; }
#loginModalOverlay, #addCourseOverlay { z-index: 1200; align-items: center; }

.modal {
  position: relative; width: 100%; max-width: 760px;
  max-height: calc(100vh - 96px); max-height: calc(100dvh - 96px);
  display: flex; flex-direction: column;
  background: var(--surface); border-radius: var(--radius-modal);
  box-shadow: var(--shadow-modal);
  transform: translateY(12px); transition: transform 0.22s ease;
}
.modal-overlay.active .modal { transform: none; }
.small-modal { max-width: 460px; }

.modal-header {
  flex-shrink: 0;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 22px 24px 18px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  border-radius: var(--radius-modal) var(--radius-modal) 0 0;
}
.modal-heading { min-width: 0; }
.modal-header h2 { font-size: 24px; word-break: break-word; }
.modal-header .sub { color: var(--text-secondary); font-size: 15px; margin-top: 2px; }
.modal-header-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.close-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; flex-shrink: 0;
  border: 1px solid var(--border-control); border-radius: var(--radius-control);
  background: var(--surface); color: var(--text); cursor: pointer;
}
.close-btn:hover { background: var(--surface-sunken); }
.modal-body { padding: 24px; overflow-y: auto; overscroll-behavior: contain; border-radius: 0 0 var(--radius-modal) var(--radius-modal); }

/* ===== Summary tiles ===== */
.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 28px; }
.summary[hidden] { display: none; }
.stat {
  background: var(--surface-sunken); border-radius: 12px; padding: 14px 16px;
  display: flex; flex-direction: column; gap: 4px;
}
.stat-label { font-size: 14px; font-weight: 600; color: var(--text-secondary); }
.stat-value { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stat-num { font-size: 24px; font-weight: 700; color: var(--text); }
.stat-bar { height: 6px; border-radius: 3px; background: #ddd5c7; overflow: hidden; margin-top: 6px; }
.stat-bar span { display: block; height: 100%; border-radius: 3px; }
.stat-bar .tone-good { background: var(--good); }
.stat-bar .tone-mid { background: var(--mid); }
.stat-bar .tone-bad { background: var(--bad); }

/* ===== Section headings ===== */
.section-heading {
  display: flex; align-items: center; gap: 8px;
  font-size: 18px; font-weight: 600; margin-bottom: 14px; color: var(--text);
}
.section-heading .icon { color: var(--accent); }
.section-count { color: var(--text-muted); font-weight: 500; }

/* ===== Reviews =====
   The student's own words are the point of a review, so each one is its own
   card with the comment set large; scores and exam details sit below it. */
.review-list { display: flex; flex-direction: column; gap: 14px; }
.review-item {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card);
  padding: 20px 22px;
}
.review-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.review-author { display: flex; align-items: center; gap: 12px; min-width: 0; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent-ink); font-weight: 700; font-size: 17px;
}
.review-author .name { font-weight: 600; }
.review-author .date { color: var(--text-secondary); font-size: 14px; display: flex; flex-wrap: wrap; gap: 0 8px; }
.review-author .taken-term::after { content: " ·"; }

.comment {
  font-size: 17px; line-height: 1.75; color: var(--text);
  max-width: 68ch; white-space: pre-wrap; word-break: break-word;
  border-left: 3px solid var(--accent); padding: 2px 0 2px 16px; margin: 0 0 16px;
}

.scores { display: flex; flex-wrap: wrap; gap: 6px; }
.verdict {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 14px; font-weight: 500; line-height: 1.2;
  padding: 4px 9px; border-radius: var(--radius-chip);
}
.verdict-good { background: var(--good-soft); color: var(--good); }
.verdict-mid { background: var(--mid-soft); color: var(--mid); }
.verdict-bad { background: var(--bad-soft); color: var(--bad); }
.verdict-sym { font-size: 11px; }
.verdict-score {
  margin-left: 4px; padding-left: 8px; border-left: 1px solid currentColor;
  font-weight: 700; font-variant-numeric: tabular-nums;
}
.verdict-score small { font-size: 12px; font-weight: 500; opacity: 0.85; }
.scores .verdict { padding: 5px 10px; }

/* Each reviewer's own points — as prominent as their comment */
.review-scores { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.score-tile {
  display: flex; flex-direction: column; gap: 2px;
  border-radius: 12px; padding: 12px 14px; background: var(--surface-sunken);
}
.score-label { font-size: 14px; font-weight: 600; color: var(--text-secondary); }
.score-num { font-size: 26px; font-weight: 700; line-height: 1.2; color: var(--text); font-variant-numeric: tabular-nums; }
.score-num small { font-size: 15px; font-weight: 500; color: var(--text-secondary); margin-left: 1px; }
.score-verdict { display: inline-flex; align-items: center; gap: 5px; font-size: 14px; font-weight: 600; }
.score-tile.tone-good { background: var(--good-soft); }
.score-tile.tone-good .score-verdict { color: var(--good); }
.score-tile.tone-mid { background: var(--mid-soft); }
.score-tile.tone-mid .score-verdict { color: var(--mid); }
.score-tile.tone-bad { background: var(--bad-soft); }
.score-tile.tone-bad .score-verdict { color: var(--bad); }
.score-none .score-num, .score-none .score-verdict { color: var(--text-muted); font-weight: 500; }

.info-details { margin-top: 12px; }
.info-details summary {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px;
  cursor: pointer; list-style: none; font-size: 15px; font-weight: 600; color: var(--text-secondary);
  border-radius: var(--radius-control); padding: 0 4px; margin-left: -4px;
}
.info-details summary::-webkit-details-marker { display: none; }
.info-details summary:hover { color: var(--text); }
.info-details summary .icon { transition: transform var(--transition); }
.info-details[open] summary .icon { transform: rotate(90deg); }
.info-count { color: var(--text-muted); font-weight: 500; }
.info-block {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 20px;
  background: var(--surface-sunken); border-radius: var(--radius-control);
  padding: 14px 16px; margin-top: 6px;
}
.info-label { font-size: 14px; color: var(--text-muted); }
.info-value { font-size: 15px; color: var(--text); word-break: break-word; }
.info-item.wide { grid-column: 1 / -1; }
.actions { display: flex; justify-content: flex-end; gap: 4px; margin-top: 10px; border-top: 1px solid var(--border); padding-top: 8px; }

/* ===== Write section ===== */
.write-section { margin-top: 28px; scroll-margin-top: 16px; }
.login-prompt {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  background: var(--accent-soft); border-radius: 12px; padding: 18px 20px;
}
.login-prompt-title { font-weight: 600; color: var(--accent-ink); }
.login-prompt-sub { font-size: 15px; color: var(--accent-ink); }
.thin-notice {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--mid-soft); color: var(--mid); border-radius: 12px;
  padding: 14px 16px; margin-bottom: 16px; font-size: 15px;
}
.thin-notice .icon { margin-top: 3px; }

.review-form {
  background: var(--surface-sunken); border-radius: var(--radius-card); padding: 24px;
}
.form-title { display: flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 600; }
.form-title .icon { color: var(--accent); }
.form-hint { color: var(--text-secondary); font-size: 15px; margin: 2px 0 20px; }

/* Score: 0–10 buttons (desktop) / big slider (phone) */
.score-field { border: none; margin-bottom: 20px; min-width: 0; }
.score-field legend { font-weight: 600; margin-bottom: 8px; }
.score-seg {
  display: grid; grid-template-columns: repeat(11, 1fr);
  border: 1px solid var(--border-control); border-radius: var(--radius-control);
  overflow: hidden; background: var(--surface);
}
.score-seg button {
  min-height: 44px; border: none; border-left: 1px solid var(--border);
  background: transparent; color: var(--text); cursor: pointer;
  font: 600 16px var(--font);
  transition: background var(--transition), color var(--transition);
}
.score-seg button:first-child { border-left: none; }
.score-seg button:hover { background: var(--accent-soft); }
.score-seg button[aria-checked="true"] { background: var(--accent); color: #fff; }
.score-seg button:focus-visible { box-shadow: inset 0 0 0 3px var(--accent-ink); border-radius: 0; position: relative; }
.score-seg button[aria-checked="true"]:focus-visible { box-shadow: inset 0 0 0 3px var(--surface); }
.score-ends { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; color: var(--text-muted); margin-top: 6px; }

.slider-row { display: none; align-items: center; gap: 14px; }
.score-slider {
  -webkit-appearance: none; appearance: none; flex: 1; height: 8px; border-radius: 4px;
  background: #ddd5c7; cursor: pointer;
}
.score-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 28px; height: 28px; border-radius: 50%;
  background: var(--surface); border: 3px solid var(--accent); box-shadow: 0 1px 3px rgba(60, 45, 30, 0.25);
}
.score-slider::-moz-range-thumb {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--surface); border: 3px solid var(--accent);
}
.score-slider:focus-visible { box-shadow: var(--focus); border-radius: 4px; }
.slider-value {
  min-width: 48px; height: 44px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-control); background: var(--accent); color: #fff;
  font-size: 20px; font-weight: 700;
}

/* Generic form controls */
.form-group { margin-bottom: 18px; }
.form-group label, .details-group-title { display: block; font-weight: 600; margin-bottom: 6px; }
.optional { font-size: 14px; font-weight: 400; color: var(--text-muted); margin-left: 4px; }
.field-help { display: block; font-size: 14px; color: var(--text-muted); margin-top: 6px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

input[type="text"], input[type="number"], input[type="search"], select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px;
  font: 400 16px/1.5 var(--font); color: var(--text);
  background: var(--surface); border: 1px solid var(--border-control); border-radius: var(--radius-control);
  transition: border-color var(--transition);
}
textarea { resize: vertical; min-height: 110px; }
select {
  -webkit-appearance: none; appearance: none; padding-right: 40px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%235c554c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
input::placeholder, textarea::placeholder { color: var(--text-muted); }
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); border-radius: var(--radius-control); }

.checkbox-group { display: flex; align-items: center; gap: 10px; min-height: 44px; margin-bottom: 8px; }
.checkbox-group input { width: 22px; height: 22px; accent-color: var(--accent); cursor: pointer; }
.checkbox-group label { cursor: pointer; }

.email-field {
  display: flex; align-items: stretch;
  border: 1px solid var(--border-control); border-radius: var(--radius-control);
  background: var(--surface); overflow: hidden;
}
.email-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.email-field input { border: none; border-radius: 0; flex: 1; min-width: 0; }
.email-field input:focus-visible { box-shadow: none; }
.email-suffix {
  display: inline-flex; align-items: center; padding: 0 12px;
  background: var(--surface-sunken); color: var(--text-secondary); font-size: 15px;
  border-left: 1px solid var(--border);
}
.first-login-note {
  background: var(--accent-soft); color: var(--accent-ink); border-radius: var(--radius-control);
  padding: 12px 14px; margin-bottom: 16px; font-size: 15px;
}
.login-note { text-align: center; margin-top: 12px; font-size: 15px; color: var(--text-secondary); }
.login-note a { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; min-height: 44px; }

/* Optional details disclosure */
.details-toggle {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 52px; margin-top: 8px; padding: 0 4px;
  background: transparent; border: none; border-top: 1px solid #ddd5c7;
  font: 600 16px var(--font); color: var(--text); cursor: pointer; text-align: left;
}
.details-toggle-main { display: inline-flex; align-items: center; gap: 8px; }
.details-toggle .chevron { transform: rotate(-90deg); transition: transform var(--transition); color: var(--text-secondary); }
.details-toggle.open .chevron { transform: none; }
.details-panel { display: none; padding-top: 8px; }
.details-panel.open { display: block; }
.details-group { margin-bottom: 20px; }
.details-group-title { color: var(--text-secondary); font-size: 15px; }

.toggle-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-control); margin-bottom: 8px; }
.toggle-item.on { border-color: var(--accent); }
.toggle-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 52px; padding: 0 14px; cursor: pointer;
}
.toggle-name { font-weight: 600; }
.switch { display: inline-flex; align-items: center; gap: 10px; position: relative; }
.switch-caption { font-size: 15px; color: var(--text-secondary); min-width: 1.5em; text-align: right; }
.switch input { position: absolute; opacity: 0; width: 46px; height: 28px; right: 0; margin: 0; cursor: pointer; }
.switch-track {
  width: 46px; height: 28px; border-radius: 14px; position: relative;
  background: var(--surface-sunken); border: 1.5px solid var(--border-control);
  transition: background var(--transition), border-color var(--transition);
}
.switch-track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 19px; height: 19px; border-radius: 50%;
  background: var(--border-control); transition: transform var(--transition), background var(--transition);
}
.switch input:checked + .switch-track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(18px); background: #fff; }
.switch input:focus-visible + .switch-track { box-shadow: var(--focus); }
.toggle-item.on .switch-caption { color: var(--accent-ink); font-weight: 600; }
.toggle-detail { display: none; padding: 0 14px 14px; }
.toggle-item.on .toggle-detail { display: block; }

.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }

/* ===== Empty / loading ===== */
.loading, .empty-state {
  grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 40px 16px; color: var(--text-secondary); text-align: center;
}
.loading { flex-direction: row; justify-content: center; }
.empty-state .icon { color: var(--text-muted); }

/* ===== Signature easter egg ===== */
.signature {
  grid-column: 1 / -1; max-width: 640px; margin: 8px auto; text-align: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card);
  padding: 36px 28px;
}
.signature-mark { font-size: 24px; color: var(--accent); }
.signature-label { font-size: 14px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-top: 8px; }
.signature-name { font-size: 26px; font-weight: 700; margin: 4px 0 16px; }
.signature-name span { margin-left: 10px; color: var(--text-secondary); font-weight: 500; }
.signature-story { text-align: left; color: var(--text-secondary); display: flex; flex-direction: column; gap: 10px; }
.signature-foot { margin-top: 20px; font-size: 14px; color: var(--text-muted); }

/* ===== Toasts ===== */
.toast-container {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 1500; display: flex; flex-direction: column; gap: 8px; align-items: center;
  width: max-content; max-width: calc(100vw - 32px); pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  background: var(--text); color: #f5f1ea; border-radius: 12px; padding: 12px 18px;
  font-size: 15px; box-shadow: var(--shadow-modal);
  opacity: 0; transform: translateY(8px); transition: opacity 0.25s, transform 0.25s;
}
.toast.show { opacity: 1; transform: none; }
.toast-success .toast-icon { color: #9fd3a8; }
.toast-error .toast-icon { color: #f0a79b; }
.toast-icon { display: inline-flex; }

/* ===== Phones ===== */
@media (max-width: 640px) {
  body { padding-top: calc(58px + env(safe-area-inset-top)); }
  .nav-inner { height: 58px; padding: 0 16px; gap: 10px; }
  .brand-text { font-size: 16px; }
  .badge, .user-role { display: none; }
  .user-name { max-width: 90px; overflow: hidden; text-overflow: ellipsis; }
  .logout-label { display: none; }
  #logoutBtn { width: 44px; padding: 0; }
  .login-label-full { display: none; }
  .login-label-short { display: inline; }

  .container { padding: 24px 16px 64px; }
  .page-head h1 { font-size: 26px; }
  .course-grid { grid-template-columns: 1fr; gap: 12px; }

  /* Course detail becomes a full-height sheet */
  .modal-overlay { padding: 0; align-items: flex-end; }
  #modalOverlay .modal {
    max-width: none; height: 100%; max-height: none; border-radius: 0;
    transform: translateY(40px);
  }
  #modalOverlay.active .modal { transform: none; }
  #modalOverlay .modal-header { border-radius: 0; padding: calc(14px + env(safe-area-inset-top)) 16px 14px; }
  #loginModalOverlay .modal, #addCourseOverlay .modal { border-radius: var(--radius-modal) var(--radius-modal) 0 0; max-width: none; max-height: 92dvh; }
  #modalOverlay .modal-body { border-radius: 0; }
  #loginModalOverlay, #addCourseOverlay { align-items: flex-end; }
  .modal-header h2 { font-size: 21px; }
  .modal-body { padding: 18px 16px calc(28px + env(safe-area-inset-bottom)); }
  .write-jump span { display: none; }
  .write-jump { width: 44px; padding: 0; }

  .summary { gap: 8px; }
  .stat { padding: 10px 12px; }
  .stat-num { font-size: 20px; }
  .stat .verdict { display: none; }

  .info-block { grid-template-columns: 1fr; }
  .review-item { padding: 16px; }
  .review-scores { gap: 6px; }
  .score-tile { padding: 10px; }
  .score-num { font-size: 22px; }
  .score-verdict { font-size: 13px; }
  .comment { font-size: 17px; padding-left: 14px; }
  .review-form { padding: 18px 16px; margin: 0 -4px; }

  /* 11 buttons are too narrow on a phone — use the large slider instead */
  .score-seg { display: none; }
  .slider-row { display: flex; }
  .form-row { grid-template-columns: 1fr; gap: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation-duration: 0.01ms !important; scroll-behavior: auto !important; }
}
