@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap");

:root {
  --bg: #0e1628;
  --bg-layer: radial-gradient(circle at 20% 20%, #1a2844 0, #0e1628 35%), radial-gradient(circle at 80% 0%, #1c2a48 0, #0e1628 35%), #0e1628;
  --panel: #131d33;
  --panel-2: #15213a;
  --input-bg: #0f1729;
  --text: #f6f8fb;
  --muted: #a8b6cf;
  --border: #22304b;
  --accent: #3b82f6;
  --accent-2: #f59e0b;
  --danger: #ef4444;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --header-bg: linear-gradient(135deg, rgba(59, 130, 246, 0.12), rgba(245, 158, 11, 0.12)), #101a2e;
  --button-bg: #1c2741;
  --field-bg: #111b2f;
  --canvas-bg: #0b1426;
  --share-bg: #0d1526;
  --loader-scrim: rgba(14, 22, 40, 0.7);
  --loader-ring: rgba(255, 255, 255, 0.14);
  --pill-bg: rgba(59, 130, 246, 0.18);
  --pill-color: #dfe8ff;
}

:root[data-theme="light"] {
  --bg: #f7f9fc;
  --bg-layer: linear-gradient(180deg, #f9fbff 0%, #eef2f9 100%);
  --panel: #ffffff;
  --panel-2: #f5f7fb;
  --input-bg: #ffffff;
  --text: #0f1729;
  --muted: #64748b;
  --border: #d9e2ec;
  --accent: #2563eb;
  --accent-2: #f59e0b;
  --danger: #e11d48;
  --shadow: 0 12px 32px rgba(15, 23, 42, 0.12);
  --header-bg: linear-gradient(135deg, rgba(59, 130, 246, 0.08), rgba(245, 158, 11, 0.08)), #ffffff;
  --button-bg: #eef2f9;
  --field-bg: #f7f9ff;
  --canvas-bg: #e8edf7;
  --share-bg: #f5f7fb;
  --loader-scrim: rgba(247, 249, 252, 0.85);
  --loader-ring: rgba(15, 23, 42, 0.12);
  --pill-bg: rgba(37, 99, 235, 0.12);
  --pill-color: #1e293b;
}

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

body {
  margin: 0;
  background: var(--bg-layer);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
  margin: 0;
}

p {
  margin: 0;
}

.app-shell {
  max-width: 1360px;
  margin: 0 auto;
  padding: 16px 12px 28px;
}

[data-page="index"] .app-shell,
[data-page="library"] .app-shell {
  max-width: 1360px;
  padding: 16px 12px 28px;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--header-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  position: static;
  z-index: 10;
  box-shadow: var(--shadow);
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  color: #0b0d17;
  font-weight: 800;
  display: grid;
  place-items: center;
  letter-spacing: 0.02em;
}

.logo-title {
  font-weight: 700;
  letter-spacing: 0.02em;
}

.logo-sub {
  color: var(--muted);
  font-size: 13px;
}

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

.theme-toggle {
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.theme-icon {
  display: inline-block;
  width: 20px;
  height: 20px;
  position: relative;
}

.theme-icon svg {
  width: 100%;
  height: 100%;
  display: block;
  stroke: currentColor;
}

.theme-icon.sun {
  color: var(--accent-2);
}

.theme-icon.moon {
  color: var(--accent);
}

.theme-toggle-animate .theme-icon {
  animation: spin-pop 0.32s ease;
}

@keyframes spin-pop {
  0% { transform: scale(0.8) rotate(-20deg); opacity: 0.6; }
  60% { transform: scale(1.1) rotate(10deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); }
}

.nav-actions a {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.nav-actions .active {
  border-color: rgba(59, 130, 246, 0.6);
  color: var(--accent);
}

.user-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 4px;
}

.user-meta .muted {
  font-size: 13px;
  color: var(--muted);
}

button,
.button-link,
.nav-actions a {
  border: 1px solid transparent;
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 600;
  background: var(--button-bg);
  color: var(--text);
  cursor: pointer;
  transition: transform 120ms ease, border 120ms ease, background 120ms ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.primary {
  background: #60a5fa;
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.danger-solid {
  background: linear-gradient(135deg, var(--danger), #ff6b6b);
  color: #ffffff;
  border-color: var(--danger);
}

.danger-solid:hover {
  color: #ffffff;
  border-color: var(--danger);
}

.warning-solid {
  background: linear-gradient(135deg, #f59e0b, #f97316);
  color: #ffffff;
  border-color: #f59e0b;
}

.warning-solid:hover {
  color: #ffffff;
  border-color: #f97316;
}

.ghost {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
}

button.danger {
  color: var(--danger);
  border-color: rgba(255, 77, 109, 0.4);
}

button.small,
.button-link.small,
.nav-actions a.small {
  padding: 7px 10px;
  font-size: 13px;
}

button.wide {
  width: 100%;
  padding: 12px;
}

button:hover {
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

.views {
  margin-top: 16px;
}

.view {
  display: block;
  animation: fadeIn 180ms ease;
}

.hero {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  align-items: stretch;
}

.hero-copy h1 {
  margin: 6px 0 10px;
  font-size: 30px;
  letter-spacing: -0.01em;
}

.hero-copy .lede {
  color: var(--muted);
  margin: 0 0 14px;
}

.cta-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 12px 0;
}

.chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--accent-2);
  font-weight: 600;
  font-size: 13px;
}

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

.library-actions {
  margin-top: auto;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
}

.danger-solid {
  background: linear-gradient(135deg, var(--danger), #ff6b6b);
  color: #ffffff;
  border-color: var(--danger);
}

.hero-card {
  background: radial-gradient(circle at 20% 20%, rgba(111, 63, 255, 0.12), transparent 50%),
              radial-gradient(circle at 80% 0%, rgba(77, 163, 255, 0.12), transparent 45%),
              var(--panel);
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  color: var(--muted);
}

.mini-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.mini-stat {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel-2);
}

.mini-value {
  font-weight: 700;
  font-size: 16px;
}

.mini-label {
  color: var(--muted);
  font-size: 13px;
}

.home-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.library-section {
  margin-top: 18px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  box-shadow: var(--shadow);
}

.library-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.library-actions-top {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.library-sort {
  display: flex;
  align-items: center;
  gap: 8px;
}

.library-sort select {
  background: var(--input-bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 10px;
}

.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
  margin-top: 10px;
  position: relative;
}

.library-grid.loading {
  position: relative;
  min-height: 140px;
}
.library-loader {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  gap: 8px;
  background: var(--loader-scrim);
  border-radius: 12px;
  z-index: 2;
  color: var(--muted);
  font-size: 13px;
}

.library-loader .spinner {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 4px solid var(--loader-ring);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}

.library-empty {
  padding: 28px;
  text-align: center;
  color: var(--muted);
  display: grid;
  gap: 12px;
  justify-items: center;
}

.library-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 100%;
}

.library-card.is-archived {
  opacity: 0.78;
}

.library-card img {
  width: 100%;
  height: 150px;
  object-fit: cover;
  background: var(--panel-2);
  display: block;
}

.library-card-content {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.library-title {
  font-weight: 700;
}

.chip-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.library-actions {
  margin-top: auto;
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  align-items: center;
  gap: 8px;
}

.library-actions .action-delete {
  justify-self: start;
}

.library-actions .action-play {
  justify-self: center;
}

.library-actions .action-archive {
  justify-self: start;
}

.library-actions .action-edit {
  justify-self: end;
}

.chip-archived {
  border-color: var(--accent);
  color: var(--accent);
}

.chip-archived svg {
  width: 14px;
  height: 14px;
}

.icon-button.action-archive:hover,
.icon-button.action-edit:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.icon-button {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  transition: transform 120ms ease, border 120ms ease, color 120ms ease;
  padding: 0;
}

.icon-button:hover {
  color: var(--danger);
  border-color: var(--danger);
  transform: translateY(-1px);
}

.icon-button.danger-solid {
  background: linear-gradient(135deg, var(--danger), #ff6b6b);
  color: #ffffff;
  border-color: var(--danger);
}

.icon-button.danger-solid:hover {
  color: #ffffff;
  border-color: var(--danger);
  transform: translateY(-1px);
}

.icon-button.danger-solid svg {
  stroke: currentColor;
}

.icon-button svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  display: block;
  pointer-events: none;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 16, 26, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.modal {
  width: min(420px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 10px;
}

.modal-wide {
  width: min(640px, 100%);
}

.modal h3 {
  margin: 0;
}

.modal p {
  margin: 0;
  color: var(--muted);
}

.modal-help-list {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  display: grid;
  gap: 4px;
  font-size: 13px;
}

.modal-format-example {
  margin: 0;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  overflow-x: auto;
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.modal-llm-block {
  display: grid;
  gap: 8px;
}

.modal-llm-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.modal-llm-prompt {
  max-height: 220px;
  overflow: auto;
}

.modal input[type="text"] {
  width: 100%;
}

.modal textarea {
  width: 100%;
  min-height: 260px;
  resize: vertical;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.auth-card {
  margin-top: 12px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.auth-form {
  display: grid;
  gap: 8px;
}

.auth-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.auth-fields {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1;
}

.auth-fields input {
  min-width: 220px;
}

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

.auth-card .view-header h2 {
  font-size: 24px;
}

.auth-card .view-header .lede {
  margin-top: 4px;
}

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

.lede {
  color: var(--muted);
  margin: 6px 0 0;
}

.list {
  list-style: none;
  padding-left: 0;
  margin: 10px 0;
  color: var(--muted);
}

.list li {
  margin-bottom: 6px;
  padding-left: 18px;
  position: relative;
}

.list li::before {
  content: "•";
  position: absolute;
  left: 0;
  color: var(--accent);
}

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

.view-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.view-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.search-input {
  min-width: 200px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--input-bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' viewBox='0 0 24 24' stroke='%23a8b6cf' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='7'%3E%3C/circle%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M16.5 16.5 21 21'/%3E%3C/svg%3E") no-repeat 10px center;
  padding-left: 34px;
  color: var(--text);
  height: 40px;
}

.builder-grid {
  display: grid;
  grid-template-columns: 1fr 3fr;
  gap: 16px;
  align-items: start;
}

.builder-grid #mcqCard {
  height: 100%;
}

.builder-grid #flashcardCard {
  height: 100%;
}

.player-grid {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(480px, 2.5fr);
  gap: 16px;
  align-items: start;
}

.player-grid > * {
  min-width: 0;
}

.player-grid.mcq-layout {
  grid-template-columns: 1fr;
}

.player-grid.mcq-layout .meta-card {
  grid-column: 1 / -1;
  max-width: 980px;
  width: 100%;
  margin: 0 auto;
}

.player-grid.mcq-layout .meta-row {
  align-items: center;
}

.player-grid.mcq-layout #playDescription,
.player-grid.mcq-layout .share-banner,
.player-grid.mcq-layout .answer-panel {
  display: none;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.load-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 8px 0 4px;
}

.load-row select {
  flex: 1;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--field-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
}

.field span {
  font-weight: 600;
}

.field .muted {
  margin: 0;
}

.banner-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
}

.banner-actions.solo {
  margin-top: 10px;
}

.banner-actions .icon-button {
  width: 34px;
  height: 34px;
}

.hidden-input {
  display: none;
}

input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
textarea,
select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
  font-size: 15px;
}

textarea {
  resize: vertical;
}

select {
  cursor: pointer;
}

.answer-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 10px 0 6px;
}

.play-status {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  margin: 12px 0;
  border: 1px solid rgba(77, 163, 255, 0.35);
  border-radius: 8px;
  background: rgba(77, 163, 255, 0.08);
  color: var(--text);
}

.play-status.is-error {
  border-color: rgba(255, 107, 107, 0.45);
  background: rgba(255, 107, 107, 0.08);
}

.play-status-title {
  font-weight: 700;
}

.play-status p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.play-status-spinner {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 3px solid var(--loader-ring);
  border-top-color: var(--accent);
}

.play-status.is-loading .play-status-spinner {
  animation: spin 0.9s linear infinite;
}

.play-status:not(.is-loading) .play-status-spinner {
  border-top-color: var(--loader-ring);
}

button:disabled,
.button-link[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.62;
  transform: none;
}

.play-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin: 14px 0 4px;
}

.play-actions {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.fill-area {
  display: flex;
  gap: 12px;
  align-items: center;
}

.fill-area input {
  flex: 1;
}

.input-error {
  border-color: rgba(255, 77, 109, 0.6) !important;
  box-shadow: 0 0 0 3px rgba(255, 77, 109, 0.18);
}

.file-input {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px dashed var(--border);
  background: var(--input-bg);
  cursor: pointer;
  width: fit-content;
}

.file-input input {
  display: none;
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.canvas-card {
  background: var(--panel-2);
}

.canvas-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.canvas {
  position: relative;
  min-height: 360px;
  max-height: 620px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--canvas-bg);
}

.canvas.disabled {
  opacity: 0.45;
  pointer-events: none;
}

.canvas img {
  width: 100%;
  max-height: 620px;
  height: auto;
  object-fit: contain;
  display: block;
}

.canvas-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  text-align: center;
  padding: 20px;
}

.overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.marker {
  position: absolute;
  width: clamp(18px, 3.2vw, 26px);
  height: clamp(18px, 3.2vw, 26px);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 12px;
  color: #0b0d17;
  background: linear-gradient(135deg, #f59e0b, #fbbf24);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.45);
  border: 2px solid rgba(12, 13, 18, 0.4);
  cursor: pointer;
  pointer-events: all;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.marker.builder {
  background: linear-gradient(135deg, #fbbf24, #fb7185);
  color: #0b0d17;
}

.marker.marker-unanswered {
  background: linear-gradient(135deg, #f59e0b, #fbbf24);
}

.marker:hover {
  transform: translate(-50%, -50%) scale(1.06);
  box-shadow: 0 16px 26px rgba(0, 0, 0, 0.45);
}

.marker.wrong {
  animation: shake 200ms ease 0s 2;
  background: linear-gradient(135deg, var(--danger), #ff8e8e);
}

.marker.marker-correct {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #052e16;
}

.marker.marker-skipped {
  background: linear-gradient(135deg, #ef4444, #b91c1c);
  color: #fff;
}

.marker.marker-deferred {
  background: linear-gradient(135deg, #facc15, #eab308);
  color: #0f172a;
}

.marker.correct {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #0b0d17;
  box-shadow: 0 0 0 8px rgba(34, 197, 94, 0.22);
}

.marker.active {
  box-shadow:
    0 0 0 6px #ff1493,
    0 0 0 12px #ffeb3b,
    0 14px 30px rgba(0, 0, 0, 0.55);
  border-color: #ffeb3b;
  transform: translate(-50%, -50%) scale(1.05);
}

@keyframes shake {
  0% { transform: translate(-50%, -50%); }
  25% { transform: translate(calc(-50% - 4px), -50%); }
  50% { transform: translate(calc(-50% + 4px), -50%); }
  75% { transform: translate(calc(-50% - 2px), -50%); }
  100% { transform: translate(-50%, -50%); }
}

.marker-card .muted {
  margin: 0;
}

.list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

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

.marker-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--panel-2);
}

.marker-id {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #fbbf24, #fb7185);
  display: grid;
  place-items: center;
  font-weight: 700;
  color: #0b0d17;
}

.marker-answer {
  color: var(--text);
  font-weight: 600;
}

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

.marker-actions button {
  padding: 6px 8px;
  font-size: 13px;
}

.mcq-composer {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.mcq-options {
  display: grid;
  gap: 8px;
}

.mcq-option-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--border);
  background: var(--panel-2);
  border-radius: 10px;
  padding: 8px 10px;
}

.mcq-option-input {
  width: 100%;
}

.mcq-radio {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.mcq-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: space-between;
}

.mcq-question-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

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

.mcq-row {
  border: 1px solid var(--border);
  background: var(--panel-2);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mcq-row-title {
  font-weight: 700;
}

.mcq-row-options {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.mcq-row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.flashcard-composer {
  display: grid;
  gap: 10px;
}

.flashcard-upload {
  display: grid;
  gap: 8px;
}

.flashcard-preview {
  border: 1px dashed var(--border);
  background: var(--panel-2);
  border-radius: 12px;
  min-height: 180px;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.flashcard-preview img {
  width: 100%;
  height: 240px;
  object-fit: contain;
  display: block;
  background: var(--canvas-bg);
}

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

.flashcard-row {
  border: 1px solid var(--border);
  background: var(--panel-2);
  border-radius: 12px;
  padding: 8px;
  display: grid;
  grid-template-columns: 140px 1fr auto;
  gap: 10px;
  align-items: center;
}

.flashcard-thumb {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--canvas-bg);
  display: grid;
  place-items: center;
  overflow: hidden;
  min-height: 100px;
}

.flashcard-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.flashcard-body {
  display: grid;
  gap: 4px;
}

.flashcard-title {
  font-weight: 700;
}

.flashcard-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

@media (max-width: 780px) {
  .flashcard-row {
    grid-template-columns: 1fr;
  }
  .flashcard-actions {
    justify-content: flex-start;
  }
}

.chip-correct {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #0b0d17;
}

.meta-card .meta-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.share-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--share-bg);
  margin: 12px 0 4px;
}

.share-link {
  font-family: "SFMono-Regular", Menlo, Consolas, monospace;
  color: #9fb2d3;
  font-size: 13px;
  word-break: break-all;
}

.share-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pill {
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--pill-bg);
  border: 1px solid var(--border);
  color: var(--pill-color);
  font-weight: 700;
}

.prompt {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
  background: rgba(77, 163, 255, 0.08);
  border-radius: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(77, 163, 255, 0.35);
  margin: 12px 0;
}

.player-grid.mcq-layout .prompt {
  grid-template-columns: 1fr;
  gap: 6px;
  margin: 14px 0 0;
  padding: 14px;
}

.prompt .label {
  color: var(--muted);
  font-weight: 600;
}

.prompt .value {
  display: block;
  font-size: 18px;
  font-weight: 700;
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  white-space: normal;
}

.player-grid.mcq-layout .prompt .value {
  font-size: 20px;
  line-height: 1.35;
}

.mcq-answer-panel {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.mcq-answer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.mcq-option-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 0;
}

.mcq-option-btn {
  justify-content: flex-start;
  text-align: left;
  min-height: 48px;
  white-space: normal;
  line-height: 1.35;
  padding: 12px 14px;
}

.mcq-option-btn.correct {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #0b0d17;
}

.mcq-option-btn.wrong {
  background: linear-gradient(135deg, var(--danger), #ff8e8e);
  color: #0b0d17;
}

.mcq-option-btn.selected {
  border-color: rgba(59, 130, 246, 0.8);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

.mcq-question {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 10px;
}

.summary {
  margin-top: 10px;
  color: var(--muted);
  min-height: 18px;
}

.stats-card {
  grid-column: 1 / -1;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
}

.stat-block {
  border: 1px solid var(--border);
  background: var(--panel-2);
  border-radius: 12px;
  padding: 12px;
}

.stats-grid.single {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.stat-label {
  text-transform: uppercase;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.stat-value {
  font-size: 24px;
  font-weight: 800;
}

.stat-sub {
  color: #cbd5e1;
  font-size: 13px;
}

.attempts-table-wrap {
  margin-top: 12px;
}

.attempt-controls {
  display: flex;
  gap: 12px;
  margin: 8px 0 6px;
  flex-wrap: wrap;
}

.attempt-controls label {
  font-size: 13px;
  color: var(--muted);
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.attempt-controls select {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 8px;
}

.attempts-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.attempts-table thead th {
  text-align: left;
  font-weight: 600;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
}

.attempts-table tbody td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
}

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

.attempts-table .score-ok {
  font-weight: 700;
}

.attempts-table .score-low {
  color: var(--danger);
  font-weight: 700;
}

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

.pill.danger {
  color: var(--danger);
}

.hidden {
  display: none !important;
}

/* Footer */
.site-footer {
  margin-top: 22px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 13px;
  text-align: center;
}

.site-footer a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.site-footer a:hover {
  text-decoration: underline;
}

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

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

  .site-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .nav-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .split {
    grid-template-columns: 1fr;
  }

  .builder-grid,
  .player-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1100px) {
  .site-header {
    padding: 10px 12px;
    gap: 10px;
  }

  .logo-title {
    font-size: 16px;
  }

  .nav-actions {
    width: 100%;
    justify-content: space-between;
  }

  .nav-actions a,
  .nav-actions button {
    padding: 8px 12px;
  }

  .canvas {
    min-height: 300px;
  }

  .mcq-option-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 12px 10px 24px;
  }

  .site-header {
    position: static;
    padding: 8px;
    border-radius: 8px;
    gap: 6px;
  }

  .logo {
    gap: 8px;
  }

  .logo-title {
    font-size: 15px;
  }

  .nav-actions {
    gap: 4px;
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .nav-actions .ghost,
  .nav-actions .primary,
  .nav-actions button {
    padding: 6px 9px;
    font-size: 12px;
  }

  .user-meta {
    display: inline-flex;
    width: 100%;
    justify-content: flex-end;
  }

  .user-meta .muted {
    display: none;
  }

  .library-actions {
    display: grid;
    grid-template-columns: auto auto auto 1fr;
    justify-content: stretch;
  }

  .library-actions .action-delete,
  .library-actions .action-archive,
  .library-actions .action-edit {
    justify-self: start;
  }

  .library-actions .action-play {
    grid-column: 4;
    justify-self: end;
  }

  .canvas {
    min-height: 240px;
  }

  .prompt {
    grid-template-columns: 1fr;
  }

  .meta-card .meta-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .share-banner {
    flex-direction: column;
    align-items: flex-start;
  }

  .play-actions {
    grid-template-columns: 1fr;
  }

  .player-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  body.quiz-playing:not(.quiz-type-mcq) #imagePlayCard {
    order: 1;
  }

  body.quiz-playing:not(.quiz-type-mcq) .meta-card {
    order: 2;
    width: 100vw;
    margin-left: -10px;
    margin-right: -10px;
    border-left: 0;
    border-right: 0;
    border-radius: 0;
  }

  body.quiz-playing.quiz-type-mcq .meta-card {
    order: 1;
  }

  body.quiz-playing .stats-card {
    order: 3;
  }

  body.quiz-playing .meta-card {
    padding: 10px;
  }

  body.quiz-playing .meta-card .meta-row,
  body.quiz-playing .meta-card .pills,
  body.quiz-playing .meta-card .eyebrow,
  body.quiz-playing #playTitle,
  body.quiz-playing #playDescription {
    display: none;
  }

  body.quiz-playing .mcq-answer-header .eyebrow {
    display: block;
  }

  body.quiz-playing .prompt {
    margin: 8px 0;
  }

  body.quiz-playing .prompt .value {
    max-width: calc(100vw - 68px);
    font-size: 16px;
    line-height: 1.35;
  }

  body.quiz-playing .answer-panel {
    margin: 10px 0 8px;
  }

  body.quiz-playing .fill-area {
    flex-direction: column;
    align-items: stretch;
  }

  body.quiz-playing .fill-area input,
  body.quiz-playing .fill-area button,
  body.quiz-playing .mcq-option-btn,
  body.quiz-playing #mcqSubmitBtn {
    width: 100%;
  }

  body.quiz-playing .mcq-answer-panel {
    margin-top: 10px;
  }

  body.quiz-playing .mcq-option-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  body.quiz-playing .mcq-option-btn {
    min-height: 52px;
    justify-content: flex-start;
  }

  body.quiz-playing .play-controls {
    grid-template-columns: 1fr;
    gap: 12px;
    margin: 14px 0 8px;
  }

  body.quiz-playing:not(.quiz-type-mcq) .prompt,
  body.quiz-playing:not(.quiz-type-mcq) .answer-panel,
  body.quiz-playing:not(.quiz-type-mcq) .play-controls,
  body.quiz-playing:not(.quiz-type-mcq) .play-actions {
    width: 100%;
  }
}
