/* Genius 9 shared study UI layer */
:root {
  --study-bg: #070b14;
  --study-bg-soft: #0d1425;
  --study-surface: rgba(17, 27, 46, 0.9);
  --study-surface-strong: rgba(22, 35, 59, 0.96);
  --study-paper: #ffffff;
  --study-paper-soft: #f7fafc;
  --study-border: rgba(226, 232, 240, 0.12);
  --study-text: #edf2f7;
  --study-ink: #142033;
  --study-muted: #a9b6c8;
  --study-muted-dark: #526173;
  --study-accent: #d4942f;
  --study-accent-2: #e8b84f;
  --study-blue: #2f73d8;
  --study-green: #1f9d76;
  --study-danger: #d94d4d;
  --study-radius: 18px;
  --study-shadow: 0 18px 50px rgba(2, 8, 23, 0.16);
}

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

body {
  font-family: 'Noto Sans Thai', 'Sarabun', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
  overflow-x: hidden;
}

body.study-enhanced {
  padding-bottom: 84px;
}

.study-progress {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 9999;
  width: 100%;
  height: 4px;
  background: rgba(148, 163, 184, 0.18);
  pointer-events: none;
}

.study-progress__bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--study-accent), var(--study-green), var(--study-blue));
  box-shadow: 0 0 18px rgba(212, 148, 47, 0.35);
  transition: width 0.12s linear;
}

.study-floating-nav {
  position: fixed;
  left: 22px;
  bottom: 22px;
  z-index: 9998;
  display: flex;
  gap: 10px;
  align-items: center;
}

.study-fab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 11px 16px;
  border-radius: 999px;
  border: 1px solid rgba(212, 148, 47, 0.34);
  background: rgba(7, 11, 20, 0.88);
  color: #f8fafc !important;
  text-decoration: none !important;
  font-weight: 800;
  font-size: 0.88rem;
  line-height: 1;
  box-shadow: 0 14px 38px rgba(2, 8, 23, 0.34);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.study-fab:hover,
.study-fab:focus-visible {
  transform: translateY(-2px);
  border-color: rgba(232, 184, 79, 0.72);
  background: rgba(13, 20, 37, 0.96);
  outline: none;
}

.study-fab--top {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 46px;
  padding: 0;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
}

.study-fab--top.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

body.has-existing-bottom-right .study-fab--top {
  bottom: 86px;
}

.study-cockpit {
  position: relative;
  z-index: 2;
  max-width: 1080px;
  margin: 0 auto 6px;
  padding: 0 20px;
}

.study-cockpit__panel {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 16px;
  border: 1px solid rgba(226, 232, 240, 0.11);
  border-radius: 22px;
  background: linear-gradient(135deg, rgba(17, 27, 46, 0.9), rgba(13, 20, 37, 0.74));
  box-shadow: 0 18px 50px rgba(2, 8, 23, 0.22);
}

.study-search {
  position: relative;
  display: flex;
  align-items: center;
}

.study-search__icon {
  position: absolute;
  left: 16px;
  color: var(--study-accent-2);
  font-size: 1rem;
  pointer-events: none;
}

.study-search input {
  width: 100%;
  min-height: 48px;
  padding: 12px 16px 12px 44px;
  border: 1px solid rgba(226, 232, 240, 0.12);
  border-radius: 16px;
  background: rgba(7, 11, 20, 0.62);
  color: #f8fafc;
  font: inherit;
  font-size: 0.98rem;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.study-search input::placeholder {
  color: rgba(226, 232, 240, 0.56);
}

.study-search input:focus {
  border-color: rgba(232, 184, 79, 0.72);
  box-shadow: 0 0 0 4px rgba(212, 148, 47, 0.12);
}

.study-cockpit__meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.study-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(226, 232, 240, 0.1);
  background: rgba(255, 255, 255, 0.045);
  color: #dbeafe;
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
}

.study-chip strong {
  color: var(--study-accent-2);
  font-size: 1rem;
}

.study-empty-state {
  grid-column: 1 / -1;
  display: none;
  padding: 26px;
  border: 1px dashed rgba(232, 184, 79, 0.32);
  border-radius: 20px;
  color: var(--study-muted);
  text-align: center;
  background: rgba(212, 148, 47, 0.06);
}

.study-empty-state.is-visible {
  display: block;
}

.grid .card,
.card {
  will-change: transform;
}

.grid .card:focus-within,
.grid .card:hover {
  outline: 1px solid rgba(232, 184, 79, 0.24);
}

.grid .card .card-link {
  min-height: 40px;
}

.header,
.hero {
  position: relative;
}

.header::after,
.hero::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: 0;
  width: min(720px, 86vw);
  height: 1px;
  transform: translateX(-50%);
  background: linear-gradient(90deg, transparent, rgba(212, 148, 47, 0.38), transparent);
  opacity: 0.75;
}

.quiz-area,
.container,
.content,
main,
article {
  max-width: min(980px, calc(100vw - 28px));
}

.question-card,
.result-panel {
  border-radius: var(--study-radius) !important;
  box-shadow: var(--study-shadow) !important;
}

.q-text,
.question,
.question-text {
  font-size: clamp(1rem, 1.4vw, 1.08rem) !important;
  line-height: 1.82 !important;
}

.q-scenario,
.explanation,
.note,
.tip,
.warning {
  line-height: 1.78 !important;
}

.option {
  min-height: 48px;
  border-radius: 14px !important;
}

.option:hover:not(.disabled) {
  transform: translateY(-1px);
}

.controls {
  gap: 10px !important;
}

.controls select,
.controls button,
.nav-btn,
.submit-btn,
button,
.button,
a.btn {
  min-height: 42px;
  font-family: inherit !important;
}

.score-display {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(47, 115, 216, 0.08);
}

p, li, td, th {
  line-height: 1.78;
}

h1, h2, h3 {
  text-wrap: balance;
}

h2, h3 {
  scroll-margin-top: 82px;
}

table {
  border-collapse: collapse;
}

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  margin: 16px 0;
}

.table-wrap table {
  margin: 0 !important;
  min-width: 520px;
}

.study-shortcuts {
  position: fixed;
  right: 22px;
  top: 18px;
  z-index: 9997;
  display: inline-flex;
  gap: 6px;
  align-items: center;
  padding: 7px 10px;
  border: 1px solid rgba(226, 232, 240, 0.12);
  border-radius: 999px;
  background: rgba(7, 11, 20, 0.76);
  color: rgba(248, 250, 252, 0.72);
  font-size: 0.74rem;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.study-shortcuts kbd {
  min-width: 20px;
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid rgba(226, 232, 240, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-family: inherit;
  font-weight: 800;
  text-align: center;
}

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

@media (max-width: 700px) {
  body.study-enhanced {
    padding-bottom: 78px;
  }

  .study-cockpit {
    padding: 0 12px;
  }

  .study-cockpit__panel {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 12px;
    border-radius: 18px;
  }

  .study-cockpit__meta {
    justify-content: flex-start;
    gap: 8px;
  }

  .study-chip {
    min-height: 34px;
    font-size: 0.76rem;
  }

  .filter-bar {
    position: sticky;
    top: 4px;
    overflow-x: auto;
    flex-wrap: nowrap !important;
    justify-content: flex-start !important;
    -webkit-overflow-scrolling: touch;
  }

  .filter-btn {
    flex: 0 0 auto;
    min-height: 38px;
  }

  .controls {
    position: sticky;
    top: 4px;
    z-index: 50;
    align-items: stretch !important;
  }

  .controls select,
  .controls button {
    flex: 1 1 150px;
    width: auto;
  }

  .controls .score-display,
  .score-display {
    flex: 1 0 100%;
    margin-left: 0 !important;
    text-align: center;
  }

  .question-card,
  .result-panel {
    padding: 18px !important;
    margin-bottom: 16px !important;
  }

  .option {
    padding: 13px 14px !important;
  }

  .study-floating-nav {
    left: 12px;
    bottom: 12px;
  }

  .study-fab {
    min-height: 42px;
    padding: 10px 13px;
    font-size: 0.78rem;
  }

  .study-fab--top {
    right: 12px;
    bottom: 12px;
    width: 42px;
  }

  body.has-existing-bottom-right .study-fab--top {
    bottom: 72px;
  }

  .study-shortcuts {
    display: none;
  }
}
