: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-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 {
  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(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;
}
.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,
.study-panel,
.session-summary,
.concept-list,
.learning-note,
.student-guide,
.data-settings {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow);
}

.research-details {
  padding: 0;
}

.research-details > summary {
  position: relative;
  display: grid;
  gap: 0.35rem;
  cursor: pointer;
  padding: clamp(1.1rem, 3vw, 2rem);
  padding-right: clamp(3.8rem, 8vw, 5.5rem);
  list-style: none;
}

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

.research-details > summary::after {
  content: "+";
  position: absolute;
  right: clamp(1.1rem, 3vw, 2rem);
  top: 50%;
  width: 2.5rem;
  height: 2.5rem;
  display: grid;
  place-items: center;
  border: 1px solid var(--green);
  border-radius: 50%;
  color: var(--green);
  font-size: 1.7rem;
  font-weight: 500;
  line-height: 1;
  transform: translateY(-50%);
}

.research-details[open] > summary::after {
  content: "−";
}

.research-details > summary .eyebrow {
  margin-bottom: 0;
}

.research-details > summary > strong {
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.8rem, 3.5vw, 2.8rem);
  line-height: 1.05;
}

.research-details > summary .research-intro {
  display: block;
}

.toggle-label {
  margin-top: 0.35rem;
  color: var(--blue);
  font-size: 0.82rem;
  font-weight: 850;
}

.research-details[open] .toggle-label {
  font-size: 0;
}

.research-details[open] .toggle-label::after {
  content: "Close research and bibliography";
  font-size: 0.82rem;
}

.profile-form {
  display: grid;
  gap: 1rem;
  padding: 1.5rem;
}

.privacy-note {
  border-left: 3px solid var(--blue);
  padding-left: 0.8rem;
  color: var(--muted);
  font-size: 0.92rem;
}

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

input,
select {
  width: 100%;
  min-height: 2.8rem;
  border: 1px solid #aebbb1;
  border-radius: 6px;
  padding: 0.6rem 0.7rem;
  background: white;
  color: var(--ink);
}

.primary-button,
.secondary-button,
.danger-button,
.rating-button {
  min-height: 2.8rem;
  border-radius: 6px;
  padding: 0.65rem 1rem;
  font-weight: 850;
}

.primary-button {
  border: 1px solid var(--green);
  background: var(--green);
  color: white;
}

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

.text-button {
  border: 0;
  padding: 0.35rem;
  background: transparent;
  color: var(--blue);
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 0.18rem;
}

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

.deck-toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.72fr);
  gap: 2rem;
  align-items: end;
  padding: 1.4rem;
}

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

.deck-toolbar p:last-child,
#deck-description {
  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);
}

.partial-review-guide {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
  border: 1px solid #9bb8c8;
  border-radius: var(--radius);
  padding: 1.2rem;
  background: var(--blue-light);
  box-shadow: var(--shadow);
}

.partial-review-mark {
  width: 3.2rem;
  height: 3.2rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--blue);
  color: white;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.15rem;
  font-weight: 900;
}

.partial-review-guide h2 {
  margin: 0 0 0.4rem;
  font-family: Georgia, "Times New Roman", serif;
}

.partial-review-guide p {
  margin-top: 0;
}

.partial-review-guide ul {
  display: grid;
  gap: 0.35rem;
  margin: 0;
  padding-left: 1.2rem;
}

.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 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.file-control input {
  padding: 0.45rem;
  font-size: 0.82rem;
}

.dashboard {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--paper);
}

.metric {
  min-width: 0;
  padding: 1.1rem;
  border-right: 1px solid var(--line);
}

.metric:last-child {
  border-right: 0;
}

.metric span,
.metric small,
.metric strong {
  display: block;
}

.metric span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 850;
  text-transform: uppercase;
}

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

.metric small {
  overflow-wrap: anywhere;
  color: var(--muted);
}

.study-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
}

.needs-review-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  border: 1px solid #d9b66f;
  border-radius: var(--radius);
  padding: 1.2rem;
  background: #fff8e8;
  box-shadow: var(--shadow);
}

.needs-review-panel h2,
.needs-review-panel p {
  margin-top: 0;
}

.needs-review-panel h2 {
  margin-bottom: 0.35rem;
  font-family: Georgia, "Times New Roman", serif;
}

.needs-review-panel p:last-child {
  margin-bottom: 0;
}

.needs-review-rule {
  color: var(--muted);
  font-size: 0.88rem;
}

.needs-review-panel button {
  flex: 0 0 auto;
}

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

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

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

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

.journal-concept {
  margin: 1rem 0 0.45rem;
  border-left: 5px solid var(--green);
  padding: 1rem 1.15rem;
  background: var(--paper);
}

.journal-concept-prompt {
  margin-bottom: 0.65rem;
  color: var(--muted);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
}

.journal-concept-code {
  overflow-x: auto;
  margin: 0.75rem 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.8rem;
  background: #f4f6f4;
  color: var(--ink);
  font-size: 0.9rem;
  white-space: pre;
}

.journal-concept-answer {
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.15rem, 2vw, 1.45rem);
  font-weight: 700;
  line-height: 1.45;
  white-space: pre-wrap;
}

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

.journal-instruction {
  max-width: 82ch;
  margin-top: 1.2rem;
}

.handwriting-research {
  margin-top: 1rem;
  border-top: 1px solid var(--line);
  padding-top: 0.8rem;
}

.handwriting-research summary {
  cursor: pointer;
  color: var(--blue);
  font-weight: 850;
}

.handwriting-research > div {
  max-width: 88ch;
  padding-top: 0.85rem;
  color: var(--muted);
}

.handwriting-research a {
  color: var(--blue);
  font-weight: 850;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}

.receipt-button {
  margin-left: auto;
  border-color: var(--blue);
  color: var(--blue);
}

.study-panel,
.session-summary,
.concept-list,
.learning-note {
  padding: clamp(1.1rem, 3vw, 2rem);
}

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

.study-topline h2 {
  margin-bottom: 0;
  font-size: clamp(1.65rem, 3vw, 2.4rem);
}

.study-prompt {
  margin: 0.45rem 0 0;
  color: var(--blue);
  font-weight: 800;
}

.progress-track {
  height: 0.55rem;
  margin-top: 1.2rem;
  overflow: hidden;
  border-radius: 4px;
  background: #dde3de;
}

.progress-track span {
  width: 0;
  height: 100%;
  display: block;
  background: var(--green);
  transition: width 180ms ease;
}

.progress-copy {
  margin: 0.4rem 0 1rem;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 750;
}

.flashcard {
  position: relative;
  min-height: 340px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border: 1px solid #aebbb1;
  border-top: 6px solid var(--green);
  border-radius: var(--radius);
  padding: clamp(1.3rem, 5vw, 3.5rem);
  padding-bottom: clamp(3.2rem, 6vw, 4rem);
  background: white;
}

.card-context {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 1.5rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.flashcard h3 {
  max-width: 32ch;
  margin: 0 auto;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.65rem, 4vw, 2.8rem);
  line-height: 1.15;
  text-align: center;
}

.card-code {
  width: min(100%, 900px);
  margin: 1.5rem auto 0;
  border: 1px solid #c8d2cb;
  border-left: 5px solid var(--green);
  border-radius: 7px;
  padding: clamp(0.9rem, 2.5vw, 1.4rem);
  overflow-x: auto;
  background: #f4f7f5;
  color: #17241b;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: clamp(0.76rem, 1.8vw, 1rem);
  line-height: 1.5;
  text-align: left;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  tab-size: 2;
}

.card-code code {
  font: inherit;
}

.card-hint {
  margin: 1.2rem auto 0;
  color: var(--muted);
  font-style: italic;
  text-align: center;
}

.answer {
  max-width: 760px;
  margin: 2rem auto 0;
  border-top: 1px solid var(--line);
  padding-top: 1.5rem;
  font-size: 1.06rem;
}

.answer-label {
  margin-bottom: 0.35rem;
  color: var(--red);
  font-size: 0.76rem;
  font-weight: 900;
  text-transform: uppercase;
}

.card-standard {
  position: absolute;
  right: clamp(1rem, 3vw, 2rem);
  bottom: 0.9rem;
  max-width: min(70%, 56ch);
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 750;
  line-height: 1.3;
  text-align: right;
}

.recall-controls {
  display: flex;
  justify-content: center;
  padding-top: 1rem;
}

.reveal-button {
  min-width: min(100%, 260px);
}

.rating-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.7rem;
  border: 0;
  margin: 0;
  padding: 1rem 0 0;
}

.rating-controls legend {
  width: 100%;
  margin-bottom: 0.5rem;
  color: var(--muted);
  font-weight: 850;
  text-align: center;
}

.rating-button {
  display: grid;
  gap: 0.1rem;
  border: 1px solid;
  background: white;
  text-align: left;
}

.rating-button span {
  font-size: 0.78rem;
  font-weight: 600;
}

.rating-button.unknown {
  border-color: var(--red);
  color: var(--red);
}

.rating-button.review {
  border-color: var(--amber);
  color: var(--amber);
}

.rating-button.known {
  border-color: var(--green);
  color: var(--green);
}

.summary-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  max-width: 640px;
  margin: 1.5rem 0;
  border: 1px solid var(--line);
}

.summary-stats p {
  margin: 0;
  padding: 1rem;
  border-right: 1px solid var(--line);
}

.summary-stats p:last-child {
  border-right: 0;
}

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

.summary-stats strong {
  font-size: 1.7rem;
}

.summary-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
}

.summary-stats span {
  color: var(--muted);
  font-size: 0.78rem;
}

.concept-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 0.75rem;
  margin-top: 1.2rem;
}

.concept-item {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1rem;
  background: white;
}

.concept-item h3 {
  margin-bottom: 0.4rem;
  font-size: 1rem;
}

.concept-item p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.concept-item.needs-review {
  border-color: #d9b66f;
  background: #fffaf0;
}

.concept-item .concept-performance {
  margin-top: 0.65rem;
  border-top: 1px solid var(--line);
  padding-top: 0.65rem;
}

.concept-item .concept-source {
  margin-top: 0.45rem;
  color: var(--blue);
  font-weight: 750;
}

.concept-item .needs-review-badge {
  width: fit-content;
  margin-top: 0.65rem;
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  background: var(--amber-light);
  color: var(--amber);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.learning-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  margin: 0 clamp(1.1rem, 3vw, 2rem);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.research-intro {
  max-width: 78ch;
  color: var(--muted);
  font-size: 1.04rem;
}

.learning-grid article {
  padding: 1.4rem;
  border-right: 1px solid var(--line);
}

.learning-grid article:first-child {
  padding-left: 0;
}

.learning-grid article:last-child {
  border-right: 0;
  padding-right: 0;
}

.learning-grid h3 {
  margin: 0 0 0.8rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.45rem;
  line-height: 1.15;
}

.learning-grid p {
  color: var(--muted);
}

.learning-grid strong,
.spaced-repetition strong {
  color: var(--ink);
}

.principle-number {
  margin-bottom: 0.35rem;
  color: var(--red) !important;
  font-size: 0.76rem;
  font-weight: 900;
}

.learning-note sup a {
  color: var(--blue);
  font-weight: 900;
  text-decoration: none;
}

.research-caution {
  border-left: 3px solid var(--amber);
  padding-left: 0.7rem;
  font-size: 0.9rem;
}

.spaced-repetition {
  margin: 1.5rem clamp(1.1rem, 3vw, 2rem) 0;
  border-left: 5px solid var(--blue);
  padding: 1.2rem 1.4rem;
  background: var(--blue-light);
}

.spaced-repetition h3 {
  margin: 0 0 0.65rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.6rem, 3vw, 2.3rem);
}

.spaced-repetition p:last-child {
  margin-bottom: 0;
}

.bibliography {
  margin-top: 1.5rem;
  border-top: 1px solid var(--line);
  padding: clamp(1.1rem, 3vw, 2rem);
}

.bibliography h2 {
  font-size: clamp(1.8rem, 3.5vw, 2.8rem);
}

.bibliography ol {
  display: grid;
  gap: 0.8rem;
  margin: 1.2rem 0 0;
  padding-left: 1.4rem;
}

.bibliography li {
  padding-left: 0.35rem;
  color: var(--muted);
}

.bibliography a {
  color: var(--blue);
  text-underline-offset: 0.14rem;
}

.bibliography li:target {
  border-left: 4px solid var(--amber);
  padding-left: 0.7rem;
  background: #fff8e8;
}

.student-guide,
.data-settings {
  padding: 1rem 1.2rem;
}

.student-guide summary,
.data-settings summary {
  cursor: pointer;
  color: var(--blue);
  font-weight: 850;
}

.guide-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem 1.5rem;
  margin-top: 1rem;
}

.guide-grid p {
  margin: 0;
  color: var(--muted);
}

.guide-grid strong {
  color: var(--ink);
}

.guide-grid .focused-guide-step {
  border-left: 3px solid var(--amber);
  padding-left: 0.8rem;
}

.guide-privacy {
  margin: 1rem 0 0;
  border-left: 3px solid var(--blue);
  padding-left: 0.8rem;
  color: var(--muted);
}

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

.danger-button {
  border: 1px solid var(--red);
  background: white;
  color: var(--red);
}

.error-message {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 30;
  max-width: 420px;
  border: 1px solid var(--red);
  border-radius: 6px;
  padding: 0.8rem 1rem;
  background: var(--red-light);
  color: #6e211d;
  box-shadow: var(--shadow);
}

.error-message[data-tone="success"] {
  border-color: var(--green);
  background: var(--green-light);
  color: var(--green);
}

[hidden] {
  display: none !important;
}

@media (max-width: 850px) {
  .onboarding,
  .deck-toolbar {
    grid-template-columns: 1fr;
  }

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

  .needs-review-panel {
    align-items: stretch;
    flex-direction: column;
  }

  .needs-review-panel button {
    width: 100%;
  }

  .journal-heading {
    flex-direction: column;
  }

  .metric:nth-child(2) {
    border-right: 0;
  }

  .metric:nth-child(-n+2) {
    border-bottom: 1px solid var(--line);
  }

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

  .learning-grid article,
  .learning-grid article:first-child,
  .learning-grid article:last-child {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 1.2rem 0;
  }

  .learning-grid article:last-child {
    border-bottom: 0;
  }

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

@media (max-width: 580px) {
  main {
    width: min(100% - 20px, 1180px);
    padding-top: 1.5rem;
  }

  .header-status > span {
    display: none;
  }

  .deck-controls,
  .rating-controls {
    grid-template-columns: 1fr;
  }

  .partial-review-guide {
    grid-template-columns: 1fr;
  }

  .study-actions {
    display: grid;
  }

  .study-actions button {
    width: 100%;
  }

  .receipt-button {
    margin-left: 0;
  }

  .flashcard {
    min-height: 300px;
  }

  .summary-stats {
    grid-template-columns: 1fr;
  }

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

  .summary-stats p:last-child {
    border-bottom: 0;
  }
}

/* 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, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 50, 77, 0.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: 0.55rem;
  padding-inline: clamp(1rem, 2vw, 2rem);
  background: var(--blue);
  color: white;
  box-shadow: 0 3px 0 rgba(23, 50, 77, 0.2);
}

.brand {
  flex: 0 0 auto;
  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 {
  flex: 0 0 auto;
  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-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .62rem;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.header-actions {
  flex: 0 1 auto;
  justify-content: flex-end;
  gap: .7rem;
}
.teacher-link, .header-status, .autosave-status { color: white; }

.autosave-status {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .66rem;
  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: var(--yellow, #f3c64e); color: #17324d; background: #f3c64e; }

h1, h2, h3,
.flashcard h3,
.journal-concept-answer,
.research-details > summary > strong {
  color: var(--blue);
  font-family: "Atkinson Hyperlegible", Arial, Helvetica, sans-serif;
  font-weight: 900;
  letter-spacing: -0.025em;
}

.eyebrow {
  color: var(--green);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .12em;
}

.profile-form,
.deck-toolbar,
.study-panel,
.session-summary,
.concept-list,
.learning-note,
.student-guide,
.data-settings,
.dashboard,
.journal-panel,
.needs-review-panel,
.partial-review-guide {
  border: 1px solid var(--blue);
}

.profile-form {
  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); }
.progress-track span { background: #f3c64e; }
.metric strong { color: var(--blue); }
.flashcard { border-color: var(--blue); border-top-color: var(--green); }

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

@media (max-width: 1040px) {
  .autosave-status,
  .header-status,
  .app-identity small { display: none !important; }
}

@media (max-width: 780px) {
  .app-header { position: static; flex-wrap: wrap; }
  .app-identity { order: 2; }
  .header-actions {
    width: 100%;
    order: 3;
    justify-content: flex-start;
    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; }
}
