:root {
  --ink: #1f1a17;
  --muted: #6b5f56;
  --paper: #f5ecde;
  --paper-strong: #fff7ec;
  --panel: rgba(255, 248, 238, 0.72);
  --panel-border: rgba(95, 73, 52, 0.18);
  --accent: #bc5b31;
  --accent-dark: #8d3917;
  --teal: #176b6b;
  --shadow: 0 24px 80px rgba(83, 56, 39, 0.18);
}

* {
  box-sizing: border-box;
}

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

body {
  position: relative;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(188, 91, 49, 0.18), transparent 30%),
    radial-gradient(circle at top right, rgba(23, 107, 107, 0.16), transparent 28%),
    linear-gradient(180deg, #f3e3d1 0%, #efe7da 45%, #eadfce 100%);
  font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.08)),
    repeating-linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.04) 0,
      rgba(255, 255, 255, 0.04) 1px,
      transparent 1px,
      transparent 24px
    );
  mix-blend-mode: soft-light;
}

.shell {
  position: relative;
  max-width: 1120px;
  margin: 0 auto;
  padding: 48px 24px 72px;
}

.hero {
  animation: rise 500ms ease-out both;
}

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

.language-bar {
  width: min(100%, 360px);
}

.eyebrow,
.panel-kicker,
.panel-field,
.card-label {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  color: var(--muted);
}

.hero h1,
.panel-header h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
}

.hero h1 {
  max-width: 10ch;
  font-size: clamp(3rem, 7vw, 5.8rem);
  line-height: 0.92;
}

.subtitle {
  max-width: 46rem;
  margin: 20px 0 0;
  font-size: 1.12rem;
  line-height: 1.7;
  color: var(--muted);
}

.mobile-copy {
  display: none;
}

.keycap {
  display: inline-block;
  padding: 0.12rem 0.45rem;
  border: 1px solid rgba(31, 26, 23, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.66);
  font-family: "Courier New", Courier, monospace;
  font-size: 0.92em;
}

.panel {
  border: 1px solid var(--panel-border);
  border-radius: 28px;
  background: var(--panel);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.advanced-panel {
  margin-top: 14px;
  border-top: 1px solid rgba(95, 73, 52, 0.12);
  padding-top: 12px;
}

.advanced-toggle {
  cursor: pointer;
  list-style: none;
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.advanced-toggle::-webkit-details-marker {
  display: none;
}

.advanced-toggle::before {
  content: "+";
  display: inline-block;
  margin-right: 0.45rem;
  font-weight: 700;
}

.advanced-panel[open] .advanced-toggle::before {
  content: "-";
}

.advanced-controls {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}

.status-field {
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.status-input {
  width: 100%;
  border: 1px solid rgba(95, 73, 52, 0.18);
  border-radius: 12px;
  padding: 0.65rem 0.75rem;
  background: rgba(255, 255, 255, 0.66);
  font: inherit;
  color: var(--ink);
}

.status-input:focus {
  outline: 2px solid rgba(188, 91, 49, 0.25);
  outline-offset: 2px;
}

.mini-button {
  justify-self: start;
  padding: 0.45rem 0.85rem;
  font-size: 0.92rem;
}

.status-hint {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 0.78fr);
  gap: 22px;
  margin-top: 28px;
}

.panel {
  min-height: 660px;
  padding: 22px;
  animation: rise 520ms ease-out both;
}

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

.panel-heading {
  max-width: 420px;
}

.panel-field {
  display: block;
  margin-top: 14px;
}

.panel-select {
  width: 100%;
  margin-top: 8px;
  border: 1px solid rgba(95, 73, 52, 0.18);
  border-radius: 16px;
  padding: 0.85rem 0.9rem;
  background: rgba(255, 255, 255, 0.7);
  font: inherit;
  color: var(--ink);
}

.panel-select:focus {
  outline: 2px solid rgba(188, 91, 49, 0.25);
  outline-offset: 2px;
}

.panel-hint {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.button-row {
  display: flex;
  gap: 10px;
  align-items: start;
  flex-wrap: wrap;
}

.button-row .accent-button {
  min-width: 150px;
}

.button-row .ghost-button {
  min-width: 132px;
}

.prompt-card {
  margin-top: 12px;
  border: 1px solid rgba(95, 73, 52, 0.14);
  border-radius: 18px;
  background: rgba(255, 252, 247, 0.76);
  padding: 14px;
}

.prompt-panel {
  margin-top: 14px;
}

.prompt-summary {
  cursor: pointer;
  list-style: none;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
}

.prompt-summary::-webkit-details-marker {
  display: none;
}

.prompt-summary::before {
  content: "+";
  display: inline-block;
  margin-right: 0.45rem;
  color: var(--accent-dark);
}

.prompt-panel[open] .prompt-summary::before {
  content: "-";
}

@media (min-width: 641px) {
  .prompt-panel[open] .prompt-summary {
    display: none;
  }

  .prompt-panel {
    margin-top: 18px;
  }

  .prompt-panel > .prompt-card {
    margin-top: 0;
  }
}

.prompt-top {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.prompt-heading {
  display: grid;
  gap: 8px;
  min-width: min(100%, 280px);
}

.prompt-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: start;
}

.prompt-label {
  margin: 0;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.prompt-field {
  margin-top: 2px;
}

.prompt-select {
  min-width: 240px;
}

.prompt-text {
  margin: 10px 0 0;
  line-height: 1.55;
  color: var(--ink);
}

.panel-header h2 {
  margin-top: 4px;
  font-size: 2rem;
}

.accent-button,
.ghost-button {
  border-radius: 999px;
  padding: 0.8rem 1.1rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition:
    transform 160ms ease,
    background 160ms ease,
    border-color 160ms ease;
  font: inherit;
}

.accent-button {
  color: #fff7ef;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
}

.ghost-button {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.4);
  border-color: rgba(95, 73, 52, 0.16);
}

.accent-button:hover,
.ghost-button:hover,
.flip-button:hover {
  transform: translateY(-1px);
}

.accent-button:disabled {
  cursor: progress;
  opacity: 0.7;
}

#editor {
  width: 100%;
  min-height: 520px;
  margin-top: 14px;
  resize: vertical;
  border: 1px solid rgba(95, 73, 52, 0.14);
  border-radius: 24px;
  background: rgba(255, 250, 244, 0.92);
  padding: 22px;
  color: var(--ink);
  font-family: "Courier New", Courier, monospace;
  font-size: 1rem;
  line-height: 1.7;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

#editor:focus {
  outline: 2px solid rgba(188, 91, 49, 0.25);
  outline-offset: 3px;
}

.panel-footer {
  margin-top: 14px;
  color: var(--muted);
  min-height: 2lh;
}

#changeSummary[data-error="true"] {
  color: var(--accent-dark);
}

.deck-list {
  display: grid;
  gap: 16px;
  margin-top: 20px;
}

.empty-state {
  margin-top: 20px;
  padding: 18px;
  border-radius: 22px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.4);
  border: 1px dashed rgba(95, 73, 52, 0.2);
}

.flashcard {
  perspective: 1000px;
}

.flip-button {
  position: relative;
  width: 100%;
  min-height: 200px;
  padding: 0;
  border: 0;
  border-radius: 24px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.card-face {
  display: grid;
  gap: 14px;
  padding: 22px;
  min-height: 200px;
  border-radius: 24px;
  border: 1px solid rgba(95, 73, 52, 0.12);
  backface-visibility: hidden;
  transition:
    transform 240ms ease,
    opacity 240ms ease;
  box-shadow: 0 18px 34px rgba(83, 56, 39, 0.12);
}

.card-front {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.82), rgba(244, 231, 216, 0.92));
}

.card-back {
  position: absolute;
  inset: 0;
  background: linear-gradient(140deg, rgba(23, 107, 107, 0.92), rgba(12, 63, 68, 0.95));
  color: #f4f6f2;
  opacity: 0;
  transform: rotateY(180deg);
}

.flashcard.revealed .card-front {
  opacity: 0;
  transform: rotateY(180deg);
}

.flashcard.revealed .card-back {
  opacity: 1;
  transform: rotateY(0deg);
}

.card-main {
  font-size: 2rem;
  line-height: 1.05;
}

.card-hint,
.card-example,
.card-notes {
  color: inherit;
  opacity: 0.82;
  line-height: 1.5;
}

.card-example {
  font-style: italic;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(16px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

  .hero h1 {
    max-width: 12ch;
    font-size: clamp(2.8rem, 14vw, 5rem);
  }

  .panel {
    min-height: auto;
  }

  .panel-header {
    flex-direction: column;
  }

  .button-row {
    width: 100%;
  }

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

  .language-bar {
    width: 100%;
  }

  .button-row .accent-button {
    width: 100%;
  }

  .button-row .ghost-button {
    width: 100%;
  }

  .prompt-card {
    padding: 12px;
  }

  .prompt-actions {
    width: 100%;
  }

  .prompt-actions .mini-button {
    flex: 1 1 140px;
  }

  #editor {
    min-height: 420px;
  }
}

@media (max-width: 640px) {
  .shell {
    padding: 28px 16px 56px;
  }

  .hero h1 {
    max-width: none;
    font-size: clamp(2.4rem, 11vw, 3.6rem);
  }

  .subtitle {
    font-size: 1rem;
    line-height: 1.55;
  }

  .desktop-copy {
    display: none;
  }

  .mobile-copy {
    display: inline;
  }

  .panel {
    padding: 18px;
  }

  .prompt-heading,
  .prompt-select {
    min-width: 0;
  }

  .prompt-text {
    font-size: 0.96rem;
  }

  .prompt-panel:not([open]) .prompt-card {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
