:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --border: #e3e7ee;
  --text: #1a2233;
  --muted: #667085;
  --accent: #1259d1;
  --accent-soft: #e8f0fe;
  --good: #1c7c3f;
  --good-soft: #e8f7ee;
  --warn: #8a6d00;
  --warn-soft: #fff7e0;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 4px 16px rgba(16, 24, 40, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1420;
    --panel: #161d2c;
    --border: #262f42;
    --text: #eef1f7;
    --muted: #9aa4b6;
    --accent: #6ea1ff;
    --accent-soft: #16233f;
    --good: #4fd17d;
    --good-soft: #10281a;
    --warn: #e0c14a;
    --warn-soft: #2c260f;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.topbar {
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}
.topbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 20px 20px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 22px;
}
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 18px;
}
.tagline {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  max-width: 640px;
}

.layout {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 20px 60px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.panel-head h2 {
  font-size: 15px;
  margin: 0;
  color: var(--muted);
  font-weight: 700;
  letter-spacing: .01em;
}
.panel-actions { display: flex; gap: 8px; position: relative; }

.btn {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, opacity .12s ease;
}
.btn:hover { background: var(--accent-soft); }
.btn:disabled { opacity: .45; cursor: default; background: none; }
.btn-ghost { background: transparent; }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { opacity: .92; background: var(--accent); }
.btn-primary:disabled { background: var(--accent); }

.example-menu { position: relative; }
.example-list {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  min-width: 200px;
  z-index: 10;
  overflow: hidden;
}
.example-list button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  border: none;
  background: none;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}
.example-list button:hover { background: var(--accent-soft); }

.pnr-textarea {
  width: 100%;
  min-height: 320px;
  resize: vertical;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  font: 13px/1.5 "SF Mono", "Fira Code", Menlo, Consolas, monospace;
}
.pnr-textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.detect-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.detect-label { font-size: 13px; color: var(--muted); font-weight: 600; }
.system-toggles { display: flex; gap: 6px; }
.sys-btn {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
}
.sys-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.confidence-badge {
  margin-left: auto;
  font-size: 12px;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--good-soft);
  color: var(--good);
  font-weight: 700;
}
.confidence-badge.low {
  background: var(--warn-soft);
  color: var(--warn);
}
.status-line {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
  min-height: 16px;
}

.report-link {
  align-self: flex-start;
  font-size: 12px;
  color: var(--muted);
  text-decoration: none;
}
.report-link:hover { color: var(--accent); text-decoration: underline; }

.error-box {
  border: 1px solid var(--warn);
  background: var(--warn-soft);
  border-radius: 10px;
  padding: 18px;
  text-align: center;
  margin: 20px 0;
}
.error-box p {
  margin: 0 0 14px;
  font-size: 13.5px;
  color: var(--text);
}
.error-box .btn { display: inline-flex; }

.preview {
  min-height: 320px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 16px;
  overflow: auto;
}
.empty-state {
  color: var(--muted);
  font-size: 13.5px;
  margin: 40px 0;
  text-align: center;
}

.site-footer {
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
  padding: 10px 20px 30px;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow);
  z-index: 50;
}
