/* Slidura app — bespoke + utility components (APP-ONLY).
   Tokens live in theme-tokens.css; shared chrome/components in
   theme-components.css. This file keeps the app's catalog/editor UI, forms,
   lists, badges, status, and other styles that have no site equivalent. They
   reference the alias tokens (--bg, --card, --border, …) which theme-tokens.css
   defines in BOTH light and dark, so these adapt to dark mode automatically.
   Load order: pico.min.css → theme-tokens.css → theme-components.css → app.css */

html { -webkit-text-size-adjust: 100%; }

.container { max-width: 960px; margin: 0 auto; padding: 0 1.5rem; }
.container.narrow { max-width: 460px; }

/* Two-pane app shell (uses .docs-layout from theme-components.css). The content
   pane is plain (not a card) so the app's own .card components provide elevation
   and don't nest card-in-card. */
.app-shell { flex: 1 1 auto; padding-block: 2rem 3rem; }
.app-content { min-width: 0; }
.app-content > h1:first-child, .app-content > .crumb:first-child { margin-top: 0; }

.brand-large {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--accent);
  font-size: 2.25rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  margin: 0 0 0.35rem;
}
.brand-large .brand-mark { width: 1.05em; height: 1.05em; }

h1 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.2;
  margin: 0.2rem 0 1.5rem;
}
h2 {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.3;
  margin: 0 0 0.7rem;
}
h3 {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 1.3rem 0 0.5rem;
  color: var(--fg);
}

p { margin: 0 0 1rem; }
a { color: var(--accent); text-underline-offset: 2px; }

.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 0.85rem; margin-top: 1rem; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1.75rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}
.login-card { margin-top: 5rem; text-align: center; padding: 2.25rem; box-shadow: var(--shadow-md); }
.login-card form { text-align: left; }

label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  margin: 0.9rem 0 0.3rem;
  color: var(--fg);
}

input[type=text], input[type=email], input[type=number], input[type=file], textarea {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font: inherit;
  background: var(--card);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:hover, textarea:hover { border-color: var(--muted); }
input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}
textarea { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.84rem; }

button, a[role=button] {
  display: inline-block;
  margin-top: 1rem;
  padding: 0.6rem 1.25rem;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, transform 0.06s ease, box-shadow 0.15s ease;
}
button:hover, a[role=button]:hover {
  background: var(--accent-dark);
  box-shadow: 0 4px 12px rgba(210, 71, 38, 0.25);
}
button:active, a[role=button]:active { transform: translateY(1px); }

.banner {
  padding: 0.8rem 1.1rem;
  border-radius: var(--radius-sm);
  margin: 0 0 1.3rem;
  font-size: 0.92rem;
  border: 1px solid transparent;
}
.banner.err { background: var(--err-bg); color: var(--err-fg); border-color: rgba(179, 60, 30, 0.2); }
.banner.ok { background: var(--ok-bg); color: var(--ok-fg); border-color: rgba(28, 122, 62, 0.2); }
.banner.warn { background: var(--warn-bg); color: var(--warn-fg); border-color: rgba(138, 90, 0, 0.2); }

.token {
  display: block;
  margin: 0.6rem 0 0;
  padding: 0.6rem 0.8rem;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
  word-break: break-all;
  user-select: all;
}
.list-row form { margin: 0; }

/* Settings: the create-API-key form — input and button on one aligned row.
   Pico sets button[type=submit] to width:100% and inputs to a fixed height;
   both are overridden here so flex controls width and the row heights match. */
.key-form {
  display: flex;
  gap: 0.6rem;
  align-items: stretch;
  margin-bottom: 1.75rem;
}
.key-form input { flex: 1 1 auto; width: auto; margin: 0; }
.key-form button { flex: 0 0 auto; width: auto; margin: 0; white-space: nowrap; }

.list { list-style: none; padding: 0; margin: 0; }
.list-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.95rem 1.25rem;
  margin-bottom: 0.6rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.list-row:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.list-main { flex: 1; text-decoration: none; color: var(--fg); display: flex; flex-direction: column; gap: 0.15rem; }
.list-main strong { font-weight: 600; }
.list-main .muted { font-size: 0.8rem; }

.badge {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  background: #f1eae0;
  color: var(--muted);
}
.badge.ready { background: var(--ok-bg); color: var(--ok-fg); }
.badge.pending { background: var(--warn-bg); color: var(--warn-fg); }
.badge.failed { background: var(--err-bg); color: var(--err-fg); }

.status {
  padding: 0.8rem 1.1rem;
  border-radius: var(--radius-sm);
  background: var(--code-bg);
  font-size: 0.92rem;
}
.status.ok { background: var(--ok-bg); color: var(--ok-fg); }
.status.err { background: var(--err-bg); color: var(--err-fg); }
.status a[role=button] { margin-left: 0.6rem; margin-top: 0; padding: 0.35rem 0.85rem; font-size: 0.85rem; }

.errtext {
  display: block;
  margin-top: 0.5rem;
  white-space: pre-wrap;
  font-size: 0.82rem;
  font-family: ui-monospace, Menlo, monospace;
}

.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.4rem 1.25rem; margin: 0; }
.facts dt { font-weight: 600; color: var(--muted); font-size: 0.88rem; }
.facts dd { margin: 0; font-size: 0.92rem; }

/* Catalog: card header with a floating help popup */
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.card-head h2 { margin-bottom: 0.25rem; }
.card-head p { margin: 0; }

details.help { position: relative; flex: none; }
details.help > summary {
  list-style: none;
  cursor: pointer;
  padding: 0.4rem 0.85rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent-dark);
  background: var(--card);
  white-space: nowrap;
  transition: border-color 0.15s ease;
}
details.help > summary:hover { border-color: var(--accent); }
details.help > summary::-webkit-details-marker,
details.help > summary::marker { display: none; content: ""; }
details.help > summary::after { display: none; }
details.help > summary::before { content: "ⓘ "; }
.help-card {
  position: absolute;
  right: 0;
  top: 2.7rem;
  z-index: 20;
  width: 360px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 1.1rem 1.25rem;
  font-size: 0.88rem;
}
.help-card h3 { margin: 0 0 0.5rem; }
.help-card dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.3rem 0.75rem;
  margin: 0.6rem 0;
}
.help-card dt { font-weight: 700; color: var(--accent-dark); }
.help-card dd { margin: 0; }

/* Catalog: collapsible slide groups */
details.slide-group {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 0.55rem;
  background: var(--card);
  transition: border-color 0.15s ease;
}
details.slide-group[open] { border-color: var(--border-strong); }
details.slide-group > summary {
  cursor: pointer;
  padding: 0.7rem 1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.6rem;
  font-size: 0.95rem;
  border-radius: var(--radius-sm);
}
details.slide-group[open] > summary {
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.slide-id {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 0.74rem;
  font-weight: 700;
  color: #fff;
  background: var(--accent);
  padding: 0.15rem 0.5rem;
  border-radius: 5px;
}
.slide-name { font-weight: 600; }
.slide-meta { margin-left: auto; color: var(--muted); font-size: 0.8rem; }
.slide-body { padding: 0.85rem 1rem 1rem; }

/* Catalog: per-slide settings form + section labels */
.slide-form {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
}
.slide-form-title,
.fields-label {
  margin: 0 0 0.45rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.slide-form-title { padding: 0.8rem 0.95rem 0; }

/* Catalog: collapsible placeholder blocks */
details.field-block {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 0.55rem;
  background: var(--card);
}
details.field-block > summary {
  cursor: pointer;
  padding: 0.55rem 0.8rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.9rem;
}
details.field-block[open] > summary { border-bottom: 1px solid var(--border); }
.field-block code {
  background: var(--code-bg);
  padding: 0.15rem 0.5rem;
  border-radius: 5px;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: ui-monospace, Menlo, monospace;
}
.fb-name { font-weight: 600; }
.fb-text { color: var(--muted); font-style: italic; font-size: 0.85rem; }
.badge.req { background: #eaf0fd; color: #2a4bbd; }

.credits-line {
  color: var(--muted);
  font-size: 0.92rem;
  margin: 0 0 1.6rem;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
}
.credit-badge {
  display: inline-block;
  padding: 0.25rem 0.8rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
}
.saved { color: var(--ok-fg); font-size: 0.82rem; font-weight: 600; }
.fb-anchor {
  color: var(--muted);
  font-size: 0.78rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.form-error {
  background: var(--err-bg);
  color: var(--err-fg);
  padding: 0.45rem 0.7rem;
  border-radius: 6px;
  font-size: 0.85rem;
  margin: 0 0 0.75rem;
}
/* Field-key hint: opt out of the label's uppercase styling. */
.stack-form small {
  display: block;
  margin-top: 0.3rem;
  font-size: 0.78rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--muted);
}

/* Catalog: vertical (top-to-bottom) edit form */
.stack-form { padding: 0.85rem 0.95rem; }
.stack-form > label {
  display: block;
  margin-bottom: 0.75rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.stack-form input[type="text"],
.stack-form input[type="number"],
.stack-form textarea {
  display: block;
  width: 100%;
  margin: 0.25rem 0 0;
  padding: 0.5rem 0.7rem;
  font-size: 0.92rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--fg);
}
.stack-form textarea { resize: vertical; }

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 1.25rem;
}
.form-actions .f-max { flex: 0 0 120px; margin: 0; }
.form-actions .f-max input { width: 100%; }
.stack-form .f-check {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0;
  flex: none;
  white-space: nowrap;
  font-size: 0.88rem;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  color: var(--fg);
}
.stack-form .f-check input[type="checkbox"] {
  flex: none;
  width: 1.1rem;
  height: 1.1rem;
  margin: 0;
  accent-color: var(--accent);
}
.form-actions button { margin: 0; }

.spinner {
  display: inline-block;
  width: 0.85em; height: 0.85em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  vertical-align: -1px;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Icon pack glyph grid */
.icon-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.icon-card {
  border: 1px solid var(--pico-muted-border-color);
  border-radius: var(--pico-border-radius);
  padding: 0.75rem;
  margin: 0;
  text-align: center;
}
.icon-card .icon-preview {
  width: 48px;
  height: 48px;
  object-fit: contain;
  display: block;
  margin: 0 auto 0.5rem;
}
.icon-card .icon-name { display: block; word-break: break-all; }
.icon-card .icon-ref {
  display: block;
  font-size: 0.7rem;
  margin: 0.25rem 0 0.5rem;
  word-break: break-all;
}
.icon-card input { font-size: 0.8rem; margin-bottom: 0.4rem; }

/* Code-block Pygments preview */
.code-preview {
  margin: 1rem 0;
  overflow-x: auto;
  border-radius: var(--pico-border-radius);
}
.code-preview pre {
  margin: 0;
  padding: 1rem;
  font-size: 0.85rem;
  line-height: 1.4;
}

/* Shared data-grid widget (chart/table data editing) */
.data-grid { overflow-x: auto; }
.dg-table { width: auto; min-width: 100%; margin-bottom: .5rem; }
.dg-table th, .dg-table td { padding: .2rem .3rem; vertical-align: middle; }
.dg-table input { margin: 0; padding: .3rem .4rem; font-size: .85rem; height: auto; }
.dg-table input.dg-cell { width: 6.5rem; }
.dg-table input.dg-col-name, .dg-table input.dg-row-name { width: 8rem; font-weight: 600; }
.dg-table .dg-rowctl { width: 1px; white-space: nowrap; }
.dg-remove {
  width: 1.8rem; padding: .1rem .3rem; margin: 0; line-height: 1;
  font-size: .8rem; --pico-color: var(--err-fg, currentColor);
}
.dg-controls { display: flex; gap: .5rem; }
.dg-controls button { margin: 0; width: auto; }

/* Build-detail source-slide reference strip (upload-and-preview-spec §3.3). */
.ref-strip { display: flex; flex-wrap: wrap; gap: .5rem; }
.ref-strip img {
  width: 180px; height: auto; border-radius: 6px;
  border: 1px solid var(--pico-form-element-border-color, #ccc);
}

/* SVG slide mock (slide-mock-spec-v1): the fill builder's live preview. */
.slide-mock {
  overflow: hidden; border-radius: 8px;
  border: 1px solid var(--pico-form-element-border-color, #ccc);
  background: #fff;
}
.slide-mock svg { display: block; width: 100%; height: auto; }
.slide-mock .mock-field { cursor: pointer; }
.slide-mock .mock-field:hover rect,
.slide-mock .mock-field:hover ellipse { stroke: var(--pico-primary, #3949ab); stroke-width: 3; }

/* Published fill endpoints (template-product-spec-v1 §4). */
#publish .list-row { display: flex; align-items: center; gap: .5rem; }
#publish .list-row > div { flex: 1; min-width: 0; }
#publish .list-row form { margin: 0; }
#publish .list-row form button { width: auto; margin: 0; padding: .15rem .5rem; font-size: .75rem; }
#publish .endpoint-form button { width: auto; }
#publish .banner code { word-break: break-all; }

/* Head variables (template-product-spec-v1 §3). */
.vars-form .vars-head, .vars-form .vars-row {
  display: grid; grid-template-columns: 1fr 1fr 1fr 2fr; gap: .5rem;
}
.vars-form .vars-head { margin-bottom: .25rem; }
.vars-form .vars-row input { margin-bottom: .5rem; }
.vars-form button { width: auto; }
.vars-grid { display: grid; gap: .75rem; }
@media (min-width: 768px) { .vars-grid { grid-template-columns: 1fr 1fr; } }

/* Fill builder (fill-ux-spec-v1 §5). */
.fill-slide { border: 1px solid var(--pico-form-element-border-color, #ccc); border-radius: 8px; padding: .25rem .75rem; margin-bottom: .5rem; }
.fill-slide > summary { display: flex; align-items: center; gap: .5rem; }
.fill-slide > summary .fs-include { margin: 0; flex: none; }
.fill-slide .fs-controls { margin-left: auto; display: flex; gap: .25rem; }
.fill-slide .fs-controls button {
  width: 2rem; margin: 0; padding: .1rem .3rem; line-height: 1.4; font-size: .8rem;
}
.fill-slide-body { padding: .5rem 0 .75rem; }
.fill-field { margin-bottom: 1rem; }
.fill-field .ff-desc { display: block; margin-bottom: .25rem; }
.fill-field .ff-counter { display: block; text-align: right; }
.fill-field .ff-counter.over { color: var(--err-fg, #b33c1e); font-weight: 600; }
.ff-modes { display: flex; gap: 1rem; margin-bottom: .25rem; }
.ff-modes label { display: inline-flex; align-items: center; gap: .35rem; margin: 0; font-size: .85rem; }
.ff-modes input { margin: 0; }
.fill-actions { display: flex; gap: .75rem; justify-content: flex-end; }
.fill-actions button { width: auto; margin: 0; }
#fill-json-adv textarea { font-family: var(--pico-font-family-monospace, monospace); font-size: .8rem; }
#fill-json-adv button { width: auto; }

/* Slide thumbnails + field locator (fill-ux-spec-v1 §4). */
.slide-overview { display: grid; gap: 1rem; align-items: start; margin-bottom: .75rem; }
@media (min-width: 768px) {
  .slide-overview { grid-template-columns: minmax(220px, 340px) 1fr; }
}
.slide-thumb {
  position: relative; margin: 0; overflow: hidden; border-radius: 8px;
  border: 1px solid var(--pico-form-element-border-color, #ccc);
  background: var(--pico-card-background-color, #fff);
}
.slide-thumb img, .slide-thumb svg { display: block; width: 100%; height: auto; }
.slide-thumb img + svg { position: absolute; inset: 0; }
.slide-thumb .fl {
  fill: transparent; stroke: var(--pico-primary, #3949ab);
  stroke-width: 4; opacity: .35; cursor: pointer;
}
.slide-thumb .fl:hover, .slide-thumb .fl.active {
  opacity: 1; fill: rgb(57 73 171 / 12%);
}
.slide-thumb .fl-image, .slide-thumb .fl-icon { stroke: #00897b; }
.slide-thumb .fl-chart, .slide-thumb .fl-table { stroke: #ef6c00; }
.slide-thumb.wire .fl { opacity: .7; }
.field-block.fl-target {
  outline: 2px solid var(--pico-primary, #3949ab); outline-offset: 2px;
}

/* Shared ref-picker widget (fill-ux-spec-v1 §3): combobox over /refs/search. */
.ref-picker .rp-combo { position: relative; }
.ref-picker .rp-input { margin-bottom: .25rem; }
.ref-picker .rp-list {
  position: absolute; z-index: 30; inset-inline: 0; top: 100%;
  margin: 0; padding: .25rem; list-style: none; max-height: 18rem; overflow-y: auto;
  background: var(--pico-card-background-color, #fff);
  border: 1px solid var(--pico-form-element-border-color, #ccc);
  border-radius: 8px; box-shadow: 0 8px 24px rgb(0 0 0 / 12%);
}
.ref-picker .rp-option {
  display: flex; align-items: center; gap: .5rem;
  padding: .35rem .5rem; border-radius: 6px; cursor: pointer;
}
.ref-picker .rp-option:hover, .ref-picker .rp-option.active {
  background: var(--pico-secondary-background, rgb(0 0 0 / 6%));
}
.ref-picker .rp-thumb {
  width: 2rem; height: 2rem; flex: none; object-fit: contain;
  background: var(--pico-card-sectioning-background-color, #f6f6f6); border-radius: 4px;
}
.ref-picker .rp-badge {
  display: inline-flex; align-items: center; justify-content: center;
  font-size: .6rem; font-weight: 700; text-transform: uppercase; opacity: .7;
}
.ref-picker .rp-text { display: flex; flex-direction: column; min-width: 0; }
.ref-picker .rp-text strong { font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ref-picker .rp-text small { opacity: .7; }
.ref-picker .rp-empty { padding: .35rem .5rem; font-size: .85rem; opacity: .7; }
.ref-picker .rp-footer {
  display: flex; gap: .75rem; padding: .35rem .5rem; font-size: .85rem;
  border-top: 1px solid var(--pico-form-element-border-color, #ccc); margin-top: .25rem;
}
.ref-picker .rp-chip { display: flex; align-items: center; gap: .5rem; margin: 0 0 .5rem; font-size: .85rem; }
.ref-picker .rp-chip small { opacity: .7; }

/* Procedural arts (domain/art): the workbench/gallery preview panes. */
.art-preview { background: var(--pico-card-background-color, #fff); border-radius: 12px; padding: .5rem; }
.art-preview svg { width: 100%; height: auto; display: block; }

/* Design palette swatch strip (design-palette-spec-v1 §5.1). Swatches are
   <button type=button>: Pico gives buttons primary bg/padding/margin — every
   box property is overridden explicitly. */
.palette-strip { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.palette-swatch {
  width: 1.75rem; height: 1.75rem; padding: 0; margin: 0;
  background: var(--swatch); border: 1px solid var(--pico-muted-border-color, #ccc);
  border-radius: .375rem; cursor: pointer; box-shadow: none;
}
.palette-swatch:hover { transform: scale(1.15); }
.palette-fonts { font-size: .8rem; margin-left: .35rem; }

/* Sidebar area toggle (ux-overhaul-spec-v1 §1.1): two links styled as a
   segmented control, pinned above the nav drawer in the sidebar grid cell. */
.sidebar-rail { position: sticky; top: 5rem; align-self: start; }
.area-toggle {
  display: flex;
  gap: 2px;
  padding: 2px;
  margin-bottom: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
}
.area-toggle a {
  flex: 1;
  text-align: center;
  padding: 0.3rem 0.5rem;
  border-radius: calc(var(--radius-sm) - 2px);
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.875rem;
}
.area-toggle a:hover { color: var(--fg); }
.area-toggle a[aria-current="page"] { background: var(--accent-tint); color: var(--accent); }
@media (max-width: 1024px) {
  .sidebar-rail { position: static; }
}

/* App modal shell (ux-overhaul-spec-v1 §2): one native <dialog>; htmx loads
   fragments into #modal-body and modal.js opens/closes it. Pico styles the
   open dialog as a full-screen overlay with the <article> as the box. */
#app-modal article { position: relative; max-width: 560px; width: 100%; }
#app-modal .modal-close {
  position: absolute; top: 0.5rem; right: 0.5rem;
  width: auto;               /* Pico: submit/plain buttons default to 100% width */
  padding: 0 0.5rem; margin: 0;
  background: none; border: none; box-shadow: none;
  color: var(--muted); font-size: 1.25rem; line-height: 1; cursor: pointer;
}
#app-modal .modal-close:hover { color: var(--fg); }

/* Templates home (ux-overhaul-spec-v1 §3): card grid, cog menu, star,
   toolbar. The card body is one submit button (click = use) — undo Pico's
   full-width/colored button defaults for it. */
.toolbar { display: flex; gap: 0.6rem; align-items: flex-start; flex-wrap: wrap; margin-bottom: 0.75rem; }
.toolbar input[type="search"] { flex: 1 1 14rem; width: auto; margin: 0; }
.toolbar select { flex: 0 0 auto; width: auto; margin: 0; }
.toolbar .reveal { flex: 0 0 auto; margin: 0; position: relative; }
.toolbar .reveal > summary { margin: 0; white-space: nowrap; }
.toolbar .reveal > .card { position: absolute; right: 0; z-index: 30; min-width: 22rem; margin-top: 0.4rem; }
.home-hint { margin: 0 0 0.75rem; font-size: 0.85rem; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
  gap: 1rem;
}
.tpl-card { margin: 0; padding: 0.6rem; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.tpl-card-use { margin: 0; }
.tpl-card-body {
  display: block; width: 100%; margin: 0; padding: 0;
  background: none; border: none; box-shadow: none; color: var(--fg);
  text-align: left; cursor: pointer;
}
.tpl-card-body:hover .tpl-thumb { box-shadow: 0 0 0 3px var(--accent-tint); }
.tpl-thumb {
  display: flex; align-items: center; justify-content: center;
  width: 100%; aspect-ratio: 16 / 9; object-fit: cover;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.tpl-thumb-empty svg { width: 2rem; height: 2rem; opacity: 0.35; }
.tpl-name { display: block; margin-top: 0.45rem; font-size: 0.95rem; line-height: 1.3; }
.tpl-card-meta { display: flex; align-items: center; gap: 0.35rem; margin-top: 0.45rem; padding: 0; background: none; border: none; }
.tpl-card-actions { margin-left: auto; display: flex; align-items: center; gap: 0.15rem; }

.star-form, .inline-form { display: inline; margin: 0; }
.star-btn, .link-btn {
  width: auto; margin: 0; padding: 0 0.25rem;
  background: none; border: none; box-shadow: none; cursor: pointer;
}
.star-btn { color: var(--muted); font-size: 1.05rem; line-height: 1; }
.star-btn.on { color: var(--accent); }
.star-btn:hover { color: var(--accent); }
.link-btn { color: var(--accent); text-decoration: underline; font-size: inherit; }

.cog-menu > summary { list-style: none; padding: 0.15rem 0.3rem; color: var(--muted); cursor: pointer; }
.cog-menu > summary::-webkit-details-marker { display: none; }
.cog-menu > summary:hover { color: var(--fg); }
.cog-menu .menu-pop form { margin: 0; }
.menu-btn {
  display: block; width: 100%; margin: 0; padding: 0.35rem 0.75rem;
  background: none; border: none; box-shadow: none; color: inherit;
  text-align: left; font-size: inherit; cursor: pointer;
}
.menu-btn:hover { background: var(--accent-tint); }

/* Template workspace (ux-overhaul-spec-v1 §4): rail, head, panels. */
.tpl-head { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
.tpl-head h1 { margin: 0; font-size: 1.4rem; }
.workspace-rail .rail-back { margin: 0 0 0.5rem; }
.workspace-rail .rail-back a { font-size: 0.85rem; color: var(--muted); text-decoration: none; }
.workspace-rail .rail-slides a { display: flex; gap: 0.35rem; align-items: baseline; }
.workspace-rail .rail-slides .slide-id { font-size: 0.7rem; color: var(--muted); font-family: monospace; }
.rail-usage { margin-top: 0.75rem; border-top: 1px solid var(--border); padding-top: 0.5rem; }
.rail-usage > summary { font-size: 0.8rem; color: var(--muted); cursor: pointer; }
.rail-usage-body { font-size: 0.8rem; }
.rail-usage-body code { display: block; overflow-wrap: anywhere; font-size: 0.7rem; margin-bottom: 0.4rem; }
.rail-usage-body p { margin: 0.25rem 0; }
.slide-overview-lg .slide-thumb { max-width: 100%; }
.static-fields { margin-top: 0.5rem; }
.static-fields > summary { font-size: 0.85rem; color: var(--muted); cursor: pointer; }
.var-row-group { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.4rem 0.6rem; margin-bottom: 0.5rem; }
.var-row-group > summary { display: flex; gap: 0.5rem; align-items: center; cursor: pointer; }
.var-config { padding-top: 0.5rem; }
.check-row { display: flex; align-items: center; gap: 0.4rem; }
.check-row input[type="checkbox"] { width: auto; margin: 0; }

/* Static (hidden) fields on the locator overlay: visible, dimmed, inert. */
.slide-thumb .fl-static { pointer-events: none; opacity: 0.35; cursor: default; }

/* Build assistant (assistant-spec-v1 §2): the chat thread + tabs. */
.build-tabs { margin-top: 0.25rem; }
.chat-thread { display: flex; flex-direction: column; gap: 0.6rem; margin-bottom: 0.75rem; }
.chat-msg { max-width: 46rem; padding: 0.5rem 0.75rem; border-radius: var(--radius); border: 1px solid var(--border); }
.chat-user { align-self: flex-end; background: var(--accent-tint); }
.chat-assistant { align-self: flex-start; background: var(--card); }
.chat-role { display: block; font-size: 0.7rem; margin-bottom: 0.15rem; }
.chat-body { white-space: pre-wrap; }
.chat-input textarea { margin-bottom: 0.4rem; }
.chat-input button { width: auto; }
.chat-answers { border-top: 1px dashed var(--border); padding-top: 0.6rem; margin-bottom: 0.75rem; }
#autosave-state { margin-right: auto; font-size: 0.85rem; align-self: center; }
