/* Editor chrome — dark local tool UI (not the Steam preview surface). */

:root {
  --bg: #08070d;
  --panel: rgba(22, 20, 31, .88);
  --border: rgba(255, 255, 255, .105);
  --border-hot: rgba(100, 170, 220, .55);
  --text: #f0edf6;
  --muted: #aaa4b5;
  --faint: #777184;
  --accent: #57b7e8;
  --good: #7bd8ad;
  --warn: #ffc66d;
  --bad: #ff7d95;
  --shadow: 0 24px 80px rgba(0, 0, 0, .46);
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 2%, rgba(40, 90, 130, .22), transparent 30rem),
    radial-gradient(circle at 92% 16%, rgba(50, 128, 178, .14), transparent 34rem),
    linear-gradient(145deg, #090810 0%, #07070b 55%, #0a0d12 100%);
  font: 15px/1.45 "Avenir Next", "Segoe UI", sans-serif;
}

button, input, textarea { font: inherit; }
button { color: inherit; }
a { color: #8fd5ff; }

.shell { width: min(1600px, calc(100% - 28px)); margin: 18px auto 34px; }

.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(160deg, rgba(25, 30, 40, .92), rgba(14, 13, 20, .90));
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px);
  position: sticky; top: 10px; z-index: 20;
}
.mark {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center;
  flex-shrink: 0;
  color: rgba(235, 232, 242, .92);
  background: linear-gradient(145deg, rgba(87, 183, 232, .28), rgba(40, 80, 120, .2));
  border: 1px solid rgba(255, 255, 255, .12);
  box-shadow: 0 0 14px rgba(87, 183, 232, .18), inset 0 1px 0 rgba(255, 255, 255, .06);
}
.mark-icon {
  width: 22px;
  height: 22px;
  display: block;
}
.brand { min-width: 0; }
.brand h1 { margin: 0; font-size: 17px; letter-spacing: .01em; }
.brand p { margin: 1px 0 0; color: var(--muted); font-size: 12px; }
.top-actions { margin-left: auto; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }

.button, .tool {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, .055);
  border-radius: 10px; cursor: pointer; transition: .16s ease;
}
.button { min-height: 38px; padding: 8px 13px; font-weight: 650; }
.button:hover, .tool:hover { border-color: var(--border-hot); background: rgba(87, 183, 232, .12); }
.button.primary {
  background: linear-gradient(140deg, rgba(70, 140, 190, .94), rgba(40, 100, 150, .90));
  border-color: rgba(255, 255, 255, .14);
}
.button.danger { color: #ff9aac; }
.button.small { min-height: 32px; padding: 6px 10px; font-size: 12px; }
.button:disabled { opacity: .55; cursor: wait; }

.workspace {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 14px;
}
.workspace-main {
  display: grid;
  /* Preview column needs room for Steam's 652px card + stage padding (~44px). */
  grid-template-columns: minmax(480px, 1fr) minmax(700px, 1.08fr);
  gap: 14px;
  /* Don't stretch the preview to the editor height — that made .steam-stage
     flex-grow into a huge empty black void under the Steam showcase card. */
  align-items: start;
}
.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(160deg, var(--panel), rgba(13, 12, 19, .94));
  box-shadow: var(--shadow); overflow: hidden; backdrop-filter: blur(20px);
}
.editor-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.editor-panel .editor-wrap { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.editor-panel .visual-editor,
.editor-panel .source-editor {
  flex: 1;
  max-height: none;
}
.panel-header {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 14px; border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, .025);
}
.panel-header h2 { margin: 0; font-size: 14px; }
.panel-header .sub { color: var(--muted); font-size: 12px; }
.panel-header .right { margin-left: auto; display: flex; gap: 7px; }

.profile-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto auto;
  gap: 8px; padding: 12px 14px;
  border-bottom: 1px solid var(--border); background: rgba(0, 0, 0, .12);
  align-items: center;
}
.cache-toggle {
  grid-column: 1 / -1;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  max-width: 100%;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  user-select: none;
}
.cache-toggle input {
  width: 15px;
  height: 15px;
  min-height: 0;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}
.cache-toggle span { line-height: 1.3; }
input[type="text"], input[type="url"], input[type="search"], textarea, select {
  width: 100%; color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  background: rgba(5, 5, 9, .58); outline: none;
}
input[type="text"], input[type="url"], input[type="search"], select {
  min-height: 38px; padding: 8px 11px;
}
input:focus, textarea:focus, .visual-editor:focus, select:focus {
  border-color: var(--border-hot);
  box-shadow: 0 0 0 3px rgba(87, 183, 232, .10);
}
.privacy-note {
  grid-column: 1 / -1; color: var(--faint); font-size: 11px; margin-top: -2px;
}
.title-row { padding: 12px 14px 0; }
.label {
  display: flex; justify-content: space-between; gap: 8px;
  color: var(--muted); font-size: 12px; margin: 0 2px 6px;
}

.mode-row {
  display: flex; align-items: center; gap: 7px;
  padding: 12px 14px 8px; flex-wrap: wrap;
}
.segmented {
  display: inline-flex; padding: 3px;
  border: 1px solid var(--border); border-radius: 11px; background: rgba(0, 0, 0, .20);
}
.segmented button {
  border: 0; border-radius: 8px; background: transparent;
  color: var(--muted); padding: 7px 11px; cursor: pointer;
}
.segmented button.active {
  background: rgba(87, 183, 232, .18); color: #fff;
  box-shadow: inset 0 0 0 1px rgba(87, 183, 232, .24);
}

.toolbar { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 10px; }
.tool {
  min-width: 34px; min-height: 32px; padding: 5px 9px;
  font-weight: 750; color: #d8d3e1;
}
.tool.wide { min-width: auto; font-size: 12px; }
.tool.separator { margin-left: 6px; }
.editor-wrap { padding: 0 14px 14px; overflow-x: auto; }
.empty-editor-state {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin-bottom: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px dashed rgba(140, 170, 200, .35);
  background: rgba(12, 18, 26, .72);
  color: #c8d2dc;
}
.empty-editor-state > p:first-child {
  margin: 0;
  font-size: 13px;
  font-weight: 650;
  flex: 1 1 12rem;
}
.empty-editor-hint {
  flex: 1 1 100%;
  margin: 0;
  font-size: 12px !important;
  font-weight: 500 !important;
  color: var(--muted);
  line-height: 1.4;
}
.empty-editor-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.source-editor {
  min-height: 520px; max-height: 72vh; overflow: auto;
  width: 100%; resize: vertical;
  border: 1px solid var(--border); border-radius: 12px;
  background: rgba(5, 5, 9, .58); color: #d8d4e2;
  padding: 16px; outline: none;
  font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", monospace;
  tab-size: 2; white-space: pre-wrap;
}
.hidden { display: none !important; }

.emoticon-drawer {
  width: 100%;
  background: linear-gradient(160deg, var(--panel), rgba(13, 12, 19, .94));
}
.drawer-head {
  display: grid; grid-template-columns: auto minmax(160px, 1fr) auto;
  gap: 9px; align-items: center; padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, .025);
}
.drawer-head strong { font-size: 13px; }
.drawer-head input { min-height: 34px; }
.emoticon-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 6px; max-height: 280px; overflow: auto; padding: 12px 16px;
}
.emo-button {
  min-width: 0; display: flex; align-items: center; gap: 7px;
  border: 1px solid var(--border); border-radius: 9px;
  background: rgba(255, 255, 255, .035); color: #d8d3df;
  padding: 6px 8px; cursor: pointer; text-align: left;
}
.emo-button:hover { border-color: var(--border-hot); background: rgba(87, 183, 232, .09); }
.emo-button img { width: 24px; height: 24px; object-fit: contain; }
.emo-button span {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font: 11px ui-monospace, SFMono-Regular, Menlo, monospace;
}
.empty-state { color: var(--faint); font-size: 12px; padding: 2px 16px 14px; }
.emoticon-drawer .empty-state { padding: 4px 16px 16px; }

.statusbar {
  display: flex; gap: 12px; flex-wrap: wrap;
  padding: 10px 14px; border-top: 1px solid var(--border);
  color: var(--faint); font-size: 11px;
}
.statusbar .push { margin-left: auto; }
.build-version {
  font-size: 10px; opacity: .55; letter-spacing: .02em;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.status-good { color: var(--good); }
.status-warn { color: var(--warn); }
.status-bad { color: var(--bad); }

.exactness-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 9px; border-radius: 999px; font-size: 11px; font-weight: 650;
  border: 1px solid var(--border);
}
.exactness-badge.live { color: var(--good); border-color: rgba(123, 216, 173, .35); background: rgba(123, 216, 173, .08); }
.exactness-badge.cached { color: var(--accent); border-color: rgba(87, 183, 232, .35); background: rgba(87, 183, 232, .08); }
.exactness-badge.fallback { color: var(--warn); border-color: rgba(255, 198, 109, .35); background: rgba(255, 198, 109, .08); }
.exactness-badge.manual { color: #d0b8ff; border-color: rgba(180, 150, 255, .35); background: rgba(180, 150, 255, .08); }

.preview-column {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}
.preview-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  /* Keep the Steam stage visible while scrolling a tall editor. */
  position: sticky;
  top: 84px;
}
/* Stage sizes to the Steam card (+ steam-preview min-height atmosphere).
   Do not flex-grow — unbounded height reads as a broken empty void. */
.preview-panel .steam-stage {
  flex: 0 0 auto;
}
.preview-controls {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 11px 14px; border-bottom: 1px solid var(--border);
  color: var(--muted); font-size: 12px;
}
.preview-controls input[type="range"] { flex: 1; min-width: 100px; accent-color: var(--accent); }
.preview-controls select { width: auto; min-width: 120px; min-height: 32px; }

.diag-body {
  padding: 12px 14px;
  font: 11px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: #c9c4d4; white-space: pre-wrap; max-height: 280px; overflow: auto;
  background: rgba(0, 0, 0, .18);
  border-radius: 10px;
}
.diag-actions { display: flex; gap: 8px; padding: 8px 0 0; }

.issues { flex-shrink: 0; }
.issues-body { padding: 13px 14px; }
.issue-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid rgba(255, 190, 94, .22);
  background: rgba(255, 190, 94, .075);
  color: #eec47f; border-radius: 999px; padding: 5px 8px;
  font: 11px ui-monospace, SFMono-Regular, Menlo, monospace; cursor: pointer;
}

.tools-section + .tools-section {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.tools-section h3 {
  margin: 0 0 6px;
  font-size: 13px;
}
.tools-note {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
}
.tools-stage {
  min-height: 0;
  padding: 10px;
}
.tools-stage iframe {
  width: 100%;
  min-height: 320px;
  border: 0;
  border-radius: 3px;
  background: #0b0d10;
}

.compare-body { padding: 12px 14px; }
.compare-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
.compare-grid label { font-size: 12px; color: var(--muted); display: grid; gap: 6px; }
.compare-stage {
  position: relative; margin-top: 12px; min-height: 180px;
  border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
  background: #0a0c10;
}
.compare-stage img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: contain; image-rendering: auto;
}
.compare-stage canvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: contain; pointer-events: none;
}
.compare-controls { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 12px; color: var(--muted); }

dialog {
  color: var(--text); width: min(520px, calc(100% - 30px));
  border: 1px solid var(--border); border-radius: 14px;
  background: #17151f; box-shadow: var(--shadow); padding: 0;
}
dialog::backdrop { background: rgba(0, 0, 0, .72); backdrop-filter: blur(5px); }
.dialog-head { padding: 14px 16px; border-bottom: 1px solid var(--border); font-weight: 750; }
.dialog-body { padding: 15px 16px; }
.dialog-body p { color: var(--muted); font-size: 13px; }
.dialog-grid { display: grid; gap: 10px; }
.dialog-actions {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 16px; border-top: 1px solid var(--border);
}

.toast {
  position: fixed; right: 18px; bottom: 18px; z-index: 50;
  max-width: min(390px, calc(100% - 36px));
  padding: 11px 13px; border: 1px solid var(--border); border-radius: 11px;
  background: rgba(24, 21, 32, .96); box-shadow: var(--shadow);
  opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.loading {
  display: flex; align-items: center; justify-content: center;
  min-width: 52px; min-height: 52px; padding: 12px;
  opacity: 1; z-index: 100; pointer-events: none;
}
.toast-spinner {
  width: 28px; height: 28px; flex: 0 0 auto;
  border: 3px solid rgba(255, 255, 255, .16);
  border-top-color: rgba(96, 176, 255, 1);
  border-radius: 50%;
  animation: toast-spin .75s linear infinite;
}
@keyframes toast-spin { to { transform: rotate(360deg); } }
.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;
}

/* Rich hover tooltips */
.rich-tooltip {
  position: fixed; z-index: 80; max-width: min(320px, calc(100vw - 24px));
  padding: 10px 12px; border-radius: 11px;
  border: 1px solid rgba(140, 190, 230, .35);
  background: linear-gradient(165deg, rgba(28, 32, 42, .98), rgba(16, 18, 26, .97));
  box-shadow: 0 16px 40px rgba(0, 0, 0, .45);
  color: var(--text); pointer-events: none;
  opacity: 0; transform: translateY(4px); transition: opacity .12s ease, transform .12s ease;
}
.rich-tooltip.show { opacity: 1; transform: translateY(0); }
.rich-tooltip[hidden] { display: none !important; }
.rich-tooltip .tip-title {
  display: block; font-size: 12px; font-weight: 750; margin-bottom: 4px; letter-spacing: .01em;
}
.rich-tooltip .tip-body {
  display: block; font-size: 12px; line-height: 1.4; color: var(--muted);
}
.rich-tooltip .tip-example {
  display: block; margin-top: 8px; padding: 6px 8px; border-radius: 7px;
  background: rgba(0, 0, 0, .35); border: 1px solid rgba(255, 255, 255, .08);
  font: 11px/1.4 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: #c8e7ff; white-space: pre-wrap; word-break: break-word;
}
.rich-tooltip .tip-example::before {
  content: "Example"; display: block; margin-bottom: 3px;
  font: 10px/1 "Avenir Next", "Segoe UI", sans-serif; font-weight: 700;
  color: var(--faint); letter-spacing: .04em; text-transform: uppercase;
}

/* Advanced / Pro tools dialog */
.advanced-dialog {
  width: min(920px, calc(100% - 30px));
  max-height: min(88vh, 960px);
  flex-direction: column; padding: 0;
}
.advanced-dialog[open] { display: flex; }
.advanced-body {
  padding: 16px 18px 22px; overflow: auto; flex: 1; min-height: 0;
}
.advanced-intro {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

/* Docs dialog */
.docs-dialog {
  width: min(840px, calc(100% - 30px));
  max-height: min(88vh, 900px);
  flex-direction: column; padding: 0;
}
.docs-dialog[open] { display: flex; }
.docs-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.docs-tabs {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
  background: rgba(0, 0, 0, .16);
}
.docs-tab {
  border: 1px solid var(--border); border-radius: 999px;
  background: rgba(255, 255, 255, .04); color: var(--muted);
  padding: 6px 12px; font-size: 12px; font-weight: 650; cursor: pointer;
}
.docs-tab:hover { border-color: var(--border-hot); color: var(--text); }
.docs-tab.active {
  color: #fff; background: rgba(87, 183, 232, .18);
  border-color: rgba(87, 183, 232, .4);
}
.docs-body {
  padding: 16px 18px 20px; overflow: auto; flex: 1; min-height: 0;
}
.docs-pane { display: none; }
.docs-pane.active { display: block; }
.docs-pane h3 { margin: 0 0 10px; font-size: 15px; }
.docs-pane h3.docs-subhead { margin-top: 18px; font-size: 14px; }
.docs-note { color: var(--muted); font-size: 13px; line-height: 1.45; margin: 10px 0 0; }
.docs-steps, .docs-list {
  margin: 0; padding-left: 1.2em; color: var(--text); font-size: 13px; line-height: 1.55;
}
.docs-steps li + li, .docs-list li + li { margin-top: 8px; }
.docs-examples {
  display: grid; gap: 14px; margin-top: 12px;
}
.docs-examples article,
.docs-tip-demo {
  padding: 12px 12px 10px; border-radius: 10px;
  border: 1px solid var(--border); background: rgba(0, 0, 0, .18);
}
.docs-tip-demo { margin-top: 14px; }
.docs-examples strong,
.docs-tip-demo strong { display: block; font-size: 12px; margin-bottom: 6px; color: var(--text); }
.docs-examples code,
.docs-tip-demo > code {
  display: block; margin: 0 0 8px; padding: 6px 8px; border-radius: 7px;
  background: rgba(0, 0, 0, .35); border: 1px solid rgba(255, 255, 255, .06);
  font: 11px/1.4 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: #c8e7ff; white-space: pre-wrap; word-break: break-word;
}
code.docs-inline {
  display: inline; margin: 0; padding: 1px 5px; border-radius: 4px;
  background: rgba(0, 0, 0, .35); border: 1px solid rgba(255, 255, 255, .06);
  font: 11px/1.35 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: #c8e7ff; white-space: nowrap;
}
.docs-preview-frame {
  margin: 0 0 6px; padding: 8px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, .08);
  background:
    radial-gradient(farthest-side at 100% 0%, rgba(253, 219, 51, .12), transparent 420px),
    radial-gradient(at 0% 0%, rgba(97, 75, 37, .55), transparent 480px),
    rgba(18, 14, 10, .85);
  overflow-x: auto;
}
.docs-preview {
  /* Compact Steam notes strip — inherits steam-preview.css variables */
  width: min(100%, var(--preview-width, 652px));
  max-width: 100%;
  max-height: none;
  overflow: visible;
  box-sizing: border-box;
}
/* Tips demo: slightly narrower so long H1 bars show clipping risk */
.docs-tip-demo .docs-preview {
  width: min(100%, 420px);
}
.docs-examples span,
.docs-tip-demo span { display: block; margin-top: 6px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.docs-pane kbd {
  display: inline-block; padding: 1px 6px; border-radius: 5px;
  border: 1px solid var(--border); background: rgba(255, 255, 255, .06);
  font: 11px ui-monospace, SFMono-Regular, Menlo, monospace;
}

iframe.calibration-frame {
  position: fixed; left: -10000px; top: 0;
  width: 1100px; height: 2400px; border: 0; opacity: 0; pointer-events: none;
}

@media (max-width: 1180px) {
  /* Below ~1180 the 700px preview min is tight — allow stage horizontal scroll. */
  .workspace-main {
    grid-template-columns: minmax(420px, 1fr) minmax(520px, 1fr);
  }
}
@media (max-width: 1040px) {
  .workspace-main { grid-template-columns: 1fr; }
  .preview-panel { position: static; }
  .visual-editor, .source-editor { min-height: 460px; }
  .compare-grid { grid-template-columns: 1fr; }
}
@media (max-width: 680px) {
  .shell { width: min(100% - 14px, 1600px); margin-top: 7px; }
  .topbar { top: 5px; padding: 10px; }
  .brand p { display: none; }
  .button .long-label { display: none; }
  .profile-row { grid-template-columns: 1fr 1fr; }
  .profile-row input { grid-column: 1 / -1; }
  .drawer-head { grid-template-columns: 1fr auto; }
  .drawer-head strong { grid-column: 1 / -1; }
  .steam-stage { padding: 10px; }
  .emoticon-grid { max-height: 220px; }
}
