:root {
  --bg:        #0d1117;
  --bg-1:      #0d1117;
  --bg-2:      #111820;
  --bg-3:      #0a0f14;
  --surface:   #161d27;
  --surface-2: #1c2535;
  --card:      #161d27;
  --line:      #253040;
  --line-strong:#2e3e52;
  --ink:       #e2eaf6;
  --muted:     #7b93ae;
  --brand:     #38a7f8;
  --brand-2:   #2ecfbf;
  --accent:    #f59540;
  --danger:    #e05252;
  --ok:        #2ac87a;
  --shadow-soft: 0 10px 32px rgba(0,0,0,0.45);
  --shadow-card: 0 6px 20px rgba(0,0,0,0.38);
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 7px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: "IBM Plex Sans", "Noto Sans KR", "Noto Sans JP", "Noto Sans SC", sans-serif;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 {
  font-family: "Space Grotesk", "Noto Sans KR", "Noto Sans JP", "Noto Sans SC", sans-serif;
  margin: 0;
  color: #dde8f8;
}

p, li { color: #a8bdd4; line-height: 1.65; }

code, pre {
  font-family: "IBM Plex Mono", "JetBrains Mono", "Consolas", monospace;
}

/* ── Header ────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(14px);
  background: rgba(13,17,23,0.88);
  border-bottom: 1px solid var(--line);
}

.site-header-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
}

.brand { display: flex; flex-direction: column; line-height: 1.2; }

.brand a {
  color: #e8f2ff;
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: 0.01em;
}

.brand small { font-size: 0.73rem; color: var(--muted); }

/* ── Nav ────────────────────────────────────────── */
.site-nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: flex-end;
}

.site-nav > a,
.nav-dropdown > .nav-dropdown-btn {
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 6px 11px;
  font-size: 0.8rem;
  font-weight: 700;
  color: #a8c0dc;
  background: var(--surface);
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.site-nav > a:hover,
.nav-dropdown > .nav-dropdown-btn:hover {
  text-decoration: none;
  border-color: #3d6e9e;
  background: var(--surface-2);
  color: #cde4f8;
}

.site-nav > a.active {
  border-color: var(--brand);
  color: #fff;
  background: #1a3a5e;
}

.nav-dropdown-btn svg {
  width: 10px; height: 10px;
  flex-shrink: 0;
  transition: transform 0.2s;
}

.nav-dropdown.open > .nav-dropdown-btn svg { transform: rotate(180deg); }

/* Dropdown wrapper */
.nav-dropdown {
  position: relative;
}

.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 210px;
  background: var(--surface-2);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
  z-index: 200;
}

.nav-dropdown.open > .nav-dropdown-menu { display: block; }

.nav-dropdown-menu a {
  display: block;
  padding: 9px 14px;
  font-size: 0.81rem;
  font-weight: 600;
  color: #a8c0dc;
  border-bottom: 1px solid var(--line);
  transition: background 0.12s, color 0.12s;
}

.nav-dropdown-menu a:last-child { border-bottom: none; }

.nav-dropdown-menu a:hover {
  background: #1e2d3f;
  color: #cde4f8;
  text-decoration: none;
}

.nav-dropdown-menu a.active {
  color: var(--brand);
  background: #0f2035;
}

/* ── Container ──────────────────────────────────── */
.container {
  max-width: 1240px;
  margin: 20px auto;
  padding: 0 18px 28px;
}

/* ── Hero ───────────────────────────────────────── */
.hero {
  margin-bottom: 14px;
  padding: 20px 22px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line-strong);
  background: linear-gradient(140deg, rgba(56,167,248,0.07), rgba(46,207,191,0.05)), var(--surface);
  box-shadow: var(--shadow-soft);
}

.hero h1 {
  font-size: clamp(1.45rem, 2.2vw, 2.1rem);
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.hero p { margin: 0; max-width: 900px; }

/* ── Language links ─────────────────────────────── */
.lang-links {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.lang-links a {
  padding: 5px 10px;
  border-radius: 5px;
  border: 1px solid var(--line-strong);
  font-size: 0.79rem;
  font-weight: 700;
  color: var(--muted);
  background: var(--surface-2);
}

.lang-links a.on {
  color: #fff;
  border-color: var(--brand);
  background: #1a3a5e;
}

/* ── Card ───────────────────────────────────────── */
.card {
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: var(--shadow-card);
  padding: 18px;
}

.card + .card { margin-top: 14px; }

.card-head {
  display: flex;
  gap: 10px;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}

.card-head h2 { font-size: 1.2rem; }

.muted { color: var(--muted); }

/* ── Grids ──────────────────────────────────────── */
.grid-main {
  display: grid;
  grid-template-columns: minmax(320px,1fr) minmax(350px,1.35fr);
  gap: 14px;
}

.grid-side { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(140px,1fr));
  gap: 10px;
}

.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(120px,1fr)); }
.form-grid.cols-4 { grid-template-columns: repeat(4, minmax(100px,1fr)); }

.form-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* ── Form elements ──────────────────────────────── */
label {
  display: block;
  margin-bottom: 5px;
  font-size: 0.8rem;
  font-weight: 700;
  color: #8aabcc;
}

input, select, textarea, button { font-family: inherit; }

input[type="text"],
input[type="number"],
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  padding: 9px 11px;
  font-size: 0.88rem;
  color: #cddff2;
}

input[type="text"],
input[type="number"],
select {
  height: 38px;
}

textarea {
  min-height: 150px;
  resize: vertical;
  line-height: 1.5;
}

input[type="color"] {
  width: 44px;
  height: 38px;
  padding: 2px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-2);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(56,167,248,0.18);
}

/* ── Checkboxes ─────────────────────────────────── */
.checks { display: flex; gap: 8px; flex-wrap: wrap; }

.checks label {
  margin: 0;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  padding: 5px 9px;
  font-size: 0.78rem;
  font-weight: 600;
  display: inline-flex;
  gap: 6px;
  align-items: center;
  background: var(--surface-2);
  color: #a8c0dc;
}

.checks input[type="checkbox"],
.checks input[type="radio"] {
  width: 14px;
  height: 14px;
  accent-color: var(--brand);
}

/* ── Buttons ────────────────────────────────────── */
.btn-row { display: flex; flex-wrap: wrap; gap: 7px; }

.btn {
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 9px 14px;
  font-size: 0.81rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: filter 0.15s, background 0.15s;
}

.btn-mini { padding: 5px 10px; font-size: 0.74rem; }

.btn-primary {
  color: #fff;
  background: #1a4f8a;
  border-color: var(--brand);
}

.btn-primary:hover { filter: brightness(1.15); }

.btn-ghost {
  color: #9bb8d4;
  border-color: var(--line-strong);
  background: var(--surface-2);
}

.btn-ghost:hover { background: #1e2d3f; }

.btn-accent {
  color: #fff;
  border-color: transparent;
  background: #7a4510;
}

.btn-accent:hover { filter: brightness(1.2); }

.btn-danger {
  color: #fff;
  border-color: transparent;
  background: #6b1c1c;
}

.btn-danger:hover { filter: brightness(1.2); }

/* ── Status / small text ────────────────────────── */
.status-line { margin-top: 8px; font-size: 0.8rem; color: var(--muted); }
.small { font-size: 0.79rem; }

/* ── KPI grid ───────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px,1fr));
  gap: 7px;
}

.kpi {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 9px 10px;
  background: var(--surface-2);
}

.kpi b {
  display: block;
  font-size: 0.71rem;
  color: var(--muted);
}

.kpi span {
  display: block;
  margin-top: 4px;
  font-size: 1rem;
  font-weight: 800;
  color: #d4eaff;
  word-break: break-word;
}

/* ── Chart ──────────────────────────────────────── */
.plot-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--surface);
}

.chart-meta { margin-bottom: 8px; }

#chart {
  width: 100%;
  height: min(78vw, 880px);
  min-height: 430px;
}

.sub-plot-block { margin-top: 12px; }

.sub-plot-title { margin: 0 0 6px; font-size: 0.96rem; color: #a8c0dc; }

#chartZoom {
  width: 100%;
  height: min(42vw, 460px);
  min-height: 260px;
}

/* ── Table ──────────────────────────────────────── */
.table-wrap {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}

table { border-collapse: collapse; width: 100%; min-width: 960px; }

th, td {
  border: 1px solid var(--line);
  padding: 7px 8px;
  font-size: 0.77rem;
  text-align: right;
  white-space: nowrap;
}

th {
  text-align: center;
  background: var(--surface-2);
  color: #8aabcc;
  font-weight: 800;
}

td.left { text-align: left; }
tr.row-focus { background: #142130; }

/* ── Note box ───────────────────────────────────── */
.note-box {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  background: var(--surface-2);
}

.note-box ul, .note-box ol { margin: 0; padding-left: 18px; }

/* ── Summary helper ─────────────────────────────── */
.summary-helper-box { margin-top: 10px; }
.summary-helper-box h3 { margin: 0 0 6px; }
.summary-helper-steps { margin: 8px 0 10px; padding-left: 18px; }

/* ── Tools grid ─────────────────────────────────── */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px,1fr));
  gap: 10px;
}

.tool-link {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px;
  background: var(--surface-2);
  transition: border-color 0.15s, background 0.15s;
}

.tool-link:hover {
  border-color: var(--brand);
  background: #0f1f30;
  text-decoration: none;
}

.tool-link h3 { margin: 0 0 5px; font-size: 0.97rem; color: #c8dff4; }
.tool-link p { margin: 0; font-size: 0.82rem; color: var(--muted); }

/* ── Footer ─────────────────────────────────────── */
.site-footer {
  margin-top: 24px;
  border-top: 1px solid var(--line);
  background: rgba(13,17,23,0.7);
}

.site-footer-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 13px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 0.77rem;
  color: var(--muted);
}

.site-footer-links { display: flex; gap: 12px; flex-wrap: wrap; }
.site-footer-links a { font-weight: 600; color: var(--muted); }
.site-footer-links a:hover { color: var(--brand); }

/* ── Page grids ─────────────────────────────────── */
.page-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.page-grid.two { grid-template-columns: 1.2fr 1fr; }
.page-grid.three { grid-template-columns: repeat(3, minmax(0,1fr)); }

ol, ul { margin-top: 8px; }

pre {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #0a1018;
  padding: 10px;
  overflow: auto;
  margin: 8px 0;
  color: #8ecdf0;
}

/* ── Tags ───────────────────────────────────────── */
.tag {
  display: inline-block;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 0.73rem;
  font-weight: 700;
  color: var(--muted);
  background: var(--surface-2);
}

/* ── Alert ──────────────────────────────────────── */
.alert {
  border-radius: var(--radius-md);
  padding: 10px 12px;
  border: 1px solid #5a3010;
  background: #1e1206;
  color: #c9894e;
  font-size: 0.83rem;
}

/* ── Panel card / workbench ─────────────────────── */
.panel-card {
  margin-top: 14px;
  background: var(--surface-2);
}

.quick-workbench {
  margin-top: 14px;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
}

.quick-workbench .quick-help { margin-top: 8px; }
.quick-scenario-row { margin-top: 8px; }

.quick-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.quick-group {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 10px;
  background: var(--surface);
}

.quick-group .form-grid { margin-top: 8px; }
.quick-sync-hint { display: flex; align-items: flex-end; }

/* ── Feature tabs ───────────────────────────────── */
.feature-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.tab-quick-actions {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-2);
}

.feature-tab {
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: #8aabcc;
  border-radius: 5px;
  padding: 7px 12px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.feature-tab.on {
  color: #fff;
  border-color: var(--brand);
  background: #1a4060;
}

.tab-panel[hidden] { display: none !important; }

.tab-help {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  padding: 8px 12px;
}

.tab-help summary {
  cursor: pointer;
  font-size: 0.81rem;
  font-weight: 700;
  color: #7a9fc2;
}

.tab-help ol { margin: 8px 0 0; padding-left: 18px; }

/* ── Range row ──────────────────────────────────── */
.range-row {
  display: grid;
  grid-template-columns: 180px 1fr 220px;
  gap: 10px;
  align-items: center;
}

.range-row input[type="range"] { width: 100%; accent-color: var(--brand); }

.inline-readout {
  font-weight: 700;
  color: var(--brand);
  font-size: 0.84rem;
}

/* ── Pass/fail pills ────────────────────────────── */
.pass-pill {
  display: inline-block;
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 0.69rem;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.pass-ok  { background: #092b1c; color: #3de0a0; border: 1px solid #1a5c3f; }
.pass-fail{ background: #2b0a0a; color: #f07070; border: 1px solid #6b2020; }

/* ── File input ─────────────────────────────────── */
input[type="file"] {
  width: 100%;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 8px;
  font-size: 0.79rem;
  background: var(--bg-2);
  color: var(--muted);
}

/* ── KPI Bar (compact inline, replaces RF Summary) ─ */
.kpi-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.kpi-bar-item {
  display: flex;
  flex-direction: column;
  min-width: 80px;
  flex: 1 1 80px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  background: var(--surface-2);
}

.kpi-bar-lbl {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}

.kpi-bar-val {
  font-size: 0.92rem;
  font-weight: 800;
  color: #d4eaff;
  word-break: break-word;
  margin-top: 2px;
}

/* ── Responsive ─────────────────────────────────── */
@media (max-width: 1080px) {
  .grid-main   { grid-template-columns: 1fr; }
  .grid-side   { grid-template-columns: 1fr; }

  .page-grid.two,
  .page-grid.three,
  .tools-grid  { grid-template-columns: 1fr; }

  .kpi-grid    { grid-template-columns: repeat(2, minmax(130px,1fr)); }

  #chart       { height: 68vw; min-height: 420px; }
  #chartZoom   { height: 48vw; min-height: 230px; }
}

@media (max-width: 760px) {
  .site-header-inner {
    align-items: flex-start;
    flex-direction: column;
  }

  .site-nav { justify-content: flex-start; }

  .hero { padding: 14px 16px; }

  .form-grid,
  .form-grid.cols-3,
  .form-grid.cols-4 { grid-template-columns: 1fr; }

  .kpi-grid { grid-template-columns: 1fr; }

  #chart     { height: 88vw; min-height: 380px; }
  #chartZoom { height: 62vw; min-height: 210px; }

  th, td { font-size: 0.72rem; padding: 5px 6px; }
}

@media (max-width: 900px) {
  .range-row { grid-template-columns: 1fr; }
}
