/* ---------- Design tokens ----------
   CSS custom properties (variables). Define once, use everywhere.
   Change a color here and it updates across the whole site. */
:root {
  --bg: #fafaf7;
  --surface: #ffffff;
  --text: #1a1a1a;
  --text-muted: #666666;
  --border: #e5e5e0;
  --accent: #d85a30;
  --accent-hover: #b8481f;
  --success-bg: #e1f5ee;
  --success-text: #0f6e56;
  --error-bg: #fcebeb;
  --error-text: #a32d2d;
  --idle-bg: #f1efe8;
  --idle-text: #5f5e5a;
  --radius: 8px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

/* Dark mode: auto-switch based on OS preference. */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1a1a;
    --surface: #262626;
    --text: #f0f0f0;
    --text-muted: #999999;
    --border: #3a3a3a;
    --idle-bg: #2a2a2a;
    --idle-text: #aaaaaa;
  }
}

/* ---------- Reset & base ----------
   Browsers ship with inconsistent defaults. These rules normalise them. */
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Header ---------- */
.site-header {
  padding: 2rem 1.5rem 1rem;
  text-align: center;
}
.site-header h1 {
  margin: 0 0 0.25rem;
  font-size: 1.75rem;
  font-weight: 600;
}
.tagline {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* ---------- Main app ---------- */
.app {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 1rem 1.5rem;
}

/* ---------- Toolbar ---------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.toolbar label {
  font-size: 0.9rem;
  color: var(--text-muted);
}
.toolbar select,
.toolbar button {
  font: inherit;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.toolbar button:hover {
  border-color: var(--text-muted);
}
.toolbar button:active {
  transform: scale(0.98);
}
.toolbar button.primary {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.toolbar button.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

/* ---------- Panels (input/output) ---------- */
.panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}
/* On narrow screens, stack the two panels vertically. */
@media (max-width: 768px) {
  .panels { grid-template-columns: 1fr; }
}
.panel {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.panel-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
}
textarea {
  width: 100%;
  min-height: 400px;
  padding: 0.75rem;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  resize: vertical;
}
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(216, 90, 48, 0.15);
}

/* ---------- Status bar ---------- */
.status {
  padding: 0.6rem 0.9rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-family: var(--mono);
}
.status-idle    { background: var(--idle-bg);    color: var(--idle-text); }
.status-success { background: var(--success-bg); color: var(--success-text); }
.status-error   { background: var(--error-bg);   color: var(--error-text); }

/* ---------- Footer ---------- */
.site-footer {
  padding: 1.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
}
.site-footer p { margin: 0; }
