:root{
  --bg:#0f172a; --card:#111827; --muted:#94a3b8; --accent:#22c55e; --accent2:#3b82f6; --danger:#ef4444; --warning:#f59e0b; --text:#e5e7eb;
}
*{box-sizing:border-box}
html,body{margin:0;padding:0;background:var(--bg);color:var(--text);font:16px/1.5 system-ui,-apple-system,Segoe UI,Roboto,Helvetica,Arial}

/* ===== Form page ===== */
.container{max-width:960px;margin:40px auto;padding:0 20px}
.header{display:flex;align-items:center;gap:12px;margin-bottom:8px}
.header h1{font-size:1.2rem;margin:0;line-height:1.35}
.card{background:linear-gradient(180deg,#0b1220 60%, #0d141e);border:1px solid #1f2937;border-radius:14px;box-shadow:0 10px 30px rgba(0,0,0,.25);padding:16px}
.grid{display:grid;gap:16px}
.grid.cols-2{grid-template-columns:repeat(2,1fr)}

/* Buttons */
.btn{display:inline-flex;align-items:center;gap:.5rem;background:#1f2937;color:var(--text);border:1px solid #334155;border-radius:12px;padding:.6rem 1rem;cursor:pointer;text-decoration:none}
.btn:hover{background:#111827}
.btn.btn--ghost{color:#cfe6ff;border:1px solid rgba(207,230,255,0.3);padding:8px 12px;border-radius:10px;}
.btn.btn--ghost:hover{background:rgba(207,230,255,0.06);}
/* stacked EN/JA label inside a button */
.btn__txt{display:inline-flex;flex-direction:column;align-items:flex-start;gap:1px;line-height:1.15;white-space:nowrap}
.btn__txt small{font-size:11px;font-weight:400;opacity:.7}

.muted{color:var(--muted)}
.small{font-size:.85rem}
.center{text-align:center}
.hr{height:1px;background:#1f2937;border:0;margin:16px 0}
code{background:#0b1220;border:1px solid #1f2937;border-radius:6px;padding:1px 6px;font-size:.9em}

/* Dropzone */
.dropzone{border:2px dashed #334155;border-radius:16px;padding:36px;background:#0b1220;display:flex;flex-direction:column;align-items:center;gap:12px;transition:.15s;text-align:center}
.dropzone.drag{border-color:var(--accent2);background:#0c1a2b}
.dropzone input{display:none}
.hint{color:var(--muted);font-size:.95rem;line-height:1.5}

/* Usage block (form page) */
.usage{margin-top:18px}
.usage h2{font-size:1.05rem;margin:0 0 10px}
.usage ol{margin:0 0 14px;padding-left:1.25rem}
.usage ol li{margin:0 0 10px;line-height:1.6}
.usage .dl-btn{margin:4px 8px 4px 0}

/* ===== Result page ===== */
.result-body{
  margin:0;background:#0a0e13;color:#e8eef5;
  font-family:system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
}

/* Top bar = single row: title (left) + metrics & actions (right) */
.topbar{
  position:sticky;top:0;z-index:10;
  background:#0b0f14;border-bottom:1px solid rgba(255,255,255,0.08);
  padding:14px 18px;margin:0 0 18px;
  display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:12px 20px;
}
.topbar__title{display:flex;flex-direction:column;gap:2px;margin:0;min-width:0;flex:0 1 auto}
.topbar__test{font-size:18px;font-weight:700;color:#f1f5f9;line-height:1.2}
.topbar__sub{font-size:13px;color:#9fb0c3;line-height:1.3}

/* right-hand cluster fills the gap between title and buttons */
.topbar__cluster{
  display:flex;align-items:center;justify-content:flex-end;flex-wrap:wrap;gap:10px 14px;
  flex:1 1 auto;min-width:0;
}
.topbar__metrics{display:flex;align-items:center;justify-content:flex-end;flex-wrap:wrap;gap:10px 14px}
.topbar__actions{display:flex;flex-wrap:wrap;gap:8px;flex:0 0 auto}

/* p-value chip */
.metric{
  display:inline-flex;flex-direction:column;justify-content:center;gap:2px;
  padding:6px 14px;border-radius:10px;
  background:rgba(255,255,255,0.04);border:1px solid rgba(255,255,255,0.08);
}
.metric__label{font-size:11px;color:#8aa0b6;letter-spacing:.02em;white-space:nowrap}
.metric__value{font-size:15px;font-weight:600;color:#e8eef5;font-variant-numeric:tabular-nums;white-space:nowrap}

/* Significance badge: tidy single pill, stacked EN/JA */
.badge{
  --c:#888;--txt:#fff;
  display:inline-flex;flex-direction:column;align-items:center;justify-content:center;gap:1px;
  padding:6px 16px;border:1px solid var(--c);border-radius:10px;
  color:var(--txt);background:#0b1220;text-align:center;line-height:1.15;
  position:relative;
  box-shadow:0 0 8px color-mix(in oklab, var(--c) 45%, transparent),
             inset 0 0 10px color-mix(in oklab, var(--c) 20%, transparent);
  backdrop-filter:blur(1px);
}
.badge::before{
  content:"";position:absolute;inset:-6px;border-radius:12px;
  background:radial-gradient(60% 60% at 50% 50%,color-mix(in oklab, var(--c) 35%, transparent) 0%, transparent 70%);
  filter:blur(8px);opacity:.9;z-index:-1;
}
.badge__en{font-size:13px;font-weight:700;white-space:nowrap}
.badge__ja{font-size:11px;font-weight:600;opacity:.85;white-space:nowrap}
.badge--sig{--c:#e53935;--txt:#ffecec;border-color:color-mix(in oklab, var(--c) 85%, #000 15%);}
.badge--ns{--c:#43a047;--txt:#eaffe6;border-color:color-mix(in oklab, var(--c) 85%, #000 15%);}

/* F-test note: two clean lines, sits beside the chips or wraps below */
.fnote{
  display:flex;flex-direction:column;justify-content:center;gap:2px;
  font-size:12px;color:#9fb0c3;line-height:1.4;
  padding-left:14px;border-left:1px solid rgba(255,255,255,0.14);
  flex:0 1 auto;max-width:460px;min-width:0;
}
.fnote__ja{opacity:.85}

/* Main grid: graphs (wide, left) + stats (right). Scroll-friendly. */
.result-grid{
  display:grid;grid-template-columns:minmax(0,1fr) 340px;gap:18px;align-items:start;
  max-width:1280px;margin:0 auto;padding:0 16px 28px;
}
.col{min-width:0;display:flex;flex-direction:column}
.col-graphs{order:1}
.col-stats{order:2}

/* Section / row headings with stacked JA subtext */
.col-title{margin:2px 0 12px;font-size:15px;color:#e8eef5;line-height:1.25;display:flex;flex-direction:column;gap:1px}
.col-title small{font-size:12px;font-weight:400;color:#9fb0c3}
.row-title{margin:2px 0 6px;font-size:13px;color:#cfe6ff;line-height:1.25;display:flex;flex-direction:column;gap:1px}
.row-title small{font-size:11px;color:#8aa0b6}

/* Graphs */
.col-graphs .panel{display:flex;flex-direction:column;gap:16px}
.col-graphs .row{display:flex;flex-direction:column}
.canvas-wrap{
  background:#0b1220;border:1px solid #1f2937;border-radius:16px;padding:8px;
  position:relative;height:clamp(240px,34vh,360px);overflow:hidden;
}
.canvas-wrap canvas,
.canvas-wrap > canvas{
  width:100%;height:100%;display:block;background:transparent;
  aspect-ratio:auto !important;border-radius:12px;
}

/* Stats */
.stats-col-grid{display:flex;flex-direction:column;gap:12px}
.stats-card{
  background:rgba(255,255,255,0.04);border:1px solid rgba(255,255,255,0.08);
  border-radius:12px;padding:14px 16px;
}
.stats-card__title{
  font-size:14px;color:#e8eef5;margin:0 0 10px;line-height:1.25;
  display:flex;align-items:baseline;gap:8px;flex-wrap:wrap;
}
.stats-card__title small{font-size:11px;font-weight:400;color:#8aa0b6}
.stats-list{list-style:none;padding:0;margin:0;color:#cdd6df}
.stats-list li{
  display:flex;justify-content:space-between;align-items:baseline;gap:12px;
  padding:6px 0;border-bottom:1px dashed #233146;
}
.stats-list li:last-child{border-bottom:0}
.stats-list li > span:first-child{color:#9fb0c3;font-size:13px}
.stats-list li > span:last-child{color:#e8eef5;font-weight:600;font-variant-numeric:tabular-nums}

/* Single column on narrow screens */
@media (max-width:760px){
  .result-grid{grid-template-columns:1fr;gap:14px}
  .canvas-wrap{height:300px}
  .topbar__actions{width:100%}
}

/* color-mix unsupported fallback */
@supports not (color-mix(in oklab, red 50%, white 50%)){
  .badge{box-shadow:0 0 8px rgba(136,136,136,.45),inset 0 0 10px rgba(136,136,136,.2);}
  .badge--sig{border-color:#e53935;box-shadow:0 0 8px rgba(229,57,53,.5),inset 0 0 10px rgba(229,57,53,.25);}
  .badge--ns{border-color:#43a047;box-shadow:0 0 8px rgba(67,160,71,.5),inset 0 0 10px rgba(67,160,71,.25);}
}

/* Screenshot helper */
.no-shot-hide{visibility:hidden !important;}
