/* โรงเรียนบ้านใต้ ปพ.6 – Royal Academic Sanctuary (Mobile-first) */

:root {
  /* Brand Primary */
  --primary: #001d41;
  --primary-2: #0f3260;
  --primary-3: #284776;
  --primary-light: #d6e3ff;

  /* Sovereign Gold Accents */
  --gold: #fdc348;
  --gold-soft: #ffdea5;
  --gold-text: #7b5800;
  --gold-dark: #705100;
  --gold-border: #fed578;

  /* Surfaces & Canvas */
  --bg: #f9f9ff;
  --card: #ffffff;
  --soft: #f0f3ff;
  --soft-2: #e7eefe;
  --soft-3: #e2e8f9;

  /* Typography & Neutrals */
  --text: #151c27;
  --muted: #43474f;
  --outline: #555962;
  --line: #c4c6d0;

  /* Semantics */
  --success-bg: #dcfce7;
  --success-on: #14532d;
  --success-border: #bbf7d0;

  --err: #ba1a1a;
  --err-bg: #ffdad6;
  --err-on: #93000a;
  --err-border: #ffb4ab;

  /* Shapes & Depth */
  --r-sm: 6px;
  --r-md: 10px;
  --r: 1rem;
  --r-full: 9999px;

  --shadow: 0 1px 3px rgba(0, 29, 65, 0.08), 0 0 0 1px rgba(196, 198, 208, 0.4);
  --shadow-float: 0 4px 12px rgba(0, 29, 65, 0.18);

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --topbar-h: 4.2rem;
}

/* Browser Surfaces */

::selection {
  background: var(--primary-light);
  color: var(--primary);
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: var(--r-full);
}

::-webkit-scrollbar-thumb:hover {
  background: #a5a8b2;
}

:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

input,
button {
  caret-color: var(--primary);
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Sarabun", "Public Sans", sans-serif;
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

h1,
h2,
h3,
h4,
h5 {
  margin: 0;
  line-height: 1.4;
}

p {
  margin: 0;
  line-height: 1.6;
}

small {
  line-height: 1.4;
}

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

img {
  max-width: 100%;
}

button,
input {
  font: inherit;
}

.material-symbols-outlined {
  font-size: 1.25rem;
  line-height: 1;
  flex-shrink: 0;
  vertical-align: middle;
}

.hidden {
  display: none !important;
}

.flex {
  display: flex;
}

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

.spinner {
  width: 2rem;
  height: 2rem;
  border: 3px solid var(--soft-3);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  .btn,
  .topbar-action,
  .input-wrap input {
    transition: none;
  }
  .spinner {
    animation: none;
    opacity: 0.85;
  }
}

.gold {
  color: var(--gold-text);
}

.card {
  background: var(--card);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  min-width: 0;
}

/* ---------- Home ---------- */

.home {
  max-width: 82rem;
  margin: 0 auto;
  padding: calc(var(--safe-t) + 2rem) 1rem calc(var(--safe-b) + 1.5rem);
  display: grid;
  gap: 1.5rem;
}

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.6rem;
}

.logo {
  width: 10.8rem;
  height: 10.8rem;
  margin-bottom: 0.25rem;
  object-fit: contain;
  /* ไม่มีกรอบ/พื้นหลัง: ถ้า logo.png มีพื้นขาวทึบ ให้กลืนไปกับพื้นหน้า */
  mix-blend-mode: multiply;
}

.hero h1 {
  margin-top: 0.15rem;
  font-family: "Noto Serif Thai", "Sarabun", serif;
  font-size: 2rem;
  line-height: 1.3;
  color: var(--primary);
}

/* เส้นคาดแบบหนังสือราชการ: กรมท่า + ทอง */

.hero h1::after {
  content: "";
  display: block;
  width: 4rem;
  height: 4px;
  margin: 0.6rem auto 0;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--primary) 0 70%, var(--gold) 70% 100%);
}

.hero p {
  max-width: 28rem;
  margin-top: 0.15rem;
  line-height: 1.6;
}

.hero .loc {
  display: block;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
}

.hero .agency {
  display: block;
  margin-top: 0.1rem;
  font-size: 0.95rem;
  color: var(--muted);
}

/* ป้ายชื่อบริการ: ชื่อระบบ + ปีการศึกษา */

.service {
  display: inline-flex;
  align-items: stretch;
  margin-top: 0.6rem;
  border: 1px solid var(--line);
  border-left: 4px solid var(--primary-2);
  border-radius: var(--r-sm);
  background: var(--card);
  overflow: hidden;
  font-size: 0.9rem;
  text-align: left;
}

.service > span {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.9rem;
}

.service-name {
  color: var(--primary);
  font-weight: 700;
}

.service-name .material-symbols-outlined {
  color: var(--gold-text);
  font-size: 1.25rem;
}

.service-year {
  border-left: 1px solid var(--line);
  background: var(--soft);
  color: var(--primary-2);
  font-weight: 600;
}

@media (max-width: 479px) {
  .service {
    flex-direction: column;
    width: 100%;
    max-width: 24rem;
  }
  .service > span {
    justify-content: center;
  }
  .service-year {
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}

.login {
  width: 100%;
  max-width: 32rem;
  margin: 0 auto;
  overflow: hidden;
}

.card-head {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  padding: 1.1rem 1.25rem;
  background: var(--soft);
  color: var(--primary);
  border-bottom: 1px solid var(--line);
}

.card-head h2 {
  font-size: 1rem;
  font-weight: 700;
}

.card-head p {
  font-size: 0.8rem;
  color: var(--muted);
}

.card-body {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.demo {
  padding: 0.9rem;
  border-radius: var(--r-md);
  background: var(--soft-2);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--primary-3);
  border: 1px solid var(--soft-3);
}

.demo button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-height: 3rem;
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: #fff;
  color: var(--primary);
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0, 29, 65, 0.04);
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.demo button:hover {
  border-color: var(--primary-2);
  background: var(--soft);
}

.demo .go {
  flex-shrink: 0;
  padding: 2px 8px;
  border-radius: var(--r-sm);
  background: var(--gold-soft);
  color: var(--gold-text);
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid var(--gold-border);
}

.field label {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: var(--text);
}

.req {
  color: var(--err);
  font-size: 0.8rem;
  font-weight: 400;
}

.input-wrap {
  position: relative;
}

.input-wrap .material-symbols-outlined {
  position: absolute;
  left: 0.875rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.input-wrap input {
  width: 100%;
  min-height: 3rem;
  padding: 0.7rem 1rem 0.7rem 2.75rem;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: #fff;
  font-size: 1rem;
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.input-wrap input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 29, 65, 0.15);
}

.input-wrap input.has-error {
  border-color: var(--err);
  background-color: var(--err-bg);
}

.input-wrap input.has-error:focus {
  border-color: var(--err);
  box-shadow: 0 0 0 3px rgba(186, 26, 26, 0.2);
}

.hint {
  margin-top: 0.4rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.hint.error {
  color: var(--err-on);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  min-height: 3.25rem;
  border: 0;
  border-radius: var(--r-md);
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-float);
  transition: background 0.2s ease, transform 0.1s ease;
}

.btn:hover {
  background: var(--primary-2);
}

.btn:active {
  transform: scale(0.98);
}

/* ---------- Result Topbar ---------- */

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  padding-top: var(--safe-t);
  background-color: var(--primary);
  background: linear-gradient(95deg, var(--primary) 0%, var(--primary-2) 100%);
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.topbar-in {
  max-width: 90rem;
  margin: 0 auto;
  height: var(--topbar-h);
  padding: 0 1rem;
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.topbar img {
  width: 3rem;
  height: 3rem;
  padding: 3px;
  border-radius: 50%;
  background: #fff;
  object-fit: contain;
  box-shadow: 0 0 0 2px var(--gold-soft), 0 2px 8px rgba(0, 29, 65, 0.25);
  flex-shrink: 0;
}

.brand {
  min-width: 0;
  flex: 1;
  line-height: 1.4;
}

.brand b {
  display: block;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.005em;
}

.brand span {
  display: block;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.82);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-action {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 2.75rem;
  padding: 0 1rem;
  border-radius: var(--r-full);
  background: var(--gold);
  color: var(--primary);
  font-weight: 700;
  font-size: 0.8rem;
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0, 29, 65, 0.2);
  transition: background 0.2s ease, transform 0.1s ease;
  text-decoration: none;
}

.topbar-action .material-symbols-outlined {
  font-size: 1.25rem;
}

/* Page Layout */

.page {
  max-width: 90rem;
  margin: 0 auto;
  padding: calc(var(--safe-t) + var(--topbar-h) + 1rem) 1rem calc(var(--safe-b) + 2rem);
}

#loadingState {
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 3rem 0;
  color: var(--muted);
}

#errorState {
  display: flex;
  gap: 0.75rem;
  padding: 1.25rem;
  border-radius: var(--r);
  background: var(--err-bg);
  color: var(--err-on);
  border: 1px solid var(--err-border);
}

#errorState b {
  display: block;
  font-size: 1rem;
}

#contentArea {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

section {
  min-width: 0;
}

/* ---------- Student Overview (Hero Card) ---------- */

.hero-card {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border-radius: var(--r);
  padding: 1.25rem;
  background: linear-gradient(135deg, var(--soft) 0%, #ffffff 50%, var(--soft-2) 100%);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  display: grid;
  gap: 1.25rem;
}

.hero-card::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: -25% auto -25% -10%;
  width: 66%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.75);
}

.hero-card .who {
  display: flex;
  align-items: center;
  gap: 1.1rem;
  min-width: 0;
}

.hero-card .avatar {
  width: 4.5rem;
  height: 4.5rem;
  border-radius: 50%;
  background: linear-gradient(160deg, var(--primary-2), var(--primary));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 0 4px #fff, 0 4px 12px rgba(0, 29, 65, 0.18);
}

.hero-card .avatar .material-symbols-outlined {
  font-size: 1.75rem;
}

.hero-card .who-info {
  min-width: 0;
  flex: 1;
}

.hero-card .eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.3rem;
  padding: 0.18rem 0.8rem 0.18rem 0.6rem;
  border-radius: var(--r-full);
  background: var(--soft-3);
  color: var(--primary-2);
  font-size: 0.8rem;
  font-weight: 600;
}

.hero-card .eyebrow .material-symbols-outlined {
  font-size: 1rem;
}

.hero-card .who-info h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.35;
  word-break: break-word;
}

.hero-card .meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.6rem;
  margin-top: 0.4rem;
  font-size: 0.8rem;
  color: var(--primary-3);
}

.hero-card .meta > span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.65rem;
  border-radius: var(--r-full);
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--soft-3);
}

.hero-card .meta .material-symbols-outlined {
  font-size: 1rem;
  color: var(--primary-2);
}

.hero-card .meta b {
  color: var(--primary);
}

.hero-card .meta .status {
  background: var(--gold-soft);
  color: var(--gold-text);
  border-color: var(--gold-border);
  font-weight: 700;
}

.hero-card .meta .status .material-symbols-outlined {
  color: var(--gold-text);
}

/* Score box & stat items */

.score-box {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.75rem 1rem;
  border-radius: var(--r-md);
  background: var(--soft);
  border: 1px solid var(--line);
}

.stat.gold-bg {
  background: var(--gold-soft);
  border: 1px solid var(--gold-border);
}

.stat-head {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.stat-ic {
  width: 2.25rem;
  height: 2.25rem;
  padding: 6px;
  box-sizing: border-box;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--soft-3);
  color: var(--primary-2);
  flex-shrink: 0;
}

.stat-ic .material-symbols-outlined {
  font-size: 1rem;
}

.stat.gold-bg .stat-ic {
  background: var(--gold-text);
  color: #fff;
}

.stat-head small {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--primary-3);
}

.stat.gold-bg .stat-head small {
  color: var(--gold-dark);
}

.stat-val {
  display: flex;
  align-items: baseline;
  gap: 0.25rem;
}

.stat strong {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
}

.stat.gold-bg strong {
  color: var(--gold-dark);
}

.stat em {
  font-style: normal;
  font-size: 1rem;
  color: var(--muted);
}

.criteria {
  font-size: 0.8rem;
  color: var(--muted);
  text-align: left;
}

/* Section Titles */

.sec-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.sec-title h3 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.25rem;
  color: var(--primary);
  font-weight: 700;
}

.sec-title h3::before {
  content: "";
  width: 6px;
  height: 1.25rem;
  border-radius: var(--r-full);
  background: var(--gold);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.8rem;
  border-radius: var(--r-full);
  background: var(--soft-2);
  border: 1px solid var(--soft-3);
  font-size: 0.8rem;
  color: var(--primary-3);
  font-weight: 500;
}

.tag .material-symbols-outlined {
  font-size: 1rem;
  color: var(--primary-2);
}

/* Subject Panels */

.grades {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
  align-items: start;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}

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

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  min-height: 2.75rem;
  padding: 0.65rem 1.1rem;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  font-size: 1rem;
}

.panel-head.alt {
  background: var(--primary-2);
}

.panel-head span:first-child {
  display: flex;
  align-items: center;
  gap: 6px;
}

.panel-head .material-symbols-outlined {
  color: var(--gold-soft);
  font-size: 1.25rem;
}

.panel-head small {
  font-weight: 400;
  color: var(--primary-light);
  font-size: 0.8rem;
}

.subj {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 1.1rem;
  transition: background-color 0.15s ease;
}

.subj:hover {
  background: var(--soft);
}

.subj + .subj,
.act-row + .act-row {
  border-top: 1px solid var(--soft-2);
}

.subj-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.subj-name {
  font-weight: 600;
  color: var(--primary);
  word-break: break-word;
  line-height: 1.4;
  font-size: 1rem;
}

.subj-hours {
  font-size: 0.8rem;
  color: var(--muted);
}

.bar {
  display: block;
  height: 5px;
  margin-top: 0.4rem;
  border-radius: var(--r-full);
  background: var(--soft-3);
  overflow: hidden;
}

.bar i {
  display: block;
  height: 100%;
  border-radius: var(--r-full);
  background: var(--primary-2);
  transition: width 0.3s ease;
}

.bar i.strong {
  background: linear-gradient(90deg, var(--gold), #d89c00);
}

.bar i.fail {
  background: var(--err);
}

.subj-end {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}

.subj-score {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
}

.subj-score.strong {
  color: var(--gold-text);
}

.subj-score small {
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--muted);
}

/* Semantic Status Badges */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--r-full);
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  background: var(--success-bg);
  color: var(--success-on);
  border: 1px solid var(--success-border);
}

.badge.fail {
  background: var(--err-bg);
  color: var(--err-on);
  border-color: var(--err-border);
}

.badge.wait {
  background: var(--soft-3);
  color: var(--muted);
  border-color: var(--line);
}

/* Activities */

.act-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 0.75rem;
  padding: 0.7rem 1.1rem;
}

.act-l {
  min-width: 0;
  flex: 1;
}

.act-row h4 {
  font-size: 1rem;
  color: var(--primary);
  line-height: 1.4;
  word-break: break-word;
}

.act-row p {
  font-size: 0.8rem;
  color: var(--muted);
}

.act-row p.gold {
  color: var(--gold-text);
  font-weight: 600;
}

/* Teacher Section: โปรไฟล์ครู (พื้นอ่อน) + บันทึกความเห็น (พื้นขาว) */

.teacher {
  display: grid;
  grid-template-columns: 1fr;
  overflow: hidden;
  padding: 0;
  border-radius: var(--r);
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.teacher-id {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 0;
  padding: 1rem 1.25rem;
  background: var(--soft);
  border-bottom: 1px solid var(--line);
}

.teacher-avatar {
  position: relative;
  width: 4.5rem;
  height: 4.5rem;
  padding: 3px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--soft-2);
  color: var(--primary-2);
  box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--gold);
}

.teacher-avatar .material-symbols-outlined {
  font-size: 1.75rem;
}

.teacher-avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 30%;
  transform: scale(1.8);
  transform-origin: 50% 40%;
}

.teacher-text {
  min-width: 0;
}

.teacher-id small {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--gold-text);
}

.teacher-id b {
  display: block;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.4;
}

.teacher-id .room {
  display: block;
  margin-top: 0.1rem;
  font-size: 0.9rem;
  line-height: 1.4;
  color: var(--muted);
}

.note {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.65rem;
  padding: 1.25rem;
}

.note h4 {
  display: flex;
  gap: 0.55rem;
  align-items: center;
  font-size: 1rem;
  color: var(--primary);
  font-weight: 700;
}

.note h4 .material-symbols-outlined {
  width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--gold-soft);
  color: var(--gold-text);
  font-size: 1.25rem;
}

.note p {
  padding-left: 1rem;
  border-left: 3px solid var(--gold);
  color: var(--text);
  font-size: 1.05rem;
  line-height: 1.8;
}

/* Page Foot */

.page-foot {
  margin-top: 2rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.page-foot p:last-child {
  color: var(--outline);
}

/* ---------- Media Queries & Device Adaptation ---------- */

/* Safe area support for horizontal notch (landscape phones) */

.home,
.page {
  padding-left: max(1rem, env(safe-area-inset-left));
  padding-right: max(1rem, env(safe-area-inset-right));
}

/* Touch (Coarse Pointer) Adaptation */

@media (pointer: coarse) {
  .topbar-action,
  .btn {
    min-height: 48px;
  }
  .demo button {
    min-height: 48px;
  }
  .subj {
    padding: 0.85rem 1.1rem;
  }
}

/* Hover-capable devices (Mouse / Trackpad) */

@media (hover: hover) {
  .topbar-action:hover {
    background: #fed578;
  }
  .btn:hover {
    background: var(--primary-2);
  }
  .subj:hover {
    background: var(--soft);
  }
  .demo button:hover {
    border-color: var(--primary-2);
    background: var(--soft);
  }
}

/* Touch-only devices (avoid stuck hover states) */

@media (hover: none) {
  .topbar-action:active {
    background: #fed578;
    transform: scale(0.97);
  }
  .btn:active {
    background: var(--primary-2);
    transform: scale(0.98);
  }
  .subj:active {
    background: var(--soft);
  }
  .demo button:active {
    background: var(--soft);
  }
}

/* Tablet (min-width: 640px) */

@media (min-width: 640px) {
  .home,
  .page {
    padding-left: max(1.5rem, env(safe-area-inset-left));
    padding-right: max(1.5rem, env(safe-area-inset-right));
  }
  .hero h1 {
    font-size: 2.25rem;
  }
}

/* Medium Desktop / Tablet Landscape (min-width: 768px) */

@media (min-width: 768px) {
  :root {
    --topbar-h: 5rem;
  }
  .topbar img {
    width: 3.5rem;
    height: 3.5rem;
  }
  .brand b {
    font-size: 1.25rem;
  }
  .hero-card {
    grid-template-columns: minmax(0, 1.25fr) minmax(18rem, 0.85fr);
    align-items: center;
    gap: 1.5rem;
    padding: 1.25rem 1.5rem;
  }
  .grades {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }
  .teacher {
    grid-template-columns: minmax(15rem, 0.5fr) minmax(0, 1fr);
  }
  .teacher-id {
    flex-direction: column;
    justify-content: center;
    gap: 1rem;
    padding: 1.75rem 1.5rem;
    text-align: center;
    border-bottom: 0;
    border-right: 1px solid var(--line);
  }
  .teacher-avatar {
    width: 7rem;
    height: 7rem;
  }
  .teacher-avatar .material-symbols-outlined {
    font-size: 3rem;
  }
  .teacher-id b {
    font-size: 1.4rem;
  }
  .note {
    padding: 1.75rem 2rem;
  }
}

/* Large Desktop (min-width: 1024px) */

@media (min-width: 1024px) {
  html {
    font-size: clamp(20px, 0.85vw + 12px, 28px);
  }
  .home {
    grid-template-columns: minmax(0, 30rem) minmax(0, 32rem);
    justify-content: center;
    align-items: center;
    gap: 5rem;
    min-height: 100vh;
    padding: 3rem 2rem;
  }
  .hero {
    align-items: flex-start;
    text-align: left;
  }
  .hero h1::after {
    margin-left: 0;
  }
  .login {
    max-width: none;
  }
  .page {
    padding: calc(var(--safe-t) + var(--topbar-h) + 1.25rem) 2rem 2.5rem;
  }
  .topbar-in {
    padding: 0 2rem;
  }
}

/* Mobile Screens (max-width: 639px) */

@media (max-width: 639px) {
  .topbar-in {
    gap: 0.55rem;
    padding-left: max(0.75rem, env(safe-area-inset-left));
    padding-right: max(0.75rem, env(safe-area-inset-right));
  }
  .topbar img {
    width: 2.6rem;
    height: 2.6rem;
  }
  .brand b {
    font-size: 1rem;
  }
  .brand span {
    font-size: 0.8rem;
  }
  .topbar-action {
    min-height: 2.5rem;
    padding: 0 0.75rem;
    font-size: 0.8rem;
  }
  .hero-card {
    gap: 0.9rem;
    padding: 1rem;
    border-radius: var(--r);
  }
  .hero-card::before {
    inset: -30% auto -30% -25%;
    width: 120%;
    background: rgba(255, 255, 255, 0.65);
  }
  .hero-card .who {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas:
      "eyebrow eyebrow"
      "avatar name"
      "meta meta";
    align-items: center;
    gap: 0.5rem 0.8rem;
  }
  .hero-card .who-info {
    display: contents;
  }
  .hero-card .eyebrow {
    grid-area: eyebrow;
    justify-self: start;
    margin: 0;
  }
  .hero-card .avatar {
    grid-area: avatar;
    width: 3.5rem;
    height: 3.5rem;
  }
  .hero-card .avatar .material-symbols-outlined {
    font-size: 1.75rem;
  }
  .hero-card .who-info h2 {
    grid-area: name;
    font-size: 1.25rem;
  }
  .hero-card .meta {
    grid-area: meta;
    margin-top: 0;
  }
  .hero-card .meta > span {
    padding: 0.15rem 0.55rem;
    font-size: 0.8rem;
  }
  .stats {
    gap: 0.5rem;
  }
  .stat {
    padding: 0.6rem 0.75rem;
  }
  .stat strong {
    font-size: 1.75rem;
  }
  .teacher-id {
    padding: 0.9rem 1rem;
  }
  .teacher-avatar {
    width: 4.75rem;
    height: 4.75rem;
  }
  .note {
    padding: 1rem;
  }
  .page-foot {
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
}

/* Small Screens (max-width: 360px) */

@media (max-width: 360px) {
  .topbar-action span:not(.material-symbols-outlined) {
    display: none;
  }
  .topbar-action {
    padding: 0 0.65rem;
  }
  .stats {
    grid-template-columns: 1fr;
  }
}

/* Extra small screens (<= 320px) */

@media (max-width: 320px) {
  .brand b {
    font-size: 0.8rem;
  }
  .topbar img {
    width: 2.2rem;
    height: 2.2rem;
  }
}
/* ฟอร์มเข้าสู่ระบบ: ช่องแสดงรหัสผ่าน */
.show-pw{display:flex;align-items:center;gap:.5rem;min-height:2.75rem;font-size:.9rem;font-weight:400;color:var(--muted);cursor:pointer}
.show-pw input{width:1.15rem;height:1.15rem;accent-color:var(--primary)}
/* .field label มีความเฉพาะเจาะจงสูงกว่า จึงต้องระบุซ้ำเพื่อให้ช่องติ๊กชิดข้อความ */
.field .show-pw{justify-content:flex-start;font-weight:400;color:var(--muted)}