/* ==========================================================================
   CMAT — อาจารย์โฟมสอน AutoCAD (ajfoamm.com)
   Engineering Clean Theme Stylesheet
   Palette: #ffffff / #f8fafc | Accent: #e63e18 | Dark: #0f172a
   Fonts: Prompt (Display), Sarabun (Body), JetBrains Mono (Tech/Commands)
   ========================================================================== */

:root {
  --bg-white: #ffffff;
  --bg-surface: #f8fafc;
  --bg-subtle: #f1f5f9;
  --accent: #e63e18;
  --accent-hover: #cc3310;
  --accent-soft: #fff2ee;
  --accent-border: #fcd5c9;
  --dark: #0f172a;
  --dark-soft: #1e293b;
  --navy: #1e3a8a;
  --navy-soft: #eff6ff;
  --text-main: #0f172a;
  --text-body: #334155;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --success: #059669;
  --success-soft: #ecfdf5;
  --warning: #d97706;
  --warning-soft: #fffbeb;
  --danger: #dc2626;
  --danger-soft: #fef2f2;

  --font-display: 'Prompt', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Sarabun', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 8px 24px -6px rgba(15, 23, 42, 0.08), 0 2px 6px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 20px 44px -12px rgba(15, 23, 42, 0.14);
  --shadow-accent: 0 8px 20px -4px rgba(230, 62, 24, 0.28);

  --container-max: 1200px;
  --nav-height: 70px;
}

/* Reset & Base */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--nav-height) + 16px);
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-white);
  color: var(--text-main);
  line-height: 1.65;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, .font-display {
  font-family: var(--font-display);
  color: var(--dark);
  line-height: 1.3;
}

code, pre, kbd, .font-mono {
  font-family: var(--font-mono);
}

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

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: transparent;
}

img, svg {
  max-width: 100%;
  display: block;
}

/* Utilities */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 20px;
}

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

.hidden {
  display: none !important;
}

.text-accent { color: var(--accent); }
.text-dark { color: var(--dark); }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }

/* Engineering Blueprint Grid */
.blueprint-bg {
  background-color: var(--bg-white);
  background-image:
    linear-gradient(to right, rgba(15, 23, 42, 0.045) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(15, 23, 42, 0.045) 1px, transparent 1px),
    linear-gradient(to right, rgba(15, 23, 42, 0.02) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(15, 23, 42, 0.02) 1px, transparent 1px);
  background-size: 80px 80px, 80px 80px, 16px 16px, 16px 16px;
}

/* Badges & Tags */
.section-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  padding: 5px 12px;
  border-radius: 999px;
}

.section-header {
  margin-bottom: 36px;
}

.section-header.center {
  text-align: center;
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
}

.section-title {
  font-size: clamp(1.65rem, 3vw, 2.35rem);
  font-weight: 700;
  margin-top: 12px;
  letter-spacing: -0.02em;
}

.section-desc {
  color: var(--text-muted);
  margin-top: 10px;
  font-size: 1.02rem;
}

.section-pad {
  padding: 80px 0;
}

.section-surface {
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.94rem;
  padding: 11px 20px;
  border-radius: var(--radius-md);
  transition: all 0.18s ease;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
  box-shadow: var(--shadow-accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.btn-dark {
  background: var(--dark);
  color: #ffffff;
}

.btn-dark:hover {
  background: var(--dark-soft);
  transform: translateY(-1px);
}

.btn-outline {
  background: var(--bg-white);
  color: var(--dark);
  border: 1.5px solid var(--border-strong);
}

.btn-outline:hover {
  border-color: var(--dark);
  background: var(--bg-surface);
}

.btn-ghost {
  background: var(--bg-subtle);
  color: var(--dark);
}

.btn-ghost:hover {
  background: var(--border);
}

.btn-sm {
  font-size: 0.84rem;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
}

.btn-lg {
  font-size: 1rem;
  padding: 14px 26px;
}

.btn-block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

/* ==========================================================================
   NAVBAR
   ========================================================================== */
.navbar {
  position: sticky;
  top: 0;
  z-index: 900;
  height: var(--nav-height);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.brand-mark {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.05em;
  line-height: 1;
}

.brand-mark .cm { color: var(--accent); }
.brand-mark .at { color: var(--dark); }

.brand-divider {
  width: 1px;
  height: 30px;
  background: var(--border-strong);
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--dark);
  line-height: 1.15;
}

.brand-domain {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-link {
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-body);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

.nav-link:hover,
.nav-link.active {
  color: var(--accent);
  background: var(--accent-soft);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-toggle {
  display: none;
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  align-items: center;
  justify-content: center;
  color: var(--dark);
}

.mobile-nav {
  display: none;
  position: fixed;
  top: var(--nav-height);
  left: 0;
  right: 0;
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  padding: 14px 20px 20px;
  z-index: 890;
  flex-direction: column;
  gap: 6px;
}

.mobile-nav.open {
  display: flex;
}

.mobile-nav a {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-weight: 500;
  color: var(--dark);
}

.mobile-nav a:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

/* ==========================================================================
   HERO SECTION
   ========================================================================== */
.hero {
  padding: 56px 0 68px;
  border-bottom: 1px solid var(--border);
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.25fr 0.95fr;
  gap: 40px;
  align-items: center;
}

.hero-slogan {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-top: 10px;
}

.hero-title {
  font-size: clamp(2.15rem, 4.4vw, 3.35rem);
  font-weight: 800;
  letter-spacing: -0.025em;
  margin-top: 14px;
  line-height: 1.18;
}

.hero-subtitle {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--navy);
  margin-top: 12px;
}

.hero-desc {
  color: var(--text-body);
  margin-top: 14px;
  max-width: 600px;
  font-size: 1.02rem;
}

.hero-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 26px;
}

/* Live Exam Status Banner */
.live-exam-banner {
  margin-top: 28px;
  background: var(--dark);
  color: #ffffff;
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: var(--shadow-md);
  border-left: 4px solid var(--accent);
}

.live-banner-left {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.pulse-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #22c55e;
  margin-top: 6px;
  flex-shrink: 0;
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
  animation: pulseGreen 1.8s infinite;
}

@keyframes pulseGreen {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); }
  70% { box-shadow: 0 0 0 10px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

.live-banner-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #86efac;
}

.live-banner-title {
  font-family: var(--font-display);
  font-size: 0.98rem;
  font-weight: 700;
  color: #ffffff;
  margin-top: 2px;
}

.live-banner-sub {
  font-size: 0.84rem;
  color: #cbd5e1;
}

/* Hero Profile & Stats Card */
.hero-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 26px;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}

.hero-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--accent), var(--dark));
}

.instructor-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.instructor-avatar {
  width: 68px;
  height: 68px;
  border-radius: var(--radius-lg);
  background: var(--dark);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  flex-shrink: 0;
  border: 2px solid var(--accent);
}

.instructor-avatar span {
  color: var(--accent);
}

.instructor-meta h3 {
  font-size: 1.15rem;
  font-weight: 700;
}

.instructor-meta p {
  font-size: 0.86rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.verified-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--navy);
  background: var(--navy-soft);
  padding: 2px 10px;
  border-radius: 999px;
  margin-bottom: 4px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 20px;
}

.stat-box {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 15px 16px;
  transition: border-color 0.2s ease;
}

.stat-box:hover {
  border-color: var(--accent-border);
}

.stat-value {
  font-family: var(--font-display);
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--dark);
  line-height: 1.1;
}

.stat-value.accent {
  color: var(--accent);
}

.stat-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 5px;
}

.hero-card-footer {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px dashed var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.cad-coord-tag {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  background: var(--bg-subtle);
  color: var(--dark);
  padding: 4px 10px;
  border-radius: 6px;
}

/* ==========================================================================
   ABOUT SECTION
   ========================================================================== */
.about-grid {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  gap: 44px;
  align-items: start;
}

.about-lead {
  font-size: 1.04rem;
  color: var(--text-body);
  margin-top: 16px;
}

.about-checklist {
  list-style: none;
  margin-top: 22px;
  display: grid;
  gap: 12px;
}

.about-checklist li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.96rem;
  color: var(--text-body);
}

.check-icon {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
  font-weight: 700;
  font-size: 0.8rem;
}

.pillar-cards {
  display: grid;
  gap: 16px;
}

.pillar-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  display: flex;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.pillar-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent-border);
}

.pillar-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: var(--dark);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.95rem;
}

.pillar-icon.accent {
  background: var(--accent);
}

.pillar-card h3 {
  font-size: 1.06rem;
  font-weight: 700;
}

.pillar-card p {
  font-size: 0.92rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ==========================================================================
   COURSES SECTION
   ========================================================================== */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 28px;
}

.filter-pill {
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 9px 18px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-white);
  color: var(--text-body);
  transition: all 0.16s ease;
}

.filter-pill:hover {
  border-color: var(--dark);
  color: var(--dark);
}

.filter-pill.active {
  background: var(--dark);
  color: #ffffff;
  border-color: var(--dark);
}

.courses-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 22px;
}

.course-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.course-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

.course-banner {
  padding: 20px 22px 16px;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: #ffffff;
  position: relative;
}

.course-banner.cat-3d {
  background: linear-gradient(135deg, #1e293b 0%, #9a2409 100%);
}

.course-banner.cat-auto {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
}

.course-banner.cat-uni {
  background: linear-gradient(135deg, #334155 0%, #0f172a 100%);
}

.course-badges {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 14px;
}

.course-cat-tag {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
}

.course-status {
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
}

.status-open {
  background: var(--accent);
  color: #ffffff;
}

.status-soon {
  background: #f59e0b;
  color: #0f172a;
}

.status-closed {
  background: rgba(255, 255, 255, 0.2);
  color: #e2e8f0;
}

.course-code {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: #cbd5e1;
}

.course-banner h3 {
  color: #ffffff;
  font-size: 1.1rem;
  font-weight: 700;
  margin-top: 4px;
}

.course-body {
  padding: 20px 22px;
  flex-grow: 1;
}

.course-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 0.82rem;
  color: var(--navy);
  font-weight: 600;
  margin-bottom: 10px;
}

.course-summary {
  font-size: 0.92rem;
  color: var(--text-body);
}

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

.course-price {
  font-family: var(--font-display);
  font-size: 1.18rem;
  font-weight: 800;
  color: var(--accent);
}

.course-actions {
  display: flex;
  gap: 8px;
}

/* ==========================================================================
   SOFTWARE SECTION (CMAT CAD Tools v2.4)
   ========================================================================== */
.software-showcase {
  background: var(--dark);
  color: #ffffff;
  border-radius: var(--radius-xl);
  padding: 40px;
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 36px;
  align-items: center;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}

.software-showcase::after {
  content: "v2.4";
  position: absolute;
  right: -12px;
  bottom: -26px;
  font-family: var(--font-mono);
  font-size: 8rem;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.04);
  pointer-events: none;
}

.software-showcase h2 {
  color: #ffffff;
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  margin-top: 12px;
}

.software-desc {
  color: #cbd5e1;
  margin-top: 12px;
  font-size: 1rem;
}

.sw-feature-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 22px;
}

.sw-feature {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-md);
  padding: 13px 15px;
}

.sw-feature strong {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: #fb923c;
}

.sw-feature span {
  font-size: 0.85rem;
  color: #e2e8f0;
}

.sw-spec-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-lg);
  padding: 24px;
  position: relative;
  z-index: 1;
}

.sw-spec-title {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #94a3b8;
  margin-bottom: 14px;
}

.sw-spec-list {
  list-style: none;
  display: grid;
  gap: 10px;
  font-size: 0.9rem;
  color: #e2e8f0;
  margin-bottom: 20px;
}

.sw-spec-list li {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 8px;
}

.sw-spec-list li span:first-child {
  color: #94a3b8;
}

.sw-price-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
}

.sw-price {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 800;
  color: #ffffff;
}

.sw-license-note {
  font-size: 0.8rem;
  color: #86efac;
  font-family: var(--font-mono);
}

/* ==========================================================================
   PROJECTS & KNOWLEDGE BASE (COMMAND CHEAT SHEET)
   ========================================================================== */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 48px;
}

.project-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 16px;
}

.project-tag {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--navy);
  background: var(--navy-soft);
  padding: 4px 10px;
  border-radius: 6px;
  display: inline-block;
}

.project-card h3 {
  font-size: 1.06rem;
  font-weight: 700;
  margin-top: 10px;
}

.project-card p {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 6px;
}

/* Cheat Sheet Table */
.cheatsheet-box {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 28px;
  box-shadow: var(--shadow-sm);
}

.cheatsheet-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 20px;
}

.search-input-wrap {
  position: relative;
  flex: 1;
  min-width: 240px;
  max-width: 420px;
}

.search-input {
  width: 100%;
  padding: 11px 16px 11px 42px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--dark);
  outline: none;
  transition: border-color 0.16s ease, background 0.16s ease;
}

.search-input:focus {
  border-color: var(--accent);
  background: var(--bg-white);
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.cmd-cat-select {
  padding: 11px 14px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-white);
  color: var(--dark);
  outline: none;
}

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.data-table th {
  background: var(--bg-surface);
  color: var(--dark);
  font-family: var(--font-display);
  font-weight: 600;
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-body);
  vertical-align: middle;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover {
  background: #fafafa;
}

.kbd-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  padding: 3px 9px;
  border-radius: 6px;
}

.cmd-full {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--dark);
}

.cat-chip {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  background: var(--bg-subtle);
  color: var(--text-body);
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

/* ==========================================================================
   CONTACT SECTION
   ========================================================================== */
.contact-grid {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 36px;
  align-items: start;
}

.contact-cards {
  display: grid;
  gap: 12px;
  margin-top: 22px;
}

.contact-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.contact-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 700;
  flex-shrink: 0;
}

.contact-item strong {
  display: block;
  font-family: var(--font-display);
  font-size: 0.9rem;
  color: var(--dark);
}

.contact-item span {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.form-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 30px;
  box-shadow: var(--shadow-md);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.form-group label {
  font-family: var(--font-display);
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--dark);
}

.form-control {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-white);
  color: var(--dark);
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(230, 62, 24, 0.12);
}

.form-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ==========================================================================
   FOOTER
   ========================================================================== */
.site-footer {
  background: var(--dark);
  color: #cbd5e1;
  padding: 40px 0;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.footer-brand .brand-mark .at {
  color: #ffffff;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  font-family: var(--font-display);
  font-size: 0.86rem;
}

.footer-links a:hover {
  color: var(--accent);
}

.footer-copy {
  font-size: 0.82rem;
  color: #94a3b8;
}

/* ==========================================================================
   MODALS & REAL-TIME EXAM PORTAL
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(15, 23, 42, 0.62);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeOverlay 0.18s ease-out;
}

@keyframes fadeOverlay {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-panel {
  background: var(--bg-white);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 680px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  border: 1px solid var(--border);
}

.modal-panel.modal-xl {
  max-width: 1060px;
}

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--bg-white);
}

.modal-title {
  font-size: 1.18rem;
  font-weight: 700;
  color: var(--dark);
}

.modal-close {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  color: var(--dark);
  font-size: 1.25rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.modal-close:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

/* Exam Portal Tabs */
.exam-tabs {
  display: flex;
  gap: 8px;
  padding: 12px 24px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.exam-tab-btn {
  font-family: var(--font-display);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  color: var(--text-body);
  background: var(--bg-white);
  border: 1px solid var(--border);
  transition: all 0.15s ease;
}

.exam-tab-btn:hover {
  border-color: var(--dark);
}

.exam-tab-btn.active {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

.mode-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.84rem;
  margin-bottom: 18px;
}

.mode-banner.demo {
  background: var(--warning-soft);
  border: 1px solid #fde68a;
  color: #92400e;
}

.mode-banner.live {
  background: var(--success-soft);
  border: 1px solid #a7f3d0;
  color: #065f46;
}

/* Active Exam Workspace */
.exam-room-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  background: var(--dark);
  color: #ffffff;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
}

.exam-timer-box {
  background: rgba(230, 62, 24, 0.18);
  border: 1px solid rgba(230, 62, 24, 0.5);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  text-align: center;
}

.exam-timer-box .label {
  display: block;
  font-size: 0.7rem;
  color: #fca5a5;
  text-transform: uppercase;
  font-family: var(--font-mono);
}

.exam-timer-box .time {
  font-family: var(--font-mono);
  font-size: 1.35rem;
  font-weight: 700;
  color: #ffffff;
}

.exam-timer-box.urgent {
  background: var(--danger);
  border-color: #ffffff;
}

.exam-workspace {
  display: grid;
  grid-template-columns: 1fr 250px;
  gap: 20px;
  align-items: start;
}

.question-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
}

.question-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.question-number {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 4px 10px;
  border-radius: 6px;
}

.question-text {
  font-family: var(--font-display);
  font-size: 1.08rem;
  font-weight: 600;
  color: var(--dark);
  margin-bottom: 18px;
}

.choices-list {
  display: grid;
  gap: 10px;
}

.choice-option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s ease;
  background: var(--bg-white);
}

.choice-option:hover {
  border-color: var(--dark);
  background: var(--bg-surface);
}

.choice-option.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.choice-letter {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--bg-subtle);
  color: var(--dark);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.86rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.choice-option.selected .choice-letter {
  background: var(--accent);
  color: #ffffff;
}

.question-nav-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* Question Map Sidebar */
.qmap-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.qmap-title {
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.qmap-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 7px;
  margin-bottom: 14px;
}

.qmap-btn {
  height: 36px;
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 700;
  border: 1.5px solid var(--border-strong);
  background: var(--bg-white);
  color: var(--dark);
  position: relative;
  transition: all 0.14s ease;
}

.qmap-btn.current {
  border-color: var(--dark);
  box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.2);
}

.qmap-btn.answered {
  background: var(--success);
  color: #ffffff;
  border-color: var(--success);
}

.qmap-btn.flagged {
  background: #f59e0b;
  color: #ffffff;
  border-color: #d97706;
}

.qmap-legend {
  display: grid;
  gap: 6px;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1px solid var(--border-strong);
  background: var(--bg-white);
}

.legend-dot.answered { background: var(--success); border-color: var(--success); }
.legend-dot.flagged { background: #f59e0b; border-color: #d97706; }

/* Printable Score Report */
.report-card {
  border: 2px solid var(--dark);
  border-radius: var(--radius-lg);
  padding: 26px;
  background: var(--bg-white);
}

.report-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid var(--border);
  padding-bottom: 16px;
  margin-bottom: 20px;
}

.report-score-hero {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin: 18px 0;
}

.report-kpi {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
}

.report-kpi .val {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--dark);
}

.report-kpi .lbl {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.pass-badge {
  display: inline-block;
  font-family: var(--font-display);
  font-weight: 700;
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 0.86rem;
}

.pass-badge.pass {
  background: var(--success-soft);
  color: var(--success);
  border: 1px solid #a7f3d0;
}

.pass-badge.fail {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid #fecaca;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 380px;
}

.toast {
  background: var(--dark);
  color: #ffffff;
  padding: 13px 18px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.9rem;
  font-weight: 500;
  border-left: 4px solid var(--accent);
  animation: slideToast 0.22s ease-out;
}

.toast.success { border-left-color: #22c55e; }
.toast.error { border-left-color: #ef4444; background: #7f1d1d; }

@keyframes slideToast {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Syllabus Modal List */
.syllabus-list {
  list-style: none;
  display: grid;
  gap: 10px;
  margin: 14px 0;
}

.syllabus-list li {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 0.92rem;
}

/* ==========================================================================
   UPGRADED 12-EXAM PORTAL (AUTH + COURSE DASHBOARD + ADMIN CONTROL)
   ========================================================================== */
.auth-box {
  max-width: 560px;
  margin: 0 auto;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
}

.auth-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 5px;
  margin-bottom: 18px;
}

.auth-switch-btn {
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-muted);
  transition: all 0.15s ease;
}

.auth-switch-btn.active {
  background: var(--dark);
  color: #ffffff;
}

.student-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--dark);
  color: #ffffff;
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 18px;
}

.student-bar-name {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
}

.student-bar-meta {
  font-size: 0.84rem;
  color: #cbd5e1;
  margin-top: 2px;
}

.exam-dashboard-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.exam-tile {
  background: var(--bg-white);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.exam-tile.is-open {
  border-color: var(--accent-border);
  box-shadow: var(--shadow-sm);
}

.exam-tile.is-done {
  background: #f8fffb;
  border-color: #a7f3d0;
}

.exam-tile.is-locked {
  background: var(--bg-surface);
  opacity: 0.78;
}

.exam-tile-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.exam-type-pill {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--bg-subtle);
  color: var(--dark);
}

.exam-type-pill.PRETEST { background: var(--navy-soft); color: var(--navy); }
.exam-type-pill.POSTTEST { background: var(--accent-soft); color: var(--accent); }

.exam-state-tag {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
}

.exam-state-tag.open { background: var(--success-soft); color: var(--success); }
.exam-state-tag.done { background: #059669; color: #ffffff; }
.exam-state-tag.locked { background: var(--bg-subtle); color: var(--text-muted); }

.exam-tile-title {
  font-family: var(--font-display);
  font-size: 0.96rem;
  font-weight: 700;
  color: var(--dark);
  margin-top: 6px;
}

.exam-tile-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.room-code-box {
  background: var(--accent-soft);
  border: 1.5px solid var(--accent-border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 18px;
}

/* Admin Sub-tabs & Gradebook */
.admin-subtabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}

.admin-subtab-btn {
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text-body);
  border: 1px solid var(--border);
}

.admin-subtab-btn.active {
  background: var(--dark);
  color: #ffffff;
  border-color: var(--dark);
}

.gradebook-table th,
.gradebook-table td {
  padding: 9px 10px;
  font-size: 0.82rem;
  text-align: center;
  white-space: nowrap;
}

.gradebook-table th:nth-child(1),
.gradebook-table td:nth-child(1),
.gradebook-table th:nth-child(2),
.gradebook-table td:nth-child(2) {
  text-align: left;
}

.cell-pass { color: var(--success); font-weight: 700; }
.cell-fail { color: var(--danger); font-weight: 700; }
.cell-empty { color: #cbd5e1; }

@media (max-width: 960px) {
  .exam-dashboard-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .exam-dashboard-grid {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   RESPONSIVE BREAKPOINTS (Tablet & Mobile)
   ========================================================================== */
@media (max-width: 1024px) {
  .nav-links {
    display: none;
  }
  .nav-toggle {
    display: inline-flex;
  }
  .hero-grid,
  .about-grid,
  .software-showcase,
  .contact-grid {
    grid-template-columns: 1fr;
  }
  .courses-grid,
  .projects-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .exam-workspace {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .section-pad {
    padding: 56px 0;
  }
  .brand-divider,
  .brand-text {
    display: none;
  }
  .courses-grid,
  .projects-grid,
  .sw-feature-grid,
  .form-grid,
  .report-score-hero {
    grid-template-columns: 1fr;
  }
  .live-exam-banner {
    flex-direction: column;
    align-items: flex-start;
  }
  .software-showcase {
    padding: 26px 20px;
  }
  .modal-header,
  .modal-body,
  .exam-tabs {
    padding-left: 16px;
    padding-right: 16px;
  }
  .course-footer {
    flex-direction: column;
    align-items: flex-start;
  }
  .course-actions {
    width: 100%;
  }
  .course-actions .btn {
    flex: 1;
  }
}

/* ==========================================================================
   PRINT STYLESHEET (ใบรายงานผลสอบ)
   ========================================================================== */
@media print {
  body * {
    visibility: hidden;
  }
  #printable-exam-report,
  #printable-exam-report * {
    visibility: visible;
  }
  #printable-exam-report {
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    border: 2px solid #0f172a;
    box-shadow: none;
    padding: 24px;
    background: #ffffff;
  }
  .no-print {
    display: none !important;
  }
}
