﻿:root {
  color-scheme: light;
  --ink: #151515;
  --muted: #5b5b5b;
  --accent: #f25f4c;
  --accent-dark: #c53a2a;
  --surface: #ffffff;
  --surface-alt: #f4f1ed;
  --stroke: #d6d0c8;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
  --radius: 20px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at top left, #fff3d9, transparent 45%),
    radial-gradient(circle at 20% 80%, #ffd2c4, transparent 35%),
    linear-gradient(120deg, #f7f2ea, #fffaf0 40%, #f0f1ff 100%);
  min-height: 100vh;
}

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 20px 60px;
}

.hero {
  margin-bottom: 36px;
  position: relative;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.3em;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 12px;
}

.hero h1 {
  font-family: "DM Serif Display", "Times New Roman", serif;
  font-size: clamp(2.4rem, 4vw, 3.4rem);
  margin: 0 0 12px;
}

.subhead {
  max-width: 620px;
  color: var(--muted);
  margin: 0;
  font-size: 1.05rem;
}

.hero-actions {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  gap: 10px;
  align-items: center;
}

.button-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 600;
  text-decoration: none;
  color: inherit;
  border: 1px solid transparent;
}

.button-link.ghost {
  border: 1px solid var(--stroke);
  background: var(--surface);
  color: var(--ink);
}

.button-link.ghost:hover {
  background: var(--surface-alt);
}

.user-switch {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  color: var(--muted);
}

.user-switch label {
  margin: 0;
  font-size: 0.9rem;
}

.user-switch select {
  margin: 0;
  padding: 8px 12px;
  border-radius: 999px;
}

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

.stats-overview,
.stats-wide {
  grid-column: 1 / -1;
}

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

.stat-card {
  border: 1px solid var(--stroke);
  border-radius: 16px;
  padding: 14px;
  background: #fffdf8;
  display: grid;
  gap: 6px;
}

.stat-card .value {
  font-size: 1.4rem;
  font-weight: 700;
}

.stat-card .label {
  color: var(--muted);
  font-size: 0.9rem;
}

.due-bars,
.stats-list {
  display: grid;
  gap: 10px;
}

.due-row {
  display: grid;
  gap: 6px;
}

.due-row .meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  color: var(--muted);
}

.due-bar {
  height: 10px;
  border-radius: 999px;
  background: #f3efe9;
  overflow: hidden;
}

.due-bar span {
  display: block;
  height: 100%;
  background: var(--accent);
}

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

.data-table th,
.data-table td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--stroke);
}

.data-table th {
  color: var(--muted);
  font-weight: 600;
}

.data-table td:last-child,
.data-table th:last-child {
  text-align: right;
}

.stats-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--stroke);
  border-radius: 14px;
  background: #fff;
}

.stats-item strong {
  font-size: 1.1rem;
}

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

.panel {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow);
}

.panel h2 {
  margin-top: 0;
  margin-bottom: 16px;
  font-size: 1.4rem;
}

.create-header {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: 14px;
}

.inline-option {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.inline-option input[type="checkbox"] {
  width: 18px;
  height: 18px;
}

textarea,
input[type="text"],
input[type="search"],
select {
  width: 100%;
  margin-top: 8px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  font: inherit;
  background: #fbfbfb;
  transition: border 0.2s ease, box-shadow 0.2s ease;
}

textarea:focus,
input[type="text"]:focus,
input[type="search"]:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(242, 95, 76, 0.2);
}

input[type="file"] {
  width: 100%;
  margin-top: 8px;
  font: inherit;
}

.hint {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 400;
}

.image-preview {
  margin-top: 10px;
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: #fff;
}

.image-preview.is-hidden {
  display: none;
}

.inline-option.compact {
  margin-top: 8px;
  font-weight: 500;
}

.actions,
.study-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 10px;
}

.form-error {
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid #d64545;
  background: #fff1f1;
  color: #922b2b;
  font-size: 0.95rem;
}

#answer-input {
  flex: 1 1 220px;
  min-width: 180px;
}

.rating-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.rating-actions button {
  flex: 1 1 110px;
  box-shadow: none;
}

button {
  border: none;
  background: var(--accent);
  color: #fff;
  padding: 12px 18px;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  box-shadow: 0 10px 20px rgba(242, 95, 76, 0.25);
}

button:hover {
  transform: translateY(-1px);
  background: var(--accent-dark);
}

button:disabled {
  cursor: not-allowed;
  background: #c4c0ba;
  box-shadow: none;
  transform: none;
}

button.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--stroke);
  box-shadow: none;
}

button.ghost:hover {
  background: var(--surface-alt);
}

#toggle-answer.is-mc {
  padding: 14px 26px;
  font-size: 1rem;
  min-width: 220px;
  width: 100%;
}

.edit-dialog {
  border: 1px solid var(--stroke);
  border-radius: 18px;
  padding: 20px;
  width: min(520px, 92vw);
  box-shadow: var(--shadow);
}

.edit-dialog::backdrop {
  background: rgba(20, 20, 20, 0.5);
}

.edit-dialog h3 {
  margin-top: 0;
}

.card-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 14px 0 18px;
}

.card-tab {
  border: 1px solid var(--stroke);
  background: #fff;
  color: var(--ink);
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 600;
  box-shadow: none;
}

.card-tab:hover {
  background: var(--surface-alt);
  transform: none;
}

.card-tab.is-active {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 10px 20px rgba(242, 95, 76, 0.2);
}

.card-tab.is-active:hover {
  background: var(--accent-dark);
}

.card-form {
  display: none;
}

.card-form.is-active {
  display: block;
}

.card-form-wrapper {
  margin-top: 6px;
}

.mc-options {
  display: grid;
  gap: 10px;
  margin-bottom: 8px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.mc-config {
  display: grid;
  gap: 10px;
  margin-bottom: 8px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.mc-correct {
  display: grid;
  gap: 6px;
  margin-bottom: 8px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.mc-config label,
.mc-options label {
  margin-bottom: 6px;
}

.mc-correct label {
  font-weight: 500;
  margin-bottom: 0;
}

.mc-option-list {
  list-style: none;
  padding: 0;
  margin: 10px 0 0;
  display: grid;
  gap: 8px;
  text-align: left;
  width: min(420px, 100%);
}

.mc-option-list li {
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: #fff;
  cursor: pointer;
}

.mc-option-list li:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.mc-option-list li.is-selected {
  border-color: #3d79ff;
  background: #dce8ff;
  box-shadow: 0 0 0 2px rgba(61, 121, 255, 0.25);
}

.mc-option-list li.is-correct {
  border-color: #2f9d5a;
  background: #e7f7ee;
  font-weight: 700;
  box-shadow: 0 0 0 2px rgba(47, 157, 90, 0.25);
}

.mc-option-list li.is-wrong {
  border-color: #d64545;
  background: #ffe6e6;
  box-shadow: 0 0 0 2px rgba(214, 69, 69, 0.2);
}

.mc-option-list li.is-selected.is-correct {
  background: linear-gradient(90deg, #dce8ff 0%, #e7f7ee 100%);
}

.mc-option-list li.is-selected.is-wrong {
  background: linear-gradient(90deg, #dce8ff 0%, #ffe6e6 100%);
}

.edit-section {
  display: none;
}

.edit-section.is-active {
  display: block;
}

.edit-image-fields.is-hidden {
  display: none;
}

.study {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.study-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
}

.study-tools {
  display: grid;
  grid-template-columns: auto minmax(160px, 1fr) auto;
  align-items: center;
  gap: 10px;
}

#study-deck {
  border-radius: 999px;
  border: 1px solid var(--stroke);
  padding: 10px 14px;
  background: #fff;
  font: inherit;
  min-width: 160px;
  width: 100%;
}

.help {
  position: relative;
}

.help-button {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--stroke);
  background: #fff;
  color: var(--ink);
  font-weight: 700;
  box-shadow: none;
  padding: 0;
}

.help-panel {
  border: 1px dashed var(--stroke);
  border-radius: 14px;
  padding: 14px 16px;
  background: #fffdf8;
  color: var(--muted);
  display: grid;
  gap: 6px;
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  width: min(280px, 70vw);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 5;
}

.help-panel strong {
  color: var(--ink);
}

.help:hover .help-panel,
.help:focus-within .help-panel {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.study-card {
  min-height: 160px;
  border-radius: 18px;
  border: 1px dashed var(--stroke);
  display: grid;
  place-items: center;
  padding: 20px;
  text-align: center;
  font-size: 1.1rem;
  background: linear-gradient(135deg, #fff7eb, #ffffff);
  transition: border 0.2s ease;
}

.study-card.flip {
  animation: card-flip 0.26s ease;
  border-style: solid;
}

.study-card .placeholder {
  color: var(--muted);
}

.study-card .content {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 10px;
  padding: 6px;
  width: 100%;
}

.study-card .content p {
  white-space: pre-wrap;
}

@keyframes card-flip {
  0% {
    transform: rotateY(0);
  }
  50% {
    transform: rotateY(90deg);
  }
  100% {
    transform: rotateY(0);
  }
}

.study-image {
  margin-top: 12px;
  max-width: 100%;
  height: auto;
  max-height: 50vh;
  object-fit: contain;
  border-radius: 14px;
  border: 1px solid var(--stroke);
  background: #fff;
}

.deck {
  grid-column: auto;
}

.deck-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.deck-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.deck-create {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.deck-create input {
  min-width: 180px;
}

.deck-create button {
  white-space: nowrap;
}

.deck-detail {
  margin-top: 18px;
}

.deck-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.deck-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  position: relative;
}

.deck-actions button {
  box-shadow: none;
}

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

.deck-list {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.deck-item {
  border-radius: 16px;
  border: 1px solid var(--stroke);
  padding: 16px;
  background: #ffffff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
}

.deck-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.deck-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  background: #fff;
  border: 1px solid var(--stroke);
  border-radius: 12px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.14);
  padding: 6px;
  display: none;
  z-index: 5;
}

.deck-menu-trigger {
  border: 1px solid var(--stroke);
  background: #fff;
  color: inherit;
  border-radius: 10px;
  padding: 6px 10px;
  font: inherit;
  line-height: 1;
  cursor: pointer;
}

.deck-menu-trigger:hover {
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
}

.deck-menu.is-open {
  display: grid;
  gap: 4px;
}

.deck-menu button {
  border: none;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 8px 10px;
  border-radius: 8px;
  font: inherit;
  cursor: pointer;
}

.deck-menu button:hover {
  background: rgba(20, 24, 31, 0.06);
}

.deck-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.08);
}

.deck-item .title {
  font-weight: 600;
}

.deck-item .meta {
  color: var(--muted);
  font-size: 0.9rem;
}

.card {
  border-radius: 16px;
  border: 1px solid var(--stroke);
  padding: 16px;
  background: #ffffff;
  display: grid;
  gap: 8px;
  position: relative;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.08);
}

.card .move-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

.card .move-control span {
  font-size: 0.85rem;
  color: var(--muted);
}

.card .move-deck {
  border: 1px solid var(--stroke);
  border-radius: 10px;
  padding: 6px 10px;
  background: #fff;
  font: inherit;
}

.card .topic {
  font-size: 0.85rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.18em;
}

.type-badge {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--accent-dark);
}

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

.card strong,
.card .back {
  white-space: pre-wrap;
}

.card-image {
  width: 100%;
  height: auto;
  max-height: 260px;
  object-fit: contain;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: #fafafa;
}

.card .meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--muted);
}

.card button {
  padding: 8px 12px;
  font-size: 0.85rem;
  box-shadow: none;
}

.card button.ghost {
  border-radius: 10px;
}


.is-hidden {
  display: none;
}

@media (max-width: 900px) {
  .deck {
    grid-column: auto;
  }
}

@media (max-width: 700px) {
  .study-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .study-tools {
    width: 100%;
    grid-template-columns: 1fr;
  }

  .hero-actions {
    position: static;
    margin-top: 16px;
  }

  .help-panel {
    right: auto;
    left: 0;
  }

  .deck-detail-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 600px) {
  .page {
    padding: 24px 16px 40px;
  }

  .panel {
    padding: 20px;
  }

  .actions,
  .study-actions,
  .rating-actions,
  .deck-actions {
    width: 100%;
  }

  .study-actions button,
  .rating-actions button,
  .deck-actions button {
    flex: 1 1 100%;
  }

  #study-deck,
  #draw-card {
    width: 100%;
  }

  .deck-controls {
    width: 100%;
  }

  #search {
    width: 100%;
  }

  .card .actions {
    flex-direction: column;
    align-items: stretch;
  }

  .card button {
    width: 100%;
  }
}
