:root {
  --bg: #171d23;
  --panel: #1e262d;
  --panel-raised: #253038;
  --border: #34424c;
  --border-soft: #29343c;
  --text: #edf0f1;
  --muted: #a1a1a1;
  --muted-2: #6c7680;
  --accent: #f56600;
  --accent-soft: rgba(245, 102, 0, 0.14);
  --accent-strong: #d95500;
  --teal: #93afb6;
  --teal-soft: rgba(147, 175, 182, 0.14);
  --danger: #d2534a;
  --danger-soft: rgba(210, 83, 74, 0.14);
  --warn: #f2b84b;
  --radius: 6px;
  --font-ui: "Open Sans", -apple-system, "Segoe UI", system-ui, sans-serif;
  --font-display: "Poppins", "Open Sans", -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

.is-hidden { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

button {
  font-family: inherit;
  cursor: pointer;
}

/* ---------- Topbar ---------- */

.topbar {
  display: flex;
  justify-content: center;
  padding: 0;
  height: 52px;
  flex: none;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 24px;
  width: 100%;
  max-width: 1200px;
  padding: 0 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

.brand-mark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.02em;
  color: var(--accent);
}

.tabs {
  display: flex;
  gap: 2px;
  flex: 1;
}

.tab-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color 0.12s, background 0.12s;
}

.tab-btn:hover {
  color: var(--text);
  background: var(--panel-raised);
}

.tab-btn.is-active {
  color: var(--bg);
  background: var(--accent);
}

.tab-btn.is-active .stash-count {
  background: rgba(15, 18, 22, 0.25);
  color: var(--bg);
}

.stash-count {
  font-size: 11px;
  font-weight: 600;
  background: var(--panel-raised);
  color: var(--muted);
  border-radius: 999px;
  padding: 1px 6px;
  min-width: 16px;
  text-align: center;
}

.toolbar {
  display: flex;
  gap: 8px;
  flex: none;
}

.tool-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--panel-raised);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  padding: 7px 12px;
  border-radius: var(--radius);
  transition: border-color 0.12s, background 0.12s;
}

.tool-btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.tool-btn svg { color: var(--muted); flex: none; }
.tool-btn:hover svg { color: var(--accent); }

/* ---------- Stage / panels ---------- */

.stage {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  justify-content: center;
}

.stage-inner {
  position: relative;
  width: 100%;
  max-width: 1200px;
}

.panel {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
}

.panel.is-active {
  display: flex;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-soft);
  flex: none;
}

.format-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  font-family: var(--font-mono);
  color: var(--muted);
}

.format-pill .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted-2);
  flex: none;
}

.format-pill.is-detected .dot { background: var(--accent); }
.format-pill.is-detected { color: var(--text); }

.icon-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: var(--radius);
  padding: 6px 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  transition: color 0.12s, border-color 0.12s;
}

.icon-btn:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--muted-2);
}

.icon-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

/* Creative panel — framed input card */

.creative-frame {
  flex: 1;
  display: flex;
  padding: 28px;
  overflow: auto;
  min-height: 0;
}

.creative-card {
  flex: 1;
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  min-height: 0;
}

.creative-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--border-soft);
  flex: none;
}

.creative-card-title {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.creative-card-title svg {
  color: var(--accent);
  flex: none;
  margin-top: 3px;
}

.creative-card-title h1 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 4px;
  color: var(--text);
}

.creative-card-title p {
  font-size: 12.5px;
  color: var(--muted);
  margin: 0;
  max-width: 440px;
  line-height: 1.5;
}

.creative-input-wrap {
  position: relative;
  flex: 1;
  min-height: 160px;
  margin: 16px 22px;
  border: 1.5px dashed var(--border);
  border-radius: 8px;
  background: var(--bg);
  overflow: hidden;
  transition: border-color 0.15s;
}

.creative-input-wrap:focus-within {
  border-color: var(--accent);
  border-style: solid;
}

.creative-input-wrap:has(.creative-input:not(:placeholder-shown)) {
  border-style: solid;
}

.creative-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  resize: none;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
  padding: 16px;
  outline: none;
  tab-size: 2;
}

.creative-input::placeholder {
  color: var(--muted-2);
  font-family: var(--font-mono);
}

.creative-clear-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--panel-raised);
}

.creative-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  border-top: 1px solid var(--border-soft);
  flex: none;
}

.hint {
  font-size: 12px;
  color: var(--muted-2);
}

.hint strong { color: var(--muted); }

.primary-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  font-weight: 600;
  font-size: 13px;
  padding: 8px 16px;
  border-radius: var(--radius);
  transition: background 0.12s;
}

.primary-btn:hover { background: var(--accent-strong); }
.primary-btn:disabled { background: var(--panel-raised); color: var(--muted-2); cursor: default; }

/* Preview panel */

.preview-frame-wrap {
  flex: 1;
  position: relative;
  background:
    linear-gradient(45deg, #14181e 25%, transparent 25%) 0 0/16px 16px,
    linear-gradient(-45deg, #14181e 25%, transparent 25%) 0 0/16px 16px,
    linear-gradient(45deg, transparent 75%, #14181e 75%) 0 0/16px 16px,
    linear-gradient(-45deg, transparent 75%, #14181e 75%) 0 0/16px 16px,
    var(--bg);
}

.preview-frame {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.preview-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
  gap: 4px;
}

.preview-empty .muted { color: var(--muted-2); font-size: 12.5px; }

/* Stash panel */

.stash-actions { display: flex; gap: 8px; }

.stash-table-wrap {
  flex: 1;
  overflow: auto;
  padding: 0 16px 16px;
}

.stash-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.stash-table thead th {
  position: sticky;
  top: 0;
  background: var(--bg);
  text-align: left;
  color: var(--muted-2);
  font-weight: 500;
  font-size: 12px;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.stash-table thead th:hover { color: var(--muted); }
.stash-table thead th.col-check,
.stash-table thead th.col-actions { cursor: default; }

.sort-arrow { font-size: 10px; color: var(--accent); }

.stash-table tbody tr {
  border-bottom: 1px solid var(--border-soft);
}

.stash-table tbody tr:hover { background: var(--panel-raised); }

.stash-table td {
  padding: 9px 8px;
  vertical-align: middle;
}

.stash-table td.col-check { width: 34px; }

.stash-name {
  font-weight: 500;
  outline: none;
  border-radius: 4px;
  padding: 2px 4px;
  margin: -2px -4px;
}

.stash-name:focus {
  background: var(--bg);
  box-shadow: 0 0 0 1px var(--accent);
}

.type-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 7px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.stash-date { color: var(--muted); font-size: 12.5px; }

.row-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.row-actions button {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  padding: 4px 9px;
  border-radius: var(--radius);
}

.row-actions button:hover { color: var(--text); border-color: var(--muted-2); }
.row-actions button.danger:hover { color: var(--danger); border-color: var(--danger); }

.stash-empty {
  padding: 40px 0;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
}

.stash-empty .muted { color: var(--muted-2); font-size: 12.5px; }

/* Trackers panel */

.tracker-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.preview-controls-box {
  padding: 6px 8px;
  border: 2px solid var(--accent-strong);
  border-radius: 8px;
  background: var(--accent);
}

.preview-controls-box .icon-btn {
  background: var(--bg);
  border: 1px solid rgba(0, 0, 0, 0.2);
  color: var(--text);
}

.preview-controls-box .icon-btn:hover:not(:disabled) {
  background: var(--panel-raised);
  border-color: rgba(0, 0, 0, 0.35);
  color: var(--text);
}

.preview-controls-box .icon-btn:disabled {
  background: var(--panel);
  color: var(--muted-2);
}

.type-filter {
  background: var(--panel-raised);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 12.5px;
  padding: 6px 8px;
  border-radius: var(--radius);
  outline: none;
}

.tracker-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.declared-block {
  flex: none;
  border-bottom: 1px solid var(--border-soft);
  padding: 12px 16px 10px;
  max-height: 230px;
  display: flex;
  flex-direction: column;
}

.declared-list {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.declared-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 8px;
}

.declared-head .muted { font-weight: 400; font-size: 12px; color: var(--muted-2); }

.declared-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-family: var(--font-mono);
}

.declared-status {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted-2);
}

.declared-row.is-fired .declared-status { background: var(--accent); }
.declared-row.is-sdk-confirmed .declared-status {
  background: transparent;
  border: 2px solid var(--teal);
  width: 5px;
  height: 5px;
}

.declared-note {
  margin: 10px 0 0;
  font-size: 11px;
  color: var(--muted-2);
  line-height: 1.6;
}

.declared-note .declared-status {
  display: inline-block;
  margin: 0 2px -1px 0;
}

.declared-note .is-fired-sample { background: var(--accent); }
.declared-note .is-sdk-sample {
  background: transparent;
  border: 2px solid var(--teal);
  width: 5px;
  height: 5px;
}

.declared-category {
  flex: none;
  font-family: var(--font-ui);
  font-size: 11px;
  color: var(--muted);
  background: var(--panel-raised);
  padding: 1px 7px;
  border-radius: 999px;
  white-space: nowrap;
}

.declared-url {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.declared-row.is-fired .declared-url { color: var(--text); }

.tracker-table-wrap {
  flex: 1;
  overflow: auto;
  padding: 0 16px 16px;
}

.tracker-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  table-layout: fixed;
}

.tracker-table thead th {
  position: sticky;
  top: 0;
  background: var(--bg);
  text-align: left;
  color: var(--muted-2);
  font-weight: 500;
  font-size: 12px;
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.tracker-table td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--border-soft);
  font-family: var(--font-mono);
  vertical-align: middle;
}

.tracker-table tbody tr:hover { background: var(--panel-raised); cursor: pointer; }

.tracker-row.is-expanded { background: var(--panel-raised); }

.col-time { width: 64px; color: var(--muted-2); }
.col-type { width: 84px; }
.col-host { width: 180px; }
.col-url { width: auto; }
.col-tracker-actions { width: 34px; }

.tracker-host {
  color: var(--muted);
  font-family: var(--font-ui);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tracker-url {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
  width: 100%;
}

.row-copy-btn {
  background: none;
  border: none;
  color: var(--muted-2);
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
}

.row-copy-btn:hover { color: var(--accent); background: var(--accent-soft); }

.tracker-detail-row { background: var(--bg); cursor: default; }
.tracker-detail-row:hover { background: var(--bg); }

.tracker-full-url {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text);
  white-space: normal;
  word-break: break-all;
  padding: 4px 4px 12px 4px;
  line-height: 1.5;
  border-left: 2px solid var(--accent);
  padding-left: 10px;
}

.tracker-empty {
  padding: 40px 0;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
}

.tracker-empty .muted { color: var(--muted-2); font-size: 12.5px; }

/* Fire Check panel */

.firecheck-note {
  flex: none;
  margin: 12px 16px;
  padding: 12px 14px;
  background: var(--panel-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted);
}

.firecheck-note strong { color: var(--text); }

.firecheck-note code {
  font-family: var(--font-mono);
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 11px;
  color: var(--teal);
}

.firecheck-table-wrap {
  flex: 1;
  overflow: auto;
  padding: 0 16px 16px;
}

.fc-status-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  display: inline-block;
}

.fc-status-idle { color: var(--muted-2); background: var(--panel-raised); }
.fc-status-pending { color: var(--teal); background: var(--teal-soft); }
.fc-status-reachable { color: var(--accent); background: var(--accent-soft); }
.fc-status-error { color: var(--danger); background: var(--danger-soft); }

.fc-fire-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 11.5px;
  padding: 4px 10px;
  border-radius: var(--radius);
}

.fc-fire-btn:hover { color: var(--text); border-color: var(--muted-2); }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translate(-50%, 12px);
  background: var(--panel-raised);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  padding: 10px 16px;
  border-radius: var(--radius);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s, transform 0.16s;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.is-danger { border-color: var(--danger); color: var(--danger); }

/* Scrollbars */

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted-2); }

/* ---------- Responsive ---------- */

@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 12px; gap: 10px; }
  .tabs { order: 3; width: 100%; }
  .toolbar { order: 2; }
  .tool-btn span { display: none; }
}
