.tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--brick);
  box-shadow: var(--engrave);
  padding: 15px 16px;
  transition: border-radius .3s cubic-bezier(.4,0,.2,1);
}
@media (min-width: 700px) { .tile { padding: 18px 20px; } }
@media (hover: hover) {
  .tile:hover { border-radius: var(--brick-flip); }
  .tile.flat:hover { border-radius: var(--brick); }
}

/* Panels are tinted washes, not saturated blocks — this is a surface someone
   reads and writes on for an hour at a time. */
.tile-hero {
  background: linear-gradient(140deg, #f3f8fd 0%, #e4eff9 55%, #fbeef0 100%);
  border-color: rgba(127, 178, 221, .38);
  color: var(--ink);
}
.tile-blue { background: var(--blue-wash); border-color: rgba(127,178,221,.4); }
.tile-pink { background: var(--pink-wash); border-color: rgba(232,180,184,.5); }
.tile-slate { background: var(--slate); color: #f2f5f8; border-color: transparent; }
.tile-slate a { color: inherit; }
.tile-slate .tile-label { opacity: .68; }

.tile-label {
  font-size: 11px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .11em; opacity: .72; margin-bottom: 6px;
}
.tile-figure {
  font-family: var(--font-display); font-weight: 900;
  font-size: clamp(1.8rem, 8vw, 2.7rem); line-height: 1; letter-spacing: -0.03em;
}
.tile-sub { font-size: 12.5px; opacity: .78; margin-top: 4px; }

/* ── Pills, badges, meta ───────────────────────────────────────── */

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 11px; border-radius: 999px; font-size: 11.5px; font-weight: 700;
  background: var(--surface-2); border: 1px solid var(--line-soft); color: var(--muted);
  text-decoration: none; white-space: nowrap;
}
a.pill, button.pill { min-height: 32px; }
.pill.solid { background: var(--slate); color: #fff; border-color: transparent; }
.pill.blue { background: var(--blue-wash); color: var(--blue-deep); border-color: rgba(127,178,221,.45); }
.pill.pink { background: var(--pink-wash); color: var(--pink-deep); border-color: rgba(232,180,184,.5); }
.pill.ok { background: color-mix(in srgb, var(--ok) 13%, transparent); color: var(--ok); border-color: transparent; }
.pill.warn { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); border-color: transparent; }
.pill.alert { background: color-mix(in srgb, var(--alert) 15%, transparent); color: var(--alert); border-color: transparent; }

.meta { color: var(--muted); font-size: 12.5px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.row.tight { gap: 6px; }
.push { margin-left: auto; }
.hide-sm { display: none; }
@media (min-width: 700px) { .hide-sm { display: initial; } }

/* Any wide thing — a table, a code block — scrolls inside its own box
   rather than pushing the page sideways. */
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ── Progress ──────────────────────────────────────────────────── */

.bar { height: 7px; background: var(--line-soft); border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--blue-deep); border-radius: 999px; transition: width .45s ease; }
.tile-hero .bar { background: rgba(61,74,92,.13); }

/* ── Notebook reading/writing view ─────────────────────────────── */

/* Single column on a phone; the contents list becomes a collapsed
   <details> that sits above the writing rather than beside it. */
.notebook-layout { display: block; }

.toc {
  border: 1px solid var(--line); border-radius: var(--brick);
  background: var(--surface); box-shadow: var(--engrave);
  font-size: 14px; margin-bottom: 16px;
}
.toc > summary {
  padding: 12px 16px; cursor: pointer; font-weight: 700; font-size: 13.5px;
  list-style: none; min-height: var(--tap); display: flex; align-items: center; gap: 8px;
}
.toc > summary::-webkit-details-marker { display: none; }
.toc > summary::after {
  content: '›'; margin-left: auto; font-size: 20px; line-height: 1;
  transform: rotate(90deg); transition: transform .2s; color: var(--muted);
}
.toc[open] > summary::after { transform: rotate(-90deg); }
.toc-body { padding: 0 12px 12px; max-height: 55vh; max-height: 55dvh;
  overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }

.toc ol { list-style: none; margin: 0; padding: 0; }
.toc li { margin: 1px 0; }
.toc a {
  display: block; padding: 9px 10px; border-radius: 9px 3px 9px 3px;
  text-decoration: none; color: var(--muted); font-weight: 600; font-size: 13.5px;
}
.toc a:hover { background: var(--surface-2); color: var(--ink); }
.toc .toc-class > a { color: var(--ink); font-weight: 800; margin-top: 8px; }
.toc .toc-module > a { padding-left: 18px; font-weight: 500; font-size: 13px; }
.toc .done::after { content: ' ·'; color: var(--ok); font-weight: 900; }

@media (min-width: 950px) {
  .notebook-layout { display: grid; grid-template-columns: 252px 1fr; gap: 22px; align-items: start; }
  .toc {
    position: sticky; top: 68px; margin-bottom: 0;
    max-height: calc(100vh - 92px); max-height: calc(100dvh - 92px); overflow: hidden;
    display: flex; flex-direction: column;
  }
  .toc > summary { display: none; }          /* always open on desktop */
  .toc-body { max-height: none; overflow-y: auto; padding: 12px; }
}

.class-block { margin-bottom: 26px; scroll-margin-top: 74px; }
.class-head {
  display: flex; align-items: baseline; gap: 9px; flex-wrap: wrap;
  border-bottom: 2px solid var(--line); padding-bottom: 7px; margin-bottom: 13px;
}

.module-block {
  border: 1px solid var(--line); border-radius: var(--brick);
  background: var(--surface); box-shadow: var(--engrave);
  padding: 15px 16px; margin-bottom: 12px; scroll-margin-top: 74px;
}
@media (min-width: 700px) { .module-block { padding: 18px 20px; margin-bottom: 14px; } }
.module-head { font-family: var(--font-display); font-weight: 700; font-size: 1.02rem; margin-bottom: 10px; }

.prompt-block {
  border-left: 3px solid var(--blue); background: var(--surface-2);
  padding: 10px 13px; margin: 10px 0; border-radius: 0 12px 12px 0;
  font-size: 14.5px;
}
.prompt-block.role-pla { border-left-color: var(--bronze); }
.prompt-block.role-ala { border-left-color: var(--pink-deep); }
.prompt-block.role-learning_points { border-left-color: var(--ok); }
.prompt-role {
  font-size: 10.5px; font-weight: 800; text-transform: uppercase;
  letter-spacing: .1em; color: var(--muted); display: block; margin-bottom: 3px;
}
.prompt-block p:last-child { margin-bottom: 0; }
.prompt-block ul { margin: 4px 0; padding-left: 18px; }

/* Long learning-point blocks collapse by default so the writing field is
   never pushed below the fold on a phone. */
.prompt-block.collapsible > summary {
  list-style: none; cursor: pointer; font-weight: 700; font-size: 13px;
  min-height: 34px; display: flex; align-items: center; gap: 6px;
}
.prompt-block.collapsible > summary::-webkit-details-marker { display: none; }
.prompt-block.collapsible > summary::after { content: '+'; margin-left: auto; color: var(--muted); font-weight: 800; }
.prompt-block.collapsible[open] > summary::after { content: '–'; }

/* ── The writing field ─────────────────────────────────────────── */

.field-block { margin-top: 14px; }
.field-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.field-title { font-weight: 700; font-size: 13.5px; }

.field-input {
  width: 100%; min-height: 150px; resize: vertical;
  font-family: var(--font-body);
  font-size: 16px;                        /* never below 16 — iOS zoom */
  line-height: 1.7; color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--brick-sm); padding: 13px 14px;
  box-shadow: var(--engrave);
  transition: border-radius .25s, border-color .2s, background .2s;
}
.field-input:focus {
  border-radius: var(--brick-sm-flip); border-color: var(--blue);
  outline: none; background: var(--surface);
}
.field-input::placeholder { color: var(--faint); }

.field-foot {
  display: flex; align-items: center; gap: 9px; margin-top: 7px;
  font-size: 12.5px; color: var(--muted); flex-wrap: wrap;
}
.save-state { font-weight: 700; font-size: 12px; }
.save-state[data-state='saving'] { color: var(--warn); }
.save-state[data-state='saved'] { color: var(--ok); }
.save-state[data-state='error'] { color: var(--alert); }

/* ── Assist / AI panels ────────────────────────────────────────── */

.assist {
  margin-top: 10px; border: 1px dashed var(--blue); border-radius: var(--brick-sm);
  background: color-mix(in srgb, var(--blue) 10%, transparent);
  padding: 12px 13px; font-size: 14px;
}
.assist h4 {
  font-family: var(--font-body); font-size: 11px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin: 0 0 6px;
}
.assist ul { margin: 0 0 8px; padding-left: 17px; }
.assist li { margin-bottom: 4px; }
.assist .opening {
  background: var(--surface); border-radius: 10px; padding: 9px 11px;
  border: 1px solid var(--line-soft); font-style: italic;
}

.chat-log { display: flex; flex-direction: column; gap: 9px; margin-bottom: 12px; }
.msg { padding: 10px 13px; border-radius: 16px 5px 16px 5px; max-width: 92%; font-size: 14.5px; }
@media (min-width: 700px) { .msg { max-width: 86%; } }
.msg.user { background: var(--slate); color: #fff; align-self: flex-end; border-radius: 5px 16px 5px 16px; }
.msg.assistant { background: var(--blue-wash); border: 1px solid rgba(127,178,221,.35); align-self: flex-start; }

/* ── Synthesis output ──────────────────────────────────────────── */

.synthesis h3 { margin-top: 18px; font-size: 1rem; }
.synthesis blockquote {
  margin: 4px 0 8px; padding: 7px 12px; border-left: 3px solid var(--pink);
  background: var(--pink-wash); border-radius: 0 10px 10px 0;
  font-size: 13.5px; color: var(--muted); font-style: italic;
  overflow-wrap: break-word;
}
.synthesis ul { padding-left: 18px; }

/* ── Empty states, forms ───────────────────────────────────────── */

.empty {
  text-align: center; padding: 30px 18px; color: var(--muted);
  border: 1px dashed var(--line); border-radius: var(--brick); background: var(--surface-2);
}
.empty strong { display: block; color: var(--ink); font-family: var(--font-display); font-size: 1.05rem; margin-bottom: 5px; }

label.lbl {
  display: block; font-size: 12px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em; margin-bottom: 5px;
}
input.inp, select.inp, textarea.inp {
  -webkit-appearance: none; appearance: none;
  width: 100%; font-family: var(--font-body);
  font-size: 16px;                        /* 16px floor again */
  color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--brick-sm); padding: 11px 13px; min-height: var(--tap);
  box-shadow: var(--engrave);
}
textarea.inp { min-height: 96px; }
input.inp:focus, select.inp:focus, textarea.inp:focus {
  border-radius: var(--brick-sm-flip); border-color: var(--blue); outline: none;
}
.field { margin-bottom: 14px; }
.help { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.errors { color: var(--alert); font-size: 12.5px; margin-top: 4px; }

/* Buttons come from Ákotí, but touch targets are ours to guarantee. */
.akoti-btn { min-height: var(--tap); font-size: 14px; }
@media (min-width: 700px) { .akoti-btn { min-height: 0; font-size: 13px; } }
.akoti-btn.primary { background: var(--slate); border-color: transparent; color: #fff; }
.akoti-btn.secondary { background: var(--blue-wash); border-color: rgba(127,178,221,.5); color: var(--blue-deep); }

/* Full-width action buttons on a phone, inline once there is room. */
.actions { display: flex; flex-direction: column; gap: 8px; }
.actions > * { width: 100%; }
@media (min-width: 560px) {
  .actions { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .actions > * { width: auto; }
}

