/* ============================================
   医療AIラボ（/lab/）共通スタイル
   top.css（共通ヘッダー・フッター）の上に重ねて使う
   ============================================ */

.lab-main { padding-top: 64px; background: #f8fafc; }
.lab-wrap { max-width: 1100px; margin: 0 auto; padding: 0 20px 56px; }
.lab-wrap > * { min-width: 0; }

/* top.css が a の色と下線を消しているので、本文のリンクは明示する */
.lab-prose a, .lab-note a, .lab-warn a, .lab-crumb a, .lab-foot a {
    color: #2563eb; text-decoration: underline; font-weight: 600;
}

.lab-crumb { font-size: 0.8rem; color: #64748b; padding: 18px 0 0; }
.lab-crumb a { font-weight: 500; }
.lab-crumb span { margin: 0 6px; color: #cbd5e1; }

.lab-hero { text-align: center; padding: 26px 0 26px; }
.lab-badge {
    display: inline-block; background: #eff6ff; color: #2563eb; border: 1px solid #bfdbfe;
    font-size: 0.76rem; font-weight: 700; letter-spacing: .08em; border-radius: 999px; padding: 4px 14px; margin-bottom: 12px;
}
.lab-hero h1 { font-size: clamp(1.45rem, 4.2vw, 2.1rem); color: #0f172a; line-height: 1.4; margin: 0 0 12px; }
.lab-hero .lead { color: #475569; font-size: 0.95rem; line-height: 1.9; max-width: 720px; margin: 0 auto; }
.lab-points { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 16px; }
.lab-points li {
    background: #fff; border: 1px solid #e2e8f0; border-radius: 999px; padding: 4px 14px;
    font-size: 0.8rem; color: #334155; font-weight: 600;
}

.lab-card {
    background: #fff; border: 1px solid #e2e8f0; border-radius: 16px;
    box-shadow: 0 6px 24px rgba(30,41,59,0.06); padding: 22px; margin: 0 0 22px;
}
.lab-card > h2 { font-size: 1.12rem; color: #0f172a; margin: 0 0 12px; line-height: 1.5; }
.lab-card > h2 small { font-size: 0.78rem; color: #64748b; font-weight: 500; margin-left: 8px; }
.lab-sub { font-size: 0.86rem; color: #475569; line-height: 1.85; margin: 0 0 12px; }

.lab-note {
    background: #eff6ff; border: 1px solid #bfdbfe; border-radius: 12px; padding: 12px 16px;
    font-size: 0.86rem; color: #1e3a8a; line-height: 1.85; margin: 0 0 16px;
}
.lab-warn {
    background: #fffbeb; border: 1px solid #fde68a; border-radius: 12px; padding: 12px 16px;
    font-size: 0.86rem; color: #78350f; line-height: 1.85; margin: 0 0 16px;
}
.lab-err {
    background: #fef2f2; border: 1px solid #fecaca; border-radius: 12px; padding: 12px 16px;
    font-size: 0.86rem; color: #991b1b; line-height: 1.85; margin: 12px 0 0;
}
.lab-ok { font-size: 0.86rem; color: #166534; line-height: 1.8; margin: 12px 0 0; }

/* ボタン */
.lab-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    font: inherit; font-size: 0.86rem; font-weight: 700; line-height: 1.3; cursor: pointer;
    border-radius: 10px; padding: 9px 16px; border: 1px solid #cbd5e1; background: #fff; color: #334155;
    transition: background .15s, border-color .15s, box-shadow .15s;
}
.lab-btn:hover { background: #f1f5f9; border-color: #94a3b8; }
.lab-btn.primary { background: #2563eb; border-color: #2563eb; color: #fff; }
.lab-btn.primary:hover { background: #1d4ed8; border-color: #1d4ed8; }
.lab-btn.small { font-size: 0.78rem; padding: 6px 11px; border-radius: 8px; }
.lab-btn:disabled { opacity: .5; cursor: not-allowed; }
.lab-btn:focus-visible, .lab-tab:focus-visible, .lab-wrap select:focus-visible, .lab-wrap input:focus-visible, .lab-wrap textarea:focus-visible {
    outline: 3px solid #93c5fd; outline-offset: 2px;
}
.lab-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.lab-row.gap-lg { gap: 14px; }

/* 入力 */
.lab-wrap textarea {
    width: 100%; font: 0.82rem/1.55 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    border: 1px solid #cbd5e1; border-radius: 10px; padding: 10px 12px; color: #0f172a; background: #fbfdff; resize: vertical;
}
.lab-wrap select, .lab-wrap input[type="number"] {
    font: inherit; font-size: 0.86rem; border: 1px solid #cbd5e1; border-radius: 8px; padding: 6px 8px; background: #fff; color: #0f172a; max-width: 100%;
}
/* スライダーは押せる範囲を高さ28pxに広げる（指で操作しやすいように） */
.lab-wrap input[type="range"] { width: 100%; height: 28px; margin: 0; accent-color: #2563eb; cursor: pointer; }
.lab-field { display: flex; flex-direction: column; gap: 4px; font-size: 0.8rem; color: #475569; font-weight: 600; min-width: 0; }

/* タブ */
.lab-tabs {
    display: flex; gap: 6px; overflow-x: auto; padding: 4px 2px 10px; margin: 0 0 6px;
    scrollbar-width: thin; -webkit-overflow-scrolling: touch;
}
.lab-tab {
    flex: 0 0 auto; font: inherit; font-size: 0.86rem; font-weight: 700; cursor: pointer; white-space: nowrap;
    border: 1px solid #cbd5e1; background: #fff; color: #475569; border-radius: 999px; padding: 8px 16px;
}
.lab-tab[aria-selected="true"] { background: #0f172a; border-color: #0f172a; color: #fff; }
.lab-panel[hidden] { display: none; }

/* 数値タイル */
.lab-tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 0 0 18px; }
.lab-tile { background: #fff; border: 1px solid #e2e8f0; border-radius: 14px; padding: 14px 14px 12px; min-width: 0; }
.lab-tile .l { font-size: 0.76rem; color: #64748b; font-weight: 700; }
.lab-tile .v { font-family: 'Inter', sans-serif; font-size: 1.55rem; font-weight: 700; color: #0f172a; line-height: 1.3; }
.lab-tile .s { font-size: 0.74rem; color: #64748b; line-height: 1.5; overflow-wrap: anywhere; }
@media (max-width: 860px) { .lab-tiles { grid-template-columns: repeat(2, 1fr); } }

/* 図と説明の2列 */
.lab-grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 26px; align-items: start; }
.lab-grid > * { min-width: 0; }
@media (max-width: 860px) { .lab-grid { grid-template-columns: 1fr; gap: 18px; } }
.lab-plot { text-align: center; }
.lab-plot canvas { display: block; margin: 0 auto; max-width: 100%; }
.lab-plot .lab-btn { margin-top: 8px; }

/* 表 */
.lab-table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
.lab-table th, .lab-table td { border-bottom: 1px solid #e2e8f0; padding: 7px 8px; text-align: left; vertical-align: top; }
.lab-table th { color: #475569; font-weight: 700; white-space: nowrap; }
.lab-table td.num, .lab-table th.num { text-align: right; font-family: 'Inter', sans-serif; font-variant-numeric: tabular-nums; }
.lab-table .ci { color: #64748b; font-size: 0.78rem; white-space: nowrap; }
.lab-scroll { overflow-x: auto; }

/* 混同行列 */
.lab-cm { display: grid; grid-template-columns: auto 1fr 1fr; gap: 4px; font-size: 0.8rem; margin: 10px 0 14px; }
.lab-cm div { padding: 8px 6px; text-align: center; border-radius: 8px; }
.lab-cm .h { color: #475569; font-weight: 700; background: transparent; }
.lab-cm .c { font-family: 'Inter', sans-serif; font-size: 1.15rem; font-weight: 700; }
.lab-cm .c small { display: block; font-size: 0.7rem; font-weight: 600; font-family: 'Noto Sans JP', sans-serif; }
.lab-cm .tp { background: #dbeafe; color: #1e40af; }
.lab-cm .tn { background: #f1f5f9; color: #334155; }
.lab-cm .fp { background: #ffedd5; color: #9a3412; }
.lab-cm .fn { background: #fee2e2; color: #991b1b; }

/* 1,000人あたりの帯グラフ */
.lab-bar { display: flex; height: 34px; border-radius: 8px; overflow: hidden; border: 1px solid #e2e8f0; margin: 8px 0 6px; }
.lab-bar span { display: block; height: 100%; min-width: 0; }
.lab-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.78rem; color: #475569; }
.lab-legend i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

.lab-progress { height: 8px; background: #e2e8f0; border-radius: 999px; overflow: hidden; flex: 1 1 160px; min-width: 120px; }
.lab-progress i { display: block; height: 100%; width: 0; background: #2563eb; transition: width .1s linear; }

.lab-big { font-family: 'Inter', sans-serif; font-size: 1.5rem; font-weight: 700; color: #0f172a; }
.lab-muted { color: #64748b; font-size: 0.8rem; line-height: 1.8; }

/* 本文（使い方・計算方法の説明） */
.lab-prose h2 { font-size: 1.2rem; color: #0f172a; margin: 34px 0 12px; padding-left: 12px; border-left: 5px solid #2563eb; line-height: 1.5; }
.lab-prose h3 { font-size: 1rem; color: #1e293b; margin: 20px 0 8px; }
.lab-prose p, .lab-prose li { font-size: 0.92rem; color: #334155; line-height: 1.95; }
.lab-prose p { margin: 0 0 12px; }
.lab-prose ul, .lab-prose ol { margin: 0 0 14px 1.3em; }
.lab-prose ul { list-style: disc; }
.lab-prose ol { list-style: decimal; }
.lab-prose code { background: #f1f5f9; border-radius: 4px; padding: 1px 5px; font-size: 0.85em; }
.lab-prose pre { background: #0f172a; color: #e2e8f0; border-radius: 10px; padding: 12px 14px; font-size: 0.8rem; line-height: 1.6; overflow-x: auto; margin: 0 0 14px; }

/* ハブのカード */
.lab-tools { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; margin: 0 0 28px; }
@media (max-width: 760px) { .lab-tools { grid-template-columns: 1fr; } }
.lab-tool {
    display: flex; flex-direction: column; background: #fff; border: 1px solid #e2e8f0; border-radius: 16px; padding: 20px;
    box-shadow: 0 6px 24px rgba(30,41,59,0.06); transition: transform .15s, box-shadow .15s, border-color .15s; color: inherit;
}
a.lab-tool:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(30,41,59,0.10); border-color: #93c5fd; }
.lab-tool .tag { align-self: flex-start; font-size: 0.72rem; font-weight: 700; color: #2563eb; background: #eff6ff; border-radius: 999px; padding: 3px 10px; margin-bottom: 10px; }
.lab-tool h3 { font-size: 1.05rem; color: #0f172a; margin: 0 0 8px; line-height: 1.5; }
.lab-tool p { font-size: 0.86rem; color: #475569; line-height: 1.85; margin: 0 0 12px; flex: 1; }
.lab-tool .go { font-size: 0.86rem; font-weight: 700; color: #2563eb; }

/* 関連コンテンツ・広告 */
.lab-rel { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 0 0 26px; }
@media (max-width: 860px) { .lab-rel { grid-template-columns: 1fr; } }
.lab-rel a { display: block; background: #fff; border: 1px solid #e2e8f0; border-radius: 14px; padding: 14px 16px; color: inherit; }
.lab-rel a:hover { border-color: #93c5fd; }
.lab-rel b { display: block; font-size: 0.9rem; color: #1d4ed8; margin-bottom: 4px; }
.lab-rel span { font-size: 0.8rem; color: #475569; line-height: 1.7; display: block; }
.lab-ad { margin: 26px 0; text-align: center; }
.lab-ad .lab-ad-label { display: block; font-size: 0.7rem; color: #94a3b8; margin-bottom: 4px; }
.lab-foot { font-size: 0.8rem; color: #64748b; line-height: 1.9; border-top: 1px solid #e2e8f0; padding-top: 16px; margin-top: 26px; }

/* hidden 属性を、display:flex などの指定より優先させる */
.lab-wrap [hidden] { display: none !important; }

/* スマホでは、表の見出しと信頼区間を折り返して横スクロールを減らす */
@media (max-width: 560px) {
    .lab-card { padding: 16px; }
    .lab-table th, .lab-table .ci { white-space: normal; }
    .lab-table th, .lab-table td { padding: 7px 5px; }
    .lab-tile .v { font-size: 1.35rem; }
}
