/* AacharyaG Phase 1 styles. No shadows; 1px borders only. */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
:lang(hi):not(:lang(hi-Latn)) { font-family: var(--font-hi); line-height: 1.8; }
button, input, select, textarea { font: inherit; color: inherit; }
code, pre, kbd, .mono { font-family: var(--font-code); }
a { color: var(--primary); font-weight: 600; }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 24px; font-weight: 800; }
h2 { font-size: 17px; font-weight: 700; }
p { margin: 0; }

:focus { outline: none; }
:focus-visible { box-shadow: var(--focus); border-radius: var(--radius-control); }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link { position: absolute; left: 8px; top: -60px; z-index: 10; background: var(--panel); padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--radius-control); }
.skip-link:focus { top: 8px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.eyebrow { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.small { font-size: 13px; }

/* ---------- Controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--control-h); padding: 0 16px; border-radius: var(--radius-control);
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--soft); }
.btn-primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); font-weight: 700; }
.btn-primary:hover:not(:disabled) { background: #16304F; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--primary); }
.btn-danger { border-color: transparent; background: transparent; color: var(--error); }
.btn-lg { min-height: 48px; font-size: 15px; padding: 0 22px; }
.btn:disabled { cursor: not-allowed; opacity: .55; }
.icon-btn { min-width: var(--control-h); padding: 0; }
.pill {
  min-height: var(--control-h); padding: 0 14px; border-radius: var(--radius-pill);
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  font-size: 14px; font-weight: 600; cursor: pointer;
}
.pill:hover:not(:disabled) { background: var(--soft); }
.pill:focus-visible { border-radius: var(--radius-pill); }
.pill:disabled { opacity: .55; cursor: not-allowed; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label, .field .label { font-size: 14px; font-weight: 600; }
.input, .select, .textarea {
  min-height: var(--control-h); padding: 0 14px; border-radius: var(--radius-control);
  border: 1px solid var(--line); background: var(--bg); color: var(--ink); font-size: 15px; width: 100%;
}
.textarea { padding: 12px 14px; line-height: 1.5; resize: vertical; font-size: 16px; }
.select { padding: 0 12px; }
.input:focus-visible, .select:focus-visible, .textarea:focus-visible { border-color: var(--primary); }
.hint { font-size: 13px; color: var(--muted); }
.field-error { font-size: 13px; color: var(--error); font-weight: 600; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-panel); }
.banner { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 14px; border-radius: var(--radius-control); background: var(--soft); border: 1px solid var(--line); font-size: 14px; }
.banner-error { border-color: var(--error); color: var(--error); background: #FFFFFF; }
.banner-error .btn { color: var(--ink); }
.banner-ok { border-color: var(--success); }
.progress { height: 8px; border-radius: var(--radius-pill); background: var(--soft); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--primary); }
.progress.done > span { background: var(--success); }

/* ---------- App shell ---------- */
#app { min-height: 100%; display: flex; flex-direction: column; }
.app-header {
  height: 64px; flex: none; padding: 0 20px; display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--line); background: var(--panel); min-width: 0;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; flex: none; }
.brand-name { font-size: 22px; font-weight: 800; letter-spacing: -0.01em; font-family: var(--font-ui); line-height: 1; }
.header-context { color: var(--muted); font-size: 14px; margin-left: 8px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.header-nav { display: flex; gap: 4px; margin-left: 8px; }
.header-nav a {
  min-height: var(--control-h); display: flex; align-items: center; padding: 0 12px; border-radius: var(--radius-control);
  color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 600;
}
.header-nav a[aria-current="page"] { background: var(--soft); color: var(--ink); font-weight: 700; }
.spacer { flex: 1; min-width: 0; }
.lang-switch { display: flex; gap: 4px; padding: 4px; border-radius: var(--radius-panel); background: var(--soft); flex: none; }
.lang-switch button {
  border: 0; padding: 6px 12px; border-radius: var(--radius-control); background: transparent; color: var(--ink);
  font-size: 13px; font-weight: 600; min-height: var(--control-h); cursor: pointer;
}
.lang-switch button[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); font-weight: 700; }
.lang-select { display: none; width: auto; min-width: 64px; }
.app-main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.page { width: 100%; max-width: 1120px; margin: 0 auto; padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.page-narrow { max-width: 768px; }
.loading { padding: 48px 24px; text-align: center; color: var(--muted); }

/* ---------- Mascot (diya) ---------- */
.mascot { flex: none; display: block; overflow: visible; }
.mascot .flame { transform-box: fill-box; transform-origin: 50% 100%; }
.mascot .eyes-happy, .mascot .mouth-flat { display: none; }
.mascot.is-happy .eyes-open { display: none; }
.mascot.is-happy .eyes-happy { display: inline; }
.mascot.is-thinking .mouth-smile { display: none; }
.mascot.is-thinking .mouth-flat { display: inline; }
.mascot.is-idle .flame { animation: flicker 2.4s ease-in-out infinite; }
.mascot.is-thinking .flame { animation: sway 0.9s ease-in-out infinite; }
.mascot.is-happy .flame { animation: grow 1.2s ease-in-out infinite; }
.mascot.is-encouraging { transform-origin: 50% 90%; animation: nod 1.6s ease-in-out 2; }
@keyframes flicker { 0%,100% { transform: scale(1); } 50% { transform: scale(1.04, .97); } }
@keyframes sway { 0%,100% { transform: rotate(-6deg); } 50% { transform: rotate(6deg); } }
@keyframes grow { 0%,100% { transform: scale(1); } 50% { transform: scale(1.1); } }
@keyframes nod { 0%,100% { transform: rotate(0); } 30% { transform: rotate(-5deg); } 60% { transform: rotate(4deg); } }

/* Motion off: OS setting or the user's reduced_motion setting. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
html.reduce-motion *, html.reduce-motion *::before, html.reduce-motion *::after {
  animation: none !important; transition: none !important; scroll-behavior: auto !important;
}

/* ---------- Auth ---------- */
.auth-wrap { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-form { width: 100%; max-width: 560px; padding: 32px; display: flex; flex-direction: column; gap: 18px; }
.auth-form fieldset { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.auth-form legend { font-size: 14px; font-weight: 600; padding: 0; margin-bottom: 8px; }
.choice-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.choice {
  min-height: 64px; border-radius: var(--radius-control); border: 1px solid var(--line); background: var(--panel);
  font-size: 15px; font-weight: 600; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; cursor: pointer; padding: 6px;
}
.choice small { font-size: 12px; color: var(--muted); font-weight: 500; font-family: var(--font-ui); line-height: 1.3; text-align: center; }
.choice[aria-pressed="true"] { border: 2px solid var(--primary); background: var(--soft); font-weight: 700; }

/* ---------- Goal ---------- */
.goal-page { max-width: 768px; gap: 24px; }
.speech { display: flex; align-items: flex-end; gap: 14px; }
.bubble-tutor-static { background: var(--soft); border-radius: 12px 12px 12px 4px; padding: 14px 16px; font-size: 16px; line-height: 1.55; }
.goal-form { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.goal-list { display: flex; flex-direction: column; gap: 8px; list-style: none; margin: 0; padding: 0; }
.goal-item {
  display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 8px 16px; border-radius: var(--radius-panel);
  border: 1px solid var(--line); background: var(--panel); color: var(--ink); text-decoration: none; width: 100%;
  text-align: left; cursor: pointer; font-weight: 400;
}
.goal-item:hover { background: var(--soft); }
.goal-row { display: flex; gap: 8px; align-items: stretch; }
.goal-row .goal-item { flex: 1; min-width: 0; }
.goal-row .delete-plan { display: flex; align-items: center; }
.delete-confirm { display: flex; flex-direction: column; gap: 8px; }
.delete-confirm p { margin: 0; max-width: 260px; }
.btn-destroy { background: var(--error); border-color: var(--error); }
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -3px; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-line { display: flex; align-items: center; gap: 8px; }
.reduce-motion .spinner { animation-duration: 2s; }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2s; } }
@media (max-width: 600px) { .goal-row { flex-direction: column; } .goal-row .delete-plan { align-self: flex-end; } }
.goal-item .title { font-weight: 600; font-size: 15px; min-width: 0; }
.goal-item .action { font-weight: 700; color: var(--primary); font-size: 14px; margin-left: auto; }

/* ---------- Clarify ---------- */
.clarify { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; max-width: 1100px; }
.clarify-main { padding: 28px; display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.clarify-aside { padding: 20px; display: flex; flex-direction: column; gap: 12px; min-width: 0; align-self: start; }
.q-head { display: flex; align-items: center; gap: 12px; }
.q-head .progress { flex: 1; height: 6px; }
.q-title { display: flex; gap: 12px; align-items: flex-start; }
.q-title h1 { font-size: 22px; line-height: 1.35; font-weight: 700; }
.options { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.option {
  min-height: 56px; padding: 8px 16px; border-radius: var(--radius-control); border: 1px solid var(--line);
  background: var(--panel); font-size: 16px; font-weight: 500; text-align: left; display: flex; align-items: center; gap: 12px; cursor: pointer;
}
.option .dot { width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--muted); flex: none; }
.option[aria-pressed="true"] { border: 2px solid var(--primary); background: var(--soft); font-weight: 600; }
.option[aria-pressed="true"] .dot { border: 6px solid var(--primary); }
.understood dt { font-size: 13px; color: var(--muted); }
.understood dd { margin: 0 0 10px; font-size: 15px; font-weight: 600; }
.divider { height: 1px; background: var(--line); border: 0; margin: 0; }
.building { padding: 48px 24px; display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center; }

/* ---------- Roadmap ---------- */
.roadmap { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; max-width: 1100px; }
.roadmap-main { padding: 24px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.roadmap-aside { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.roadmap-aside .panel { padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.big-number { font-size: 32px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stage-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.stage-row {
  display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 6px 8px 6px 12px;
  border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--panel); min-width: 0;
}
.stage-row.dragging { opacity: .5; }
.stage-row.drop-target { border: 2px solid var(--primary); background: var(--soft); }
.grip { cursor: grab; flex: none; color: var(--muted); }
.num { width: 26px; height: 26px; border-radius: 50%; background: var(--primary); color: var(--on-primary); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; flex: none; }
.stage-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.stage-title-btn { all: unset; font-weight: 600; font-size: 15px; cursor: text; border-radius: 4px; }
.stage-title-btn:focus-visible { box-shadow: var(--focus); }
.stage-row .input { min-height: 40px; font-weight: 600; background: var(--panel); }
.stage-est { font-size: 13px; color: var(--muted); width: 64px; text-align: right; flex: none; }
.row-actions { display: flex; flex: none; }
.row-actions .btn { min-width: 44px; padding: 0; font-size: 18px; border-color: transparent; background: transparent; }
.confirm-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 1; min-width: 0; }

/* ---------- Lesson (three panels) ---------- */
.lesson {
  flex: 1; min-height: 0; display: grid; grid-template-columns: 260px minmax(0, 1fr) 450px; grid-template-rows: minmax(0, 1fr); gap: 16px; padding: 16px;
}
body.is-full #app { height: 100vh; height: 100dvh; }
body.is-full .app-main { overflow: hidden; }
.lesson > * { min-height: 0; min-width: 0; }
.path-panel { padding: 16px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; }
.path-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.path-item {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: var(--control-h); padding: 9px 10px; text-align: left;
  border-radius: var(--radius-control); border: 1px solid transparent; background: transparent; color: var(--muted);
  font-weight: 500; font-size: 14px; cursor: pointer;
}
.path-item:hover { background: var(--soft); }
.path-item[aria-current="step"] { background: var(--soft); border-color: var(--primary); color: var(--ink); font-weight: 700; }
.path-dot { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--line); display: flex; align-items: center; justify-content: center; font-size: 12px; flex: none; }
.path-item.is-done .path-dot { background: var(--success); border-color: var(--success); }
.path-item[aria-current="step"] .path-dot { background: var(--primary); border-color: var(--primary); color: var(--on-primary); font-weight: 700; }

.chat-panel { padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.chat-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.chat-head h1 { font-size: 16px; font-weight: 700; }
.chat-log { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding: 2px 2px 8px; }
.msg { display: flex; gap: 10px; align-items: flex-start; min-width: 0; }
.msg-learner { justify-content: flex-end; }
.bubble { border-radius: 12px; padding: 12px 14px; font-size: 15px; line-height: 1.55; min-width: 0; max-width: min(560px, 100%); }
.bubble:lang(hi):not(:lang(hi-Latn)) { font-size: 16px; line-height: 1.8; }
.msg-tutor .bubble { background: var(--soft); border-radius: 12px 12px 12px 4px; }
.msg-learner .bubble { background: var(--primary); color: var(--on-primary); border-radius: 12px 12px 4px 12px; white-space: pre-wrap; max-width: min(420px, 85%); }
.msg-event { justify-content: center; color: var(--muted); font-size: 13px; }
.bubble p + p, .bubble p + pre, .bubble pre + p, .bubble ul, .bubble ol { margin-top: 8px; }
.bubble ul, .bubble ol { padding-left: 20px; margin-bottom: 0; }
.bubble pre { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-control); padding: 10px 12px; overflow-x: auto; font-size: 13px; line-height: 1.6; margin: 8px 0 0; white-space: pre; }
.bubble code { font-size: .9em; background: var(--panel); border-radius: 4px; padding: 1px 4px; }
.bubble pre code { background: none; padding: 0; }
.bubble.streaming:empty::after { content: '…'; color: var(--muted); }
.typing { display: inline-flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; }
.typing-dots { display: inline-flex; gap: 4px; }
.typing-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); opacity: .35; animation: typing-dot 1.2s infinite ease-in-out; }
.typing-dots i:nth-child(2) { animation-delay: .15s; }
.typing-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes typing-dot { 0%, 60%, 100% { opacity: .35; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
.reduce-motion .typing-dots i { animation: none; opacity: .7; }
@media (prefers-reduced-motion: reduce) { .typing-dots i { animation: none; opacity: .7; } }
.msg-error { border: 1px solid var(--error); color: var(--error); background: var(--panel); }
.quick-replies { display: flex; gap: 8px; flex-wrap: wrap; }
.composer { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea {
  flex: 1; min-width: 0; min-height: var(--control-h); max-height: 160px; padding: 11px 14px; border-radius: var(--radius-control);
  border: 1px solid var(--line); background: var(--bg); resize: none; font-size: 15px; line-height: 1.4;
}
.composer textarea:focus-visible { border-color: var(--primary); }
.chat-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.work-panel { display: flex; flex-direction: column; overflow: hidden; }
.tablist { display: flex; gap: 4px; padding: 10px 12px; border-bottom: 1px solid var(--line); align-items: center; }
.tab { min-height: var(--control-h); padding: 0 12px; border-radius: var(--radius-control); border: 0; background: transparent; color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer; }
.tab[aria-selected="true"] { background: var(--soft); color: var(--ink); font-weight: 700; }
.tab-lang { font-size: 12px; color: var(--muted); font-family: var(--font-code); margin-left: auto; }
.tabpanel { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.editor-host { flex: 1; min-height: 200px; background: var(--code-bg); }
.editor-fallback { width: 100%; height: 100%; border: 0; resize: none; padding: 14px; background: var(--code-bg); font-family: var(--font-code); font-size: 13px; line-height: 22px; }
.work-actions { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); flex-wrap: wrap; align-items: center; }
.work-out { padding: 12px 14px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.soon { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 24px; text-align: center; color: var(--muted); }
.mobile-tabs { display: none; }

/* ---------- Phase 2: practice questions and the code runner ---------- */
.quiz-panel { overflow-y: auto; }
.quiz { padding: 14px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.quiz-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.quiz-title { font-size: 16px; }
.quiz-status:empty { display: none; }
.quiz-status { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--muted); font-size: 14px; }
.quiz-foot { padding: 0 14px 14px; }
.q-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.q-card { border: 1px solid var(--line); border-radius: var(--radius-panel); padding: 14px; display: flex; flex-direction: column; gap: 10px; min-width: 0; background: var(--panel); }
.q-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.q-kind { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.badge { display: inline-flex; align-items: center; min-height: 24px; padding: 0 10px; border-radius: var(--radius-pill); border: 1px solid var(--line); background: var(--soft); font-size: 12px; font-weight: 700; color: var(--ink); }
.badge-passed { border-color: var(--success); color: var(--success); background: var(--panel); }
.badge-revealed { color: var(--muted); }
.q-prompt { font-size: 15px; line-height: 1.55; }
.q-prompt:focus-visible { border-radius: 4px; }
.md p + p, .md p + pre, .md pre + p, .md ul, .md ol { margin-top: 8px; }
.md ul, .md ol { padding-left: 20px; margin-bottom: 0; }
.md code, .q-prompt code { font-size: .9em; background: var(--soft); border-radius: 4px; padding: 1px 4px; }
.md pre, .q-code { background: var(--code-bg); border: 1px solid var(--line); border-radius: var(--radius-control); padding: 10px 12px; overflow-x: auto; font-size: 13px; line-height: 1.6; margin: 0; white-space: pre; }
.md pre code, .q-code code { background: none; padding: 0; }
.q-body { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.q-option { min-height: var(--control-h); padding: 8px 14px; font-size: 15px; }
.q-option input { width: 20px; height: 20px; margin: 0; flex: none; accent-color: var(--primary); }
.q-option:has(input:checked) { border: 2px solid var(--primary); background: var(--soft); font-weight: 600; }
.q-option:has(input:focus-visible) { box-shadow: var(--focus); }
.q-option input:focus-visible { box-shadow: none; }
.q-option.is-correct { border: 2px solid var(--success); }
.q-option:has(input:disabled) { cursor: default; }
.opt-text { min-width: 0; font-family: var(--font-code); font-size: 14px; }
.q-hints { margin: 0; padding: 10px 12px 10px 30px; background: var(--soft); border-radius: var(--radius-control); font-size: 14px; display: flex; flex-direction: column; gap: 4px; }
.q-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.q-confirm { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--soft); }
.q-feedback:empty { display: none; }
.q-feedback { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border-radius: var(--radius-control); border: 1px solid var(--line); font-size: 14px; }
.q-feedback.is-ok { border-color: var(--success); }
.q-feedback.is-ok .fb-line { color: var(--success); font-weight: 700; }
.q-feedback.is-error { border-color: var(--error); }
.q-feedback.is-error .fb-line, .q-feedback.is-error > p { color: var(--error); font-weight: 600; }
.q-answer { display: flex; flex-direction: column; gap: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
.q-answer-h { font-size: 14px; font-weight: 700; }
.q-answer-text { font-weight: 600; }
.q-card.is-closed .q-actions .btn-primary { display: none; }
.textarea.mono { font-family: var(--font-code); font-size: 14px; }

.q-context { padding: 12px 14px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; max-height: 40%; overflow-y: auto; flex: none; }
.q-context h2.q-kind { font-size: 12px; }
.test-list { margin: 0; padding-left: 18px; font-size: 13px; display: flex; flex-direction: column; gap: 2px; }
.test-list code { font-size: 12px; overflow-wrap: anywhere; }
.test-name { font-weight: 600; }
.work-out { max-height: 45%; overflow-y: auto; }
.out-status:empty, .step-status:empty { display: none; }
.code-out { margin: 0; padding: 10px 12px; background: var(--code-bg); border: 1px solid var(--line); border-radius: var(--radius-control); font-size: 13px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 220px; overflow-y: auto; }
.out-error { color: var(--error); font-family: var(--font-code); font-size: 13px; font-weight: 600; white-space: pre-wrap; }
.test-results { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.test-results li { display: flex; gap: 8px; align-items: baseline; }
.test-results .is-pass .tr-mark, .test-results .is-pass strong { color: var(--success); }
.test-results .is-fail .tr-mark, .test-results .is-fail strong { color: var(--error); }
.tr-mark { font-weight: 800; width: 14px; flex: none; }
.tr-detail { color: var(--muted); font-family: var(--font-code); font-size: 12px; }

/* ---------- Step-through (Animation tab) ---------- */
.step-tab { overflow-y: auto; }
.step-panel { display: flex; flex-direction: column; gap: 10px; padding: 14px; min-width: 0; }
.step-title { font-size: 16px; margin: 0 0 4px; }
.step-actions { padding: 0; border: 0; }
.stepper { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.step-controls { display: flex; gap: 6px; flex-wrap: wrap; }
.step-controls .btn { min-width: 64px; }
.step-slider { width: 100%; accent-color: var(--primary); }
.step-counter { margin: 0; color: var(--muted); }
.step-caption { margin: 0; font-weight: 600; min-height: 1.5em; }
.step-caption.is-error { color: var(--error); }
.step-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 12px; align-items: start; }
@media (max-width: 720px) { .step-grid { grid-template-columns: minmax(0, 1fr); } }
.trace-code { list-style: none; margin: 0; padding: 6px 0; background: var(--code-bg); border: 1px solid var(--line); border-radius: var(--radius-control); font-family: var(--font-code); font-size: 13px; line-height: 1.6; max-height: 340px; overflow: auto; }
.trace-code li { display: flex; gap: 10px; padding: 0 10px; border-left: 3px solid transparent; transition: background-color .15s ease; }
.trace-code .ln { color: var(--muted); width: 2.5ch; text-align: right; flex: none; user-select: none; }
.trace-code code { white-space: pre; }
.trace-code li.is-current { background: #FFF3DC; border-left-color: var(--flame); }
.trace-code li.is-current .ln { color: var(--ink); font-weight: 700; }
.trace-code li.is-error { background: #FBEAE8; border-left-color: var(--error); }
.step-side { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.vars-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.vars-table th, .vars-table td { text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
.vars-table thead th { color: var(--muted); font-size: 12px; font-weight: 600; }
.vars-table tr.is-changed td { background: #FFF3DC; animation: var-flash .6s ease-out; }
.vars-table tr.is-changed .chg { color: var(--muted); font-size: 12px; }
.vars-table tr.is-return th, .vars-table tr.is-return td { font-weight: 700; color: var(--success); }
@keyframes var-flash { from { background: #FFE2A8; } to { background: #FFF3DC; } }

/* ---------- Small UI motion (all off under reduced motion, see top of file) ---------- */
.msg { animation: rise-in .22s ease-out; }
.q-feedback.is-ok, .q-feedback.is-error { animation: pop-in .25s ease-out; }
.tabpanel:not([hidden]) { animation: fade-in .15s ease-out; }
@keyframes rise-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes pop-in { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Progress ---------- */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.stat { padding: 18px 20px; display: flex; flex-direction: column; gap: 2px; }
.stat .value { font-size: 30px; font-weight: 800; font-family: var(--font-ui); font-variant-numeric: tabular-nums; line-height: 1.3; }
.up { color: var(--success); font-weight: 600; }
.progress-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; }
.progress-grid > section { padding: 20px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.goal-progress { display: flex; flex-direction: column; gap: 8px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.goal-progress:last-child { border-bottom: 0; padding-bottom: 0; }
.chart { height: 160px; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; align-items: end; border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.chart .bar { background: var(--primary); border-radius: 4px 4px 0 0; min-height: 2px; }
.chart .bar.zero { background: var(--line); border-radius: 0; height: 2px; }
.chart .bar.top { background: var(--flame); }
.chart-labels { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; font-size: 13px; color: var(--muted); text-align: center; }

/* ---------- Settings ---------- */
.settings { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 16px; max-width: 1120px; }
.settings-nav { display: flex; flex-direction: column; gap: 4px; position: sticky; top: 16px; align-self: start; }
.settings-nav a { min-height: var(--control-h); display: flex; align-items: center; padding: 0 12px; border-radius: var(--radius-control); color: var(--ink); text-decoration: none; font-size: 14px; font-weight: 600; border: 1px solid transparent; }
.settings-nav a:hover { background: var(--panel); border-color: var(--line); }
.settings-body { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.settings-section { padding: 24px; display: flex; flex-direction: column; gap: 16px; scroll-margin-top: 16px; }
.settings-section h2 { font-size: 20px; font-weight: 800; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.key-input { font-family: var(--font-code); }
.toggle { display: flex; align-items: center; gap: 12px; min-height: var(--control-h); cursor: pointer; font-weight: 600; }
.toggle input { width: 22px; height: 22px; accent-color: var(--primary); }
.key-aside ul { margin: 0; padding-left: 18px; font-size: 14px; line-height: 1.55; display: flex; flex-direction: column; gap: 6px; }

/* ---------- Mobile (≤900px) ---------- */
@media (max-width: 900px) {
  .app-header { padding: 0 12px; gap: 8px; height: 60px; }
  .brand-name, .header-context { display: none; }
  .header-nav { margin-left: 0; }
  .header-nav a { padding: 0 8px; font-size: 13px; }
  .lang-switch { display: none; }
  .lang-select { display: block; }
  .page { padding: 16px; }
  .clarify, .roadmap, .settings, .progress-grid { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: minmax(0, 1fr); }
  .grid-2, .choice-grid { grid-template-columns: minmax(0, 1fr); }
  .auth-form, .clarify-main, .roadmap-main, .settings-section { padding: 18px; }
  .settings-nav { position: static; flex-direction: row; flex-wrap: wrap; }
  .stage-est { display: none; }
  .stage-row { flex-wrap: wrap; }

  .lesson {
    display: flex; flex-direction: column; padding: 0; gap: 0;
  }
  .lesson > .panel { border-radius: 0; border-width: 0; flex: 1; }
  .lesson[data-mobile="path"] > :not(.path-panel):not(.mobile-tabs),
  .lesson[data-mobile="tutor"] > :not(.chat-panel):not(.mobile-tabs),
  .lesson[data-mobile="work"] > :not(.work-panel):not(.mobile-tabs) { display: none; }
  .chat-panel { padding: 12px; }
  .quick-replies { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; }
  .quick-replies .pill { flex: none; }
  .mobile-tabs {
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); height: 64px; flex: none;
    border-top: 1px solid var(--line); background: var(--panel);
  }
  .mobile-tabs button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border: 0;
    background: transparent; color: var(--muted); font-size: 12px; font-weight: 600; cursor: pointer; min-height: 44px;
  }
  .mobile-tabs button[aria-current="true"] { color: var(--primary); font-weight: 800; }
}

.toast {
  position: fixed; left: 50%; bottom: 80px; transform: translateX(-50%); z-index: 20; max-width: calc(100% - 32px);
  background: var(--ink); color: #FFFFFF; padding: 12px 16px; border-radius: var(--radius-control); font-size: 14px;
}

/* ---------- Account and admin (Phase 4) ---------- */
.account { gap: 16px; }
.limits { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.limit { display: flex; flex-direction: column; gap: 6px; }
.limit-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 14px; }
.limit-label { font-weight: 600; }
.limit-used { font-variant-numeric: tabular-nums; font-weight: 700; }
.limit-foot { display: flex; gap: 10px; flex-wrap: wrap; }
.limit.is-warn .limit-bar > span { background: var(--flame); }
.limit.is-full .limit-bar > span { background: var(--error); }
.limit-warn { color: #8A4B00; }
.limit.is-full .limit-warn { color: var(--error); }
.limit.is-warn .limit-bar, .limit.is-full .limit-bar { outline: 1px solid currentColor; outline-offset: 1px; }
.table-wrap { overflow-x: auto; max-width: 100%; }
.table { border-collapse: collapse; width: 100%; font-size: 14px; }
.table th, .table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table thead th { font-size: 13px; color: var(--muted); font-weight: 700; }
.table tbody th { font-weight: 600; }
.table .num-col { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.delete-account .delete-confirm p { max-width: none; }
.badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: var(--radius-pill); font-size: 12px; font-weight: 700; border: 1px solid var(--line); background: var(--soft); vertical-align: middle; margin-left: 6px; }
.badge-ok { border-color: var(--success); color: var(--success); background: #FFFFFF; }
.badge-fail { border-color: var(--error); color: var(--error); background: #FFFFFF; }
.row > .badge:first-child { margin-left: 0; }
.subnav { display: flex; gap: 4px; flex-wrap: wrap; }
.subnav-link { min-height: var(--control-h); display: inline-flex; align-items: center; padding: 0 14px; border-radius: var(--radius-control); color: var(--ink); text-decoration: none; font-weight: 600; border: 1px solid var(--line); background: var(--panel); }
.subnav-link[aria-current="page"] { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.admin-grid { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 16px; }
.admin-side, .admin-main { padding: 20px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.admin-side h2, .admin-main h2 { font-size: 18px; font-weight: 800; }
.prompt-group { display: flex; flex-direction: column; gap: 6px; }
.prompt-name { font-family: var(--font-code); font-size: 14px; }
.version-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.version-btn { width: 100%; min-height: var(--control-h); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--panel); color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.version-btn:hover { background: var(--soft); }
.version-btn[aria-pressed="true"] { border: 2px solid var(--primary); background: var(--soft); }
.version-n { font-weight: 700; }
.version-btn .badge { margin-left: 0; }
.prompt-detail { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.placeholders { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; font-size: 14px; }
.placeholders .label, .eval-case .label { font-weight: 600; }
.placeholders .chips { list-style: none; margin: 0; padding: 0; }
.chip { font-family: var(--font-code); font-size: 12px; padding: 2px 6px; border-radius: 6px; background: var(--soft); border: 1px solid var(--line); }
.prompt-text, .reply-text { font-family: var(--font-code); font-size: 13px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; background: var(--code-bg); border: 1px solid var(--line); border-radius: var(--radius-control); padding: 12px; margin: 0; }
.prompt-text { max-height: 420px; overflow-y: auto; }
.code-textarea { font-family: var(--font-code); font-size: 13px; min-height: 320px; }
.prompt-editor { gap: 8px; }
.activate-confirm p { max-width: 520px; }
.plain-fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.plain-fieldset legend { font-size: 14px; font-weight: 600; padding: 0; margin-bottom: 4px; }
.eval-status:empty { display: none; }
.eval-cases { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.eval-case { border: 1px solid var(--line); border-left-width: 4px; border-radius: var(--radius-control); padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.eval-case.is-pass { border-left-color: var(--success); }
.eval-case.is-fail { border-left-color: var(--error); }
.case-id { font-family: var(--font-code); font-size: 13px; overflow-wrap: anywhere; }
.failed-checks { color: var(--error); font-weight: 600; margin: 0; }
.judge-list { display: inline-flex; flex-wrap: wrap; gap: 4px 12px; list-style: none; margin: 0; padding: 0; }
.replies summary { cursor: pointer; font-weight: 600; font-size: 14px; min-height: 32px; display: flex; align-items: center; }
.replies .reply { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.run-facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; margin: 0; font-size: 14px; }
.run-facts dt { color: var(--muted); }
.run-facts dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
@media (max-width: 900px) {
  .header-nav { overflow-x: auto; min-width: 0; flex: 0 1 auto; scrollbar-width: none; }
  .header-nav a { white-space: nowrap; flex: none; }
  .admin-grid { grid-template-columns: minmax(0, 1fr); }
  .admin-side, .admin-main { padding: 16px; }
}

/* ---------- Kitaab redesign (2026-11-14): a printed book. Mockups: docs/design/kitaab.md ---------- */
h1, h2, .serif { font-family: var(--font-serif); font-weight: 600; letter-spacing: -0.015em; }
h1 { font-size: 34px; line-height: 1.1; }
h2 { font-size: 22px; line-height: 1.2; }
h3 { font-family: var(--font-ui); }
.eyebrow { color: var(--accent); letter-spacing: .1em; }
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

/* Header: wordmark with a red full stop, uppercase tracked nav, 2px ink rule */
.app-header { border-bottom: 2px solid var(--ink); height: 68px; padding: 0 28px; }
.brand-name { font-family: var(--font-serif); font-size: 28px; font-weight: 600; letter-spacing: -0.01em; }
.brand-dot { color: var(--accent); }
.header-nav { gap: 6px; margin-left: 16px; }
.header-nav a { color: var(--ink); font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; padding: 0 10px; }
.header-nav a[aria-current="page"] { background: none; color: var(--accent); text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 6px; }
.lang-switch { background: none; border: 1px solid var(--ink); padding: 0; gap: 0; }
.lang-switch button[aria-pressed="true"] { background: var(--ink); color: #FFFFFF; }
/* 1px ink line between the language buttons (English | हिन्दी | Hinglish). */
.lang-switch button + button { border-left: 1px solid var(--ink); }

/* Buttons: ink primary, red for the main action in a form, square */
.btn { border-color: var(--ink); }
.btn:hover:not(:disabled) { background: var(--soft); }
.btn-primary:hover:not(:disabled) { background: #000000; }
.btn-ghost { color: var(--accent); }
.composer .btn-primary, .btn-accent { background: var(--accent); border-color: var(--accent); }
.composer .btn-primary:hover:not(:disabled), .btn-accent:hover:not(:disabled) { background: var(--accent-hover); }
.pill { border-color: var(--ink); }

/* Panels are framed boxes; the lesson reads like an article */
.panel { border-width: 1px; }
.chat-head h1 { font-size: 26px; }
.bubble { font-size: 17px; line-height: 1.6; max-width: min(680px, 100%); }
.msg-tutor .bubble { background: none; padding: 2px 0; font-family: var(--font-serif); font-size: 19px; }
.msg-tutor .bubble:lang(hi):not(:lang(hi-Latn)) { font-family: var(--font-hi); }
.msg-learner { justify-content: flex-start; }
.msg-learner .bubble { background: none; color: var(--ink); border-left: 4px solid var(--ink); padding: 4px 0 4px 16px; max-width: min(560px, 90%); }
.bubble pre { border: 2px solid var(--ink); background: var(--code-bg); }
.bubble code { background: var(--soft); }
.composer textarea { border: 2px solid var(--ink); background: #FFFFFF; }

/* Path as a table of contents */
.path-item { color: var(--ink); font-family: var(--font-serif); font-size: 16px; }
.path-item[aria-current="step"] { background: none; border-color: transparent; color: var(--ink); }
.path-dot { border: 0; border-radius: 0; width: 30px; justify-content: flex-start; font-family: var(--font-ui); font-size: 12px; font-weight: 700; background: none; color: var(--ink); }
.path-item[aria-current="step"] .path-dot { background: none; color: var(--accent); }
.path-item[aria-current="step"] { font-weight: 600; }
.path-item.is-done { color: var(--muted); }
.path-item.is-done .path-dot { background: none; color: var(--muted); }

/* Workspace tabs: typographic, red underline */
.tab { color: var(--ink); text-transform: uppercase; letter-spacing: .08em; font-size: 12px; font-weight: 700; }
.tab[aria-selected="true"] { background: none; color: var(--accent); box-shadow: inset 0 -3px 0 var(--accent); }
.tablist { border-bottom-width: 1px; }

/* Practice questions as numbered exercises */
.q-card { border-width: 1px; }
.q-kind { letter-spacing: .1em; }
.progress { background: #FFFFFF; border: 1px solid var(--ink); height: 8px; }
.progress > * { background: var(--ink); }
.trace-code li.is-current { background: var(--tint); border-left-color: var(--accent); }
.vars-table tr.is-changed td { background: var(--tint); animation: none; }
.vars-table tr.is-return th, .vars-table tr.is-return td { color: var(--success); }

/* Phone: mobile tabs as typographic labels with a red top rule */
.mobile-tabs button[aria-selected="true"], .mobile-tabs a[aria-current="page"] { color: var(--accent); box-shadow: inset 0 3px 0 var(--accent); background: none; }
@media (max-width: 720px) {
  .app-header { padding: 0 14px; height: 60px; }
  .brand-name { font-size: 22px; }
  h1 { font-size: 28px; }
  .msg-tutor .bubble { font-size: 17px; }
}

/* Kitaab lesson screen: chapters column, article in the middle, framed workspace (mockup "D · Kitaab") */
.lesson { background: #FFFFFF; }
.lesson .panel.path-panel, .lesson .panel.chat-panel { border: 0; background: none; }
.lesson .path-panel { padding: 4px 0; }
.lesson .path-panel .eyebrow { color: var(--muted); }
.chat-head { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding-bottom: 16px; border-bottom: 2px solid var(--ink); }
.chat-head h1 { font-size: 44px; line-height: 1.05; }
.chapter-eyebrow { margin: 0; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--accent); }
.chapter-eyebrow > * { color: inherit; font: inherit; }
.chat-log { gap: 22px; padding-top: 10px; }
.composer { border: 2px solid var(--ink); gap: 0; align-items: stretch; }
.composer textarea { border: 0; min-height: 52px; padding: 14px 16px; font-size: 16px; }
.composer .btn { min-height: 52px; padding: 0 26px; }
.lesson .work-panel { border: 2px solid var(--ink); }
.lesson .work-panel .tablist { background: var(--soft); border-bottom: 1px solid var(--ink); }
.lesson .work-actions, .lesson .work-out { border-top-color: var(--ink); }
@media (min-width: 1200px) {
  .lesson { grid-template-columns: 220px minmax(0, 1fr) 460px; gap: 40px; padding: 28px 40px; }
}

/* Kitaab Progress: a newspaper front page (mockup board KProgress) */
.progress-page { max-width: 1200px; gap: 28px; }
.masthead { text-align: center; padding-bottom: 14px; border-bottom: 1px solid var(--ink); }
.masthead h1 { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.masthead-date { font-family: var(--font-ui); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); line-height: 1.4; }
.masthead-name { font-family: var(--font-serif); font-size: 56px; font-weight: 600; line-height: 1.02; letter-spacing: -0.015em; }
.masthead-sub { margin: 6px 0 0; font-family: var(--font-serif); font-size: 18px; font-style: italic; color: #3D3D3D; }

.k-front { display: flex; flex-wrap: wrap; gap: 40px; align-items: flex-start; }
.k-lead { flex: 999 1 520px; min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.k-side { flex: 1 1 380px; min-width: 0; max-width: 420px; display: flex; flex-direction: column; gap: 26px; padding-left: 28px; border-left: 1px solid var(--ink); }
.k-label { margin: 0 0 10px; font-family: var(--font-ui); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.k-kicker { margin: 0; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--accent); }
.k-lead-title { margin: 0; font-family: var(--font-serif); font-size: 46px; font-weight: 600; line-height: 1.05; letter-spacing: -0.015em; }
.k-lead-text { margin: 0; font-family: var(--font-serif); font-size: 20px; line-height: 1.6; max-width: 62ch; }
.k-lead-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 18px; }
.k-btn-lead { height: 52px; padding: 0 28px; font-size: 16px; font-weight: 700; gap: 10px; }
.k-note { margin: 0; font-size: 14px; color: var(--muted); }
.k-ok { color: var(--success); font-weight: 600; }

.k-contents { margin-top: 14px; border-top: 2px solid var(--ink); padding-top: 14px; }
.k-contents-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 16px; }
.k-contents-head .k-label { margin: 0; }
.k-contents-head .k-note { color: #3D3D3D; }
.k-contents .progress { margin: 10px 0 6px; }
.progress-page .progress { height: 6px; }
.k-toc { margin: 0; padding: 0; list-style: none; font-family: var(--font-serif); font-size: 19px; }
.k-toc-item { display: flex; align-items: baseline; gap: 14px; padding: 10px 0; border-bottom: 1px dashed var(--muted); color: #3D3D3D; }
.k-toc-item:last-child { border-bottom: 0; }
.k-toc-num { flex: none; width: 34px; font-family: var(--font-ui); font-size: 12px; font-weight: 700; }
.k-toc-title { flex: 1 1 auto; min-width: 0; }
.k-toc-state { flex: none; font-family: var(--font-ui); font-size: 13px; color: var(--muted); }
.k-toc-item.is-done { color: var(--muted); }
.k-toc-state.is-done { color: var(--success); font-weight: 600; }
/* Finished chapters: a green tick before the title, no line through it (mobile check 2026-11-21). */
.k-toc-item.is-done .k-toc-title::before { content: "✓ "; color: var(--success); font-weight: 700; }
.k-toc-item.is-now { color: var(--ink); font-weight: 600; }
.k-toc-item.is-now .k-toc-num, .k-toc-state.is-now { color: var(--accent); font-weight: 700; }

.k-side-sec .stats { display: flex; flex-wrap: wrap; gap: 0; border-top: 2px solid var(--ink); border-bottom: 1px solid var(--ink); }
.k-side-sec .stat { flex: 1 1 90px; padding: 12px; gap: 0; border-left: 1px solid var(--ink); }
.k-side-sec .stat:first-child { border-left: 0; padding-left: 0; }
.k-side-sec .stat:last-child { padding-right: 0; }
.k-side-sec .stat p { margin: 0; }
.k-side-sec .stat .value { font-family: var(--font-serif); font-size: 40px; font-weight: 600; line-height: 1; white-space: nowrap; }
.k-unit { font-size: 20px; }
.k-stat-label { margin-top: 6px !important; font-size: 13px; font-weight: 600; }
.k-stat-note { margin-top: 2px !important; font-family: var(--font-serif); font-size: 15px; color: #3D3D3D; }
.chart { height: 120px; border-bottom-color: var(--ink); }
.chart .bar { border-radius: 0; background: var(--ink); }
.chart .bar.top { background: var(--accent); }
.k-side-sec .k-note { margin-top: 8px; font-size: 13px; }

.k-goals { margin: 0; padding: 0; list-style: none; }
.k-goals .goal-progress { gap: 8px; padding: 12px 0; border-bottom: 1px dashed var(--muted); }
.k-goals .goal-progress:last-child { padding-bottom: 12px; border-bottom: 1px dashed var(--muted); }
.k-goal-link { display: flex; align-items: baseline; gap: 12px; width: 100%; min-height: 44px; padding: 0; border: 0; background: none; text-align: left; cursor: pointer; color: var(--ink); font: inherit; }
.k-goal-title { flex: 1 1 auto; min-width: 0; font-family: var(--font-serif); font-size: 20px; font-weight: 600; }
.k-goal-action { flex: none; font-size: 13px; font-weight: 700; color: var(--accent); }
.k-goal-link:hover .k-goal-title, .k-goal-link:focus-visible .k-goal-title { text-decoration: underline; }
.k-goal-bar { display: flex; align-items: center; gap: 10px; }
.k-goal-bar .progress { flex: 1 1 auto; }
.k-goal-bar .k-note { margin: 0; font-size: 13px; color: #3D3D3D; }

.k-box { border: 2px solid var(--ink); }
.k-box-head { margin: 0; padding: 10px 14px; background: var(--soft); border-bottom: 1px solid var(--ink); font-family: var(--font-ui); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; }
.k-box-body { padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.k-box-label { font-family: var(--font-serif); font-size: 17px; }
.k-inline-field { display: flex; border: 1px solid var(--ink); }
.k-inline-field input { flex: 1 1 auto; min-width: 0; height: 48px; padding: 0 12px; border: 0; border-radius: 0; font: inherit; font-size: 16px; color: var(--ink); background: #FFFFFF; }
.k-inline-field input:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.k-inline-field .btn { color: #FFFFFF; height: 48px; padding: 0 22px; border: 0; font-weight: 700; }
.k-box .k-note { font-size: 13px; }
.k-lead-topic { margin: 8px 0 0; font-family: var(--font-ui); font-size: 14px; font-weight: 700; color: var(--accent); }

/* Progress: "Start a new book" card (redesign 2026-11-16, prefix kp-new). */
.k-box.kp-new { border: 2px solid var(--ink); border-radius: 0; background: #FFFFFF; box-shadow: 6px 6px 0 var(--ink); padding: 18px 18px 16px; }
.kp-new-kicker { margin: 0; font-family: var(--font-ui); font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
.kp-new-body { display: flex; flex-direction: column; gap: 10px; }
.kp-new-title { margin-top: 4px; font-family: var(--font-serif); font-size: 24px; font-weight: 600; line-height: 1.15; }
.kp-new-area { width: 100%; min-height: 84px; padding: 12px 14px; border: 1px solid var(--ink); border-radius: 0; background: #FFFFFF; font-family: var(--font-serif); font-size: 16px; line-height: 1.45; resize: vertical; }
.kp-new-area:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.kp-new-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.kp-chip { padding: 5px 11px; border: 1px solid var(--ink); border-radius: 0; background: #FFFFFF; color: var(--ink); font-family: var(--font-ui); font-size: 12px; cursor: pointer; }
.kp-chip:hover { background: var(--soft); }
.kp-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.kp-new-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; }
.kp-new-foot .k-note { margin: 0; flex: 1 1 160px; }
.kp-new-go.btn { flex: none; min-height: 42px; padding: 0 20px; border-radius: 0; color: #FFFFFF; font-weight: 700; }

@media (max-width: 720px) {
  .masthead-name { font-size: 34px; }
  .k-lead-title { font-size: 32px; }
  .k-lead-text { font-size: 18px; }
  .k-side { max-width: none; padding-left: 0; border-left: 0; border-top: 2px solid var(--ink); padding-top: 18px; }
  .k-side-sec .stat .value { font-size: 32px; }
}
