:root {
  color-scheme: light;
  --magenta: #e20074;
  --magenta-deep: #c00063;
  --magenta-pressed: #9e0051;
  --ink: #000000;
  --ink-soft: rgba(0,0,0,.65);
  --paper: #fbfbfb;
  --surface-subtle: #efeff0;
  --white: #ffffff;
  --line: #d0d0d0;
  --focus: #2238df;
  --mint: #008653;
  --yellow: #ac5600;
  --danger: #d91308;
  --shadow: 0 8px 32px rgba(0,0,0,.1), 0 4px 8px rgba(0,0,0,.1);
  --radius: 8px;
  font-family: "TeleNeoWeb", "TeleNeo", Arial, Helvetica, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: inherit;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font: inherit; }

button, a { -webkit-tap-highlight-color: transparent; }

button {
  border: 0;
  border-radius: 4px;
  background: var(--magenta);
  color: var(--white);
  cursor: pointer;
  font-weight: 700;
  padding: .82rem 1.25rem;
  transition: transform .18s ease, background .18s ease;
}

button:hover { background: var(--magenta-deep); box-shadow: none; }
button:active { background: var(--magenta-pressed); transform: translateY(1px); }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.button-secondary {
  background: var(--white);
  color: var(--ink);
  border: 1px solid var(--line);
}
.button-secondary:hover { background: var(--surface-subtle); box-shadow: none; }
.button-secondary:active { background: #dadae0; }

.eyebrow {
  color: var(--magenta);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .08em;
  margin: 0 0 .42rem;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(2rem, 3vw, 3.6rem); letter-spacing: -.015em; line-height: 1.05; margin-bottom: 0; }
h2 { font-size: clamp(1.75rem, 2.4vw, 2.7rem); letter-spacing: -.01em; line-height: 1.1; margin-bottom: .55rem; }
h3 { font-size: 1.22rem; letter-spacing: 0; margin-bottom: 0; }

.login-body {
  align-items: center;
  background:
    radial-gradient(circle at 15% 12%, rgba(226,0,116,.22), transparent 29rem),
    #000;
  display: flex;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
}

.login-body::after {
  color: rgba(255,255,255,.028);
  content: "LERN-BAR";
  font-size: min(20vw, 18rem);
  font-weight: 700;
  left: 50%;
  letter-spacing: -.02em;
  pointer-events: none;
  position: fixed;
  top: 50%;
  transform: translate(-50%, -50%) rotate(-8deg);
}

.login-card {
  background: var(--white);
  border-radius: 8px;
  box-shadow: 0 24px 96px rgba(0,0,0,.18), 0 12px 24px rgba(0,0,0,.18);
  max-width: 500px;
  padding: 3.1rem;
  position: relative;
  width: 100%;
  z-index: 1;
}

.brand-lockup, .admin-brand { align-items: center; display: flex; flex-direction: row; gap: 1rem; }
.brand-copy { display: flex; flex-direction: column; min-width: 0; }
.brand-logo { display: block; flex: 0 0 auto; height: 60px; width: 60px; }
.brand-kicker {
  color: var(--magenta);
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .08em;
  margin-bottom: .45rem;
}
.brand-lockup strong, .admin-brand strong {
  font-size: 1.75rem;
  letter-spacing: -.015em;
  line-height: 1.05;
}
.brand-lockup strong span, .admin-brand strong span { color: var(--magenta); }
.login-lead { color: var(--ink-soft); line-height: 1.6; margin: 1.4rem 0 1.8rem; }
.login-error {
  background: #fff0f5;
  border-left: 4px solid var(--danger);
  border-radius: 4px;
  color: #75102f;
  margin-bottom: 1.25rem;
  padding: .9rem 1rem;
}
.login-form { display: grid; gap: 1.05rem; }
.login-form label, .settings-card label, .editor-fields label {
  color: #3f3d42;
  display: grid;
  font-size: .78rem;
  font-weight: 700;
  gap: .45rem;
  letter-spacing: .02em;
}
.login-form input, .settings-card input, .settings-card textarea,
.editor-fields input, .editor-fields textarea, .editor-fields select {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink);
  min-height: 48px;
  padding: .78rem .9rem;
  width: 100%;
}
.login-form button { margin-top: .45rem; min-height: 50px; }
.login-meta { color: #99939a; font-size: .74rem; margin: 1.4rem 0 0; text-align: center; }

.admin-body { min-height: 100vh; }
.admin-sidebar {
  background: #000;
  bottom: 0;
  color: var(--white);
  display: flex;
  flex-direction: column;
  left: 0;
  padding: 2.2rem 1.35rem 1.35rem;
  position: fixed;
  top: 0;
  width: 250px;
  z-index: 20;
}
.admin-brand { align-items: flex-start; padding: 0 .65rem 2.4rem; }
.admin-brand .brand-logo { height: 48px; width: 48px; }
.admin-brand .brand-kicker { color: rgba(255,255,255,.65); font-size: .58rem; letter-spacing: .08em; }
.admin-brand strong { font-size: 1.55rem; }
.admin-sidebar nav { display: grid; gap: .45rem; }
.nav-item {
  align-items: center;
  background: transparent;
  border-radius: 4px;
  color: #c9c5c8;
  display: flex;
  font-size: .92rem;
  font-weight: 700;
  gap: .9rem;
  justify-content: flex-start;
  padding: .9rem .85rem;
  width: 100%;
}
.nav-item span {
  color: #706a6f;
  font-size: .68rem;
  letter-spacing: .08em;
}
.nav-item:hover { background: rgba(255,255,255,.06); box-shadow: none; color: #fff; }
.nav-item.is-active { background: var(--magenta); color: #fff; }
.nav-item.is-active:active { background: var(--magenta-pressed); }
.nav-item.is-active span { color: rgba(255,255,255,.72); }
.admin-user {
  border-top: 1px solid rgba(255,255,255,.12);
  display: grid;
  gap: .28rem;
  margin-top: auto;
  padding: 1.2rem .65rem .25rem;
}
.admin-user > span { color: #8e888d; font-size: .7rem; }
.admin-user strong { font-size: .9rem; }
.admin-user form { margin-top: .65rem; }
.admin-user button {
  background: transparent;
  color: #aaa4a8;
  font-size: .76rem;
  padding: 0;
}
.admin-user button:hover { box-shadow: none; color: #fff; }

.admin-main { margin-left: 250px; min-height: 100vh; padding: 0 clamp(1.2rem, 3.5vw, 4.5rem) 4rem; }
.admin-topbar {
  align-items: center;
  background: rgba(251,251,251,.94);
  backdrop-filter: blur(16px);
  display: flex;
  justify-content: space-between;
  padding: 2.7rem 0 1.9rem;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-actions { align-items: center; display: flex; gap: .75rem; }
.topbar-actions a {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink);
  font-size: .78rem;
  font-weight: 700;
  padding: .62rem .9rem;
  text-decoration: none;
}
.live-dot {
  align-items: center;
  background: #eaf8f2;
  border-radius: 999px;
  color: #137451;
  display: inline-flex;
  font-size: .72rem;
  font-weight: 700;
  gap: .45rem;
  padding: .6rem .8rem;
}
.live-dot::before { background: #20ad79; border-radius: 50%; content: ""; height: .48rem; width: .48rem; }

.admin-section { display: none; }
.admin-section.is-active { display: block; animation: section-in .28s ease both; }
@keyframes section-in { from { opacity: 0; transform: translateY(6px); } }

.report-filter, .section-intro {
  align-items: flex-end;
  display: flex;
  justify-content: space-between;
  margin: 1.4rem 0 1.35rem;
  gap: 1.5rem;
}
.report-filter h2, .section-intro h2 { margin-bottom: 0; }
.section-intro p:last-child { color: var(--ink-soft); margin-bottom: 0; }
.date-controls, .section-actions { align-items: flex-end; display: flex; gap: .6rem; }
.date-controls label { color: var(--ink-soft); display: grid; font-size: .68rem; font-weight: 700; gap: .3rem; }
.date-controls input {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 4px;
  min-height: 40px;
  padding: .45rem .65rem;
}
.date-controls button, .date-controls a {
  align-items: center;
  border-radius: 4px;
  display: inline-flex;
  font-size: .75rem;
  justify-content: center;
  min-height: 40px;
  padding: .5rem .8rem;
}
.date-controls a { background: #242426; color: #fff; font-weight: 700; text-decoration: none; }
.date-controls a:hover { background: #000; }

.metric-grid {
  display: grid;
  gap: .8rem;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: .8rem;
}
.metric-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-height: 146px;
  overflow: hidden;
  padding: 1.25rem;
  position: relative;
}
.metric-card.is-featured { background: var(--magenta); color: #fff; }
.metric-card::after {
  background: var(--accent, var(--magenta));
  border-radius: 50%;
  content: "";
  height: 76px;
  opacity: .1;
  position: absolute;
  right: -20px;
  top: -20px;
  width: 76px;
}
.metric-card span { color: var(--ink-soft); font-size: .72rem; font-weight: 700; }
.metric-card.is-featured span { color: rgba(255,255,255,.72); }
.metric-card strong { display: block; font-size: clamp(1.8rem, 3vw, 3rem); letter-spacing: -.02em; margin: .5rem 0 .2rem; }
.metric-card small { color: #8a8589; font-size: .7rem; }
.metric-card.is-featured small { color: rgba(255,255,255,.7); }

.report-layout {
  display: grid;
  gap: .8rem;
  grid-template-columns: minmax(0, 1.75fr) minmax(280px, .85fr);
  margin-bottom: .8rem;
}
.panel {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-width: 0;
  padding: 1.35rem;
}
.panel-head { align-items: flex-start; display: flex; justify-content: space-between; margin-bottom: 1.2rem; }
.panel-head > span { color: var(--ink-soft); font-size: .72rem; }
.table-panel { margin-bottom: .8rem; }
.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; min-width: 760px; width: 100%; }
th {
  border-bottom: 1px solid var(--line);
  color: #827d81;
  font-size: .66rem;
  letter-spacing: .09em;
  padding: .75rem .65rem;
  text-align: left;
  text-transform: uppercase;
}
td { border-bottom: 1px solid #eeebed; font-size: .79rem; padding: .86rem .65rem; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
.table-title { display: grid; gap: .16rem; }
.table-title strong { font-size: .84rem; }
.table-title span { color: var(--ink-soft); font-size: .68rem; }
.rate-bar { align-items: center; display: flex; gap: .5rem; min-width: 110px; }
.rate-bar i { background: #ece8eb; border-radius: 99px; display: block; height: 6px; overflow: hidden; width: 64px; }
.rate-bar i::after { background: var(--magenta); border-radius: inherit; content: ""; display: block; height: 100%; width: var(--rate); }

.trend-chart {
  align-items: end;
  display: grid;
  gap: clamp(3px, .55vw, 8px);
  grid-auto-columns: minmax(9px, 1fr);
  grid-auto-flow: column;
  height: 220px;
  padding: 1rem .25rem .25rem;
  position: relative;
}
.trend-chart::before {
  background: repeating-linear-gradient(to bottom, #ece9eb 0 1px, transparent 1px 52px);
  content: "";
  inset: 0;
  pointer-events: none;
  position: absolute;
}
.trend-day { align-items: center; display: flex; flex-direction: column; height: 100%; justify-content: flex-end; position: relative; }
.trend-day i {
  background: linear-gradient(to top, var(--magenta), #f06eaf);
  border-radius: 4px 4px 2px 2px;
  display: block;
  min-height: 3px;
  transition: height .35s ease;
  width: 72%;
}
.trend-day span { color: #918b90; font-size: .56rem; margin-top: .42rem; white-space: nowrap; }
.trend-day:hover::after {
  background: #1b191d;
  border-radius: 4px;
  bottom: calc(var(--height) + 1.8rem);
  color: #fff;
  content: attr(data-tip);
  font-size: .62rem;
  left: 50%;
  padding: .4rem .5rem;
  pointer-events: none;
  position: absolute;
  transform: translateX(-50%);
  white-space: nowrap;
  z-index: 3;
}
.category-chart { display: grid; gap: .85rem; }
.category-row { display: grid; gap: .38rem; }
.category-row header { align-items: center; display: flex; font-size: .74rem; justify-content: space-between; }
.category-row header strong { font-size: .77rem; }
.category-row header span { color: var(--ink-soft); }
.category-row > i { background: #eeeaec; border-radius: 99px; display: block; height: 10px; overflow: hidden; }
.category-row > i::after { background: var(--bar); border-radius: inherit; content: ""; display: block; height: 100%; width: var(--width); }

.rank-list, .session-list { display: grid; gap: .6rem; }
.rank-item, .session-item {
  align-items: center;
  background: var(--surface-subtle);
  border-radius: var(--radius);
  display: grid;
  gap: .65rem;
  grid-template-columns: 1fr auto;
  padding: .78rem .85rem;
}
.rank-item div, .session-item div { min-width: 0; }
.rank-item strong, .session-item strong { display: block; font-size: .76rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-item span, .session-item span { color: var(--ink-soft); display: block; font-size: .65rem; margin-top: .18rem; }
.accuracy {
  background: var(--tone);
  border-radius: 999px;
  color: #fff;
  font-size: .66rem;
  font-weight: 700;
  min-width: 48px;
  padding: .4rem .48rem;
  text-align: center;
}

.content-tree { display: grid; gap: .9rem; }
.content-category {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.category-head {
  align-items: center;
  display: grid;
  gap: 1rem;
  grid-template-columns: 8px 1fr auto;
  padding: 1.1rem 1.2rem;
}
.category-accent { align-self: stretch; background: var(--accent); border-radius: 99px; min-height: 50px; }
.category-copy strong { display: block; font-size: 1.03rem; }
.category-copy span { color: var(--ink-soft); display: block; font-size: .75rem; margin-top: .2rem; }
.category-tools, .module-tools { align-items: center; display: flex; gap: .4rem; }
.icon-button {
  background: var(--surface-subtle);
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--ink);
  font-size: .72rem;
  padding: .48rem .62rem;
}
.icon-button:hover { background: #dadae0; box-shadow: none; }
.module-list { border-top: 1px solid #ede9eb; display: grid; }
.module-row {
  align-items: center;
  border-bottom: 1px solid #f0edef;
  display: grid;
  gap: .9rem;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  padding: .8rem 1.2rem;
}
.module-row:last-child { border-bottom: 0; }
.module-index {
  align-items: center;
  background: #f4f1f3;
  border-radius: 4px;
  color: var(--magenta);
  display: flex;
  font-size: .69rem;
  font-weight: 700;
  height: 38px;
  justify-content: center;
}
.module-copy { min-width: 0; }
.module-copy strong { display: block; font-size: .84rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.module-copy span { color: var(--ink-soft); display: block; font-size: .68rem; margin-top: .17rem; }
.status-pill { border-radius: 999px; font-size: .61rem; font-weight: 700; padding: .3rem .48rem; }
.status-pill.is-live { background: #e7f7f1; color: #0c7350; }
.status-pill.is-draft { background: #f3ecef; color: #806b75; }
.empty-state { color: var(--ink-soft); padding: 2rem; text-align: center; }

.settings-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: grid;
  gap: 1.15rem;
  max-width: 820px;
  padding: 1.5rem;
}
.field-row { display: grid; gap: 1rem; grid-template-columns: repeat(2, minmax(0,1fr)); }
.settings-card > button { justify-self: start; }

.editor-dialog {
  background: transparent;
  border: 0;
  max-height: 92vh;
  max-width: 760px;
  padding: 0;
  width: calc(100% - 2rem);
}
.editor-dialog::backdrop { background: rgba(0,0,0,.5); backdrop-filter: blur(5px); }
.editor-shell { background: var(--white); border-radius: 12px; box-shadow: 0 24px 96px rgba(0,0,0,.1), 0 12px 24px rgba(0,0,0,.1); overflow: hidden; }
.editor-shell > header {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding: 1.25rem 1.4rem;
}
.editor-shell h2 { font-size: 1.55rem; margin: 0; }
.dialog-close { background: var(--surface-subtle); color: var(--ink); font-size: 1.4rem; height: 38px; padding: 0; width: 38px; }
.dialog-close:hover { background: #dadae0; box-shadow: none; }
.editor-fields {
  display: grid;
  gap: 1rem;
  max-height: calc(92vh - 160px);
  overflow-y: auto;
  padding: 1.35rem 1.4rem;
}
.editor-fields textarea { min-height: 100px; resize: vertical; }
.editor-fields .checkbox-label { align-items: center; display: flex; flex-direction: row; gap: .65rem; }
.editor-fields .checkbox-label input { min-height: 0; width: auto; }
.editor-shell > footer { border-top: 1px solid var(--line); display: flex; gap: .7rem; justify-content: flex-end; padding: 1rem 1.4rem; }
.option-editor { background: var(--surface-subtle); border-radius: var(--radius); display: grid; gap: .55rem; padding: .8rem; }
.option-editor-row { align-items: center; display: grid; gap: .5rem; grid-template-columns: auto 1fr auto; }
.option-editor-row input[type=checkbox] { min-height: 0; width: auto; }
.option-editor-row button { background: transparent; color: var(--danger); padding: .35rem; }

.toast-region { bottom: 1.2rem; display: grid; gap: .5rem; position: fixed; right: 1.2rem; z-index: 100; }
.toast {
  animation: toast-in .25s ease both;
  background: #18161a;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: #fff;
  font-size: .78rem;
  max-width: 340px;
  padding: .85rem 1rem;
}
.toast.is-error { background: #8d183a; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.loading-block { animation: pulse 1.15s ease-in-out infinite alternate; background: var(--surface-subtle); border-radius: var(--radius); height: 90px; }
@keyframes pulse { to { opacity: .45; } }

@media (max-width: 1100px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .report-layout { grid-template-columns: 1fr; }
}

@media (max-width: 780px) {
  .admin-sidebar {
    bottom: auto;
    flex-direction: row;
    height: 74px;
    padding: .8rem 1rem;
    position: fixed;
    width: 100%;
  }
  .admin-brand { justify-content: center; padding: 0; }
  .admin-brand .brand-logo { height: 40px; width: 40px; }
  .admin-brand .brand-kicker { display: none; }
  .admin-brand strong { font-size: 1.05rem; }
  .admin-sidebar nav { display: flex; gap: .25rem; margin-left: auto; }
  .nav-item { border-radius: 4px; font-size: 0; gap: 0; justify-content: center; padding: .7rem; width: 40px; }
  .nav-item span { font-size: .66rem; }
  .admin-user { display: none; }
  .admin-main { margin-left: 0; padding: 74px 1rem 3rem; }
  .admin-topbar { padding: 1.4rem 0 1.1rem; }
  .topbar-actions a { display: none; }
  .report-filter, .section-intro { align-items: stretch; flex-direction: column; }
  .date-controls { align-items: stretch; display: grid; grid-template-columns: 1fr 1fr; }
  .date-controls button, .date-controls a { align-self: end; }
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .field-row { grid-template-columns: 1fr; }
  .category-head { grid-template-columns: 6px 1fr; }
  .category-tools { grid-column: 2; }
  .module-row { grid-template-columns: 38px 1fr; }
  .module-tools { grid-column: 2; justify-content: flex-start; }
}

@media (max-width: 480px) {
  .login-body { padding: 1rem; }
  .login-card { border-radius: var(--radius); padding: 2rem 1.35rem; }
  .metric-grid { grid-template-columns: 1fr; }
  .metric-card { min-height: 120px; }
  .section-actions { align-items: stretch; flex-direction: column; }
}

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