:root {
  color-scheme: light;
  --bg: #f8f7f3;
  --surface: #fffefa;
  --ink: #222620;
  --muted: #62685e;
  --line: #e5e4db;
  --side: #1d211d;
  --peach: #f6a773;
  --accent: #83411f;
  --active: #fff1e6;
  font-family: "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--bg);
  font-synthesis: none;
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; color: inherit; }
button svg, .breadcrumb svg { flex-shrink: 0; vertical-align: middle; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid #b95124;
  outline-offset: 2px;
}
h1, h2, h3, h4, p, ol { margin: 0; }
[hidden] { display: none !important; }
.skip-link { position: fixed; z-index: 10; top: 8px; left: 8px; transform: translateY(-160%); padding: 10px; color: var(--ink); background: var(--peach); border-radius: 6px; }
.skip-link:focus { transform: none; }

.shell { display: grid; grid-template-columns: 237px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100dvh; overflow-y: auto; display: flex; flex-direction: column; padding: 26px 15px 16px; background: var(--side); color: #f8f7ef; }
.brand { display: flex; align-items: center; gap: 11px; margin: 0 6px 36px; }
.brand-mark { flex: 0 0 39px; height: 39px; display: grid; place-items: center; color: #262820; background: var(--peach); border-radius: 11px; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 17px; letter-spacing: -.42px; }
.brand small, .side-label, .eyebrow { font: 700 10px/1.5 "Cascadia Mono", Consolas, monospace; letter-spacing: 1.25px; }
.brand small { margin-top: 3px; color: #b5baae; }
.side-heading { display: flex; align-items: center; justify-content: space-between; margin: 0 0 8px 8px; }
.side-label { color: #a6ada0; }
.side-heading .icon-button { width: 30px; height: 30px; color: #c3c9bc; }
.sidebar .icon-button:hover, .sidebar .button.quiet:hover { background: #353c33; }
.channels { display: grid; gap: 4px; }
.channel-item { display: flex; width: 100%; align-items: center; gap: 9px; text-align: left; padding: 8px; border-radius: 8px; background: none; border: 1px solid transparent; color: #c6cbc0; font-size: 13px; }
.channel-item:hover { background: #2a3029; color: #fff; }
.channel-item.current { background: #38342c; border-color: #594638; color: #fbd4bb; font-weight: 650; }
.channel-item span:nth-child(2) { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.channel-icon { display: grid; flex: 0 0 28px; place-items: center; height: 28px; border-radius: 7px; color: #34352b; font: 700 10px "Cascadia Mono", Consolas, monospace; }
.peach { background: #f2b590; }
.lime { background: #c9d9a2; }
.lilac { background: #d8c8eb; }
.blue { background: #b5d7eb; }
.side-foot { margin-top: auto; padding-top: 18px; }
.sidebar .button.quiet { color: #c6cbc0; }
.surface { min-width: 0; }
.topbar { height: 62px; padding: 0 clamp(20px, 4vw, 54px); display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); background: #fcfbf7; }
.breadcrumb { min-width: 0; display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 13px; }
.breadcrumb strong { color: #282d26; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.menu-toggle, .backdrop { display: none; }

.content { max-width: 1240px; margin-inline: auto; padding: 34px clamp(20px, 4vw, 54px) 60px; outline: 0; }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 14px; margin-bottom: 25px; }
.eyebrow { margin-bottom: 7px; color: var(--accent); }
h1 { font-size: clamp(30px, 4vw, 45px); line-height: 1.12; letter-spacing: -.05em; overflow-wrap: anywhere; }
.section-bar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 9px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.section-nav { display: flex; flex-wrap: wrap; gap: 6px; }
.section-tab { display: flex; align-items: center; gap: 7px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 8px 12px; min-height: 38px; font-size: 13px; font-weight: 650; overflow-wrap: anywhere; text-align: left; }
.section-tab:hover { border-color: #c5c7bb; }
.section-tab.current { color: var(--accent); background: var(--active); border-color: #e6b08e; }
.section-heading { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 23px 0 13px; }
.section-heading h2, .empty h2 { font-size: 24px; letter-spacing: -.035em; overflow-wrap: anywhere; }
.section-heading p, .empty p { margin-top: 3px; color: var(--muted); font-size: 13px; }
.stage-list { display: grid; gap: 9px; list-style: none; padding: 0; }
.stage { min-width: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.stage-heading { display: flex; align-items: center; gap: 11px; min-height: 65px; padding: 10px 13px; }
.stage-icon { display: inline-grid; flex: 0 0 37px; place-items: center; width: 37px; height: 37px; border-radius: 9px; color: #455041; background: #eeefe7; }
.stage-name { flex: 1; }
.stage-name h3 { font-size: 14px; letter-spacing: -.17px; }
.stage-name p { margin-top: 3px; color: var(--muted); font-size: 12px; }
.prompts { display: grid; gap: 6px; padding: 0 13px 12px; }
.prompt-card { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; padding: 10px 11px; background: #f8f8f2; border: 1px solid var(--line); border-radius: 8px; }
.prompt-text { min-width: 0; }
.prompt-title { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.prompt-title h4 { font-size: 13px; overflow-wrap: anywhere; }
.prompt-text p { margin-top: 4px; font-size: 12px; line-height: 1.45; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; white-space: pre-wrap; }
.prompt-actions, .backup-buttons { display: flex; gap: 5px; flex-wrap: wrap; }
.tag { padding: 3px 6px; border-radius: 5px; background: #eeefe7; color: #535e50; font-size: 10px; font-weight: 650; }
.empty { display: grid; justify-items: center; gap: 9px; padding: 60px 14px; text-align: center; }
.empty .button { margin-top: 5px; }

.button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 35px; padding: 7px 10px; border: 1px solid transparent; border-radius: 8px; font-size: 12px; line-height: 1.25; font-weight: 650; white-space: nowrap; }
.button.primary { background: var(--peach); color: #2b261e; border-color: #eea06c; }
.button.primary:hover { background: #ffbc8d; }
.button.secondary { background: var(--surface); border-color: #dfdfd5; }
.button.secondary:hover, .button.quiet:hover { background: #efefe7; }
.button.quiet { background: transparent; color: #50584c; }
.button.danger { color: #a13928; background: #fff2ed; border-color: #f0d4cb; }
.button.danger:hover { background: #ffe6dc; }
.icon-button { display: inline-grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 7px; background: transparent; color: #586151; }
.icon-button:hover { background: #efefe6; }

dialog { width: min(620px, calc(100% - 24px)); max-height: 88dvh; overflow-y: auto; padding: 0; border: 1px solid #d6d9ce; border-radius: 15px; color: var(--ink); background: var(--surface); box-shadow: 0 18px 70px #161c1742; }
dialog::backdrop { background: #1319139e; }
.modal-heading, .modal-actions { display: flex; justify-content: space-between; align-items: start; gap: 9px; padding: 15px 18px; }
.modal-heading { border-bottom: 1px solid var(--line); }
.modal-heading h2 { font-size: 23px; letter-spacing: -.04em; overflow-wrap: anywhere; }
.modal-heading p { margin-top: 4px; color: var(--muted); font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.modal-body { padding: 12px 18px; }
.modal-actions { border-top: 1px solid var(--line); background: #faf9f4; flex-wrap: wrap; }
.modal-actions > div { display: flex; gap: 6px; margin-left: auto; }
.modal-error { padding: 0 18px 10px; color: #a13928; font-size: 12px; }
.modal-error:empty { display: none; }
.field { display: grid; gap: 6px; min-width: 0; margin-bottom: 10px; }
.field:last-child { margin-bottom: 0; }
.field > span { color: #4b5648; font-size: 12px; font-weight: 650; }
.field small { margin-left: 4px; color: var(--muted); font-weight: 400; }
.filled-preview { margin-top: 16px; }
.filled-preview textarea { background: #f8f8f2; }
input:not([type=file]), textarea, select { display: block; width: 100%; min-width: 0; padding: 9px 10px; border: 1px solid #dcded3; border-radius: 8px; color: var(--ink); background: var(--surface); font-size: 13px; line-height: 1.5; }
textarea { resize: vertical; }
.toast { position: fixed; z-index: 5; right: 18px; bottom: 18px; max-width: min(420px, calc(100% - 36px)); padding: 11px 14px; border: 1px solid #5d695a; border-radius: 8px; color: #fff; background: #2d392e; font-size: 13px; line-height: 1.4; opacity: 0; transform: translateY(7px); transition: opacity .18s, transform .18s; pointer-events: none; }
.toast.visible { opacity: 1; transform: translateY(0); }

@media (max-width: 720px) {
  .shell { display: block; }
  .sidebar { position: fixed; z-index: 4; top: 0; bottom: 0; width: min(260px, 82vw); visibility: hidden; transform: translateX(-100%); }
  .menu-open .sidebar { visibility: visible; transform: none; }
  .menu-open .backdrop { display: block; position: fixed; inset: 0; z-index: 3; background: #141a147d; border: 0; }
  .menu-toggle { display: block; }
  .topbar { height: 54px; padding: 0 14px; }
  .content { padding: 23px 16px 45px; }
}
@media (max-width: 460px) {
  .page-heading { align-items: start; flex-wrap: wrap; margin-bottom: 18px; }
  .section-heading { margin-top: 19px; }
  .stage-heading { padding-inline: 9px; gap: 7px; }
  .prompts { padding-inline: 9px; }
  .prompt-card { align-items: start; flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) {
  .toast { transition: none; }
}

.login { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-card { display: grid; gap: 14px; width: min(360px, 100%); padding: 22px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.login-card h1 { font-size: 26px; }
.login-card .field { margin-bottom: 0; }
.login-card .modal-error { padding: 0; }
.side-foot { display: flex; flex-wrap: wrap; gap: 4px; }
