:root {
  color-scheme: dark;
  font-family: "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif;
  font-size: 16px;
  --ink: #0a101b;
  --ink-2: #0e1725;
  --panel: #121d2d;
  --panel-2: #172437;
  --line: #26364b;
  --muted: #8ea0b8;
  --text: #f3f7fb;
  --cyan: #67c9dc;
  --cyan-soft: rgba(103, 201, 220, 0.14);
  --amber: #f4b96b;
  --danger: #ff7782;
  background: var(--ink);
  color: var(--text);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-width: 320px; min-height: 100%; background: var(--ink); }
button, input { font: inherit; }
button { color: inherit; }
button:disabled, input:disabled, textarea:disabled, select:disabled { opacity: .55; cursor: not-allowed; }

.auth-screen, .loading-screen, .error-screen {
  display: grid; place-items: center; min-height: 100vh; padding: 24px;
  background: radial-gradient(circle at 50% 10%, rgba(103,201,220,.12), transparent 38%), #0a101b;
}
.auth-card { width: min(440px, 100%); padding: 34px; border: 1px solid var(--line); border-radius: 18px; background: rgba(18,29,45,.96); box-shadow: 0 28px 80px rgba(0,0,0,.35); }
.auth-brand { display: flex; align-items: center; gap: 14px; }
.auth-brand h1 { margin: 0; font-size: 1.55rem; }
.auth-intro { margin: 22px 0; color: var(--muted); line-height: 1.7; }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; border: 1px solid var(--line); border-radius: 10px; background: var(--ink); }
.auth-tabs button { padding: 9px; border: 0; border-radius: 7px; color: var(--muted); background: transparent; cursor: pointer; }
.auth-tabs button.active { color: var(--text); background: var(--panel-2); }
.auth-form { display: grid; gap: 15px; margin-top: 22px; }
.auth-submit { width: 100%; margin-top: 5px; }
.form-hint { margin: -5px 0 0; color: var(--muted); font-size: .8rem; }
.form-error { margin: 0; color: var(--danger); font-size: .85rem; }

.app-shell {
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
  min-height: 100vh;
}

.rail {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 24px 18px 18px;
  border-right: 1px solid var(--line);
  background: #0c1421;
}

.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 28px; }
.brand-mark {
  display: grid; place-items: center; width: 40px; height: 40px;
  border: 1px solid rgba(103, 201, 220, 0.5); border-radius: 12px;
  color: var(--cyan); background: linear-gradient(145deg, rgba(103,201,220,.14), transparent);
  font: 700 1.18rem/1 "STKaiti", serif;
}
.brand strong, .brand span { display: block; }
.brand strong { font-size: 1rem; letter-spacing: .08em; }
.brand span { margin-top: 4px; color: var(--muted); font-size: .78rem; }

.primary-nav { display: grid; gap: 6px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 11px 12px;
  border: 0; border-radius: 9px; color: var(--muted); background: transparent; cursor: pointer;
  text-align: left;
}
.nav-item span { width: 22px; color: #70849e; font-weight: 700; text-align: center; }
.nav-item:hover, .nav-item.active { color: var(--text); background: var(--cyan-soft); }
.nav-item.active span { color: var(--cyan); }

.section-label {
  display: flex; justify-content: space-between; align-items: center;
  color: #71839b; font-size: .76rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
}
.section-label button, .inspector-heading button {
  border: 0; color: var(--muted); background: transparent; cursor: pointer;
}
.chapter-list { margin-top: 34px; }
.chapter {
  display: flex; gap: 11px; width: 100%; margin-top: 11px; padding: 12px 10px;
  border: 1px solid transparent; border-radius: 10px; color: var(--muted); background: transparent;
  text-align: left; cursor: pointer;
}
.chapter.active { border-color: rgba(103,201,220,.2); background: rgba(103,201,220,.08); color: var(--text); }
.chapter-number { color: var(--cyan); font: 700 .76rem/1.45 ui-monospace, monospace; }
.chapter strong, .chapter small { display: block; }
.chapter strong { font-size: .88rem; font-weight: 600; }
.chapter small { margin-top: 5px; color: #71839b; }

.rail-footer {
  display: flex; align-items: center; gap: 10px; margin-top: auto; padding: 15px 10px 4px;
  border-top: 1px solid var(--line);
}
.storage-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 0 4px var(--cyan-soft); }
.rail-footer strong, .rail-footer small { display: block; font-size: .75rem; }
.rail-footer small { margin-top: 3px; color: var(--muted); }

.workspace { min-width: 0; height: 100vh; overflow: hidden; }
.topbar {
  display: flex; justify-content: space-between; align-items: center; height: 82px; padding: 0 22px 0 28px;
  border-bottom: 1px solid var(--line); background: rgba(14, 23, 37, .9);
}
.eyebrow { margin: 0 0 4px; color: var(--cyan); font-size: .7rem; font-weight: 800; letter-spacing: .18em; text-transform: uppercase; }
.topbar h1 { margin: 0; font-size: 1.2rem; font-weight: 650; }
.topbar-actions { display: flex; align-items: center; gap: 9px; }
.readonly-badge { padding: 7px 10px; border: 1px solid rgba(244,185,107,.35); border-radius: 999px; color: var(--amber); font-size: .78rem; }
.user-menu { display: flex; align-items: center; gap: 10px; margin-left: 5px; padding-left: 14px; border-left: 1px solid var(--line); }
.user-menu span, .user-menu strong, .user-menu small { display: block; }
.user-menu strong { font-size: .8rem; }
.user-menu small { margin-top: 3px; color: var(--muted); font-size: .7rem; }
.search-box {
  display: flex; align-items: center; gap: 8px; min-width: 230px; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: 9px; color: var(--muted); background: #0b1421;
}
.search-box input { width: 100%; border: 0; outline: 0; color: var(--text); background: transparent; }
.search-box input::placeholder { color: #71839b; }
.button { padding: 9px 13px; border: 1px solid var(--line); border-radius: 9px; cursor: pointer; }
.button.ghost, .button.subtle { background: transparent; }
.button.primary { border-color: var(--cyan); color: #071219; background: var(--cyan); font-weight: 750; }
.button.subtle { color: var(--cyan); border-color: rgba(103,201,220,.32); }

.admin-workspace { height: calc(100vh - 82px); padding: 24px 28px 48px; overflow: auto; }
.admin-section { max-width: 1180px; margin: 0 auto 22px; padding: 24px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); }
.admin-heading { display: flex; justify-content: space-between; align-items: start; gap: 20px; margin-bottom: 20px; }
.admin-heading h2 { margin: 0; font-size: 1.15rem; }
.admin-heading p:last-child { margin: 7px 0 0; color: var(--muted); font-size: .85rem; }
.admin-table-wrap { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: .84rem; }
.admin-table th, .admin-table td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.admin-table th { color: var(--muted); font-size: .72rem; letter-spacing: .08em; }
.admin-table td strong, .admin-table td small { display: block; }
.admin-table td small { margin-top: 4px; color: var(--cyan); }
.admin-table select, .invite-form select, .invite-form input { padding: 8px; border: 1px solid var(--line); border-radius: 7px; color: var(--text); background: var(--ink-2); }
.status-toggle { display: flex; align-items: center; gap: 7px; }
.invite-form { display: grid; grid-template-columns: 180px 180px minmax(220px, 1fr) auto; align-items: end; gap: 12px; margin-bottom: 18px; }
.invite-result { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; margin: 0 0 18px; padding: 14px; border: 1px solid rgba(103,201,220,.35); border-radius: 10px; background: var(--cyan-soft); }
.invite-result code { padding: 8px; border-radius: 6px; color: var(--cyan); background: var(--ink); user-select: all; }
.invite-result small { grid-column: 1 / -1; color: var(--muted); }

.story-layout { display: grid; grid-template-columns: minmax(560px, 1fr) 326px; height: calc(100vh - 82px); }
.canvas-panel { min-width: 0; background: var(--ink); }
.canvas-toolbar {
  display: flex; justify-content: space-between; align-items: center; height: 58px; padding: 0 20px;
  border-bottom: 1px solid var(--line);
}
.view-switch { display: flex; padding: 3px; border: 1px solid var(--line); border-radius: 9px; background: #0b1421; }
.view-switch button { padding: 6px 12px; border: 0; border-radius: 6px; color: var(--muted); background: transparent; cursor: pointer; }
.view-switch button.active { color: var(--text); background: var(--panel-2); }

.graph-canvas {
  position: relative; height: calc(100% - 58px); overflow: auto;
  background-color: #0a111d;
  background-image: radial-gradient(circle, rgba(117,143,173,.22) 1px, transparent 1px);
  background-size: 24px 24px;
}
.connectors { position: absolute; inset: 0; width: 980px; height: 560px; overflow: visible; pointer-events: none; }
.connectors path { fill: none; stroke: #3b586c; stroke-width: 2; }
.story-node {
  position: absolute; left: var(--x); top: var(--y); width: 226px; min-height: 138px; padding: 15px 16px 13px;
  border: 1px solid #2c4157; border-radius: 12px; background: rgba(18,29,45,.97);
  box-shadow: 0 16px 36px rgba(0,0,0,.22); cursor: pointer;
}
.story-node:hover { border-color: #49627a; transform: translateY(-1px); }
.story-node.selected { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(103,201,220,.1), 0 18px 42px rgba(0,0,0,.3); }
.node-kicker { display: flex; justify-content: space-between; color: var(--muted); font-size: .7rem; letter-spacing: .08em; }
.node-index { color: var(--cyan); font-family: ui-monospace, monospace; }
.story-node h2 { margin: 13px 0 9px; font-size: 1rem; }
.story-node p { min-height: 35px; margin: 0; color: #aab7c8; font-size: .8rem; line-height: 1.55; }
.story-node p b { color: var(--amber); font-weight: 650; }
.story-node footer { display: flex; justify-content: space-between; margin-top: 13px; color: #71839b; font-size: .7rem; }
.choice-pill { color: var(--amber); }

.inspector { overflow: auto; padding: 20px; border-left: 1px solid var(--line); background: var(--ink-2); }
.inspector-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.inspector-heading span, .inspector-heading strong { display: block; }
.inspector-heading span { color: var(--muted); font-size: .72rem; }
.inspector-heading strong { margin-top: 5px; font-size: 1rem; }
.field { display: grid; gap: 7px; margin-bottom: 14px; color: var(--muted); font-size: .78rem; }
.field input {
  width: 100%; padding: 10px 11px; border: 1px solid var(--line); border-radius: 8px;
  outline: none; color: var(--text); background: #0b1421;
}
.field input:focus { border-color: var(--cyan); }
.command-section { margin-top: 26px; }
.command-card {
  display: grid; grid-template-columns: 26px 1fr; gap: 9px; margin-top: 9px; padding: 11px;
  border: 1px solid var(--line); border-radius: 9px; background: #101b2a;
}
.command-order { color: #5e7087; font: 700 .68rem/1.7 ui-monospace, monospace; }
.command-card small, .command-card strong { display: block; }
.command-card small { color: var(--cyan); font-size: .69rem; font-weight: 700; letter-spacing: .06em; }
.command-card strong, .command-card p { margin: 5px 0 0; font-size: .78rem; line-height: 1.5; }
.command-card p { color: #b7c2d0; }
.command-card.choice small { color: var(--amber); }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 76px minmax(0, 1fr); }
  .rail { padding-inline: 11px; }
  .brand div, .nav-item:not(.active) { display: none; }
  .brand { justify-content: center; padding-inline: 0; }
  .nav-item { justify-content: center; padding-inline: 0; font-size: 0; }
  .nav-item span { font-size: .9rem; }
  .chapter-list, .rail-footer span:not(.storage-dot) { display: none; }
  .rail-footer { justify-content: center; }
  .story-layout { grid-template-columns: minmax(520px, 1fr) 300px; }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .rail { display: none; }
  .topbar { height: auto; min-height: 84px; align-items: flex-start; gap: 12px; padding: 16px; }
  .topbar-actions { flex-wrap: wrap; justify-content: flex-end; }
  .search-box { min-width: 190px; }
  .story-layout { display: block; height: auto; }
  .canvas-panel { height: 58vh; }
  .inspector { height: auto; border-left: 0; border-top: 1px solid var(--line); }
}

/* Interactive editor states */
.loading-screen,
.error-screen {
  display: grid;
  place-content: center;
  justify-items: center;
  min-height: 100vh;
  gap: 14px;
  color: var(--muted);
  background:
    radial-gradient(circle at 50% 34%, rgba(103, 201, 220, .1), transparent 26rem),
    var(--ink);
}
.loading-screen p, .error-screen p { margin: 0; }
.error-screen h1 { margin: 8px 0 0; color: var(--text); font-size: 1.5rem; }
.error-screen .button { margin-top: 10px; }

.topbar-title { min-width: 170px; }
.button.compact { padding-inline: 10px; }
.button.danger { border-color: var(--danger); color: #fff; background: #a83445; }
.validation-button { display: inline-flex; align-items: center; gap: 7px; }
.count-badge {
  display: grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 999px; color: #fff; background: #a83445; font-size: .7rem; font-weight: 800;
}

.chapter-items { max-height: calc(100vh - 330px); overflow: auto; }
.chapter > span:last-child { min-width: 0; }
.chapter strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-footer[data-state="dirty"] .storage-dot,
.rail-footer[data-state="saving"] .storage-dot { background: var(--amber); box-shadow: 0 0 0 4px rgba(244, 185, 107, .12); }
.rail-footer[data-state="error"] .storage-dot { background: var(--danger); box-shadow: 0 0 0 4px rgba(255, 119, 130, .12); }

.story-layout { grid-template-columns: minmax(520px, 1fr) minmax(340px, 390px); }
.canvas-actions { display: flex; align-items: center; gap: 10px; }
.entry-select { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: .76rem; }
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  color: var(--text);
  background: #0b1421;
  font: inherit;
}
select:focus,
textarea:focus { border-color: var(--cyan); }
select { padding: 8px 28px 8px 9px; }
textarea { width: 100%; padding: 10px 11px; resize: vertical; line-height: 1.55; }

.graph-stage { position: relative; min-width: 100%; min-height: 100%; }
.connectors { position: absolute; inset: 0; overflow: visible; pointer-events: none; }
.connectors path { fill: none; stroke: #3b586c; stroke-width: 2; }
.connectors marker path { fill: #4f7487; stroke: none; }
.story-node { touch-action: none; user-select: none; transition: border-color .12s ease, box-shadow .12s ease, opacity .12s ease, transform .12s ease; }
.story-node.dragging { z-index: 5; transform: scale(1.015); cursor: grabbing; }
.story-node.search-miss { opacity: .2; }
.canvas-hint {
  position: sticky; left: 18px; bottom: 16px; width: max-content; padding: 7px 10px;
  border: 1px solid rgba(38,54,75,.8); border-radius: 8px; color: #71839b; background: rgba(10,17,29,.84);
  font-size: .7rem; pointer-events: none;
}

.inspector { scrollbar-color: #31465e transparent; }
.danger-icon { font-size: .75rem; }
.danger-icon:hover { color: var(--danger); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field { min-width: 0; }
.field small { color: #657991; font-size: .7rem; line-height: 1.5; }
.field input, .field select { min-width: 0; }
.add-command-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin: 11px 0 14px; }
.add-command-row select { width: 100%; }
.command-list { display: grid; gap: 10px; }
.command-card.command-editor { display: block; margin: 0; padding: 0; overflow: hidden; }
.command-card-head {
  display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; align-items: center; gap: 7px;
  padding: 9px 9px 9px 11px; border-bottom: 1px solid var(--line); background: #132033;
}
.command-card-head select { width: 100%; padding-block: 6px; border: 0; background: transparent; font-size: .8rem; font-weight: 700; }
.mini-actions { display: flex; }
.mini-actions button,
.choice-row-head button {
  min-width: 27px; height: 27px; padding: 0 6px; border: 0; border-radius: 6px;
  color: #8395ab; background: transparent; cursor: pointer;
}
.mini-actions button:hover { color: var(--text); background: #22344a; }
.mini-actions button:last-child:hover,
.choice-row-head button:hover { color: var(--danger); background: rgba(255,119,130,.09); }
.command-fields { padding: 12px; }
.command-fields .field:last-child { margin-bottom: 0; }
.choice-editor { display: grid; gap: 12px; }
.choice-row { padding: 10px; border: 1px solid #293b51; border-radius: 8px; background: #0d1725; }
.choice-row-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.choice-row-head strong { color: var(--amber); font-size: .75rem; }
.inline-add {
  padding: 9px; border: 1px dashed #38516a; border-radius: 8px; color: var(--cyan); background: transparent; cursor: pointer;
}
.muted-copy { margin: 0; color: var(--muted); font-size: .8rem; }
.empty-inline { padding: 24px 16px; border: 1px dashed var(--line); border-radius: 10px; color: var(--muted); text-align: center; font-size: .84rem; }

.script-view { height: calc(100% - 58px); overflow: auto; padding: 22px clamp(18px, 4vw, 52px) 60px; }
.script-node { max-width: 780px; margin: 0 auto 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); overflow: hidden; }
.script-node.selected { border-color: rgba(103,201,220,.7); }
.script-node-heading {
  display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 9px; width: 100%; padding: 13px 16px;
  border: 0; color: var(--text); background: #162338; text-align: left; cursor: pointer;
}
.script-node-heading > span { color: var(--cyan); font: 700 .72rem ui-monospace, monospace; }
.script-node-heading code { color: var(--muted); font-size: .72rem; }
.script-lines { padding: 14px 18px 16px; }
.script-lines p { margin: 0 0 10px; color: #c4cedb; line-height: 1.7; }
.script-lines p:last-child { margin-bottom: 0; }
.script-lines .speaker { display: inline-block; min-width: 66px; margin-right: 12px; color: var(--amber); font-weight: 700; }
.script-lines .narration { color: #9fadc0; font-style: italic; }
.script-lines .directive { display: flex; gap: 12px; color: #92a2b7; font-size: .82rem; }
.script-lines .directive span { min-width: 66px; color: var(--cyan); }
.script-choice { display: grid; gap: 7px; margin: 12px 0; padding-left: 16px; border-left: 2px solid rgba(244,185,107,.5); }
.script-choice span { color: #d6deea; font-size: .86rem; }
.script-choice code { margin-left: 7px; color: var(--muted); }

.character-layout { display: grid; grid-template-columns: minmax(430px, 1fr) minmax(320px, 390px); height: calc(100vh - 82px); }
.character-panel { overflow: auto; padding: 26px; }
.character-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.character-card {
  display: grid; grid-template-columns: 54px minmax(0, 1fr); grid-template-rows: 1fr auto; gap: 0 14px;
  min-height: 148px; padding: 17px; border: 1px solid var(--line); border-radius: 13px;
  color: var(--text); background: var(--panel); text-align: left; cursor: pointer;
}
.character-card:hover, .character-card.selected { border-color: rgba(103,201,220,.72); background: #142236; }
.avatar {
  display: grid; place-items: center; width: 54px; height: 54px; border-radius: 16px;
  color: var(--character-color); background: color-mix(in srgb, var(--character-color) 14%, #111c2b); font: 700 1.25rem serif;
}
.character-summary { min-width: 0; }
.character-summary strong, .character-summary code, .character-summary small { display: block; }
.character-summary strong { font-size: 1rem; }
.character-summary code { margin-top: 5px; color: var(--cyan); font-size: .7rem; }
.character-summary small { margin-top: 12px; overflow: hidden; color: var(--muted); font-size: .76rem; line-height: 1.5; text-overflow: ellipsis; white-space: nowrap; }
.expression-count { grid-column: 2; align-self: end; margin-top: 12px; color: #71839b; font-size: .72rem; }
.color-field input { width: 100%; height: 42px; padding: 5px; }

.empty-state { display: grid; justify-items: center; place-content: center; min-height: 300px; padding: 40px; text-align: center; }
.empty-state > span { color: var(--cyan); font-size: 2.5rem; }
.empty-state h2 { margin: 12px 0 4px; font-size: 1.15rem; }
.empty-state p { max-width: 320px; margin: 0 0 18px; color: var(--muted); font-size: .84rem; line-height: 1.6; }

.modal-backdrop {
  position: fixed; z-index: 20; inset: 0; display: grid; place-items: center; padding: 24px;
  background: rgba(3, 7, 13, .76); backdrop-filter: blur(8px);
}
.modal-card {
  width: min(640px, 100%); max-height: min(720px, calc(100vh - 48px)); overflow: auto;
  border: 1px solid #30445b; border-radius: 16px; background: #101a29; box-shadow: 0 28px 90px rgba(0,0,0,.55);
}
.modal-card > header { display: flex; justify-content: space-between; align-items: flex-start; padding: 22px 24px 18px; border-bottom: 1px solid var(--line); }
.modal-card > header h2 { margin: 4px 0 0; font-size: 1.2rem; }
.modal-card > header > button { border: 0; color: var(--muted); background: transparent; font-size: 1.4rem; cursor: pointer; }
.modal-card > footer { display: flex; justify-content: flex-end; gap: 9px; padding: 16px 24px 22px; }
.validation-summary { display: flex; gap: 8px; padding: 18px 24px 0; }
.validation-summary span { padding: 5px 8px; border-radius: 6px; font-size: .72rem; font-weight: 700; }
.error-summary { color: #ff9ba4; background: rgba(255,119,130,.1); }
.warning-summary { color: var(--amber); background: rgba(244,185,107,.1); }
.issue-list { display: grid; gap: 8px; padding: 14px 24px 8px; }
.issue {
  display: grid; grid-template-columns: 48px 1fr auto; align-items: center; gap: 10px; width: 100%; padding: 11px 12px;
  border: 1px solid var(--line); border-radius: 9px; color: var(--text); background: #0d1725; text-align: left; cursor: pointer;
}
.issue > span { font-size: .7rem; font-weight: 800; }
.issue.error > span { color: var(--danger); }
.issue.warning > span { color: var(--amber); }
.issue p { margin: 0; color: #bdc8d6; font-size: .8rem; line-height: 1.5; }
.issue code { color: var(--cyan); font-size: .7rem; }
.all-clear { display: grid; justify-items: center; padding: 34px; color: var(--muted); text-align: center; }
.all-clear > span { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%; color: #071219; background: var(--cyan); font-weight: 900; }
.all-clear strong { margin-top: 14px; color: var(--text); }
.all-clear p { margin: 6px 0 0; font-size: .8rem; }
.confirm-modal { width: min(460px, 100%); }
.confirm-modal > p { margin: 0; padding: 22px 24px 6px; color: var(--muted); line-height: 1.7; }
.settings-content { padding: 20px 24px 4px; }
.settings-content h3 { margin: 0 0 12px; color: var(--cyan); font-size: .75rem; letter-spacing: .1em; text-transform: uppercase; }
.settings-content h3:not(:first-child) { margin-top: 22px; }
.settings-danger {
  display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-top: 24px; padding: 14px;
  border: 1px solid rgba(255,119,130,.25); border-radius: 10px; background: rgba(255,119,130,.045);
}
.settings-danger strong { font-size: .84rem; }
.settings-danger p { margin: 4px 0 0; color: var(--muted); font-size: .72rem; }
.button:disabled { opacity: .4; cursor: not-allowed; }

.toast {
  position: fixed; z-index: 40; left: 50%; bottom: 24px; transform: translate(-50%, 18px);
  max-width: min(480px, calc(100vw - 32px)); padding: 11px 16px; border: 1px solid #344a62; border-radius: 10px;
  opacity: 0; color: var(--text); background: #162338; box-shadow: 0 14px 44px rgba(0,0,0,.4);
  pointer-events: none; transition: opacity .18s ease, transform .18s ease; font-size: .84rem;
}
.toast.visible { opacity: 1; transform: translate(-50%, 0); }
.toast[data-tone="error"] { border-color: rgba(255,119,130,.5); }
.toast[data-tone="success"] { border-color: rgba(103,201,220,.55); }

@media (max-width: 1180px) {
  .topbar-actions .search-box { min-width: 170px; }
  .story-layout, .character-layout { grid-template-columns: minmax(470px, 1fr) 340px; }
}

@media (max-width: 900px) {
  .invite-form { grid-template-columns: 1fr 1fr; }
  .topbar { align-items: flex-start; height: auto; min-height: 96px; padding-block: 14px; }
  .topbar-actions { flex-wrap: wrap; }
  .story-layout, .character-layout { height: calc(100vh - 96px); grid-template-columns: 1fr; }
  .canvas-panel, .character-panel { min-height: 54vh; }
  .inspector { display: none; }
  .story-layout:has(.story-node.selected) .inspector { display: block; position: fixed; z-index: 10; inset: 96px 0 0 auto; width: min(390px, 94vw); box-shadow: -18px 0 48px rgba(0,0,0,.38); }
  .character-layout .inspector { display: block; position: static; width: auto; }
}

@media (max-width: 760px) {
  .app-shell { grid-template-columns: 76px minmax(0, 1fr); }
  .rail { padding-inline: 10px; }
  .brand > div, .nav-item:not(.active) { font-size: 0; }
  .chapter-list, .rail-footer span:last-child { display: none; }
  .invite-form { grid-template-columns: 1fr; }
  .invite-result { grid-template-columns: 1fr; }
  .invite-result small { grid-column: auto; }
  .topbar-actions { width: 100%; }
  .topbar-actions .button.primary { flex: 1 0 100%; }
  .story-layout { display: block; height: auto; }
  .canvas-panel { height: 62vh; }
  .story-layout:has(.story-node.selected) .inspector {
    display: block;
    position: static;
    width: auto;
    height: auto;
    max-height: none;
    box-shadow: none;
  }
  .topbar { display: block; }
  .topbar-actions { justify-content: flex-start; margin-top: 12px; }
  .topbar-actions .search-box { width: 100%; }
  .topbar-actions .button.primary { flex: 1; }
  .canvas-toolbar { height: auto; min-height: 62px; align-items: flex-start; gap: 10px; padding-block: 10px; }
  .canvas-actions { flex-wrap: wrap; justify-content: flex-end; }
  .graph-canvas { height: calc(58vh - 72px); }
  .field-row { grid-template-columns: 1fr; gap: 0; }
  .character-layout { height: auto; }
  .character-panel { padding: 16px; }
  .modal-backdrop { padding: 10px; }
  .issue { grid-template-columns: 42px 1fr; }
  .issue code { grid-column: 2; }
}
