:root {
  --bg: #e8edf4; --panel: #ffffff; --panel-2: #f5f7fa;
  --line: #e6e9ee; --line-2: #d7dde5;
  --text: #111827; --muted: #4b5563; --faint: #6b7280;
  --accent: #111827; --accent-ink: #ffffff;
  --shadow: 0 16px 40px -16px rgba(17,24,39,0.22);
  --shadow-sm: 0 1px 3px rgba(17,24,39,0.08);
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0b1020; --panel: #12192b; --panel-2: #1a2336;
  --line: #243044; --line-2: #334155;
  --text: #f1f5f9; --muted: #94a3b8; --faint: #64748b;
  --accent: #f1f5f9; --accent-ink: #0b1020;
  --shadow: 0 18px 44px -16px rgba(0,0,0,0.55);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.28);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font-family: "Inter", ui-sans-serif, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--text); outline-offset: 2px;
}
.skip {
  position: absolute; left: 12px; top: -48px; z-index: 5;
  background: var(--text); color: var(--accent-ink); padding: 8px 12px; border-radius: 8px;
  font-weight: 700; text-decoration: none;
}
.skip:focus { top: 12px; }
.top {
  display: flex; align-items: center; justify-content: space-between;
  max-width: 1180px; margin: 0 auto; padding: 18px 22px 0;
}
.back, .top-links a {
  color: var(--muted); text-decoration: none; font-size: 13px; font-weight: 700;
}
.back:hover, .top-links a:hover { color: var(--text); }
.top-links { display: flex; gap: 14px; }
.tool {
  display: grid; grid-template-columns: minmax(320px, 480px) minmax(280px, 1fr);
  gap: 22px; max-width: 1180px; margin: 0 auto; padding: 18px 22px 48px;
}
.intro { grid-column: 1 / -1; max-width: 720px; }
.kicker {
  margin: 8px 0 0; font-size: 12px; font-weight: 800; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--faint);
}
h1 { margin: 6px 0 8px; font-size: 34px; line-height: 1.12; letter-spacing: -0.6px; }
.lede { margin: 0; color: var(--muted); font-size: 16px; line-height: 1.5; }
h2 { margin: 0; font-size: 14px; font-weight: 800; letter-spacing: -0.2px; }
.composer-head, .list-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 16px 0 8px;
}
.composer-head label, .list-head h2 { font-size: 13px; font-weight: 800; }
textarea, input[type="text"], input:not([type]) {
  width: 100%; border: 1px solid var(--line-2); background: var(--panel); color: var(--text);
  border-radius: 10px; font: 14px/1.45 ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  padding: 10px 12px;
}
textarea { resize: vertical; min-height: 168px; }
.hint, .fine, .status { color: var(--muted); font-size: 12.5px; line-height: 1.45; }
.hint code { font-size: 12px; background: var(--panel); padding: 1px 4px; border-radius: 4px; }
.warn { color: #b45309; font-size: 12.5px; font-weight: 650; }
[data-theme="dark"] .warn { color: #fdba74; }
.panel {
  margin-top: 14px; padding: 12px 14px 14px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-sm);
}
.panel h2 { margin-bottom: 8px; }
.commands dl { margin: 0; display: grid; gap: 8px; }
.commands div { display: grid; grid-template-columns: 148px 1fr; gap: 10px; align-items: baseline; }
.commands dt { margin: 0; }
.commands dd { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.4; }
.commands code { font-size: 12.5px; background: var(--bg); padding: 1px 5px; border-radius: 4px; }
.summary {
  padding: 12px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  font-size: 13px; line-height: 1.45;
}
.summary strong { font-weight: 800; }
.ring-field {
  display: grid; gap: 4px; justify-items: start;
  font-size: 12px; font-weight: 700; color: var(--muted);
}
.ring-field input, .ring-field select {
  height: 38px; width: 88px; box-sizing: border-box;
  border: 1px solid var(--line-2); background: var(--panel); color: var(--text);
  border-radius: 10px; padding: 0 10px;
  font: 700 14px/1 Inter, ui-sans-serif, system-ui, sans-serif;
}
.ring-field input { width: 96px; }
#ringHub { text-transform: uppercase; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.ring-custom { display: flex; flex-wrap: wrap; align-items: end; gap: 8px; margin-top: 12px; }
.ring-custom .btn { height: 38px; padding: 0 12px; }
.presets button, .text-btn, .btn {
  border: 1px solid var(--line-2); background: var(--panel); color: var(--text);
  border-radius: 8px; font: 700 12.5px/1 Inter, ui-sans-serif, system-ui, sans-serif;
  padding: 7px 10px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center;
}
.text-btn { border: 0; background: transparent; color: var(--muted); padding: 4px 2px; }
.text-btn:hover, .presets button:hover, .btn:hover { color: var(--text); border-color: var(--text); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.route-list, .ring-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.route, .ring {
  display: grid; gap: 8px; padding: 10px 12px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 12px;
}
.route-main, .route-actions, .swatches { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.pair { font-weight: 800; letter-spacing: -0.2px; }
.swatch {
  width: 16px; height: 16px; border-radius: 50%; border: 2px solid transparent; padding: 0; cursor: pointer;
}
.swatch[aria-pressed="true"] { border-color: var(--text); }
.plane {
  width: 64px; font-family: Inter, ui-sans-serif, system-ui, sans-serif; font-weight: 800;
  letter-spacing: 0.04em; text-transform: uppercase;
}
.miles { margin-top: 8px; }
.miles table { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: 12px; overflow: hidden; }
.miles th, .miles td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 13px; }
.miles td:nth-child(2), .miles th:nth-child(2) { text-align: right; font-variant-numeric: tabular-nums; }
.preview { position: sticky; top: 16px; align-self: start; }
.settings { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.seg { display: flex; background: var(--panel); border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button {
  border: 0; background: transparent; color: var(--muted); font: 700 12px/1 Inter, ui-sans-serif, system-ui, sans-serif;
  padding: 8px 10px; cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.frame-wrap {
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow); overflow: hidden; min-height: 280px;
}
.frame-wrap iframe { display: block; width: 100%; border: 0; background: var(--panel-2); }
.empty { margin: 0; padding: 48px 20px; text-align: center; color: var(--faint); font-weight: 650; }
.copies { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.status { min-height: 1.2em; font-weight: 700; color: var(--text); }
.fine a { color: var(--text); }
@media (max-width: 640px) {
  .commands div { grid-template-columns: 1fr; gap: 2px; }
}
@media (max-width: 860px) {
  .tool { grid-template-columns: 1fr; }
  .preview { position: static; }
  h1 { font-size: 28px; }
}
