:root {
  --bg:#eef1f6; --panel:#ffffff; --panel2:#f6f8fb; --ink:#0f1b2d; --mut:#6b7787;
  --acc:#10b981; --acc-d:#0e9f74; --acc2:#2563eb; --line:#e4e9f0;
  --shadow:0 1px 3px rgba(16,30,54,.06), 0 6px 24px rgba(16,30,54,.05);
}
* { box-sizing:border-box; }
body { font-family:"Inter",-apple-system,Segoe UI,Roboto,Arial,sans-serif;
  margin:0; background:var(--bg); color:var(--ink); font-size:13px;
  -webkit-font-smoothing:antialiased; }
header { display:flex; align-items:center; gap:24px; padding:0 22px; height:60px;
  background:var(--panel); border-bottom:1px solid var(--line); position:sticky;
  top:0; z-index:10; }
.brand { display:flex; flex-direction:column; line-height:1.1;
  text-decoration:none; color:inherit; cursor:pointer; }
.brand:hover .logo { color:var(--acc-d); }
.logo { font-weight:800; letter-spacing:.14em; font-size:17px; color:var(--ink); }
.logo::before { content:"⬡ "; color:var(--acc); }
.tag { font-size:10.5px; color:var(--mut); letter-spacing:.04em; }
nav { display:flex; gap:4px; background:var(--panel2); padding:4px; border-radius:10px; }
nav a { padding:7px 18px; border-radius:7px; text-decoration:none; color:var(--mut);
  font-weight:600; font-size:13px; transition:.15s; }
nav a:hover { color:var(--ink); }
nav a.active { background:var(--acc); color:#fff; box-shadow:0 2px 8px rgba(16,185,129,.35); }
.contact { margin-left:auto; color:var(--mut); font-size:11.5px; }
main { padding:18px 22px; max-width:1480px; margin:0 auto; }
.view { display:none; }
.view.active { display:grid; gap:16px; }
.view.geom, .view.study, .view.optimize, .view.rom { grid-template-columns:340px 1fr; }
.panel { background:var(--panel); border:1px solid var(--line); border-radius:14px;
  padding:16px; box-shadow:var(--shadow); }
h2 { font-size:12px; text-transform:uppercase; letter-spacing:.07em; color:var(--mut);
  margin:0 0 12px; }
label { display:block; color:var(--mut); margin-bottom:9px; font-size:12px; font-weight:500; }
input, select { width:100%; margin-top:4px; padding:8px 9px; background:#fff;
  border:1px solid var(--line); border-radius:8px; color:var(--ink); font-size:13px;
  transition:.12s; }
input:focus, select:focus { outline:none; border-color:var(--acc);
  box-shadow:0 0 0 3px rgba(16,185,129,.13); }
button { padding:9px 16px; background:var(--acc); color:#fff; border:0;
  border-radius:9px; font-weight:700; font-size:13px; cursor:pointer; transition:.15s;
  box-shadow:0 2px 8px rgba(16,185,129,.28); }
button:hover { background:var(--acc-d); }
button:disabled { opacity:.5; cursor:default; box-shadow:none; }
.anim-controls button { background:var(--panel2); color:var(--ink);
  border:1px solid var(--line); box-shadow:none; font-weight:600; }
.anim-controls button:hover { background:#eef2f7; }
button.ghost, .ghost.filebtn { background:var(--panel2); color:var(--ink);
  border:1px solid var(--line); box-shadow:none; font-weight:600; }
button.ghost:hover, .ghost.filebtn:hover { background:#eef2f7; }
.filebtn { display:inline-flex; align-items:center; padding:9px 16px;
  border-radius:9px; font-size:13px; cursor:pointer; margin:0; color:var(--ink); }
button.ghost:disabled { opacity:.5; cursor:default; }
.status,.state { color:var(--mut); font-size:12px; }
/* geometry params */
.params .preset-row { margin-bottom:12px; }
.grp { margin-bottom:4px; border-top:1px solid var(--line); padding-top:10px; }
.grp h4 { margin:0 0 9px; font-size:10.5px; text-transform:uppercase;
  letter-spacing:.07em; color:var(--acc-d); font-weight:700; }
.grp .row { display:grid; grid-template-columns:1fr 104px; align-items:center;
  gap:8px; margin-bottom:7px; }
.grp .row span { color:var(--mut); font-size:12px; }
.grp .row input, .grp .row select { margin:0; padding:6px 7px; }
.actions { display:flex; align-items:center; gap:14px; margin-top:14px; }
.chk { display:flex; align-items:center; gap:6px; margin:0; color:var(--mut); }
.chk input { width:auto; margin:0; }
.canvasarea { display:flex; flex-direction:column; }
.viewgrid { display:grid; grid-template-columns:1fr 1fr; gap:14px; }
.viewgrid figure { margin:0; background:var(--panel2); border:1px solid var(--line);
  border-radius:12px; padding:10px; }
.viewgrid figcaption { font-size:10px; letter-spacing:.07em; color:var(--mut);
  margin-bottom:8px; font-weight:700; }
.pz { overflow:hidden; border-radius:8px; cursor:grab; background:#fff;
  border:1px solid var(--line); min-height:120px; }
.pz.grab { cursor:grabbing; }
.pz img, .pz svg { display:block; width:100%; height:auto; border:0; border-radius:0;
  transform-origin:0 0; will-change:transform; user-select:none; }
.pz canvas.geocanvas { display:block; width:100%; user-select:none; }
.pzc { display:inline-flex; gap:3px; margin-left:6px; vertical-align:middle; }
.pzc button { padding:0; width:20px; height:18px; line-height:16px; font-size:13px;
  background:var(--panel2); color:var(--ink); border:1px solid var(--line);
  border-radius:5px; box-shadow:none; font-weight:700; }
.pzc button:hover { background:#eef2f7; }
.hint-row { font-size:10.5px; color:var(--mut); margin-top:7px; font-style:italic; }
.legend { display:flex; flex-wrap:wrap; gap:16px; margin-top:14px; color:var(--mut);
  font-size:11.5px; }
.legend span { display:flex; align-items:center; gap:6px; }
.legend i { width:13px; height:13px; border-radius:4px; display:inline-block; }
.legend i.mk { width:auto; height:auto; background:none; border-radius:0;
  font-size:14px; line-height:1; color:#0b1320; }
.plot-head { font-size:10.5px; text-transform:uppercase; letter-spacing:.06em;
  color:var(--mut); margin:4px 0 8px; font-weight:700; }
.plot-head .hint { color:var(--acc-d); text-transform:none; letter-spacing:0;
  font-weight:500; }
img { max-width:100%; background:#fff; border-radius:8px; }
.kv { width:100%; border-collapse:collapse; margin-top:14px; }
.kv td { padding:6px 8px; border-bottom:1px solid var(--line); }
.kv td:first-child { color:var(--mut); }
.kv td:last-child { text-align:right; font-variant-numeric:tabular-nums; font-weight:600; }
/* calculation */
.controlbar { display:flex; flex-wrap:wrap; align-items:flex-end; gap:14px; position:relative; }
.controlbar label { margin:0; }
.controlbar select, .controlbar input { width:auto; min-width:96px; }
.active-geo { color:var(--mut); align-self:center; }
.active-geo b { color:var(--ink); }
.active-geo .lock { margin-left:4px; opacity:.6; font-size:11px; cursor:help; }
.inline-params { display:inline-flex; gap:12px; flex-wrap:wrap; }
.inline-params label { display:flex; flex-direction:column; }
.inline-params input { width:84px; }
.bar { position:absolute; bottom:-1px; left:0; height:3px; width:100%; }
.bar > div { height:100%; width:0; background:var(--acc); transition:width .1s;
  border-radius:2px; }
.anim-controls { display:flex; align-items:center; gap:12px; }
.anim-controls label { margin:0; display:flex; align-items:center; gap:6px; }
.anim-controls select { width:auto; }
.calc-body { display:grid; grid-template-columns:1fr 1fr; gap:16px; }
.left img { width:100%; }
.log { background:#0f1b2d; color:#8be0c4; border:1px solid var(--line);
  border-radius:10px; height:92px; overflow:auto; margin:0 0 12px; padding:9px;
  font-size:11px; white-space:pre-wrap; font-family:ui-monospace,Menlo,monospace; }
.wplot { margin-bottom:10px; }
canvas { width:100%; height:auto; background:#fff; border:1px solid var(--line);
  border-radius:10px; }
.wplot canvas { height:168px; display:block; }
/* about */
.view.about { grid-template-columns:1fr; }
.about-panel { max-width:880px; margin:0 auto; padding:34px 40px 40px; }
.about-head { display:flex; align-items:center; gap:18px; margin-bottom:22px; }
.about-avatar { position:relative; width:72px; height:72px; border-radius:16px;
  flex:0 0 auto; overflow:hidden;
  background:linear-gradient(135deg,var(--acc),var(--acc2)); color:#fff;
  display:flex; align-items:center; justify-content:center; font-weight:800;
  font-size:24px; letter-spacing:.04em; box-shadow:0 6px 18px rgba(16,185,129,.3); }
.about-avatar img { position:absolute; inset:0; width:100%; height:100%;
  object-fit:cover; }
.about-name { margin:0; font-size:26px; font-weight:800; letter-spacing:-.01em; }
.about-role { margin:4px 0 0; color:var(--mut); font-size:14px; }
.about-lead { font-size:15px; line-height:1.65; color:var(--ink); margin:0 0 18px; }
.about-stats { display:grid; grid-template-columns:repeat(4,1fr); gap:12px; margin:0 0 26px; }
.about-stats > div { background:var(--panel2); border:1px solid var(--line);
  border-radius:12px; padding:14px 15px; font-size:12.5px; font-weight:600; color:var(--ink); }
.about-stats .num { display:block; font-size:28px; font-weight:800; color:var(--acc-d); line-height:1.05; }
.about-stats small { display:block; margin-top:6px; font-size:11px; font-weight:400; color:var(--mut); }
@media (max-width:680px){ .about-stats { grid-template-columns:repeat(2,1fr); } }
.about-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:14px; margin-bottom:26px; }
.about-card { background:var(--panel2); border:1px solid var(--line); border-radius:12px;
  padding:14px 16px; }
.about-card h4 { margin:0 0 7px; font-size:13px; color:var(--acc-d); font-weight:700; }
.about-card p { margin:0; font-size:12.5px; line-height:1.55; color:var(--mut); }
.about-h3 { font-size:14px; margin:24px 0 8px; color:var(--ink); }
.about-panel p { font-size:14px; line-height:1.65; color:var(--ink); }
.about-note { color:var(--mut); font-style:italic; border-left:3px solid var(--acc);
  padding-left:14px; margin:22px 0 26px; }
.about-linkedin { display:inline-flex; align-items:center; gap:6px; text-decoration:none;
  background:#0a66c2; color:#fff; font-weight:700; font-size:14px; padding:11px 20px;
  border-radius:10px; box-shadow:0 4px 14px rgba(10,102,194,.32); transition:.15s; }
.about-linkedin:hover { background:#08539e; }
@media (max-width:680px){ .about-grid{ grid-template-columns:1fr; } }

/* ---------- study: segmented toggle ---------- */
.seg { display:flex; gap:4px; background:var(--panel2); padding:4px; border-radius:9px; }
.seg button { flex:1; background:transparent; color:var(--mut); box-shadow:none;
  font-size:12px; font-weight:600; padding:7px 8px; }
.seg button.active { background:var(--acc); color:#fff; box-shadow:0 2px 8px rgba(16,185,129,.3); }
.st-adv { margin-top:4px; }
.st-adv summary { cursor:pointer; color:var(--mut); font-size:11px; padding:2px 0; }
.st-pt { border:1px solid var(--line); border-radius:9px; padding:8px; margin-bottom:7px; background:var(--panel2); }
.st-pt .pt-head { display:flex; gap:6px; align-items:center; margin-bottom:6px; }
.st-pt .pt-head input { font-weight:600; }

/* ---------- API-key gate modal ---------- */
.gate-overlay { display:none; position:fixed; inset:0; z-index:100; padding:20px;
  background:rgba(15,27,45,.5); align-items:center; justify-content:center; }
.gate-box { background:#fff; border-radius:16px; padding:24px 26px; max-width:450px;
  width:100%; box-shadow:0 24px 70px rgba(16,30,54,.35); }
.gate-box h3 { margin:0 0 10px; font-size:18px; }
.gate-box p { font-size:13px; line-height:1.6; color:var(--mut); margin:0 0 14px; }
.gate-box input { margin-bottom:6px; }
.gate-err { color:#e11d48; font-size:12px; min-height:16px; margin-bottom:10px; }
.gate-actions { display:flex; align-items:center; gap:10px; }
.gate-link { display:inline-flex; align-items:center; text-decoration:none; background:#0a66c2;
  color:#fff; font-weight:700; font-size:12px; padding:8px 13px; border-radius:8px; }
.gate-link:hover { background:#08539e; }

/* ---------- responsive / mobile ---------- */
@media (max-width:1000px){
  .view.geom, .view.study, .view.optimize, .view.rom { grid-template-columns:1fr; }
}
@media (max-width:860px){
  .calc-body { grid-template-columns:1fr; }    /* flux above waveforms */
  main { padding:14px 13px; }
  header { gap:12px; padding:0 14px; }
  .contact { display:none; }
  nav a { padding:7px 13px; font-size:12.5px; }
  .controlbar { gap:11px; }
  .controlbar select, .controlbar input { min-width:0; }
}
@media (max-width:560px){
  .viewgrid { grid-template-columns:1fr; }      /* one geometry pane per row */
  header { height:auto; flex-wrap:wrap; padding:10px 12px; gap:9px; }
  nav { width:100%; justify-content:space-between; }
  nav a { flex:1; text-align:center; padding:8px 4px; }
  .anim-controls { flex-wrap:wrap; gap:8px; }
  .inline-params input { width:72px; }
  .grp .row { grid-template-columns:1fr 92px; }
  .about-panel { padding:22px 17px 28px; }
  .about-name { font-size:22px; }
  .about-head { gap:13px; }
}
