/* Lecture Studio — editorial interface
   Paper, ink, and a single oxblood accent. Mobile first. */

:root {
  --paper: #f7f4ec;
  --paper-deep: #efe9dc;
  --surface: #fffdf8;
  --surface-2: #fbf8f1;
  --ink: #14120f;
  --ink-2: #3c3730;
  --muted: #6a6155;
  --line: #e3dccd;
  --line-strong: #cfc5b2;
  --accent: #8a1c1c;
  --accent-ink: #6d1414;
  --accent-soft: #f4e5e1;
  --green: #1f5f4e;
  --green-soft: #e2efe9;
  --amber: #8a641c;
  --amber-soft: #f6ecd7;
  --shadow: 0 1px 2px rgba(30, 24, 16, .05), 0 10px 30px -18px rgba(30, 24, 16, .25);
  --shadow-lg: 0 2px 6px rgba(30, 24, 16, .06), 0 24px 60px -28px rgba(30, 24, 16, .35);
  --radius: 14px;
  --radius-sm: 9px;
  --font-display: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, "Noto Naskh Arabic", serif;
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans Arabic", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --max: 1180px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-ui);
  color: var(--ink);
  background:
    radial-gradient(1100px 520px at 100% -8%, rgba(138, 28, 28, .05), transparent 62%),
    radial-gradient(900px 480px at -8% 108%, rgba(31, 95, 78, .05), transparent 60%),
    var(--paper);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-size: 15.5px;
  line-height: 1.5;
  overflow-x: hidden;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; letter-spacing: -.015em; margin: 0; }
p { margin: 0 0 12px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 22px 0; }
.muted { color: var(--muted); }
.mono { font-family: var(--font-mono); }
.small { font-size: 13px; }
.tiny { font-size: 11.5px; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ------------------------------------------------------------------ chrome */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px max(18px, env(safe-area-inset-left)) 12px max(18px, env(safe-area-inset-right));
  background: rgba(247, 244, 236, .86);
  -webkit-backdrop-filter: saturate(1.2) blur(14px);
  backdrop-filter: saturate(1.2) blur(14px);
  border-bottom: 1px solid var(--line);
}
.wordmark { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none !important; }
.wordmark .mark {
  display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 9px;
  background: var(--ink); color: #f7f4ec;
  font-family: var(--font-display); font-size: 13px; letter-spacing: .04em;
}
.wordmark-text { font-family: var(--font-display); font-size: 18px; letter-spacing: -.02em; }
.wordmark-text strong { font-weight: 600; }
.wordmark-text em { font-style: italic; color: var(--accent); font-weight: 400; margin-left: 2px; }
.topnav { display: flex; align-items: center; gap: 4px; }
.topnav > a {
  color: var(--ink-2); padding: 9px 12px; border-radius: 999px; font-size: 13.5px;
  text-decoration: none; min-height: 40px; display: inline-flex; align-items: center;
}
.topnav > a:hover { background: rgba(20, 18, 15, .05); }
.topnav > a.is-active { background: var(--ink); color: var(--paper); }
.userchip {
  display: none; align-items: center; gap: 7px; font-size: 12px; color: var(--muted);
  padding-left: 10px; margin-left: 4px; border-left: 1px solid var(--line);
}
.userchip .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
.sitefoot {
  margin-top: auto; border-top: 1px solid var(--line);
  padding: 18px max(18px, env(safe-area-inset-left));
  display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center;
  font-size: 12px; color: var(--muted);
}
.sitefoot a { color: var(--muted); }
.shell { width: min(var(--max), 100%); margin: 0 auto; padding: 26px 18px 48px; flex: 1 0 auto; }

/* ------------------------------------------------------------------ pieces */
.kicker {
  font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--accent); font-weight: 700;
}
.pagehead { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 26px; }
.pagehead h1 { font-size: clamp(28px, 5vw, 42px); line-height: 1.06; }
.pagehead .sub { color: var(--muted); font-size: 13.5px; margin-top: 6px; }
.pagehead .actions { display: flex; flex-wrap: wrap; gap: 8px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 44px; padding: 0 17px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  font-size: 14px; font-weight: 550; cursor: pointer; text-decoration: none !important;
  transition: transform .12s ease, background .15s ease, border-color .15s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: var(--ink-2); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--ink); border-color: var(--ink); color: #fbf8f1; }
.btn-primary:hover { background: #2a251e; border-color: #2a251e; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: rgba(20, 18, 15, .05); border-color: transparent; }
.btn-danger { color: var(--accent); border-color: #e6c9c3; background: #fff8f6; }
.btn-danger:hover { background: var(--accent-soft); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 12.5px; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.iconbtn {
  width: 38px; height: 38px; min-height: 38px; padding: 0; border-radius: 9px;
  border: 1px solid transparent; background: transparent; color: #5f574b; cursor: pointer;
  display: inline-grid; place-items: center; font-size: 15px;
}
.iconbtn:hover { background: rgba(20, 18, 15, .06); color: var(--ink); }
.iconbtn.danger:hover { background: var(--accent-soft); color: var(--accent); }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.pad { padding: 20px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 650; letter-spacing: .02em; background: var(--paper-deep); color: var(--ink-2);
  white-space: nowrap;
}
.chip.ok { background: var(--green-soft); color: var(--green); }
.chip.warn { background: var(--amber-soft); color: var(--amber); }
.chip.draft { background: #eee9de; color: #6d6456; }
.chip.accent { background: var(--accent-soft); color: var(--accent); }
.chip .pulse { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

/* ------------------------------------------------------------------- forms */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 15px; }
.field label { font-size: 12px; font-weight: 650; letter-spacing: .03em; color: var(--ink-2); text-transform: uppercase; }
.field .hint { font-size: 12px; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; min-height: 46px; padding: 10px 13px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(138, 28, 28, .1);
}
.textarea { min-height: 110px; resize: vertical; line-height: 1.55; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 620px) { .row2 { grid-template-columns: 1fr; } }

/* --------------------------------------------------------------- dashboard */
.hero {
  display: grid; grid-template-columns: 1.5fr .9fr; gap: 28px; align-items: end;
  padding: 10px 0 26px;
}
.hero h1 { font-size: clamp(34px, 6vw, 58px); line-height: .98; letter-spacing: -.03em; }
.hero h1 em { font-style: italic; color: var(--accent); }
.hero p { color: var(--muted); max-width: 52ch; margin-top: 14px; font-size: 15px; }
.hero-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin-top: 22px; }
.hero-stats div { padding: 14px 12px 14px 0; }
.hero-stats strong { display: block; font-family: var(--font-display); font-size: 30px; line-height: 1; font-weight: 600; }
.hero-stats span { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.hero-side { border-left: 1px solid var(--line); padding-left: 24px; }
.hero-side .kicker { display: block; margin-bottom: 10px; }
.sysline { display: flex; justify-content: space-between; gap: 10px; font-size: 12.5px; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.sysline:last-child { border-bottom: 0; }
.sysline span:first-child { color: var(--muted); }

.course-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 10px; }
.course-card {
  display: flex; flex-direction: column; gap: 12px; padding: 20px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); color: var(--ink); text-decoration: none !important;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
  position: relative; overflow: hidden;
}
.course-card::after {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--accent);
  transform: scaleY(0); transform-origin: top; transition: transform .18s ease;
}
.course-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--line-strong); }
.course-card:hover::after { transform: scaleY(1); }
.course-card .code { font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); font-weight: 700; }
.course-card h3 { font-size: 22px; line-height: 1.15; }
.course-card p { color: var(--muted); font-size: 13px; margin: 0; min-height: 38px; }
.course-card .meta { display: flex; justify-content: space-between; align-items: center; margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); font-size: 11.5px; color: var(--muted); }
.progress { height: 4px; border-radius: 9px; background: var(--paper-deep); overflow: hidden; margin-top: 4px; }
.progress > i { display: block; height: 100%; background: var(--green); border-radius: 9px; }

.sectionhead { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin: 38px 0 14px; }
.sectionhead h2 { font-size: 24px; }
.jobs { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.jobrow { display: grid; grid-template-columns: 14px 1fr auto; gap: 12px; align-items: center; padding: 11px 2px; border-bottom: 1px solid var(--line); font-size: 13px; }
.jobrow .st { width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); }
.jobrow .st.done { background: var(--green); }
.jobrow .st.error { background: var(--accent); }
.jobrow .st.running { background: var(--amber); animation: breathe 1.4s infinite; }
@keyframes breathe { 50% { opacity: .35; } }
.jobrow .what { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jobrow .when { color: var(--muted); font-size: 11.5px; }

.empty {
  border: 1px dashed var(--line-strong); border-radius: var(--radius);
  padding: 40px 24px; text-align: center; background: rgba(255, 253, 248, .5);
}
.empty .glyph { font-family: var(--font-display); font-size: 48px; color: var(--accent); opacity: .55; line-height: 1; }
.empty h3 { font-size: 22px; margin: 10px 0 6px; }
.empty p { color: var(--muted); max-width: 46ch; margin: 0 auto 16px; }

/* -------------------------------------------------------------- course page */
.crumb { font-size: 12px; color: var(--muted); margin-bottom: 10px; display: flex; gap: 7px; align-items: center; }
.crumb a { color: var(--muted); }
.course-head { border-bottom: 2px solid var(--ink); padding-bottom: 20px; margin-bottom: 6px; }
.course-head h1 { font-size: clamp(30px, 5.5vw, 52px); margin-top: 6px; }
.course-head .desc { color: var(--muted); max-width: 70ch; margin-top: 10px; }
.lecture-list { border-bottom: 1px solid var(--line); }
.lecture-row {
  display: grid; grid-template-columns: 52px 1fr auto; gap: 14px; align-items: center;
  padding: 15px 4px; border-top: 1px solid var(--line); color: var(--ink);
  text-decoration: none !important; transition: background .12s ease;
}
.lecture-row:hover { background: rgba(255, 253, 248, .75); }
.lecture-row .num { font-family: var(--font-display); font-size: 22px; color: #b3a793; text-align: right; }
.lecture-row:hover .num { color: var(--accent); }
.lecture-row h3 { font-size: 18px; font-weight: 550; line-height: 1.25; }
.lecture-row .sub { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 4px; color: var(--muted); font-size: 11.5px; }
.lecture-row .end { display: flex; align-items: center; gap: 6px; }
.lecture-row .end .btn { min-height: 36px; }
@media (max-width: 720px) {
  .lecture-row { grid-template-columns: 38px 1fr; }
  .lecture-row .end { grid-column: 2; justify-content: flex-start; flex-wrap: wrap; }
  .lecture-row .num { font-size: 18px; }
}

/* ------------------------------------------------------------------ editor */
body.editor { background: #f4f0e7; }
body.editor .sitefoot { display: none; }
.editor-shell { width: min(1320px, 100%); margin: 0 auto; padding: 0 0 180px; flex: 1 0 auto; }
.editor-top {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px; padding: 10px max(14px, env(safe-area-inset-left));
  background: rgba(247, 244, 236, .93); border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
}
.editor-top .back { flex: none; }
.editor-title { min-width: 0; flex: 1; }
.editor-title .t { font-family: var(--font-display); font-size: 18px; line-height: 1.15; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.editor-title .s { font-size: 11px; color: var(--muted); letter-spacing: .05em; text-transform: uppercase; margin-top: 2px; }
.editor-top .actions { display: flex; gap: 6px; align-items: center; }
.save-state { font-size: 11.5px; color: var(--ink-2); min-width: 64px; text-align: right; }
.save-state.dirty { color: var(--amber); }
.save-state.error { color: var(--accent); font-weight: 600; }

.tabbar { display: flex; gap: 2px; padding: 10px max(14px, env(safe-area-inset-left)); border-bottom: 1px solid var(--line); background: transparent; overflow-x: auto; }
.tabbar button {
  border: 0; background: transparent; padding: 9px 14px; min-height: 40px; border-radius: 999px;
  font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap;
}
.tabbar button.is-active { background: var(--ink); color: var(--paper); }
.tabbar .spacer { flex: 1; }
.tabbar .meta-note { align-self: center; font-size: 11px; color: var(--muted); padding: 4px 10px; border-radius: 999px; }
.tabbar .meta-note.warn-chip { background: var(--amber-soft); color: var(--amber); font-weight: 600; }

.panel { display: none; padding: 20px max(14px, env(safe-area-inset-left)); }
.panel.is-active { display: block; }
.cells { display: flex; flex-direction: column; gap: 12px; max-width: 980px; margin: 0 auto; }
.cell {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 1px 1px rgba(30, 24, 16, .03); overflow: hidden;
}
.cell.is-running { border-color: var(--amber); box-shadow: 0 0 0 3px rgba(138, 100, 28, .1); }
.cell:focus-within { border-color: #c9a9a2; box-shadow: 0 0 0 3px rgba(138, 28, 28, .06); }
.cell-head { display: flex; align-items: center; gap: 8px; padding: 7px 10px; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.cell-head .idx { font-family: var(--font-mono); font-size: 10.5px; color: var(--muted); min-width: 24px; }
.cell-head .type {
  border: 1px solid var(--line-strong); background: transparent; border-radius: 6px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  padding: 3px 6px; color: var(--ink-2); cursor: pointer;
}
.cell.markdown .cell-head .type { color: var(--green); border-color: #bcd8cd; }
.cell-head .grow { flex: 1; }
.cell-head .tools { display: flex; gap: 2px; }
.cell-body .cm-host { font-size: 13.5px; }
.cell-body .cm-editor { min-height: 42px; }
.cell-body .cm-scroller { font-family: var(--font-mono); }
.cell-out { border-top: 1px dashed var(--line); padding: 8px 14px 10px; background: #fcfaf4; font-size: 12.5px; }
.cell-out .outprompt { font-family: var(--font-mono); font-size: 10px; color: var(--accent); opacity: .7; margin-bottom: 4px; }
.cell-out pre { margin: 0 0 6px; font-family: var(--font-mono); font-size: 12px; white-space: pre-wrap; word-break: break-word; }
.cell-out img { border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.cell-out .err { color: var(--accent); }
.cell-out iframe { width: 100%; border: 0; background: #fff; min-height: 40px; }
.md-preview { padding: 14px 18px; font-size: 14.5px; line-height: 1.6; min-height: 26px; }
.md-preview:empty::before { content: "Empty cell — tap to write."; color: var(--muted); font-style: italic; font-size: 13px; }
.md-preview h1, .md-preview h2, .md-preview h3 { margin: 14px 0 6px; }
.md-preview h1 { font-size: 26px; } .md-preview h2 { font-size: 21px; } .md-preview h3 { font-size: 17px; }
.md-preview p { margin: 0 0 8px; }
.md-preview code { background: var(--paper-deep); padding: 1px 5px; border-radius: 4px; font-family: var(--font-mono); font-size: 12.5px; }
.md-preview pre { background: var(--paper-deep); padding: 10px; border-radius: 8px; overflow-x: auto; }
.md-preview table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.md-preview td, .md-preview th { border: 1px solid var(--line); padding: 5px 7px; }
.md-preview img { border-radius: 6px; }

.addrow { display: flex; justify-content: center; gap: 8px; padding: 16px 0 8px; }
.addrow .btn { background: rgba(255, 253, 248, .7); }

.editor-bar {
  position: fixed; z-index: 35; left: 0; right: 0; bottom: 0;
  display: flex; gap: 8px; align-items: center; justify-content: center;
  padding: 10px max(12px, env(safe-area-inset-left)) calc(10px + env(safe-area-inset-bottom));
  background: rgba(247, 244, 236, .95); border-top: 1px solid var(--line);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
.editor-bar .grow { flex: 1; }
.editor-bar .status { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 42vw; }

/* ------------------------------------------------------------------- files */
.files-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; margin-bottom: 12px; max-width: 980px; margin-inline: auto; }
.breadcrumb { font-family: var(--font-mono); font-size: 12px; color: var(--muted); display: flex; gap: 4px; flex-wrap: wrap; }
.breadcrumb a { color: var(--ink-2); }
.filelist { max-width: 980px; margin: 0 auto; border-top: 1px solid var(--line); }
.filerow { display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; align-items: center; padding: 10px 4px; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.filerow .ico { color: var(--muted); text-align: center; font-size: 15px; }
.filerow a.name { color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filerow .size { font-size: 11px; color: var(--muted); white-space: nowrap; }
.filerow .acts { display: flex; gap: 2px; }
.dropzone { border: 1px dashed var(--line-strong); border-radius: var(--radius); padding: 26px; text-align: center; color: var(--muted); font-size: 13px; max-width: 980px; margin: 14px auto; }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }

/* ------------------------------------------------------------------ details */
.details-wrap { max-width: 720px; margin: 0 auto; }
.details-wrap h3 { font-size: 20px; margin-bottom: 12px; }

/* ----------------------------------------------------------------- settings */
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.settings-grid .wide { grid-column: 1 / -1; }
.settings-grid h3 { font-size: 20px; margin-bottom: 4px; }
.settings-grid .lead { color: var(--muted); font-size: 12.5px; margin-bottom: 16px; }
@media (max-width: 860px) { .settings-grid { grid-template-columns: 1fr; } }

/* -------------------------------------------------------------------- auth */
body.auth { background: var(--ink); }
.auth-shell { display: grid; grid-template-columns: 1.05fr .95fr; min-height: 100dvh; }
.auth-art {
  position: relative; overflow: hidden; padding: 48px;
  background:
    radial-gradient(700px 500px at 80% 10%, rgba(138, 28, 28, .5), transparent 60%),
    radial-gradient(600px 500px at 10% 90%, rgba(31, 95, 78, .35), transparent 60%),
    #14120f;
  color: #f4efe4; display: flex; flex-direction: column; justify-content: space-between;
}
.auth-art .mark { width: 44px; height: 44px; border-radius: 11px; background: #f4efe4; color: var(--ink); display: grid; place-items: center; font-family: var(--font-display); font-size: 15px; }
.auth-art h2 { font-size: clamp(32px, 4vw, 52px); line-height: 1.02; max-width: 15ch; }
.auth-art h2 em { font-style: italic; color: #e9b9ae; }
.auth-art p { color: #b9b0a2; font-size: 13.5px; max-width: 42ch; }
.auth-art .foot { font-size: 11.5px; letter-spacing: .1em; text-transform: uppercase; color: #8a8072; }
.auth-form { background: var(--paper); display: flex; align-items: center; justify-content: center; padding: 32px 22px; }
.auth-card { width: min(410px, 100%); }
.auth-card h1 { font-size: 32px; margin-bottom: 6px; }
.auth-card .lead { color: var(--muted); font-size: 13.5px; margin-bottom: 24px; }
.auth-card .btn { width: 100%; }
.auth-card .alt { margin-top: 18px; font-size: 12px; color: var(--muted); text-align: center; }
.qrbox { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: grid; place-items: center; }
.qrbox svg { width: 190px; height: 190px; }
.secret { font-family: var(--font-mono); font-size: 12px; background: var(--paper-deep); padding: 9px 11px; border-radius: 8px; word-break: break-all; text-align: center; }
.steps { display: flex; gap: 6px; margin-bottom: 22px; }
.steps i { height: 3px; border-radius: 3px; background: var(--line); flex: 1; }
.steps i.on { background: var(--accent); }
@media (max-width: 820px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .auth-form { min-height: 100dvh; background: var(--paper); }
}

/* ------------------------------------------------------------------ dialog */
dialog.modal {
  border: 1px solid var(--line); border-radius: 16px; padding: 0; width: min(520px, calc(100vw - 28px));
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg);
}
dialog.modal::backdrop { background: rgba(20, 18, 15, .42); backdrop-filter: blur(2px); }
dialog.modal form { padding: 22px; }
dialog.modal h3 { font-size: 23px; margin-bottom: 4px; }
dialog.modal .lead { color: var(--muted); font-size: 12.5px; margin-bottom: 18px; }
dialog.modal .modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

/* ------------------------------------------------------------------- toast */
.toast {
  position: fixed; left: 50%; bottom: 86px; transform: translate(-50%, 16px);
  background: var(--ink); color: #fbf8f1; padding: 11px 18px; border-radius: 999px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease;
  z-index: 100; max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--accent); }

/* ------------------------------------------------------------- CodeMirror */
.cm-editor { outline: none; background: transparent; }
.cm-editor.cm-focused { outline: none; }
.cm-content { padding: 10px 0; caret-color: var(--accent); }
.cm-line { padding: 0 14px; }
.cm-gutters { background: transparent; border: 0; color: #b3a999; }
.cm-activeLine { background: rgba(20, 18, 15, .025); }
.cm-selectionBackground, .cm-editor ::selection { background: rgba(138, 28, 28, .16) !important; }
.cm-cursor { border-left-color: var(--accent) !important; }
.cm-placeholder { color: #a89e8e; font-style: italic; }
.cm-tooltip { border-radius: 8px; border: 1px solid var(--line); box-shadow: var(--shadow); }

/* ---------------------------------------------------------------- responsive */
@media (min-width: 700px) { .userchip { display: inline-flex; } }
@media (max-width: 960px) {
  .course-grid { grid-template-columns: repeat(2, 1fr); }
  .hero { grid-template-columns: 1fr; }
  .hero-side { border-left: 0; padding-left: 0; border-top: 1px solid var(--line); padding-top: 18px; }
}
@media (max-width: 420px) {
  .wordmark-text { display: none; }
}
@media (max-width: 640px) {
  body { font-size: 15px; }
  .shell { padding: 18px 14px 40px; }
  .course-grid { grid-template-columns: 1fr; }
  .hero { padding-top: 4px; gap: 10px; }
  .hero-stats strong { font-size: 25px; }
  .pagehead { align-items: flex-start; }
  .pagehead .actions { width: 100%; }
  .pagehead .actions .btn { flex: 1; }
  .editor-top { top: 0; flex-wrap: nowrap; }
  .editor-title { order: 2; flex: 1; }
  .editor-title .s { display: none; }
  .editor-title .t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .editor-top .save-state { order: 3; margin-left: auto; }
  .tabbar { padding-top: 8px; padding-bottom: 8px; }
  .panel { padding: 12px 10px; }
  .cell-head { padding: 5px 7px; }
  .cell-head .tools .iconbtn { width: 44px; height: 44px; min-height: 44px; font-size: 16px; background: rgba(20,18,15,.04); }
  .cell-head .type { padding: 6px 7px; }
  .editor-bar { justify-content: space-between; }
  .editor-bar .status { display: none; }
  .editor-bar .btn { flex: 1; padding: 0 10px; font-size: 13px; }
  .settings-grid { gap: 12px; }
  .pad { padding: 16px; }
  .lecture-row .end .btn span { display: none; }
}
@media (min-width: 900px) {
  .editor-bar { display: none; }
}
@media (max-width: 899px) {
  .editor-top .actions { display: none; }
  .addrow { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* =========================================================================
   v2 — expanded studio: palette, preview, outline, image cells, system
   ========================================================================= */
.topsearch {
  display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 12px;
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  border-radius: 999px; font-size: 12.5px; cursor: pointer;
}
.topsearch:hover { border-color: var(--line-strong); color: var(--ink); }
.topsearch kbd {
  font-family: var(--font-mono); font-size: 9.5px; background: var(--paper-deep);
  padding: 1px 5px; border-radius: 4px; color: var(--ink-2);
}
.mark-img {
  width: 36px; height: 36px; object-fit: contain; border-radius: 9px;
  background: #fff; border: 1px solid var(--line); padding: 2px;
}

/* command palette */
.palette {
  position: fixed; inset: 0; z-index: 200; display: flex; justify-content: center;
  padding: 11vh 12px 12px; background: rgba(20, 18, 15, .42);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
}
.palette-box {
  width: min(660px, 100%); max-height: 68vh; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow-lg); overflow: hidden;
}
.palette-input {
  width: 100%; border: 0; border-bottom: 1px solid var(--line); background: transparent;
  padding: 17px 18px; font-size: 16px; outline: none;
}
.palette-results { overflow: auto; padding: 6px; }
.palette-item {
  display: flex; gap: 10px; width: 100%; text-align: left; border: 0; background: transparent;
  padding: 10px; border-radius: 10px; cursor: pointer;
}
.palette-item.on { background: var(--accent-soft); }
.pkind {
  min-width: 54px; padding-top: 3px; font-size: 9.5px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--accent); font-weight: 700;
}
.pmain { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.psub {
  font-size: 11.5px; color: var(--muted); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.palette-foot {
  display: flex; gap: 16px; padding: 8px 14px; border-top: 1px solid var(--line);
  font-size: 10.5px; color: var(--muted);
}
.palette-hint { padding: 18px; text-align: center; font-size: 13px; color: var(--muted); }
.shortcut-grid { display: grid; grid-template-columns: auto 1fr; gap: 9px 18px; font-size: 13px; }
.shortcut-grid .mono { color: var(--accent); }

/* editor workspace + live preview */
.workspace { display: block; }
.workspace.with-preview {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px; max-width: 1500px; margin: 0 auto; padding: 0 14px;
}
.workspace.with-preview .panel { max-height: calc(100vh - 190px); overflow: auto; padding-right: 6px; }
.preview-pane {
  position: sticky; top: 118px; height: calc(100vh - 150px); display: flex; flex-direction: column;
  border: 1px solid var(--line); border-radius: 12px; background: #fff; overflow: hidden;
}
.preview-head {
  display: flex; gap: 6px; align-items: center; padding: 8px 10px;
  border-bottom: 1px solid var(--line); background: var(--surface-2);
  font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
}
.preview-head .grow { flex: 1; }
.preview-pane iframe { flex: 1; border: 0; width: 100%; background: #fff; }

/* outline */
.outline-panel {
  position: fixed; top: 68px; right: 18px; z-index: 80; width: min(330px, calc(100vw - 24px));
  max-height: 70vh; overflow: auto; padding: 8px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow-lg);
}
.outline-head {
  display: flex; justify-content: space-between; align-items: center; padding: 6px 8px;
  font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
}
.outline-item {
  display: block; width: 100%; text-align: left; border: 0; background: transparent;
  padding: 7px 10px; border-radius: 8px; font-size: 13px; color: var(--ink-2); cursor: pointer;
}
.outline-item:hover { background: var(--paper-deep); }
.outline-item.lvl-1 { font-weight: 700; }
.outline-item.lvl-2 { padding-left: 22px; }
.outline-item.lvl-3 { padding-left: 34px; font-size: 12px; color: var(--muted); }

/* cell chrome v2 */
.cell { overflow: visible; position: relative; }
.cell-head { border-radius: 11px 11px 0 0; }
.grip { cursor: grab; color: #c3b8a5; font-size: 12px; padding: 0 2px; user-select: none; }
.cell.dragging { opacity: .45; }
.cell.flash { animation: lsflash 1.2s ease; }
@keyframes lsflash {
  0% { box-shadow: 0 0 0 4px rgba(138, 28, 28, .18); }
  100% { box-shadow: var(--shadow); }
}
.cmenu { position: relative; }
.cmenu summary { list-style: none; cursor: pointer; }
.cmenu summary::-webkit-details-marker { display: none; }
.cmenu-body {
  position: absolute; right: 0; top: 40px; z-index: 60; min-width: 196px; padding: 6px;
  display: flex; flex-direction: column; background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg);
}
.cmenu-body button {
  border: 0; background: transparent; text-align: left; padding: 8px 10px;
  border-radius: 7px; font-size: 12.5px; color: var(--ink-2); cursor: pointer;
}
.cmenu-body button:hover { background: var(--paper-deep); }
.cmenu-body button.danger { color: var(--accent); }
.cmenu-body hr { margin: 4px 2px; }

/* image cells */
.image-cell { padding: 10px 14px 14px; }
.image-frame {
  background: var(--paper-deep); border-radius: 10px; padding: 10px;
  text-align: center; margin-bottom: 10px;
}
.image-frame img { border-radius: 6px; max-height: 440px; object-fit: contain; }
.image-drop {
  width: 100%; padding: 30px 20px; display: flex; flex-direction: column; align-items: center;
  gap: 4px; border: 1.5px dashed var(--line-strong); border-radius: 12px;
  background: var(--surface-2); color: var(--ink-2); cursor: pointer;
}
.image-drop .big { font-size: 30px; color: var(--accent); line-height: 1; }
.image-drop:hover { border-color: var(--accent); background: var(--accent-soft); }
.ic-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.ic-row .input { min-height: 40px; }
.segmented { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; }
.segmented button {
  border: 0; background: transparent; padding: 7px 10px; font-size: 11.5px;
  color: var(--muted); cursor: pointer;
}
.segmented button.on { background: var(--ink); color: var(--paper); }

/* details extras */
.exportrow { display: flex; gap: 6px; flex-wrap: wrap; }
.history-list { display: flex; flex-direction: column; }
.history-row {
  display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center;
  padding: 9px 0; border-bottom: 1px solid var(--line);
}
.history-row:last-child { border-bottom: 0; }

/* files v2 */
.filerow .thumb {
  width: 34px; height: 34px; border-radius: 6px; overflow: hidden; display: grid;
  place-items: center; background: #fff; border: 1px solid var(--line);
}
.filerow .thumb img { width: 100%; height: 100%; object-fit: cover; }

/* system page */
.statgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 22px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 15px; }
.stat strong { display: block; font-family: var(--font-display); font-size: 26px; line-height: 1.1; }
.stat span { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.jobline {
  display: grid; grid-template-columns: 92px 1fr 70px 150px; gap: 10px; align-items: center;
  padding: 9px 2px; border-bottom: 1px solid var(--line); font-size: 12.5px;
}
.jobline .err { color: var(--accent); }
.pillstatus { font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.pillstatus.done { color: var(--green); }
.pillstatus.error { color: var(--accent); }
.pillstatus.running { color: var(--amber); }
.pillstatus.canceled { color: var(--muted); }

/* settings extras */
.logo-row { display: flex; gap: 14px; align-items: center; margin-bottom: 12px; }
.logo-preview {
  width: 76px; height: 76px; border-radius: 12px; border: 1px solid var(--line);
  background: #fff; display: grid; place-items: center; overflow: hidden; flex: none;
}
.logo-preview img { max-width: 100%; max-height: 100%; }
.trash-row {
  display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center;
  padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13px;
}

/* dashboard mark */
.cc-mark {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
  background: var(--paper-deep); color: var(--accent);
  font-family: var(--font-display); font-size: 15px;
}

@media (max-width: 1100px) {
  .workspace.with-preview { grid-template-columns: 1fr; padding: 0; }
  .preview-pane { position: fixed; inset: 0; height: 100dvh; z-index: 120; border-radius: 0; }
  .workspace.with-preview .panel { max-height: none; overflow: visible; }
}
@media (max-width: 700px) {
  .topnav a[href="/system"] { display: none; }
  .topsearch { width: 40px; padding: 0; justify-content: center; }
  .topsearch span, .topsearch kbd { display: none; }
  .topsearch::before { content: "⌕"; font-size: 18px; }
  .statgrid { grid-template-columns: repeat(2, 1fr); }
  .jobline { grid-template-columns: 1fr auto; }
  .jobline .mono { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .history-row { grid-template-columns: 1fr auto; }
  .history-row > div:nth-child(2) { display: none; }
  .image-frame img { max-height: 300px; }
}

