: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}
.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}
.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:14px}
.grid{display:grid;gap:16px}
.grid.cols-2{grid-template-columns:repeat(2,1fr)}
.badge{
  --c: #888; --txt: #fff;
  display: inline-flex; align-items: center; gap: .4em;
  padding: 4px 10px; border: 1px solid var(--c); border-radius: 8px;
  color: var(--txt); background: #0b1220; font-size: .9rem; font-weight: 700; line-height: 1;
  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--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%);}
.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:6px 10px;border-radius:8px;}
.btn.btn--ghost:hover{background:rgba(207,230,255,0.06);}
.muted{color:var(--muted)}
.small{font-size:.85rem}
.center{text-align:center}
.hr{height:1px;background:#1f2937;border:0;margin:16px 0}

/* 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}
.dropzone.drag{border-color:var(--accent2);background:#0c1a2b}
.dropzone input{display:none}
.hint{color:var(--muted);font-size:.95rem}

/* Charts */
.canvas-wrap{
  background:#0b1220;border:1px solid #1f2937;border-radius:16px;padding:8px;
  position:relative;margin:6px 0 4px;height:36vh;min-height:0;overflow:hidden;flex:1 1 auto;
}
.canvas-wrap canvas,
.canvas-wrap > canvas{
  width:100%;height:100%;display:block;background:transparent;aspect-ratio:auto !important;
  border-radius:12px;
}
.stat{
  display:flex;justify-content:space-between;border-bottom:1px dashed #233146;padding:.32rem 0;
}
.stat:last-child{border-bottom:0}
.stat b{color:#e2e8f0}

/* レイアウト */
.screen{height:100vh;padding:10px 18px;overflow:hidden}
.grid-16x9{
  display:grid;grid-template-columns:36% 64%;grid-template-rows:auto 1fr;
  gap:12px 16px;height:calc(100vh - 20px);
}
.panel-stats{overflow:hidden}
.panel-charts{display:grid;grid-template-rows:1fr 1fr;gap:12px;overflow:hidden}

.result-grid{
  display: grid;
  grid-template-columns: 1fr 340px; /* 左右幅を調整 */
  gap: 16px;
  align-items: stretch; /* 高さ揃え */
  min-height: 0;
}
.col-graphs, .col-stats{
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.col-graphs{order:1;}
.col-stats{order:2;}
.result-header{display:flex;justify-content:space-between;align-items:center;padding:10px 14px;}
.panel .row{margin-block:10px;}
.col-title{margin:2px 0 8px;font-size:15px;}
.row-title{margin:2px 0 6px;font-size:13px;color:var(--muted);}
.col-graphs .panel{
  display:grid;grid-template-rows:1fr 1fr;gap:8px;height:calc(100vh - 110px);overflow:hidden;
}
.col-graphs .row{min-height:0;display:flex;flex-direction:column;}
.col-graphs .row-title{flex:0 0 auto;margin-bottom:6px;}
.col-graphs .canvas-wrap{flex:1 1 auto;min-height:0;overflow:hidden;}
.col-graphs .canvas-wrap > canvas{width:100%;height:100%;display:block;}

.topbar{
  display:flex;justify-content:flex-start;align-items:center;
  position:sticky;top:0;z-index:10;
  margin:10px 0 15px;padding:10px 14px;background:#0b0f14;
  border-bottom:1px solid rgba(255,255,255,0.08);
}
.topbar__title{font-size:16px;font-weight:600;color:#e8eef5;}
.topbar__summary{display:flex;gap:1rem;align-items:center;}
.pval{color:#ccc;font-size:1rem;font-weight:500;font-variant-numeric:tabular-nums;}
/* F検定メモの控えめスタイル */
.topbar__summary .fnote{
  font-size: 12px;
  color: #9fb0c3;
  margin-left: 10px;
  padding-left: 10px;
  border-left: 1px solid rgba(255,255,255,0.18);
  white-space: nowrap;   /* 折り返しを防いでコンパクトに */
}
@media (max-width: 900px){
  .topbar__summary .fnote{ display: none; } /* せまい画面では省略 */
}

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

/* 2段構成 */
.ab-grid{
  display:grid;grid-template-rows:1fr 1fr;gap:14px;padding:14px;
  height:calc(100vh - 60px);box-sizing:border-box;min-height:0;
}
.ab-row{
  display:grid;grid-template-columns:320px 1fr;gap:14px;min-height:0;align-items:stretch;
}
.ab-row>.stats-card,.ab-row>.canvas-card{height:100%;min-height:0;}
.stats-card{
  background:rgba(255,255,255,0.04);border:1px solid rgba(255,255,255,0.08);
  border-radius:10px;padding:12px;display:flex;flex-direction:column;overflow:auto;
}
.stats-card__title{font-size:14px;color:#e8eef5;margin:0 0 8px 0;}
.stats-list{list-style:none;padding:0;margin:0;color:#cdd6df;}
.stats-list li{padding:2px 0;font-variant-numeric:tabular-nums;}
.canvas-card{
  background:rgba(255,255,255,0.03);border:1px solid rgba(255,255,255,0.08);
  border-radius:10px;padding:10px 10px 6px;display:flex;flex-direction:column;min-height:0;
}
.canvas-title{font-size:13px;color:#cfe6ff;margin-bottom:6px;}

/* メディアクエリ */
@media (max-height:820px){
  .result-grid{
    grid-template-columns:2fr 1fr;
    gap:1rem;
  }
  .canvas-wrap{margin:4px 0 2px;}
  .ab-grid,.ab-row{gap:12px;}
}

/* color-mix未対応対策 */
@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);
  }
}
  
/* === ab-grid 行では固定36vhを無効化し、行高にフィットさせる === */

/* 行の両カラムを“行いっぱい”に伸ばす（保険） */
.ab-row { align-items: stretch; min-height: 0; }

/* 左右のカード自身が行高にフィット */
.ab-row > .stats-card,
.ab-row > .canvas-card {
  height: 100%;
  min-height: 0;
}

/* 右のキャンバスカードは縦方向に伸びるフレックス */
.ab-row > .canvas-card {
  display: flex;
  flex-direction: column;
}

/* ab-row 内では .canvas-wrap の固定36vhを無効化してフレックスで伸ばす */
.ab-row .canvas-wrap {
  height: auto;          /* ← 36vh を打ち消す */
  min-height: 0;
  flex: 1 1 auto;        /* 余白をキャンバスに配分 */
  margin: 6px 0 4px;     /* 既存の見た目を維持 */
}

/* キャンバス自体も親の伸縮に追従 */
.ab-row .canvas-wrap > canvas {
  width: 100%;
  height: 100%;
  display: block;
}
/* 左カラムの統計も、右グラフと同じく 2 段 (= A/B) にして高さを同期 */
.col-stats .stats-col-grid {
  display: grid;
  grid-template-rows: 1fr 1fr;           /* A と B を等分 */
  gap: 8px;
  height: calc(100vh - 110px);           /* 右の .col-graphs .panel と同じ基準 */
  min-height: 0;
}

.col-stats .stats-card {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  overflow: auto;                        /* 内容が多い時でも高さを崩さない */
  min-height: 0;                         /* グリッド内での正しい縮み */
}

/* 見出しとリストの基本 */
.stats-card__title { 
  font-size: 14px; 
  color: #e8eef5; 
  margin: 0 0 8px 0; 
}
.stats-list { 
  list-style: none; 
  padding: 0; 
  margin: 0; 
  color: #cdd6df; 
}
.stats-list li { 
  padding: 2px 0; 
  font-variant-numeric: tabular-nums; 
}
/* スクショ時に一時的に不可視化（レイアウトは保持） */
.no-shot-hide { visibility: hidden !important; }

