:root {
  color-scheme: light;
  --ink: #172126;
  --muted: #66747c;
  --paper: #f7f4ec;
  --surface: #ffffff;
  --line: #dcd6ca;
  --teal: #1f8a83;
  --teal-dark: #166b67;
  --coral: #e56b4f;
  --gold: #d99b2b;
  --leaf: #5f8f3a;
  --blue: #3867a6;
  --shadow: 0 24px 70px rgba(29, 39, 46, 0.15);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(31, 138, 131, 0.12), transparent 38%),
    radial-gradient(circle at top right, rgba(229, 107, 79, 0.14), transparent 34%),
    var(--paper);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(18px);
  padding: 28px;
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 28px;
}

.brand-logo {
  display: block;
  width: 54px;
  height: 54px;
  object-fit: contain;
  border-radius: 8px;
}

.brand > div {
  display: flex;
  align-items: center;
  min-height: 54px;
}

.brand h1 {
  line-height: 1;
}

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

h1 {
  font-size: 1.35rem;
  line-height: 1.1;
}

.brand p,
.form-head p,
.field-hint,
small,
.card-sub,
.card-meta,
.eyebrow,
.panel-title-row span {
  color: var(--muted);
}

.brand p {
  margin-top: 5px;
  font-size: 0.9rem;
}

.panel,
.add-card,
.list-panel,
.quiz-panel,
.excel-panel {
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.panel {
  padding: 16px;
  margin-bottom: 16px;
}

.panel h2,
.add-card h2,
.list-panel h2 {
  font-size: 1rem;
}

.deck-select-label {
  margin-top: 12px;
}

.deck-list {
  margin-top: 0;
}

.deck-chip {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
  text-align: left;
  padding: 0 12px;
}

.deck-chip.active {
  border-color: rgba(31, 138, 131, 0.42);
  background: #edf6f5;
  color: var(--teal-dark);
}

.deck-form {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.deck-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.segmented {
  display: grid;
  gap: 6px;
  margin-top: 7px;
  padding: 5px;
  background: #ece5d7;
  border-radius: 8px;
}

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

.segment {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.segment.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 4px 14px rgba(29, 39, 46, 0.1);
}

.control-label {
  display: block;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 1.1rem;
}

.study-area {
  min-width: 0;
  padding: 30px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0;
  font-size: 0.78rem;
  font-weight: 800;
}

.topbar h2 {
  margin-top: 4px;
  font-size: clamp(1.8rem, 4vw, 3.1rem);
  line-height: 1;
}

.secondary-button,
.primary-button {
  border: 0;
  border-radius: 8px;
  font-weight: 800;
}

.secondary-button {
  min-height: 42px;
  padding: 0 18px;
  background: var(--ink);
  color: #fff;
}

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

.flashcard-wrap {
  min-width: 0;
}

.flashcard {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 100%;
  min-height: 390px;
  padding: 38px;
  border: 1px solid rgba(23, 33, 38, 0.08);
  border-radius: 8px;
  background:
    linear-gradient(145deg, rgba(31, 138, 131, 0.95), rgba(22, 107, 103, 0.98)),
    var(--teal);
  color: #fff;
  box-shadow: var(--shadow);
  text-align: left;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.flashcard:hover {
  transform: translateY(-2px);
  box-shadow: 0 30px 78px rgba(29, 39, 46, 0.2);
}

.card-label {
  position: absolute;
  top: 24px;
  left: 24px;
  padding: 7px 10px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 850;
}

.card-main {
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: clamp(3rem, 9vw, 6.8rem);
  font-weight: 900;
  line-height: 1.02;
}

.card-sub {
  margin-top: 20px;
  color: rgba(255, 255, 255, 0.84);
  font-size: 1.15rem;
  font-weight: 720;
}

.card-sub:empty,
.card-meta:empty {
  display: none;
}

.card-meta {
  margin-top: 10px;
  color: rgba(255, 255, 255, 0.72);
}

.card-actions {
  display: grid;
  grid-template-columns: minmax(180px, 320px);
  gap: 10px;
  margin-top: 12px;
}

.quiz-panel {
  margin-top: 22px;
  padding: 20px;
}

.quiz-panel h2 {
  font-size: 1.2rem;
}

.quiz-controls {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(240px, 1fr) auto;
  gap: 14px;
  align-items: end;
  margin-top: 16px;
}

.quiz-card {
  display: grid;
  gap: 12px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.quiz-label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

.quiz-card strong {
  overflow-wrap: anywhere;
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 1.05;
}

.quiz-answer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.quiz-feedback {
  min-height: 1.4em;
  color: var(--muted);
  line-height: 1.4;
}

.quiz-feedback.correct {
  color: var(--leaf);
  font-weight: 800;
}

.quiz-feedback.incorrect {
  color: var(--coral);
  font-weight: 800;
}

.quiz-mistakes {
  display: grid;
  gap: 10px;
  padding-top: 4px;
}

.quiz-mistakes h3 {
  font-size: 0.98rem;
}

.mistake-list {
  display: grid;
  gap: 8px;
}

.mistake-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid rgba(229, 107, 79, 0.3);
  border-radius: 8px;
  background: #fff8f6;
}

.mistake-row strong,
.mistake-row span,
.mistake-row small {
  display: block;
  overflow-wrap: anywhere;
}

.mistake-row span,
.mistake-row small {
  color: var(--muted);
}

.mistake-row small {
  font-weight: 800;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  gap: 22px;
  margin-top: 22px;
}

.excel-panel {
  margin-top: 22px;
  padding: 20px;
}

.excel-panel h2 {
  font-size: 1.2rem;
}

.excel-panel .panel-title-row span.success {
  color: var(--leaf);
  font-weight: 800;
}

.excel-panel .panel-title-row span.error {
  color: var(--coral);
  font-weight: 800;
}

.excel-grid {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(240px, 0.8fr);
  gap: 18px;
  margin-top: 16px;
}

.excel-tool {
  display: grid;
  gap: 13px;
  align-content: start;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.excel-tool h3 {
  font-size: 1rem;
}

.add-card,
.list-panel {
  padding: 20px;
}

.add-card {
  display: grid;
  gap: 13px;
  align-content: start;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
}

[hidden] {
  display: none !important;
}

input:focus,
select:focus,
button:focus-visible {
  outline: 3px solid rgba(31, 138, 131, 0.28);
  outline-offset: 2px;
}

.primary-button {
  min-height: 48px;
  margin-top: 3px;
  background: var(--teal);
  color: #fff;
}

.primary-button.compact {
  min-height: 42px;
}

.field-hint {
  margin-top: -7px;
  font-size: 0.82rem;
  line-height: 1.35;
}

.form-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.secondary-form-button {
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.secondary-form-button.danger:hover {
  border-color: rgba(229, 107, 79, 0.5);
  color: var(--coral);
}

.card-list {
  display: grid;
  gap: 10px;
  max-height: 360px;
  margin-top: 15px;
  overflow: auto;
  padding-right: 4px;
}

.vocab-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.custom-card {
  border-color: rgba(31, 138, 131, 0.36);
  background: #fbfefd;
}

.vocab-row strong,
.vocab-row span {
  display: block;
  overflow-wrap: anywhere;
}

.vocab-row strong {
  font-size: 1.05rem;
}

.vocab-row span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.9rem;
}

.row-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.tag {
  padding: 6px 9px;
  border-radius: 999px;
  background: #edf6f5;
  color: var(--teal-dark);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.row-button {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 850;
}

.row-button:hover {
  border-color: rgba(31, 138, 131, 0.42);
  color: var(--teal-dark);
}

.row-button.danger:hover {
  border-color: rgba(229, 107, 79, 0.5);
  color: var(--coral);
}

@media (max-width: 980px) {
  .app-shell,
  .hero-grid,
  .workspace,
  .quiz-controls,
  .excel-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .flashcard {
    min-height: 320px;
  }
}

@media (max-width: 640px) {
  .sidebar,
  .study-area {
    padding: 18px;
  }

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

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

  .flashcard {
    min-height: 280px;
    padding: 28px 22px;
  }
}
