:root {
  --bg: #141210;
  --bg-2: #1c1916;
  --panel: #221e1a;
  --panel-2: #2a2520;
  --line: #3c342c;
  --line-2: #4a4036;
  --text: #f4ece3;
  --muted: #b5a394;
  --faint: #7d7166;
  --accent: #e07a4c;
  --accent-2: #c4a574;
  --accent-dim: rgba(224, 122, 76, 0.18);
  --danger: #d4655a;
  --paper: #f4eee4;
  --paper-line: #e2d5c4;
  --ink: #1c1814;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --font: "Segoe UI", "Helvetica Neue", ui-sans-serif, system-ui, sans-serif;
  --mono: "Cascadia Mono", "Segoe UI Mono", ui-monospace, monospace;
  --rail: 176px;
  --inspector: 280px;
  --top: 52px;
  --status: 28px;
  --pagebar: 40px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
html { color-scheme: dark; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

[hidden] { display: none !important; }

.topbar {
  height: var(--top);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 14px 0 12px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #1f1b18, var(--bg-2));
}

.filebar {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 10px;
  overflow: hidden;
}
.filebar[hidden] { display: none !important; }
.file-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-status {
  font-size: 11px;
  color: var(--faint);
  white-space: nowrap;
}

.brand {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 132px;
  flex-shrink: 0;
  margin: 0 0 0 -4px;
  padding: 4px 8px 4px 4px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  text-align: left;
}
.brand:hover { background: rgba(255, 255, 255, 0.05); }

.logo { width: 28px; height: 28px; display: block; }

.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-text .name {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: 0.04em;
}
.brand-text .tag {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.top-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.sep {
  width: 1px;
  height: 18px;
  background: var(--line);
  margin: 0 4px;
}

.btn {
  appearance: none;
  border: 1px solid var(--line-2);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 7px;
  padding: 6px 11px;
  font-size: 12.5px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, opacity 0.12s;
}
.btn:hover:not(:disabled) {
  background: #332c26;
  border-color: #5a4e42;
}
.btn:disabled { opacity: 0.38; cursor: default; }
.btn.primary {
  background: var(--accent);
  border-color: #c46238;
  color: #1a120e;
  font-weight: 650;
}
.btn.primary:hover:not(:disabled) { background: #f08a5a; }
.btn.on {
  background: var(--accent-2);
  border-color: #b08d58;
  color: var(--ink);
}
.btn.danger { border-color: #6a3a34; color: #f0b8b2; }
.btn.danger:hover:not(:disabled) { background: #3a2422; }
.btn.block { width: 100%; }
.btn.block + .btn.block { margin-top: 6px; }
.btn.lg { padding: 10px 18px; font-size: 14px; }
.btn-row { display: flex; gap: 6px; margin-bottom: 6px; }
.btn-row .btn { flex: 1; }

.notes-format {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0 0 10px;
}
.fmt-gap {
  width: 1px;
  height: 16px;
  margin: 0 2px;
  background: var(--line);
}
.fmt-btn {
  appearance: none;
  width: 30px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--line-2);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 13px;
  line-height: 1;
}
.fmt-btn:hover:not(:disabled) {
  background: #332c26;
  border-color: #5a4e42;
}
.fmt-btn.on {
  background: var(--accent-2);
  border-color: #b08d58;
  color: var(--ink);
}
.fmt-btn b { font-family: Georgia, serif; }
.fmt-btn i { font-family: Georgia, serif; }

.icon-btn {
  appearance: none;
  width: 28px;
  height: 28px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 6px;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.icon-btn:hover:not(:disabled) { background: var(--panel-2); color: var(--text); }
.icon-btn:disabled { opacity: 0.35; cursor: default; }
.icon-btn svg { width: 14px; height: 14px; }

.app {
  display: grid;
  grid-template-columns: var(--rail) 1fr var(--inspector);
  grid-template-rows: 1fr var(--pagebar);
  height: calc(100% - var(--top) - var(--status));
}

.app:not(.has-doc) {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr;
}
.app:not(.has-doc) .rail,
.app:not(.has-doc) .inspector,
.app:not(.has-doc) .pagebar { display: none; }
.app:not(.has-doc) .workspace {
  grid-column: 1;
  grid-row: 1;
  display: grid;
  place-items: center;
  overflow: auto;
}

.rail {
  grid-column: 1;
  grid-row: 1 / span 2;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--panel);
  border-right: 1px solid var(--line);
}
.rail-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 10px 8px 8px 12px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.rail-tools { display: flex; gap: 2px; }

.inspector {
  grid-column: 3;
  grid-row: 1 / span 2;
  background: var(--panel);
  border-left: 1px solid var(--line);
  overflow: auto;
  padding: 8px 0 24px;
}
.pagebar {
  grid-column: 2;
  grid-row: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 0 10px;
  background: var(--panel);
  border-top: 1px solid var(--line);
  min-width: 0;
}

.thumbs {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 4px 10px 12px;
  min-height: 0;
}
.thumb {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: #151310;
  border-radius: 8px;
  padding: 5px 5px 4px;
  cursor: pointer;
  user-select: none;
}
.thumb:hover { border-color: var(--line-2); }
.thumb.current { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent-dim); }
.thumb.selected { background: #2a221c; }
.thumb canvas {
  width: 100%;
  height: auto;
  display: block;
  background: var(--paper);
  border-radius: 3px;
  box-shadow: 0 4px 10px rgba(0,0,0,.35);
}
.thumb .meta {
  display: flex;
  justify-content: space-between;
  margin-top: 5px;
  font-size: 10px;
  color: var(--muted);
}
.thumb .badge {
  color: var(--accent-2);
}

.workspace {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
  min-height: 0;
  position: relative;
  background:
    radial-gradient(1200px 500px at 50% -10%, #2a221c 0%, transparent 55%),
    var(--bg);
  overflow: hidden;
}

.welcome {
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
  padding: 28px 28px 40px;
  animation: rise 0.45s ease both;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.hero-mark {
  position: relative;
  width: 88px;
  height: 72px;
  margin-bottom: 18px;
}
.sheet {
  position: absolute;
  width: 46px;
  height: 62px;
  border-radius: 3px;
}
.sheet-a {
  left: 0; top: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0 10px,
    #e2d5c4 10px 11px
  );
}
.sheet-b {
  left: 34px; top: 0;
  border: 1.5px dashed var(--accent);
  background: rgba(224, 122, 76, 0.06);
}

.welcome h1 {
  font-size: 34px;
  font-weight: 650;
  letter-spacing: -0.03em;
  margin: 0 0 10px;
  line-height: 1.15;
}
.lede {
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
  margin: 0 0 22px;
}
.welcome-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 32px;
}
.welcome-btns {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 10px 12px;
}
.welcome-actions .btn {
  box-sizing: border-box;
  height: 44px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  white-space: nowrap;
  flex: 0 0 auto;
}
.welcome-actions .hint {
  margin: 0;
}
.hint { color: var(--faint); font-size: 13px; }

.features {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 18px;
}
.features li {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.45;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255,255,255,0.02);
}
.features strong {
  display: block;
  color: var(--text);
  margin-bottom: 4px;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.stage-wrap {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(28, 25, 22, 0.92);
  backdrop-filter: blur(8px);
  flex-wrap: wrap;
}

.tool-group { display: flex; gap: 3px; align-items: center; flex-wrap: wrap; }
.tool-colors {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 7px;
  padding-left: 8px;
}
.tool-colors .swatch {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  aspect-ratio: auto;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
}
.zoom-group { margin-left: auto; }

.tool {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 12px;
  cursor: pointer;
}
.tool:hover { color: var(--text); background: var(--panel-2); }
.tool.on {
  color: var(--ink);
  background: var(--accent-2);
  border-color: #b08d58;
}

.swatch-wrap {
  width: 28px;
  height: 22px;
  border-radius: 5px;
  overflow: hidden;
  border: 1px solid var(--line-2);
  display: block;
}
.swatch-wrap input { border: 0; padding: 0; width: 140%; height: 140%; margin: -20%; cursor: pointer; background: none; }

.tiny {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--muted);
}
.tiny input[type="range"] { width: 72px; }

.zoom-label {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  min-width: 48px;
  font-size: 11px;
  cursor: pointer;
}

.stage-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: grid;
  place-items: center;
  padding: 28px;
  cursor: default;
}
.stage-scroll.fit { overflow: hidden; }
.stage-scroll.pan { cursor: grab; }
.stage-scroll.pan.dragging { cursor: grabbing; }
.stage-scroll.draw { cursor: crosshair; }
.stage-scroll.erase { cursor: cell; }

.stage {
  position: relative;
  background: var(--paper);
  box-shadow: var(--shadow), 0 0 0 1px #cfc3b3;
  color: var(--ink);
}
.stage canvas {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
#pageCanvas { z-index: 1; }
#annotCanvas { z-index: 2; }
.guides {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}
.split-pane {
  position: absolute;
  pointer-events: none;
}
.split-pane.pane-a { background: rgba(80, 150, 220, 0.16); }
.split-pane.pane-b { background: rgba(224, 122, 76, 0.18); }
.split-pane.pane-c { background: rgba(90, 180, 130, 0.16); }
.split-pane.pane-d { background: rgba(180, 120, 200, 0.16); }
.split-gutter {
  position: absolute;
  background: rgba(20, 14, 10, 0.45);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
  pointer-events: none;
  z-index: 4;
}
.split-line {
  position: absolute;
  background: #ffe14a;
  pointer-events: auto;
  cursor: ew-resize;
  z-index: 5;
  box-shadow:
    0 0 0 1px rgba(80, 40, 0, 0.55),
    0 0 12px 2px rgba(255, 200, 60, 0.85);
}
.split-line::before {
  content: "";
  position: absolute;
  inset: 0 -10px;
}
.split-line.tb,
.split-line-h {
  cursor: ns-resize;
}
.split-line.tb::before,
.split-line-h::before {
  inset: -10px 0;
}
.split-handle {
  position: absolute;
  width: 14px;
  height: 28px;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  border-radius: 4px;
  background: #ffe14a;
  border: 1px solid #8a5a10;
  box-shadow: 0 1px 4px rgba(0,0,0,.35);
  pointer-events: none;
}
.split-line.tb .split-handle,
.split-line-h .split-handle {
  width: 28px;
  height: 14px;
}
.split-badge {
  position: absolute;
  left: 50%;
  top: 12px;
  transform: translateX(-50%);
  background: #1c1814;
  color: #ffe14a;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 99px;
  pointer-events: none;
  white-space: nowrap;
}
.split-line.tb .split-badge,
.split-line-h .split-badge {
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
}
.split-tag {
  position: absolute;
  z-index: 6;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #1c1814;
  background: rgba(255, 255, 255, 0.82);
  padding: 2px 7px;
  border-radius: 4px;
  pointer-events: none;
}
.split-tag.tag-a { top: 10px; left: 10px; }
.split-tag.tag-b { top: 10px; right: 10px; }
.crop-rect {
  position: absolute;
  border: 1.5px dashed var(--accent);
  background: rgba(224, 122, 76, 0.12);
  pointer-events: none;
}
.text-overlay {
  position: absolute;
  z-index: 8;
  border: 1px solid var(--accent);
  background: rgba(255,255,255,0.96);
  color: var(--ink);
  padding: 4px 6px;
  resize: both;
  min-width: 80px;
  min-height: 28px;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.3;
  outline: none;
  pointer-events: auto;
}
.notes-editor {
  position: absolute;
  z-index: 5;
  margin: 0;
  border: none;
  background: transparent;
  color: #000000;
  padding: 0;
  resize: none;
  overflow-x: hidden;
  overflow-y: hidden;
  outline: none;
  box-shadow: none;
  pointer-events: auto;
  caret-color: #1c1814;
  white-space: pre;
  word-wrap: normal;
  overflow-wrap: normal;
  tab-size: 2;
  -moz-tab-size: 2;
  cursor: text;
  user-select: text;
  -webkit-user-select: text;
}
.notes-editor:focus {
  box-shadow: inset 0 0 0 1px rgba(224, 122, 76, 0.28);
}
.notes-editor.passthrough {
  pointer-events: none;
  opacity: 0;
}
.notes-editor > div {
  margin: 0;
  padding: 0;
  min-height: var(--notes-line, 1.4em);
  height: var(--notes-line, 1.4em);
  line-height: var(--notes-line, 1.4em);
  overflow: hidden;
  white-space: pre;
}
.notes-editor b, .notes-editor strong { font-weight: 700; }
.notes-editor i, .notes-editor em { font-style: italic; }

.field.tight { margin-bottom: 0; }
.palette-label {
  margin: 0 0 6px;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.color-picker { margin: 0 0 10px; }
.palette {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 5px;
  margin: 0 0 8px;
}
.swatch {
  appearance: none;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 6px;
  border: 1px solid rgba(28, 24, 20, 0.22);
  padding: 0;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}
.swatch:hover { transform: scale(1.06); }
.swatch.on {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: transparent;
}
.field input[type="color"] {
  width: 100%;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-2);
  padding: 2px;
  cursor: pointer;
}
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
}
.shape-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 0 0 10px;
}
.shape-btn {
  appearance: none;
  height: 36px;
  border: 1px solid var(--line-2);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
}
.shape-btn:hover { border-color: var(--accent-2); }
.shape-btn.on {
  background: var(--accent-2);
  color: var(--ink);
  border-color: #b08d58;
}
.zoom-bar {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 4px;
}
.zoom-btn {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 5px;
  padding: 3px 6px;
  font-size: 11px;
  cursor: pointer;
}
.zoom-btn:hover { color: var(--text); background: var(--panel-2); }
.zoom-btn.on {
  color: var(--ink);
  background: var(--accent-2);
}
.panel {
  padding: 12px 14px 14px;
  border-bottom: 1px solid var(--line);
}
.panel.muted { opacity: 0.9; }
.panel h2 {
  margin: 0 0 6px;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-2);
  font-weight: 650;
}
.panel-copy {
  margin: 0 0 10px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.45;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}
.field .val { float: right; color: var(--faint); }
.field select, .field input[type="range"] { width: 100%; }
.field select {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
}

.keys { list-style: none; margin: 0; padding: 0; font-size: 12px; color: var(--muted); }
.keys li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}
.keys li > span:first-child { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.keys li > span:last-child { color: var(--faint); text-align: right; }
kbd {
  font-family: var(--mono);
  font-size: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--text);
}

.statusbar {
  height: var(--status);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 12px;
  border-top: 1px solid var(--line);
  background: var(--bg-2);
  font-size: 11px;
  color: var(--muted);
}
.statusbar #statusRight { text-align: right; }
.statusbar .credit {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--faint);
  letter-spacing: 0.04em;
  font: inherit;
  padding: 0;
  cursor: pointer;
}
.statusbar .credit:hover {
  color: var(--muted);
}

.contact-card { width: min(380px, 100%); }
.contact-mail {
  display: block;
  margin: 4px 16px 8px;
  color: var(--accent);
  font-size: 14px;
  word-break: break-all;
}
.contact-mail:hover { color: var(--accent-2); }
.popout-actions.contact-actions .btn:first-child { grid-column: auto; }
a.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  box-sizing: border-box;
}

.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(10, 8, 7, 0.72);
  display: grid;
  place-items: center;
}
.drop-card {
  border: 1.5px dashed var(--accent);
  background: var(--panel);
  padding: 28px 36px;
  border-radius: 14px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.drop-card span { color: var(--muted); font-size: 13px; }

.toast {
  position: fixed;
  bottom: 44px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  background: #2e2823;
  border: 1px solid var(--line-2);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: var(--shadow);
}

.busy {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(10, 8, 7, 0.55);
  display: grid;
  place-items: center;
}
.busy-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 14px 18px;
  border-radius: 10px;
}
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--line-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

input[type="range"] {
  appearance: none;
  height: 4px;
  background: var(--line);
  border-radius: 99px;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
}

.popout {
  position: fixed;
  inset: 0;
  z-index: 45;
  background: rgba(10, 8, 7, 0.45);
  display: grid;
  place-items: center;
  padding: 24px;
}
.popout-card {
  width: min(420px, 100%);
  max-height: min(78vh, 640px);
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.popout-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px 8px 14px;
  border-bottom: 1px solid var(--line);
}
.popout-head h2 {
  margin: 0;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-2);
}
.popout-head .icon-btn { font-size: 18px; color: var(--muted); }
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 12px 4px;
}
.chip {
  appearance: none;
  border: 1px solid var(--line-2);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 99px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}
.chip:hover { border-color: var(--accent-2); color: #fff; }
.range-field { padding: 6px 12px 8px; margin: 0; }
.range-row { display: flex; gap: 6px; }
.range-row input {
  flex: 1;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
}
.page-list {
  flex: 1;
  overflow: auto;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  min-height: 140px;
  max-height: 280px;
  padding: 6px 0;
}
.page-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px;
  font-size: 13px;
  cursor: pointer;
}
.page-row:hover { background: rgba(255,255,255,0.04); }
.page-row.current { background: var(--accent-dim); }
.page-row input { accent-color: var(--accent); }
.page-row .num {
  width: 2em;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.page-row .mark { margin-left: auto; font-size: 11px; color: var(--accent-2); }
.popout-count {
  margin: 0;
  padding: 8px 14px 0;
  font-size: 12px;
  color: var(--muted);
}
.popout-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 10px 12px 12px;
}
.popout-actions .btn:first-child { grid-column: 1 / -1; }

.download-card { width: min(460px, 100%); }
.mass-card { width: min(440px, 100%); }
.rule-block {
  padding: 10px 16px 6px;
  border-bottom: 1px solid var(--line);
}
.rule-kicker {
  margin: 0 0 8px;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent-2);
  font-weight: 650;
}
.mass-card .field input[type="text"] {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  color: var(--text);
}
.mass-preview {
  margin: 0;
  padding: 10px 16px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
  max-height: 140px;
  overflow: auto;
  white-space: pre-wrap;
}
.popout-actions.mass-actions {
  grid-template-columns: 1fr 1fr;
}
.popout-actions.mass-actions.three {
  grid-template-columns: 1fr 1fr 1fr;
}
.popout-actions.mass-actions.three .btn:first-child { grid-column: auto; }
.rule-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 10px 0;
  max-height: min(48vh, 420px);
  overflow: auto;
}
.rule-list:empty::before {
  content: "No rules yet.";
  display: block;
  font-size: 12px;
  color: var(--faint);
  padding: 8px 0;
}
.rule-row {
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 8px;
  padding: 8px 8px 8px 10px;
  cursor: grab;
}
.rule-row:hover { border-color: var(--line-2); }
.rule-row.drag { opacity: 0.5; }
.rule-row .rule-name {
  margin: 0;
  font-size: 13px;
  color: var(--text);
  font-weight: 650;
}
.rule-row .rule-sum {
  margin: 2px 0 8px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.35;
}
.rule-row .rule-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.rule-row .rule-tools .btn {
  padding: 4px 8px;
  font-size: 11px;
}
.download-lead {
  margin: 0;
  padding: 12px 16px 4px;
  font-size: 13px;
  color: var(--muted);
}
.download-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px 14px;
}
.dl-option {
  appearance: none;
  text-align: left;
  border: 1px solid var(--line-2);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 10px;
  padding: 12px 14px;
  cursor: pointer;
}
.dl-option:hover {
  border-color: var(--accent);
  background: #2f2823;
}
.dl-option strong {
  display: block;
  font-size: 14px;
  font-weight: 650;
  margin-bottom: 4px;
}
.dl-option span {
  display: block;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.4;
}

.about-card { width: min(480px, 100%); }
.about-body {
  overflow: auto;
  padding: 12px 16px 16px;
}
.about-body > p {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}
.about-features {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 14px;
}
.about-features li {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}
.about-features strong {
  display: block;
  color: var(--text);
  margin-bottom: 2px;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.about-body h3 {
  margin: 0 0 8px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-2);
}

@media (max-width: 960px) {
  :root { --inspector: 240px; --rail: 148px; }
  .features, .about-features { grid-template-columns: 1fr; }
}
