:root {
  --ink: #1d2923;
  --muted: #5c6961;
  --paper: #fffef9;
  --canvas: #edf1ec;
  --line: #cbd4cc;
  --green: #24543c;
  --green-light: #e1eee5;
  --blue: #315e78;
  --blue-light: #e4eef4;
  --amber: #8a5a12;
  --amber-light: #f8ecd5;
  --red: #a33b35;
  --red-light: #f7e4e1;
  --shadow: 0 14px 34px rgba(31, 48, 38, 0.1);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.55;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible,
a:focus-visible {
  outline: 3px solid #e0a52b;
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  left: 1rem;
  top: -5rem;
  z-index: 50;
  padding: 0.65rem 0.9rem;
  background: var(--ink);
  color: white;
}

.skip-link:focus {
  top: 1rem;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 4.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--line);
  padding: 0.65rem max(1rem, calc((100vw - 1180px) / 2));
  background: rgba(255, 254, 249, 0.96);
  backdrop-filter: blur(12px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  width: 2.6rem;
  height: 2.6rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--green);
  color: white;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.35rem;
  font-weight: 700;
}

.brand strong,
.brand small {
  display: block;
  line-height: 1.1;
}

.brand small {
  margin-top: 0.15rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--muted);
  font-size: 0.9rem;
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 3rem 0 5rem;
}

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

h1,
h2,
h3 {
  letter-spacing: 0;
}

h1 {
  max-width: 16ch;
  margin-bottom: 1rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.5rem, 6vw, 5.2rem);
  line-height: 0.98;
}

h2 {
  margin-bottom: 0.75rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.8rem, 3.5vw, 3rem);
  line-height: 1.05;
}

.eyebrow {
  margin-bottom: 0.45rem;
  color: var(--red);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.onboarding {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.72fr);
  gap: 3rem;
  align-items: start;
}

.onboarding-intro {
  padding-top: 1.5rem;
}

.onboarding-intro > p:not(.eyebrow) {
  max-width: 62ch;
  color: var(--muted);
  font-size: 1.12rem;
}

.method-list {
  max-width: 680px;
  display: grid;
  gap: 0.75rem;
  margin: 2rem 0 0;
  padding-left: 2.4rem;
}

.method-list li {
  border-left: 4px solid var(--green);
  padding: 0.7rem 1rem;
  background: rgba(255, 254, 249, 0.65);
}

.profile-form,
.deck-toolbar,
.problem-panel,
.learning-note,
.data-settings {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow);
}

.profile-form {
  position: sticky;
  top: 6rem;
  display: grid;
  gap: 1rem;
  padding: 1.5rem;
}

.profile-form label,
.deck-controls label {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.75rem 0.85rem;
  background: white;
  color: var(--ink);
}

.privacy-note {
  color: var(--muted);
  font-size: 0.95rem;
}

.workspace {
  display: grid;
  gap: 1.25rem;
}

.deck-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1.35rem;
}

.deck-toolbar h1 {
  max-width: none;
  margin-bottom: 0.3rem;
  font-size: clamp(2rem, 4vw, 3.4rem);
}

.deck-toolbar p {
  margin-bottom: 0;
  color: var(--muted);
}

.deck-controls {
  width: min(430px, 100%);
  display: grid;
  gap: 0.8rem;
}

.dashboard {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.8rem;
}

.metric {
  min-height: 8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  background: var(--paper);
}

.metric span,
.metric small {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.metric strong {
  display: block;
  margin: 0.25rem 0;
  color: var(--green);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2.2rem;
  line-height: 1;
}

.problem-actions,
.check-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
}

.primary-button,
.secondary-button,
.danger-button,
.text-button,
.mini-button {
  border: 0;
  border-radius: 6px;
  font-weight: 900;
}

.primary-button,
.secondary-button,
.danger-button {
  padding: 0.78rem 1rem;
}

.primary-button {
  background: var(--green);
  color: white;
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--green);
}

.danger-button {
  background: var(--red-light);
  color: var(--red);
}

.text-button {
  padding: 0.3rem 0;
  background: transparent;
  color: var(--green);
}

.mini-button {
  padding: 0.45rem 0.6rem;
  background: var(--green-light);
  color: var(--green);
  font-size: 0.8rem;
}

.problem-panel {
  padding: 1.35rem;
}

.problem-topline {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.2rem;
}

.problem-topline h2 {
  max-width: 18ch;
}

#problem-prompt,
.problem-goal {
  max-width: 72ch;
  color: var(--muted);
}

.problem-goal {
  margin-bottom: 0;
  font-weight: 800;
}

.problem-position {
  flex: 0 0 auto;
  align-self: start;
  border-radius: 999px;
  padding: 0.45rem 0.75rem;
  background: var(--blue-light);
  color: var(--blue);
  font-size: 0.85rem;
  font-weight: 900;
}

.board {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.line-bank,
.solution-bank {
  min-height: 34rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  background: #f8faf7;
}

.line-bank h3,
.solution-bank h3 {
  margin-bottom: 0.25rem;
  font-size: 1.1rem;
}

.line-bank > p,
.solution-bank > p {
  color: var(--muted);
  font-size: 0.9rem;
}

.card-list {
  min-height: 24rem;
  display: grid;
  align-content: start;
  gap: 0.65rem;
  border: 2px dashed transparent;
  border-radius: 6px;
  padding: 0.25rem;
}

.solution-list {
  min-height: 30rem;
  padding-bottom: 7rem;
}

.card-list.drag-over {
  border-color: var(--green);
  background: var(--green-light);
}

.code-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.6rem;
  align-items: center;
  border: 1px solid var(--line);
  border-left: 5px solid var(--blue);
  border-radius: 6px;
  padding: 0.75rem;
  background: white;
  box-shadow: 0 8px 18px rgba(31, 48, 38, 0.08);
}

.code-card[draggable="true"] {
  cursor: grab;
}

.code-card.dragging {
  opacity: 0.55;
}

.code-text {
  display: block;
  overflow-x: auto;
  color: #17251f;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.95rem;
  white-space: pre;
}

.indent-1 .code-text {
  padding-left: 1.5rem;
}

.indent-2 .code-text {
  padding-left: 3rem;
}

.card-controls {
  display: flex;
  gap: 0.35rem;
}

.feedback {
  margin: 1rem 0;
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  font-weight: 800;
}

.feedback.correct {
  background: var(--green-light);
  color: var(--green);
}

.feedback.try-again {
  background: var(--amber-light);
  color: var(--amber);
}

.feedback.incorrect {
  background: var(--red-light);
  color: var(--red);
}

.data-settings,
.learning-note {
  padding: 1rem 1.2rem;
}

.data-settings summary,
.learning-note summary {
  cursor: pointer;
  font-weight: 900;
}

.learning-note summary strong,
.learning-note summary span {
  display: block;
}

.learning-note summary span:last-child {
  max-width: 70ch;
  color: var(--muted);
  font-weight: 500;
}

.learning-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.learning-grid article {
  border-left: 4px solid var(--green);
  padding: 0.75rem 1rem;
  background: var(--green-light);
}

.error-message {
  position: fixed;
  left: 50%;
  bottom: 1rem;
  z-index: 100;
  width: min(620px, calc(100% - 32px));
  transform: translateX(-50%);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  background: var(--red);
  color: white;
  box-shadow: var(--shadow);
  font-weight: 800;
}

@media (max-width: 860px) {
  main {
    width: min(100% - 24px, 1180px);
    padding-top: 2rem;
  }

  .onboarding,
  .board,
  .learning-grid {
    grid-template-columns: 1fr;
  }

  .profile-form {
    position: static;
  }

  .deck-toolbar,
  .problem-topline {
    display: grid;
  }

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

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

  h1 {
    font-size: 2.7rem;
  }

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

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