: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;
}

[hidden] {
  display: none !important;
}

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(0.75rem, calc((100vw - 1500px) / 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-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.teacher-link {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-decoration-color: transparent;
  text-underline-offset: 0.2em;
}

.teacher-link:hover,
.teacher-link:focus-visible {
  color: var(--green);
  text-decoration-color: currentColor;
}

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

main {
  width: min(1500px, calc(100% - 16px));
  margin: 0 auto;
  padding: 2rem 0 4rem;
}

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;
}
.onboarding-intro .app-slogan { margin:.35rem 0 1rem; color:var(--navy); font-size:clamp(1.25rem,2.4vw,1.9rem); letter-spacing:-.025em; }
.profile-form .login-slogan { margin:-.25rem 0 1rem; color:var(--muted); font-size:1rem; font-weight:700; }

.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);
}

.goal-card {
  margin-top: 1rem;
  border-left: 4px solid var(--green);
  border-radius: 6px;
  padding: 0.8rem 1rem;
  background: var(--green-light);
}

.goal-card p {
  margin: 0;
}

.deck-toolbar .goal-label {
  color: var(--green);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.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,
.problem-navigation,
.check-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
}

.problem-actions {
  align-items: center;
}

.problem-navigation {
  justify-content: space-between;
  align-items: center;
  margin: 1rem 0 0.7rem;
  border-top: 1px solid var(--line);
  padding-top: 1rem;
}

.problem-navigation .primary-button,
.problem-navigation .secondary-button {
  min-width: min(100%, 12rem);
}

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

.session-notice {
  flex: 1 1 100%;
  margin: 0;
  border-left: 4px solid var(--amber);
  border-radius: 6px;
  padding: 0.8rem 1rem;
  background: var(--amber-light);
  color: var(--ink);
  font-weight: 750;
}

.end-session-button {
  justify-self: end;
  margin-top: 0.25rem;
}

.notebook-checkpoint {
  border: 1px solid #a9bcae;
  border-radius: var(--radius);
  padding: clamp(1.2rem, 3vw, 2rem);
  background: linear-gradient(145deg, #fffef9 0%, #eef5ef 100%);
  box-shadow: var(--shadow);
}

.notebook-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
}

.notebook-heading h2 {
  max-width: none;
  margin-bottom: 0.45rem;
  font-size: clamp(1.7rem, 3vw, 2.45rem);
}

.notebook-session-badge {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  background: var(--green-light);
  color: var(--green);
  font-size: 0.75rem;
  font-weight: 850;
}

.notebook-problem-context {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.3rem 1rem;
  margin-top: 1rem;
}

.notebook-problem-context strong {
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.2rem;
}

.notebook-problem-context span {
  color: var(--blue);
  font-size: 0.82rem;
  font-weight: 800;
}

.notebook-problem-context p {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
}

.notebook-algorithm {
  overflow-x: auto;
  margin: 1rem 0;
  border: 1px solid var(--line);
  border-left: 5px solid var(--green);
  border-radius: 6px;
  padding: 1rem;
  background: #f7f9f7;
  color: var(--ink);
  font-size: clamp(0.78rem, 1.6vw, 0.95rem);
  line-height: 1.55;
  white-space: pre;
}

.notebook-instruction {
  max-width: 88ch;
  margin-bottom: 0;
}

.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: 1rem;
}

.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;
}

.problem-meta {
  flex: 0 0 min(25rem, 42%);
  display: grid;
  justify-items: end;
  gap: 0.75rem;
}

.problem-standard {
  max-width: 25rem;
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1.35;
  text-align: right;
}

.board {
  display: grid;
  grid-template-columns: minmax(300px, 0.82fr) minmax(0, 1.18fr);
  gap: 0.75rem;
  align-items: start;
}

.line-bank,
.solution-bank {
  min-height: 34rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.75rem;
  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: minmax(0, 1fr) auto;
  gap: 0.4rem;
  align-items: center;
  border: 1px solid var(--line);
  border-left: 5px solid var(--blue);
  border-radius: 6px;
  padding: 0.6rem;
  background: white;
  box-shadow: 0 8px 18px rgba(31, 48, 38, 0.08);
}

.code-card[draggable="true"] {
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

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

.code-card.pointer-drag-source {
  opacity: 0.35;
}

.pointer-drag-ghost {
  position: fixed;
  z-index: 1000;
  pointer-events: none;
  opacity: 0.94;
  transform: rotate(-1deg);
  box-shadow: 0 18px 36px rgba(31, 48, 38, 0.22);
}

.is-touch-dragging {
  overscroll-behavior: none;
}

.code-text {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
  color: #17251f;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.9rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

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

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

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

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

.card-controls {
  display: flex;
  flex: 0 0 auto;
  justify-content: flex-end;
  gap: 0.2rem;
}

.icon-button {
  display: inline-grid;
  width: 1.55rem;
  height: 1.55rem;
  place-items: center;
  padding: 0;
  font-size: 0.9rem;
  line-height: 1;
}

.add-line-button {
  font-size: 1rem;
}

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

.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;
}

.data-settings p {
  max-width: 70ch;
  margin: 1rem 0;
  color: var(--muted);
}

.data-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin: 1rem 0;
}

.backup-upload {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

#load-backup {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.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: calc(100% - 16px);
    padding-top: 2rem;
  }

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

  .profile-form {
    position: static;
  }

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

  .problem-meta {
    justify-items: start;
    width: 100%;
    max-width: none;
  }

  .problem-standard {
    max-width: none;
    text-align: left;
  }

  .notebook-heading,
  .notebook-problem-context {
    display: flex;
    flex-direction: column;
  }

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

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

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

  h1 {
    font-size: 2.7rem;
  }

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

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

/* Dr. Teach Tech shared application shell */
:root {
  --ink: #263238; --muted: #52626a; --paper: #fffdfc; --canvas: #f5f0e6;
  --line: #17324d; --green: #2a9d9f; --green-light: #e3f1f0;
  --blue: #17324d; --blue-light: #e7eff2; --amber: #a56e00;
  --amber-light: #fff2c4; --red: #c65327; --red-light: #fbe8df;
  --shadow: 5px 6px 0 rgba(23, 50, 77, 0.14); --radius: 12px;
}

body {
  background-color: var(--canvas);
  background-image: linear-gradient(rgba(23,50,77,.035) 1px, transparent 1px), linear-gradient(90deg, rgba(23,50,77,.035) 1px, transparent 1px);
  background-size: 22px 22px;
  font-family: "Atkinson Hyperlegible", Arial, Helvetica, sans-serif;
}
.app-header { min-height: 4.25rem; border: 0; border-bottom: 4px solid var(--green); padding-block: .55rem; background: var(--blue); color: white; box-shadow: 0 3px 0 rgba(23,50,77,.2); }
.brand { color: white; }
.brand small { color: #d9e5e9; }
.brand-mark { position: relative; border: 2px solid white; background: transparent; }
.brand-mark::before, .brand-mark::after, .brand-mark span { content: ""; position: absolute; inset: 7px 11px; border-radius: 999px; background: white; }
.brand-mark::before { transform: rotate(60deg); }
.brand-mark::after { transform: rotate(-60deg); }
.app-identity { margin-right: auto; border-left: 1px solid rgba(255,255,255,.35); padding-left: 1rem; font-weight: 900; }
.app-identity small { display: block; color: #d9e5e9; font: 700 .62rem ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .08em; text-transform: uppercase; }
.header-actions { gap: .55rem; }
.teacher-link, .header-status, .autosave-status { color: white; }
.autosave-status { font: 700 .66rem ui-monospace, SFMono-Regular, Menlo, monospace; white-space: nowrap; }
.header-button { min-height: 2.25rem; border: 1px solid rgba(255,255,255,.55); border-radius: 7px; padding: .42rem .65rem; background: transparent; color: white; font-size: .72rem; font-weight: 800; }
.header-button:hover { background: rgba(255,255,255,.1); }
.header-button-primary { border-color: #f3c64e; color: var(--blue); background: #f3c64e; }
h1, h2, h3 { color: var(--blue); font-family: "Atkinson Hyperlegible", Arial, Helvetica, sans-serif; font-weight: 900; letter-spacing: -.025em; }
.eyebrow { color: var(--green); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .12em; }
.profile-form, .deck-toolbar, .problem-panel, .learning-note, .data-settings, .dashboard, .notebook-checkpoint { border: 1px solid var(--blue); }
.profile-form { position: static; border-top: 0; overflow: hidden; padding-top: 1.25rem; }
.login-brand { display: flex; align-items: center; gap: .65rem; margin: -1.25rem -1.5rem .35rem; border-bottom: 3px solid var(--green); padding: .8rem 1rem; background: var(--blue); color: white; }
.login-brand strong, .login-brand small { display: block; line-height: 1.1; }
.login-brand small { font: 700 .64rem ui-monospace, monospace; letter-spacing: .1em; text-transform: uppercase; }
.mini-mark { width: 2rem; height: 2rem; display: grid; place-items: center; border: 1px solid white; border-radius: 50%; font-weight: 900; }
.privacy-note { border-left-color: var(--green); background: var(--blue-light); padding: .75rem .85rem; }
.profile-form label small { color: var(--muted); font-weight: 500; }
.login-guide { text-align: center; text-decoration: none; }
.resume-card { border: 1px solid var(--blue); border-left: 6px solid #f3c64e; border-radius: 9px; padding: 1rem; background: #fff8dc; }
.resume-card h3 { margin-bottom: .35rem; }
.resume-card p { margin-bottom: .75rem; }
.resume-actions { display: flex; flex-wrap: wrap; gap: .55rem; }
.signin-backup { display: grid; gap: .35rem; border-top: 1px solid #cad3d6; padding-top: 1rem; color: var(--muted); font-size: .82rem; }
.signin-backup strong { color: var(--blue); }
#signin-load-backup { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.activity-status { margin-top: .8rem !important; border-left: 4px solid #f3c64e; padding: .5rem .7rem; background: #fff8dc; color: var(--blue) !important; font-weight: 800; }
.primary-button { border-color: var(--blue); background: var(--blue); }
.secondary-button { border-color: var(--blue); color: var(--blue); }
.metric strong { color: var(--blue); }
.problem-position { border-color: #f3c64e; background: #fff8dc; color: var(--blue); }
.code-card { border-color: var(--blue); }
.app-footer { border-top: 1px solid rgba(23,50,77,.35); padding: 1.25rem; color: var(--blue); font: 800 .72rem ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .04em; text-align: center; text-transform: uppercase; }
.app-footer span { color: var(--green); }
.error-message[data-tone="success"] { border: 1px solid var(--green); background: var(--green-light); color: var(--blue); }
@media (max-width: 1100px) { .autosave-status, .header-status, .app-identity small { display: none !important; } }
@media (max-width: 780px) {
  .app-header { position: static; align-items: center; flex-direction: row; flex-wrap: wrap; }
  .app-identity { order: 2; }
  .header-actions { width: 100%; order: 3; overflow-x: auto; padding-bottom: .2rem; }
  .header-actions > * { flex: 0 0 auto; }
  .onboarding { gap: 1.5rem; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; } }
