:root {
  --ink: #14122f;
  --muted: #6f6b86;
  --paper: #f5f5f7;
  --surface: #ffffff;
  --line: #dedbea;
  --accent: #7e36cc;
  --accent-dark: #3b33a0;
  --accent-soft: #f0e8fb;
  --accent-softer: #f8f5fc;
  --accent-line: #dbc9ef;
  --warm: #c4b1ff;
  --shadow: 0 18px 60px rgb(20 18 47 / 10%);
  font-family: Geist, Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--paper); }
a { color: inherit; }
button, input, select, textarea { font: inherit; }

.app-header {
  min-height: 68px;
  padding: 0 4vw;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgb(255 255 255 / 12%);
  background: #14122f;
  backdrop-filter: blur(16px);
}
.header-actions, .app-header nav { display: flex; gap: 1.5rem; align-items: center; }
.app-header nav a, .app-header .link-button { color: rgb(255 255 255 / 78%); text-decoration: none; }
.app-header nav a:hover, .app-header .link-button:hover { color: white; }
.organisation-switcher { display: flex; align-items: center; gap: .45rem; }
.organisation-switcher label { color: rgb(255 255 255 / 58%); font-size: .72rem; }
.organisation-switcher select {
  width: min(220px, 22vw);
  min-height: 34px;
  padding: .35rem 1.9rem .35rem .6rem;
  border: 1px solid rgb(255 255 255 / 22%);
  border-radius: 7px;
  background: #211e43;
  color: white;
  cursor: pointer;
  font-size: .78rem;
  text-overflow: ellipsis;
}
.organisation-switcher button {
  min-height: 32px;
  padding: .3rem .55rem;
  border: 1px solid rgb(255 255 255 / 22%);
  border-radius: 7px;
  background: transparent;
  color: rgb(255 255 255 / 82%);
  cursor: pointer;
  font-size: .72rem;
}
.organisation-switcher button:hover { border-color: rgb(255 255 255 / 45%); color: white; }
.link-button { border: 0; background: none; cursor: pointer; padding: 0; }
.brand { display: flex; align-items: center; gap: .85rem; color: white; text-decoration: none; }
.brand-logo { display: block; width: 111px; height: 32px; }
.brand-product { padding-left: .85rem; border-left: 1px solid rgb(255 255 255 / 25%); color: rgb(255 255 255 / 76%); font-size: .82rem; font-weight: 500; letter-spacing: .01em; }
.shell { width: min(1180px, 92vw); margin-inline: auto; }
.beta-banner {
  min-height: 40px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid #ead5a2;
  background: #fff7df;
  color: #684b0f;
}
.beta-banner-inner { display: flex; align-items: center; min-height: 39px; }
.beta-banner p { margin: 0; font-size: .78rem; line-height: 1.35; }
.beta-banner strong { margin-right: .1rem; color: #513907; letter-spacing: .02em; text-transform: uppercase; }
.dashboard-heading { padding: 2rem 0 1.25rem; display: flex; justify-content: space-between; align-items: center; gap: 2rem; }
.dashboard-heading h1 { margin: 0; font-size: 2rem; letter-spacing: -.035em; }
.dashboard-heading p { margin: .35rem 0 0; color: var(--muted); font-size: .92rem; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; border-radius: 8px; border: 1px solid var(--line); padding: .65rem 1rem; cursor: pointer; text-decoration: none; font-weight: 700; }
.button-primary { background: var(--accent); color: white; border-color: var(--accent); }
.button-primary:hover { background: var(--accent-dark); }
.button:disabled { opacity: .45; cursor: not-allowed; }
.empty-state { min-height: 150px; display: grid; place-items: center; align-content: center; text-align: center; border: 1px dashed var(--accent-line); border-radius: 12px; background: rgb(255 255 255 / 65%); padding: 2rem; }
.empty-state h2 { margin: .8rem 0 .2rem; }
.empty-state p { color: var(--muted); max-width: 500px; }
.empty-icon { width: 50px; height: 50px; display: grid; place-items: center; border-radius: 16px; background: var(--accent-soft); color: var(--accent); font-size: 1.5rem; }
.auth-card { width: min(420px, 92vw); margin: 9vh auto; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 2rem; }
.auth-card h1 { font-size: 1.75rem; letter-spacing: -.035em; margin: 0 0 .5rem; }
.auth-card > p { color: var(--muted); }
.stack-form p { display: grid; gap: .4rem; }
.stack-form input { width: 100%; border: 1px solid var(--line); border-radius: 12px; min-height: 46px; padding: .7rem .85rem; }
.stack-form .button { width: 100%; margin-top: .7rem; }
.messages {
  position: fixed;
  inset-inline-end: 1.5rem;
  top: 7.5rem;
  z-index: 20;
  display: grid;
  gap: .55rem;
  width: min(420px, calc(100vw - 2rem));
  pointer-events: none;
}
.message {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: .75rem;
  align-items: start;
  margin: 0;
  padding: .8rem .65rem .8rem 1rem;
  border-radius: 12px;
  background: var(--ink);
  color: white;
  box-shadow: var(--shadow);
  line-height: 1.4;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
.message.is-dismissing { opacity: 0; transform: translateY(-.4rem); }
.message-copy { min-width: 0; overflow-wrap: anywhere; }
.message-dismiss {
  display: none;
  width: 30px;
  height: 30px;
  margin: -.3rem 0;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: white;
  cursor: pointer;
  font-size: 1.35rem;
  line-height: 1;
  pointer-events: auto;
}
.js .message-dismiss { display: grid; place-items: center; }
.message-dismiss:hover { background: rgb(255 255 255 / 14%); }
.message-dismiss:focus-visible { outline: 2px solid white; outline-offset: 1px; }

@media (max-width: 700px) {
  .dashboard-heading { align-items: start; flex-direction: column; }
  .app-header { gap: .5rem; padding: .5rem 1rem; flex-wrap: wrap; }
  .app-header nav a { display: none; }
  .brand-product, .organisation-switcher label { display: none; }
  .organisation-switcher select { width: min(145px, 37vw); }
  .organisation-switcher button { padding-inline: .4rem; }
  .js .organisation-switcher button { display: none; }
  .header-actions, .app-header nav, .organisation-switcher { gap: .4rem; }
  .messages { inset-inline: 1rem; width: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .message { transition: none; }
}

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.muted-copy { color: var(--muted); }
.danger { color: #a63f3f !important; }
.button-secondary { background: var(--surface); color: var(--ink); }
.button-secondary:hover { border-color: var(--accent-line); background: var(--accent-softer); }
.dashboard-actions, .workspace-actions { display: flex; gap: .65rem; flex-wrap: wrap; }

.connection-strip {
  display: grid; grid-template-columns: auto 1fr auto; gap: 1rem; align-items: center;
  background: var(--accent-softer); border: 1px solid var(--accent-line); border-radius: 10px; padding: .8rem 1rem;
}
.connection-strip.is-connected { background: #eaf4f0; border-color: #c9ded6; }
.connection-strip p { margin: .18rem 0 0; color: var(--muted); font-size: .88rem; }
.connection-strip a { color: var(--accent-dark); font-weight: 750; text-decoration: none; }
.connection-dot { width: 11px; height: 11px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px rgb(126 54 204 / 16%); }
.is-connected .connection-dot { background: #3b9b7c; box-shadow: 0 0 0 4px rgb(59 155 124 / 18%); }

.source-browser, .section-block { margin-top: 2rem; }
.source-browser { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 1.25rem; scroll-margin-top: 2rem; }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 2rem; margin-bottom: 1.4rem; }
.section-heading h2 { font-size: 1.25rem; margin: 0; letter-spacing: -.02em; }
.search-form { display: flex; gap: .55rem; }
.search-form input { min-width: 290px; border: 1px solid var(--line); border-radius: 999px; padding: .7rem 1rem; }
.search-form.is-searching input { border-color: var(--accent-line); background: var(--accent-softer); }
.source-scope-note { margin: -.35rem 0 .9rem; color: var(--muted); font-size: .82rem; }
.source-search-loading {
  display: flex;
  align-items: center;
  gap: .9rem;
  margin: 0 0 1rem;
  padding: .85rem 1rem;
  border: 1px solid var(--accent-line);
  border-radius: 12px;
  background: var(--accent-softer);
}
.source-search-loading .render-pending-spinner { flex: 0 0 auto; width: 28px; height: 28px; margin: 0; border-width: 3px; }
.source-search-loading-copy { min-width: 0; }
.source-search-loading-copy strong { display: block; overflow-wrap: anywhere; font-size: .9rem; }
.source-search-loading-copy p { margin: .15rem 0 0; color: var(--muted); font-size: .82rem; }
.source-search-loading-copy small { display: block; margin-top: .25rem; color: var(--muted); font-size: .72rem; }
.source-search-loading.is-error { border-color: #efc8c3; background: #fff7f5; color: #7f322a; }
.source-search-loading.is-error .render-pending-spinner { display: none; }
.source-result-summary { margin: 0 0 .65rem; color: var(--muted); font-size: .82rem; }
.source-list { display: grid; }
.source-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 1rem; padding: 1.2rem .25rem; border-bottom: 1px solid var(--line); }
.source-row:last-child { border-bottom: 0; }
.document-glyph { width: 45px; height: 56px; border-radius: 4px 10px 4px 4px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-family: Georgia, serif; font-size: 1.4rem; font-weight: 700; }
.source-main h3 { margin: 0 0 .3rem; font-size: 1.03rem; }
.source-main > p { color: var(--muted); margin: 0; font-size: .88rem; }
.meta-line { display: flex; gap: 1.1rem; margin-top: .55rem; color: var(--muted); font-size: .75rem; }
.meta-line span::before { content: "·"; color: var(--warm); margin-right: .35rem; font-weight: 900; }
.callout { border-radius: 14px; padding: 1rem 1.15rem; }
.error-callout { background: #f9e8e6; border: 1px solid #efc8c3; color: #7f322a; }
.error-callout p { margin-bottom: 0; }
.count-chip { border: 1px solid var(--line); border-radius: 999px; padding: .4rem .75rem; color: var(--muted); font-size: .8rem; }

.project-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.project-card { display: grid; grid-template-columns: 105px minmax(0, 1fr); gap: 1.2rem; align-items: center; color: inherit; text-decoration: none; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 1.1rem; }
.project-card:hover { border-color: var(--accent-line); }
.project-card h3 { margin: .55rem 0 .3rem; font-size: 1.08rem; }
.project-card p, .project-card small { display: block; color: var(--muted); font-size: .8rem; margin: 0 0 .3rem; }
.paper-preview { width: 96px; height: 128px; background: white; border: 1px solid var(--line); box-shadow: 0 8px 20px rgb(20 18 47 / 10%); border-radius: 2px; padding: 16px 12px; display: flex; flex-direction: column; gap: 7px; }
.paper-preview span { display: block; height: 3px; border-radius: 2px; background: #dedbea; }
.paper-preview .paper-accent { width: 65%; height: 10px; background: var(--accent); margin-bottom: 12px; }
.paper-preview .short { width: 60%; }
.status-pill { display: inline-flex; width: fit-content; padding: .22rem .45rem; border-radius: 999px; background: #eef1f0; color: #61706c; text-transform: uppercase; letter-spacing: .07em; font-weight: 800; font-size: .59rem; }
.status-pill.ready, .status-pill.succeeded { background: #dff0ea; color: #17664f; }
.status-pill.error, .status-pill.failed { background: #fae7e4; color: #963b31; }
.status-pill.rendering, .status-pill.queued { background: #f8eddc; color: #8a5b24; }

.template-summary { padding-bottom: 6rem; }
.template-summary .section-heading > a { color: var(--accent); text-decoration: none; font-weight: 750; }
.template-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: .75rem; }
.mini-template-card { display: flex; align-items: center; gap: .8rem; color: inherit; text-decoration: none; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: .75rem; }
.mini-template-card .swatch { width: 35px; height: 44px; border-radius: 5px; background: linear-gradient(145deg, var(--swatch), color-mix(in srgb, var(--swatch) 50%, white)); }
.mini-template-card small { display: block; color: var(--muted); font-size: .72rem; margin-top: .15rem; }
.mini-template-card.new > span { width: 35px; text-align: center; font-size: 1.4rem; color: var(--accent); }

.workspace-heading { min-height: 105px; padding: 1.2rem 2vw; background: var(--surface); border-bottom: 1px solid var(--line); display: flex; align-items: end; justify-content: space-between; gap: 2rem; }
.workspace-heading h1 { margin: .25rem 0 .2rem; font-size: 1.75rem; letter-spacing: -.045em; }
.workspace-heading p { color: var(--muted); margin: 0; font-size: .82rem; }
.back-link { color: var(--muted); text-decoration: none; font-size: .83rem; }
.title-line { display: flex; align-items: center; gap: .7rem; }
.studio-workspace { height: calc(100vh - 214px); min-height: 650px; display: grid; grid-template-columns: 260px minmax(500px, 1fr) 355px; overflow: hidden; }
.outline-panel, .inspector-panel { background: var(--surface); overflow-y: auto; }
.outline-panel { border-right: 1px solid var(--line); }
.inspector-panel { border-left: 1px solid var(--line); }
.panel-heading { padding: 1.2rem; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); }
.panel-heading h2 { margin: .15rem 0 0; font-size: 1.2rem; }
.panel-heading > span { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; background: var(--accent-soft); color: var(--accent-dark); font-size: .75rem; }
.outline-list { padding: .5rem 0; }
.outline-item { position: relative; display: grid; grid-template-columns: 17px minmax(0, 1fr) auto; align-items: start; gap: .5rem; padding: .55rem .9rem; font-size: .78rem; color: var(--ink); }
.outline-item:hover { background: var(--accent-softer); }
.outline-item input { accent-color: var(--accent); margin: .1rem 0 0; }
.outline-item span { overflow: hidden; text-overflow: ellipsis; }
.outline-item a { color: var(--muted); text-decoration: none; }
.outline-include-form { display: contents; }
.outline-layout-menu { position: relative; }
.outline-layout-menu > summary { color: var(--muted); cursor: pointer; line-height: 1; list-style: none; }
.outline-layout-menu > summary::-webkit-details-marker { display: none; }
.outline-layout-form { position: absolute; z-index: 5; top: 1.35rem; right: 0; display: grid; gap: .6rem; width: 205px; padding: .75rem; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); box-shadow: 0 10px 28px rgb(20 18 47 / 18%); }
.outline-layout-form strong { font-size: .75rem; }
.outline-layout-form label { display: grid; grid-template-columns: 17px 1fr; gap: .45rem; align-items: start; cursor: pointer; font-size: .72rem; }
.outline-layout-form a { color: var(--accent); font-size: .72rem; }
.outline-layout-status { min-height: .9rem; margin: 0; color: var(--muted); font-size: .66rem; }
.outline-item.depth-1 { padding-left: 1.35rem; }
.outline-item.depth-2 { padding-left: 1.9rem; }
.outline-item.depth-3, .outline-item.depth-4, .outline-item.depth-5, .outline-item.depth-6 { padding-left: 2.4rem; font-size: .74rem; }
.outline-pagination { display: grid; gap: .45rem; padding: .8rem .9rem 1rem; border-top: 1px solid var(--line); text-align: center; }
.outline-pagination button { width: 100%; }
.outline-pagination p { margin: 0; color: var(--muted); font-size: .7rem; }
.add-section-drawer { border-top: 1px solid var(--line); margin-top: .5rem; }
.add-section-drawer summary { padding: .9rem; color: var(--accent); cursor: pointer; font-weight: 750; font-size: .8rem; }

.preview-panel { min-width: 0; background: #e5e3ec; display: grid; grid-template-rows: auto 1fr; }
.preview-toolbar { min-height: 52px; display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .45rem 1rem; background: #f2f1f5; border-bottom: 1px solid var(--line); color: var(--muted); font-size: .75rem; }
.preview-toolbar a { color: var(--accent); text-decoration: none; }
.preview-label { display: flex; align-items: center; min-width: 0; }
.preview-label > span:last-child { display: grid; gap: .08rem; min-width: 0; }
.preview-label strong { color: var(--ink); font-size: .75rem; }
.preview-label small { overflow: hidden; color: var(--muted); font-size: .62rem; text-overflow: ellipsis; white-space: nowrap; }
.preview-toolbar-actions { display: flex; gap: .75rem; flex: 0 0 auto; }
.preview-toolbar-actions form { margin: 0; }
.preview-toolbar .full-preview-link { font-weight: 800; }
.live-dot { width: 7px; height: 7px; display: inline-block; margin-right: .35rem; border-radius: 50%; background: #47a586; }
.preview-stage { position: relative; padding: 1.4rem; overflow: hidden; }
.preview-stage iframe { display: block; width: 100%; height: 100%; border: 0; background: white; box-shadow: 0 15px 45px rgb(20 18 47 / 16%); border-radius: 5px; }
.preview-loading { position: absolute; z-index: 2; inset: 1.4rem; display: grid; place-content: center; justify-items: center; gap: .8rem; padding: 2rem; text-align: center; border-radius: 5px; background: rgb(248 245 252 / 94%); color: var(--ink); }
.preview-loading .render-pending-spinner { width: 38px; height: 38px; margin: 0 0 .35rem; border-width: 4px; }
.preview-loading strong { font-size: .88rem; }
.preview-loading small { color: var(--muted); font-size: .7rem; }
.preview-loading.is-error { color: #943d33; background: rgb(255 247 245 / 97%); }
.preview-loading.is-error .render-pending-spinner { display: none; }
.preview-loading progress, .document-loading progress { width: min(330px, 70vw); height: 8px; overflow: hidden; border: 0; border-radius: 999px; background: var(--accent-soft); accent-color: var(--accent); }
.preview-loading progress::-webkit-progress-bar, .document-loading progress::-webkit-progress-bar { border-radius: 999px; background: var(--accent-soft); }
.preview-loading progress::-webkit-progress-value, .document-loading progress::-webkit-progress-value { border-radius: 999px; background: var(--accent); transition: width .35s ease; }
.preview-loading progress::-moz-progress-bar, .document-loading progress::-moz-progress-bar { border-radius: 999px; background: var(--accent); }

.ai-panel { padding: 1rem; background: linear-gradient(145deg, #f8f5fc, #f0e8fb); border-bottom: 1px solid var(--accent-line); }
.ai-label { display: flex; gap: .65rem; align-items: center; margin-bottom: .7rem; }
.ai-label > span { width: 31px; height: 31px; display: grid; place-items: center; background: var(--accent); color: white; border-radius: 9px; }
.ai-label strong, .ai-label small { display: block; }
.ai-label strong { font-size: .82rem; }
.ai-label small { color: var(--muted); font-size: .66rem; margin-top: .1rem; }
.ai-form { border: 1px solid var(--accent-line); border-radius: 13px; overflow: hidden; background: white; }
.ai-form textarea { width: 100%; border: 0; outline: 0; resize: vertical; padding: .75rem; min-height: 74px; font-size: .8rem; }
.ai-options { display: grid; grid-template-columns: 1fr 80px 32px; gap: .35rem; align-items: center; padding: .45rem; border-top: 1px solid var(--line); }
.ai-options select { min-width: 0; border: 0; background: var(--accent-softer); border-radius: 7px; padding: .35rem; font-size: .67rem; }
.ai-options button { width: 32px; height: 32px; border: 0; border-radius: 8px; color: white; background: var(--accent); cursor: pointer; }
.form-status { margin: 0; padding: 0 .55rem .45rem; color: var(--muted); font-size: .68rem; }
.form-status:empty { display: none; }
.prompt-chips { display: flex; gap: .35rem; margin-top: .55rem; overflow-x: auto; }
.prompt-chips button { border: 1px solid var(--accent-line); border-radius: 999px; padding: .3rem .5rem; background: rgb(255 255 255 / 70%); color: var(--accent-dark); white-space: nowrap; font-size: .62rem; cursor: pointer; }
.inspector-section { border-bottom: 1px solid var(--line); }
.inspector-section > summary { list-style: none; padding: .9rem 1rem; cursor: pointer; font-size: .82rem; font-weight: 800; }
.inspector-section > summary::-webkit-details-marker { display: none; }
.inspector-section > summary::after { content: "+"; float: right; color: var(--muted); }
.inspector-section[open] > summary::after { content: "−"; }
.inspector-section > summary span { color: var(--muted); font-size: .7rem; margin-left: .3rem; }
.compact-form { padding: 0 1rem 1rem; }
.design-scope-note { margin: 0 0 .8rem; padding: .65rem .75rem; border-radius: 9px; background: var(--accent-softer); color: var(--muted); font-size: .69rem; line-height: 1.45; }
.design-control-groups { display: grid; gap: .5rem; }
.design-group { border: 1px solid var(--line); border-radius: 10px; background: #fcfbfd; }
.design-group > summary { padding: .65rem .75rem; cursor: pointer; color: var(--ink); font-size: .74rem; font-weight: 800; list-style: none; }
.design-group > summary::-webkit-details-marker { display: none; }
.design-group > summary::after { content: "+"; float: right; color: var(--muted); }
.design-group[open] > summary::after { content: "−"; }
.design-group[open] > summary { border-bottom: 1px solid var(--line); }
.design-grid { display: grid; gap: .55rem; padding: .7rem; }
.design-grid.two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.design-grid > div { min-width: 0; }
.design-colour-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; padding: 0 .7rem .7rem; }
.design-colour-grid.table-colour-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.design-colour-grid input[type="color"] { min-height: 38px; padding: .15rem; }
.design-group > .helptext { display: block; margin: 0; padding: 0 .7rem .7rem; line-height: 1.45; }
.advanced-design-group > div { padding: .7rem; }
.advanced-design-group textarea { min-height: 220px; resize: vertical; }
.css-example { margin: .7rem; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.css-example summary { padding: .55rem .65rem; cursor: pointer; color: var(--muted); font-size: .7rem; font-weight: 750; }
.css-example pre { margin: 0; padding: .7rem; overflow-x: auto; border-top: 1px solid var(--line); background: var(--accent-softer); color: var(--ink); font-size: .64rem; line-height: 1.55; }
.design-actions { display: grid; gap: .65rem; padding-top: .8rem; text-align: center; }
.design-actions .link-button { justify-self: center; font-size: .7rem; }
.design-template-link { color: var(--accent); font-size: .7rem; font-weight: 750; text-decoration: none; }
.stack-form label { font-size: .72rem; color: var(--muted); font-weight: 700; }
.stack-form input, .stack-form select, .stack-form textarea { width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: .55rem .65rem; background: white; }
.stack-form input[type="checkbox"] { width: auto; min-height: 0; accent-color: var(--accent); }
.stack-form .helptext { color: var(--muted); font-size: .66rem; }
.stack-form .errorlist { color: #9f3f34; padding-left: 1rem; font-size: .7rem; }
.code-input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace !important; font-size: .76rem !important; line-height: 1.55; }
.asset-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .55rem; padding: 0 1rem .7rem; }
.asset-grid figure { margin: 0; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.asset-grid img { display: block; width: 100%; height: 80px; object-fit: contain; background: #f4f3f7; }
.asset-grid figcaption { padding: .4rem; font-size: .65rem; }
.asset-grid form { display: inline; float: right; }
.upload-form { border-top: 1px solid var(--line); padding-top: .7rem; }
.job-list { padding: 0 1rem 1rem; }
.job-list > div { display: grid; grid-template-columns: auto 1fr auto; gap: .55rem; align-items: center; padding: .55rem 0; border-bottom: 1px solid var(--line); }
.job-list strong, .job-list small { display: block; font-size: .67rem; }
.job-list small { color: var(--muted); margin-top: .1rem; }
.job-list a { color: var(--accent); text-decoration: none; font-size: .7rem; font-weight: 750; }
.job-actions { display: flex; gap: .55rem; align-items: center; justify-content: flex-end; }
.job-actions form { margin: 0; }

.page-heading { padding: 2rem 0 1.25rem; display: flex; justify-content: space-between; align-items: center; gap: 2rem; }
.page-heading h1 { margin: .45rem 0 0; font-size: 2rem; letter-spacing: -.035em; }
.page-heading p { margin: .4rem 0 0; color: var(--muted); max-width: 650px; font-size: .88rem; }
.template-library { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; padding-bottom: 5rem; }
.template-card { display: grid; grid-template-columns: 155px 1fr; gap: 1.3rem; background: white; border: 1px solid var(--line); border-radius: 12px; padding: 1.1rem; }
.template-card h2 { margin: 0; letter-spacing: -.035em; }
.template-card p, .template-card small { color: var(--muted); font-size: .84rem; }
.template-cover { width: 145px; height: 195px; border: 1px solid var(--line); background: #fff; box-shadow: 0 8px 18px rgb(20 18 47 / 10%); padding: 20px 16px; display: flex; flex-direction: column; }
.template-cover span { height: 8px; width: 60%; background: var(--primary); margin-bottom: 28px; }
.template-cover strong { color: var(--primary); font-family: Georgia, serif; font-size: 2rem; margin-bottom: 30px; }
.template-cover i { height: 3px; background: #dedbea; margin-bottom: 7px; }
.template-cover i:last-child { width: 65%; background: var(--accent); }
.card-actions { display: flex; gap: .8rem; align-items: center; margin-top: 1rem; }
.template-library > .empty-state { grid-column: 1 / -1; }
.revision-badge { border: 1px solid var(--line); border-radius: 999px; padding: .5rem .8rem; color: var(--muted); }
.template-editor { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; padding-bottom: 8rem; }
.settings-card { background: white; border: 1px solid var(--line); border-radius: 12px; padding: 1.25rem; }
.wide-card { grid-column: 1 / -1; }
.settings-title { margin-bottom: 1rem; }
.settings-title h2 { margin: 0; font-size: 1.2rem; }
.settings-title p { color: var(--muted); margin: .2rem 0 0; font-size: .75rem; }
.field-grid { display: grid; gap: .75rem; }
.two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field-grid > div, .colour-grid > div, .settings-card > div:last-child { min-width: 0; }
.field-grid label, .colour-grid label, .settings-card label { display: block; color: var(--muted); font-size: .72rem; font-weight: 750; margin-bottom: .3rem; }
.field-grid input:not([type="checkbox"]), .field-grid select, .field-grid textarea, .settings-card textarea { width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: .55rem; }
.field-grid input[type="checkbox"] { accent-color: var(--accent); }
.colour-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: .6rem; }
.colour-grid.table-colour-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 1rem; }
.colour-grid input { width: 100%; height: 48px; border: 0; border-radius: 8px; background: none; padding: 0; }
.settings-card .errorlist { color: #9f3f34; font-size: .7rem; }
.sticky-save { position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; min-height: 68px; display: flex; align-items: center; justify-content: flex-end; gap: 1rem; padding: .7rem 4vw; background: rgb(255 255 255 / 93%); backdrop-filter: blur(14px); border-top: 1px solid var(--line); box-shadow: 0 -8px 30px rgb(20 18 47 / 7%); }
.sticky-save > a { color: var(--muted); text-decoration: none; }
.narrow-card { max-width: 820px; background: white; border: 1px solid var(--line); border-radius: 12px; padding: 1.5rem; margin-bottom: 5rem; }
.template-assets-card { margin-bottom: 8rem; }
.template-asset-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); padding: 0 0 1rem; }
.template-asset-grid img { height: 125px; }
.template-asset-form { max-width: 620px; border-top: 1px solid var(--line); padding-top: 1rem; }
.form-actions { display: flex; justify-content: flex-end; }
.delete-zone { display: flex; justify-content: space-between; align-items: center; gap: 1rem; border-top: 1px solid #efd5d2; margin-top: 2rem; padding-top: 1.2rem; color: #80392f; }
.delete-zone p { margin: 0; font-size: .8rem; }
.danger-button { color: #962f25; border-color: #e2afa9; background: #fff6f4; }

.render-pending-card {
  width: min(720px, 92vw);
  margin: 12vh auto 4rem;
  padding: 2rem;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.render-pending-card h1 { margin: 0 0 1rem; font-size: 1.75rem; letter-spacing: -.035em; }
.render-pending-card > p { max-width: 560px; margin: .7rem auto 1.5rem; }
.render-pending-spinner {
  width: 48px;
  height: 48px;
  margin: 0 auto 1.4rem;
  border: 5px solid var(--accent-soft);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: render-pending-spin .9s linear infinite;
}
@keyframes render-pending-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .render-pending-spinner { animation: none; } }

.document-loading { position: fixed; z-index: 100; inset: 0; display: grid; place-items: center; padding: 1.5rem; background: rgb(20 18 47 / 55%); backdrop-filter: blur(8px); }
.document-loading-card { width: min(620px, 94vw); padding: clamp(2rem, 5vw, 3.5rem); text-align: center; border: 1px solid var(--line); border-radius: 26px; background: var(--surface); box-shadow: 0 28px 90px rgb(20 18 47 / 32%); }
.document-loading-card h2 { margin: .6rem 0 .85rem; font-size: clamp(1.6rem, 4vw, 2.5rem); letter-spacing: -.045em; }
.document-loading-card > p { margin: .7rem auto 1rem; max-width: 500px; }
.document-loading-card > small { display: block; margin-top: .55rem; color: var(--muted); }
.is-document-loading { overflow: hidden; }
[hidden] { display: none !important; }

@media (max-width: 1150px) {
  .project-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .template-row { grid-template-columns: repeat(2, 1fr); }
  .studio-workspace { grid-template-columns: 220px minmax(480px, 1fr); }
  .inspector-panel { position: fixed; right: 0; top: 213px; bottom: 0; width: 355px; box-shadow: -12px 0 35px rgb(20 18 47 / 13%); transform: translateX(calc(100% - 8px)); transition: transform .2s; z-index: 5; }
  .inspector-panel:hover, .inspector-panel:focus-within { transform: translateX(0); }
}

@media (max-width: 800px) {
  .project-grid, .template-library, .template-editor { grid-template-columns: 1fr; }
  .wide-card { grid-column: auto; }
  .template-row { grid-template-columns: 1fr; }
  .workspace-heading { align-items: start; flex-direction: column; }
  .studio-workspace { height: auto; grid-template-columns: 1fr; overflow: visible; }
  .outline-panel { max-height: 360px; border-right: 0; }
  .preview-panel { min-height: 680px; }
  .inspector-panel { position: static; width: auto; transform: none; box-shadow: none; }
  .source-row { grid-template-columns: auto 1fr; }
  .source-row > form { grid-column: 2; }
  .section-heading, .page-heading { align-items: start; flex-direction: column; }
  .search-form { width: 100%; }
  .search-form input { min-width: 0; flex: 1; }
  .colour-grid { grid-template-columns: repeat(3, 1fr); }
  .design-colour-grid.table-colour-grid, .colour-grid.table-colour-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
