/* ═══════════════════════════════════════════════════════════════════
   App extras — only what Ákotí does not ship

   Two kinds of rule live here.

   1. Things Ákotí has no component for: the form shell, the notebook
      reading/writing surface, the chat log, the synthesis output, the
      dashboard tile variants, and a handful of layout utilities.

   2. Legacy aliases. Templates across the app still use the hand-rolled
      names `.tile .pill .inp .lbl .field .empty`. They are kept here as
      thin equivalents of the Ákotí component they replace, so pages can be
      converted one at a time instead of all at once. Every alias is
      labelled ALIAS and is meant to be deleted once no template uses it.

   Loaded last, so it wins over akoti-theme.css where it needs to.
   ═══════════════════════════════════════════════════════════════════ */

/* ── Form shell ────────────────────────────────────────────────────
   Every form in the app sits in this. Horizontally centred at any width;
   vertically centred too when the form is short enough to fit, which is
   what `justify-content: center` on a min-height flex column gives without
   pinning a height. A tall form grows downward and never clips. */

.form-shell {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 100%;
  width: 100%;
  padding: 4px 0 8px;
}
.form-shell > * {
  width: 100%;
  max-width: 34rem;
  min-width: 0;
}
.form-shell.wide > * { max-width: 52rem; }
.form-shell.narrow > * { max-width: 26rem; }
/* A form-shell inside a page that already has a heading should not fight it. */
.form-shell > .form-shell-head { max-width: 34rem; margin-bottom: 2px; }

/* ── Brick mark ────────────────────────────────────────────────────
   Stands in where none of the 22 Ákotí icons fits. Not an emoji. */

.brick-mark {
  display: inline-block; width: 11px; height: 11px; flex: none;
  border-radius: 6px 2px 6px 2px;
  background: currentColor;
  opacity: .85;
}
.brand-dot { width: 11px; height: 11px; background: var(--bronze);
  border-radius: 6px 2px 6px 2px; display: inline-block; flex: none; }

/* ── Utilities ─────────────────────────────────────────────────────── */

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

/* 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; }
}

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

/* ── Dashboard tile variants ───────────────────────────────────────
   Ákotí cards are one surface. The dashboard needs tinted ones to separate
   "where you are" from "what to do next", so the variants stay. */

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

/* ── ALIAS: .tile → .akoti-card ────────────────────────────────────── */

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

/* ── ALIAS: .pill → .akoti-badge / .akoti-tag ─────────────────────── */

.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: var(--ok-wash); color: var(--ok); border-color: transparent; }
.pill.warn { background: var(--warn-wash); color: var(--warn); border-color: transparent; }
.pill.alert { background: var(--alert-wash); color: var(--alert); border-color: transparent; }

/* ── ALIAS: .lbl .inp .field .help .errors → .akoti-field group ────── */

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 — iOS zoom */
  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; }

/* ── ALIAS: .empty → .akoti-empty ─────────────────────────────────── */

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

/* ── ALIAS: .nav → a filter strip, not navigation ──────────────────
   Navigation is the sidebar now. Two pages (notebook list, task list) still
   use `.nav` for their status filter chips, so the strip survives under the
   old name. Rename those to `.chips` and this block goes away. */

.nav {
  display: flex; gap: 4px; width: 100%;
  overflow-x: auto; overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }
.nav a {
  padding: 9px 14px; border-radius: var(--brick-sm); text-decoration: none;
  color: var(--muted); font-size: 13.5px; font-weight: 600;
  white-space: nowrap; scroll-snap-align: start;
  display: inline-flex; align-items: center; gap: 5px; min-height: 38px;
  background: var(--surface); border: 1px solid var(--line-soft);
  transition: background .2s, color .2s, border-radius .25s;
}
.nav a:hover { background: var(--surface-2); color: var(--ink); border-radius: var(--brick-sm-flip); }
.nav a.active { background: var(--slate); color: #fff; border-color: transparent; }

/* ── Notebook reading and writing ──────────────────────────────────
   Ákotí has no equivalent of any of this. Single column on a phone; the
   contents list is a collapsed <details> above the writing rather than
   beside it, and becomes a sticky rail once there is width. */

.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: 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; }
/* No ::after completion marker here. It hung off the <li>, and because the
   link inside is block-level the glyph landed on its own line as a stray "·"
   in the rail. It was also colour-only, which fails for anyone who cannot
   distinguish it. The written/total count in the markup is the real signal;
   this just reinforces it. */
.toc .done > a { color: var(--ok); }
.toc .done > a .meta { color: var(--ok); font-weight: 700; }

@media (min-width: 950px) {
  .notebook-layout { display: grid; grid-template-columns: 252px 1fr; gap: 22px; align-items: start; }
  .toc {
    position: sticky; top: 16px; margin-bottom: 0;
    max-height: calc(100dvh - 40px); overflow: hidden;
    display: flex; flex-direction: column;
  }
  .toc > summary { display: none; }          /* always open once there is room */
  .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 panel, chat log, synthesis ─────────────────────────────── */

.assist {
  margin-top: 10px; border: 1px dashed var(--blue); border-radius: var(--brick-sm);
  background: var(--blue-wash);
  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 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; }

/* ── Coach notebook picker ─────────────────────────────────────────
   The chat endpoint is scoped to one notebook, so the launcher needs to
   know which one before it can send anything. This bar is injected into
   the Ákotí float-ai panel by shell.js. */

.coach-pick {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid var(--line-soft);
  background: var(--blue-wash);
  font-size: 12.5px; color: var(--blue-deep);
}
.coach-pick label { font-weight: 700; white-space: nowrap; }
.coach-pick select {
  flex: 1; min-width: 0; font-family: var(--font-body); font-size: 16px;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px 4px 10px 4px;
  padding: 7px 9px; min-height: 38px;
}
.coach-pick select:focus { outline: 2px solid var(--blue); outline-offset: 1px; }

/* ── Ákotí checkbox / radio / switch: keyboard access ───────────────
   The vendored component hides the real input with `display: none`
   (akoti-checkbox.css:39, :97, :146). A display:none input is removed from
   the accessibility tree entirely — it cannot be tabbed to, cannot be
   toggled with Space, and shows no focus ring. Every checkbox in Settings
   was unreachable by keyboard.

   Fix without touching the vendored file: keep the input in the layout but
   invisible, and move the focus ring onto the mark that is actually drawn.
   The adjacent-sibling selectors the component relies on
   (`input:checked + .akoti-check-mark`) still match, because the input is
   still there in the same DOM position. */

.akoti-check input,
.akoti-radio input,
.akoti-switch input {
  display: revert;                  /* undo the vendored display:none */
  position: absolute;
  width: 1px; height: 1px;
  margin: 0;
  opacity: 0;
  pointer-events: none;             /* the label already covers the hit area */
}

.akoti-check input:focus-visible + .akoti-check-mark,
.akoti-radio input:focus-visible + .akoti-radio-mark,
.akoti-switch input:focus-visible + .akoti-switch-track {
  outline: 2px solid var(--blue-deep);
  outline-offset: 2px;
}

/* The label is the hit target, so it carries the tap-size guarantee. */
.akoti-check, .akoti-radio, .akoti-switch {
  position: relative;
  min-height: var(--tap);
  align-items: center;
}

/* ── Small layout utilities ─────────────────────────────────────────
   Ákotí ships components, not spacing helpers, so these are the few
   arrangements templates kept re-declaring with inline styles. */

.chip-wrap { display: flex; flex-wrap: wrap; gap: 6px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* Two selects side by side once there is room; stacked on a phone. */
.filter-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 620px) { .filter-grid { grid-template-columns: 1fr 1fr; gap: 12px; } }

/* The filter fold sits inside a card body, so it should not repeat the card's
   border on all four sides. */
.filter-fold { margin-top: 12px; }
.filter-fold .aka2-item { border-left: 0; border-right: 0; border-bottom: 0; }

/* The coach launcher is fixed at bottom-right and was sitting on top of the
   footer's contact link. Keep the footer's own content clear of it; the
   launcher is 56px plus its 24px offset. */
.app-foot-inner { padding-right: 0; }
.app-foot { padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
.app-foot-link { margin-right: 88px; }
@media (min-width: 700px) { .app-foot-link { margin-right: 92px; } }

/* Ákotí pagination buttons are 34px tall (40px with .akoti-pg-lg), both under
   the 44px minimum this app holds itself to. Raise them without touching the
   vendored file. */
.akoti-pg-btn { min-width: var(--tap); min-height: var(--tap); }
