:root {
  --ink: #17202a;
  --muted: #657486;
  --line: #d9e1ea;
  --panel: #ffffff;
  --soft: #f4f7fb;
  --brand: #146c5c;
  --brand-strong: #0f5448;
  --gold: #c47a1b;
  --rose: #b8324b;
  --blue: #2764b5;
  --shadow: 0 16px 40px rgba(23, 32, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--soft);
}

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

button {
  border: 0;
  cursor: pointer;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  background: #10251f;
  color: white;
  padding: 24px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: grid;
  gap: 4px;
  margin-bottom: 28px;
}

.brand strong {
  font-size: 23px;
  letter-spacing: 0;
}

.brand span,
.sidebar-note {
  color: rgba(255, 255, 255, 0.68);
  line-height: 1.5;
}

.role-tabs {
  display: grid;
  gap: 8px;
}

.role-tab {
  width: 100%;
  color: rgba(255, 255, 255, 0.74);
  background: transparent;
  border-radius: 8px;
  padding: 11px 12px;
  text-align: left;
}

.role-tab.active {
  color: white;
  background: rgba(255, 255, 255, 0.14);
}

.logout-tab {
  margin-top: 8px;
}

.sidebar-note {
  margin-top: 28px;
  font-size: 13px;
}

.main {
  padding: 28px;
}

.public-quiz-shell {
  min-height: 100vh;
  padding: 32px 18px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  background:
    linear-gradient(180deg, rgba(16, 37, 31, 0.96) 0, rgba(16, 37, 31, 0.96) 220px, transparent 220px),
    var(--soft);
}

.public-quiz-main {
  width: min(100%, 880px);
}

.public-quiz-shell .topbar .actions {
  display: none;
}

.public-quiz-card {
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.public-quiz-body {
  padding: 22px;
  display: grid;
  gap: 18px;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(320px, 1.1fr);
}

.auth-copy {
  color: white;
  background: #10251f;
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
}

.auth-copy h1 {
  font-size: 48px;
  margin-bottom: 0;
}

.auth-copy .lead {
  color: rgba(255, 255, 255, 0.78);
}

.auth-panel {
  align-self: center;
  justify-self: center;
  width: min(560px, calc(100% - 36px));
}

.auth-title {
  font-size: 28px;
  font-weight: 850;
  margin-bottom: 6px;
}

.auth-subtitle {
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 18px;
}

.auth-links {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.text-button {
  width: fit-content;
  padding: 0;
  color: var(--brand);
  background: transparent;
  font-weight: 750;
  text-align: left;
}

.text-button:hover {
  color: var(--brand-strong);
  text-decoration: underline;
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 18px;
}

.auth-tab {
  min-height: 38px;
  border-radius: 7px;
  color: var(--ink);
  background: #e9eef4;
  font-weight: 750;
}

.auth-tab.active {
  color: white;
  background: var(--brand);
}

.auth-hint {
  margin-top: 12px;
  margin-bottom: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 22px;
}

.publish-hero {
  background: #10251f;
  color: white;
  padding: 28px;
  border-radius: 8px;
  margin-bottom: 18px;
}

.public-quiz-card .publish-hero {
  border-radius: 0;
  margin-bottom: 0;
}

.publish-hero.compact {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  padding: 24px;
}

.publish-hero .eyebrow {
  color: #94d8c3;
}

.publish-hero h1 {
  font-size: 42px;
  margin-bottom: 8px;
}

.publish-hero.compact h1 {
  max-width: 560px;
  font-size: 32px;
  line-height: 1.12;
}

.publish-hero p {
  color: rgba(255, 255, 255, 0.78);
  margin-bottom: 0;
}

.publish-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.publish-badges span {
  color: #e9fff8;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  padding: 7px 10px;
  font-size: 13px;
  font-weight: 800;
}

.public-quiz-meta {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.public-quiz-meta div {
  min-width: 0;
  padding: 12px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fbfcfe;
}

.public-quiz-meta div:nth-child(3n) {
  border-right: 0;
}

.public-quiz-meta div:nth-last-child(-n + 3) {
  border-bottom: 0;
}

.public-quiz-meta span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  margin-bottom: 4px;
}

.public-quiz-meta strong {
  display: block;
  overflow-wrap: anywhere;
}

.countdown-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfd;
  padding: 16px;
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}

.countdown-box span {
  color: var(--muted);
  font-weight: 750;
}

.countdown-box strong {
  font-size: 28px;
}

.eyebrow {
  color: var(--brand);
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 6px;
  font-size: 31px;
  letter-spacing: 0;
}

h2 {
  font-size: 20px;
  margin-bottom: 14px;
}

h3 {
  font-size: 16px;
  margin-bottom: 10px;
}

.lead {
  color: var(--muted);
  line-height: 1.55;
  max-width: 760px;
}

.grid {
  display: grid;
  gap: 18px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.panel,
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
}

.card {
  padding: 14px;
}

.metric {
  display: grid;
  gap: 4px;
}

.metric strong {
  font-size: 30px;
}

.metric span {
  color: var(--muted);
}

.form {
  display: grid;
  gap: 10px;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
  color: var(--ink);
  padding: 10px 11px;
  outline: none;
}

textarea {
  resize: vertical;
  min-height: 76px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(20, 108, 92, 0.13);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  align-items: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 39px;
  border-radius: 7px;
  padding: 9px 12px;
  color: white;
  background: var(--brand);
  font-weight: 750;
}

.btn:hover {
  background: var(--brand-strong);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.btn.secondary {
  color: var(--ink);
  background: #e9eef4;
}

.btn.secondary:hover {
  background: #dfe7ef;
}

.btn.warn {
  background: var(--gold);
}

.btn.danger {
  background: var(--rose);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 11px 9px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 750;
  color: #0f5448;
  background: #dff3eb;
}

.pill.blue {
  color: #184981;
  background: #e1edfb;
}

.pill.gold {
  color: #87510d;
  background: #fff0d6;
}

.pill.rose {
  color: #94283c;
  background: #ffe3e9;
}

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

.muted {
  color: var(--muted);
}

.split-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}

.qr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
}

.qr-card {
  border: 1px dashed #9fb0c1;
  border-radius: 8px;
  background: #fff;
  padding: 13px;
  display: grid;
  grid-template-columns: 74px 1fr;
  gap: 12px;
  align-items: center;
}

.qr-art {
  width: 74px;
  height: 74px;
  border: 7px solid #111;
  background:
    linear-gradient(90deg, #111 50%, transparent 50%) 0 0 / 14px 14px,
    linear-gradient(#111 50%, transparent 50%) 0 0 / 14px 14px,
    #fff;
}

.qr-image {
  width: 86px;
  height: 86px;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px;
}

.scanner-box {
  display: grid;
  gap: 10px;
}

.scanner-video {
  width: 100%;
  aspect-ratio: 16 / 10;
  background: #111;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: cover;
}

.scanner-status {
  border-left: 4px solid var(--blue);
  background: #eef5ff;
  color: #184981;
  border-radius: 7px;
  padding: 10px 12px;
  line-height: 1.45;
}

.scanner-status[data-tone="success"] {
  border-left-color: var(--brand);
  background: #edf8f4;
  color: #123d35;
}

.scanner-status[data-tone="warn"] {
  border-left-color: var(--gold);
  background: #fff7e8;
  color: #87510d;
}

.scanner-status[data-tone="error"] {
  border-left-color: var(--rose);
  background: #fff0f3;
  color: #94283c;
}

.mono {
  font-family: "SFMono-Regular", Consolas, monospace;
  word-break: break-all;
}

.notice {
  border-left: 4px solid var(--brand);
  background: #edf8f4;
  padding: 12px 13px;
  border-radius: 7px;
  color: #123d35;
}

.quiz-option {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.quiz-option input {
  width: auto;
  margin-top: 4px;
}

.question-builder {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfd;
  padding: 14px;
  display: grid;
  gap: 12px;
}

.answer-grid {
  display: grid;
  gap: 10px;
}

.answer-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
}

.correct-choice {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  white-space: nowrap;
}

.correct-choice input {
  width: auto;
}

.btn.compact {
  min-height: 36px;
  padding: 7px 10px;
}

.publish-link {
  margin-top: 8px;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
}

.quiz-row {
  align-items: flex-start;
}

.result-box {
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 14px;
  background: #fff;
}

.hidden {
  display: none !important;
}

@media (max-width: 900px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .auth-shell {
    grid-template-columns: 1fr;
  }

  .auth-copy {
    padding: 30px 22px;
  }

  .auth-copy h1 {
    font-size: 36px;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .role-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .role-tab {
    text-align: center;
  }

  .grid.two,
  .grid.three {
    grid-template-columns: 1fr;
  }

  .public-quiz-shell {
    padding: 18px 12px;
    background:
      linear-gradient(180deg, rgba(16, 37, 31, 0.96) 0, rgba(16, 37, 31, 0.96) 180px, transparent 180px),
      var(--soft);
  }

  .publish-hero.compact {
    display: grid;
  }

  .publish-hero.compact h1 {
    font-size: 28px;
  }

  .publish-badges {
    justify-content: flex-start;
  }

  .public-quiz-body {
    padding: 16px;
  }

  .public-quiz-meta {
    grid-template-columns: 1fr;
  }

  .public-quiz-meta div,
  .public-quiz-meta div:nth-child(3n),
  .public-quiz-meta div:nth-last-child(-n + 3) {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .public-quiz-meta div:last-child {
    border-bottom: 0;
  }

  .topbar {
    display: grid;
  }
}

@media print {
  body {
    background: white;
  }

  .sidebar,
  .topbar,
  .no-print,
  form,
  .panel:not(.printable) {
    display: none !important;
  }

  .shell,
  .main {
    display: block;
    padding: 0;
  }

  .panel,
  .card,
  .qr-card {
    box-shadow: none;
  }
}
