/* Shared by the home page and every tool: colours, base type, top bar. */

:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --text: #1c1f24;
  --muted: #5f6672;
  --border: #d9dce1;
  --hover: #eef0f3;
  --accent: #2563eb;
  --accent-text: #ffffff;
  --accent-soft: #e6eefe;
  --error: #b91c1c;
  --error-bg: #fdecec;
  --stage: #e9ebef;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171b;
    --panel: #1d2026;
    --text: #e6e8eb;
    --muted: #a1a8b3;
    --border: #2f343c;
    --hover: #262a31;
    --accent: #3b82f6;
    --accent-soft: #1e2b44;
    --error: #fca5a5;
    --error-bg: #3a1d1f;
    --stage: #111316;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font: 14px/1.45 system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 48px;
  padding: 0 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}
.brand:hover { color: var(--accent); }
.brand svg { width: 22px; height: 22px; color: var(--accent); }
.crumb { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumb::before { content: "/"; margin-right: 10px; color: var(--border); }

/* ---------- tool page: sidebar + preview (body.tool-page) ---------- */

body.tool-page {
  height: 100vh;
  display: flex;
  flex-direction: column;
}
.tool {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 300px 1fr;
}
@media (max-width: 760px) {
  body.tool-page { height: auto; }
  .tool { grid-template-columns: 1fr; }
  .viewer { min-height: 70vh; }
}

.panel {
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ---------- form controls ---------- */

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-weight: 600; }
.help { display: block; color: var(--muted); font-size: 12px; }

select, input[type="text"] {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
}
input[type="text"]:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }

.check { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; }
.check input { margin: 3px 0 0; }

.error {
  margin: 0;
  padding: 10px 12px;
  border-radius: 6px;
  background: var(--error-bg);
  color: var(--error);
  white-space: pre-wrap;
}

/* ---------- buttons ---------- */

button, .button {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
button:hover, .button:hover { background: var(--hover); }
button:focus-visible, .button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button:disabled, .button[aria-disabled="true"] { opacity: .45; cursor: default; pointer-events: none; }
.primary, .primary:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }

/* ---------- preview ---------- */

.viewer { display: flex; flex-direction: column; min-width: 0; }
.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.out-name { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.stage {
  position: relative;
  flex: 1;
  overflow: hidden;
  background: var(--stage);
}
.stage svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.placeholder {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  color: var(--muted); padding: 16px; text-align: center;
}

.stats {
  display: flex; flex-wrap: wrap; gap: 4px 24px;
  margin: 0; padding: 10px 14px;
  border-top: 1px solid var(--border);
  background: var(--panel);
  min-height: 40px;
}
.stats div { display: flex; gap: 6px; }
.stats dt { color: var(--muted); }
.stats dd { margin: 0; font-variant-numeric: tabular-nums; }
