:root {
  color-scheme: light dark;
  --bg: #0e1116;
  --surface: #161b22;
  --surface-2: #1f2630;
  --border: #2a313c;
  --text: #e6edf3;
  --muted: #8b95a3;
  --accent: #ff6b6b;
  --accent-text: #fff;
  --success: #46d18d;
  --error: #ff7676;
  --radius: 8px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f7f7f5;
    --surface: #fff;
    --surface-2: #eef0f3;
    --border: #dde1e6;
    --text: #1a1d22;
    --muted: #61707f;
    --accent: #d6443e;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; padding: 20px 16px;
  background: var(--bg); color: var(--text);
  font-family: var(--sans); font-size: 14px; line-height: 1.5;
}
.wrap { max-width: none; margin: 0; }

.layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  align-items: start;
}
.col-left, .col-right { display: flex; flex-direction: column; gap: 16px; }
.col-left .card, .col-right .card { margin-bottom: 0; }
@media (min-width: 960px) {
  .layout { grid-template-columns: minmax(280px, 33%) minmax(0, 1fr); }
  .col-right { position: sticky; top: 16px; }
  .col-left {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: calc(var(--radius) + 4px);
    padding: 14px;
    gap: 12px;
    align-self: start;
  }
  .col-left .card {
    border-color: transparent;
    box-shadow: 0 1px 0 var(--border);
  }
}

.card-title {
  margin: -4px 0 12px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
  font-family: var(--mono);
}

header { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 24px; }
h1 { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: -0.01em; }
h1 .tag { color: var(--muted); font-weight: 400; margin-left: 8px; font-size: 13px; }
.ghost { color: var(--muted); font-size: 12px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
input[type="text"], input[type="password"], textarea, select {
  width: 100%;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  font-family: var(--sans);
  font-size: 14px;
  outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { font-family: var(--mono); font-size: 13px; resize: vertical; min-height: 64px; }
.row { display: grid; gap: 12px; }
.row.two { grid-template-columns: 1fr 100px; }

/* per-field grouping: small label above input */
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > label {
  font-size: 11px;
  color: var(--muted);
  font-family: var(--mono);
  text-transform: lowercase;
  letter-spacing: 0.02em;
  margin: 0;
}

.zone-toggle label {
  display: flex; align-items: center; gap: 8px;
  margin: 0; cursor: pointer;
  color: var(--text); font-size: 13px;
}
.zone-toggle input[type="checkbox"] { width: auto; margin: 0; }

.zone-inputs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px 12px;
  margin-top: 12px;
}
.zone-inputs input { width: 100%; }
.zone-inputs input[type="number"] { font-family: var(--mono); }
.field-button button.chip {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12px;
  font-family: var(--mono);
  cursor: pointer;
}
.field-button button.chip:hover { color: var(--text); border-color: var(--accent); }
.pill.zone-yes { color: var(--success); border-color: var(--success); }
.pill.zone-no { color: var(--accent); border-color: var(--accent); }
.pill.provider-places { color: var(--success); border-color: var(--success); }

.alternatives { margin-top: 16px; padding-top: 12px; border-top: 1px dashed var(--border); }
.alternatives-title {
  margin: 0 0 10px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
  font-family: var(--mono);
}
.alternatives ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.alt {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  cursor: pointer;
  transition: border-color 0.15s ease;
}
.alt:hover { border-color: var(--accent); }
.alt.selected {
  border-color: var(--accent);
  background: var(--surface);
}
.primary-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-family: var(--mono);
  color: var(--accent);
  border: 1px solid var(--accent);
  vertical-align: middle;
}
.alt-name { font-size: 13px; font-weight: 500; color: var(--text); margin-bottom: 2px; }
.alt-meta { font-size: 11px; color: var(--muted); font-family: var(--mono); }
.alt-coords { font-size: 11px; color: var(--muted); font-family: var(--mono); margin-top: 2px; }

.cost-row dd, dd.cost-row { font-family: var(--mono); font-size: 12px; }
dt.cost-row { padding-top: 6px; border-top: 1px dashed var(--border); margin-top: 4px; }
dd.cost-row { padding-top: 6px; border-top: 1px dashed var(--border); margin-top: 4px; }
dt.cost-row.total { color: var(--text); font-weight: 600; padding-top: 4px; border-top: 0; }
dd.cost-row.total { color: var(--accent); font-weight: 600; padding-top: 4px; border-top: 0; }

.placeholder { color: var(--muted); }
.placeholder p { margin: 0; font-size: 13px; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 0; }
.preset {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  cursor: pointer;
  font-family: var(--mono);
}
.preset:hover { color: var(--text); border-color: var(--accent); }
.actions { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
button.primary {
  background: var(--accent);
  color: var(--accent-text);
  border: none; border-radius: 6px;
  padding: 9px 18px; font-weight: 600; font-size: 14px;
  cursor: pointer;
}
button.primary:hover { filter: brightness(1.1); }
button.primary:disabled { opacity: 0.5; cursor: progress; }
kbd {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}
.result { display: none; }
.result.show { display: block; }
.result-head {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 12px; padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.pill {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12px;
  font-family: var(--mono);
  color: var(--muted);
}
.pill.script-arabic { color: #b794f4; }
.pill.script-latin { color: #63b3ed; }
.pill.script-arabizi { color: #f6ad55; }
.pill.script-mixed { color: #f687b3; }
.latency { margin-left: auto; color: var(--muted); font-size: 12px; font-family: var(--mono); }
dl { margin: 0; display: grid; grid-template-columns: 90px 1fr; gap: 6px 12px; font-size: 13px; }
dt { color: var(--muted); font-family: var(--mono); font-size: 12px; }
dd { margin: 0; word-break: break-word; }
dd.ar { direction: rtl; text-align: right; font-size: 15px; }
dd.coords { font-family: var(--mono); }
#map { height: 240px; border-radius: var(--radius); margin-top: 12px; background: var(--surface-2); }
.map-hidden { display: none; }
details { font-size: 12px; }
details summary { color: var(--muted); cursor: pointer; user-select: none; padding: 4px 0; }
dd.reasoning {
  font-style: italic;
  color: var(--muted);
  line-height: 1.4;
}

pre.json {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px;
  padding: 10px 12px; overflow-x: auto;
  font-family: var(--mono); font-size: 12px; line-height: 1.5;
  margin: 6px 0 0; color: var(--text);
}
.error {
  border-color: var(--error);
  background: color-mix(in srgb, var(--error) 10%, var(--surface));
}
.error .pill { color: var(--error); border-color: var(--error); }
.recent ul { list-style: none; margin: 0; padding: 0; }
.recent li {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 0; border-bottom: 1px dashed var(--border);
  font-size: 13px;
}
.recent li:last-child { border-bottom: 0; }
.recent .when { color: var(--muted); font-family: var(--mono); font-size: 11px; min-width: 44px; }
.recent .text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent .replay {
  background: transparent; border: 1px solid var(--border);
  color: var(--muted); border-radius: 4px;
  padding: 2px 8px; font-size: 11px; cursor: pointer;
}
.recent .replay:hover { color: var(--text); border-color: var(--accent); }
.hint { color: var(--muted); font-size: 12px; margin-top: 6px; }
.hint.warn { color: var(--accent); }
