/* =====================================================================
   ui.css — index.html / cadcam.html 共通の見た目と動き（2026-11-17c 追加）
   各ページの <style> の後に読み込み、上書きする。判定ロジックには関係しない。
   ===================================================================== */

@view-transition { navigation: auto; }

:root {
    --ok: #16a34a;
    --ok-ink: #14532d;
    --ng: #dc2626;
    --ng-ink: #7f1d1d;
    --chk: #d97706;
    --chk-ink: #78350f;
    --ink: #1f2d3d;
    --muted: #5b6b7a;
    --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
    --ease-out: cubic-bezier(.22, 1, .36, 1);
    --topbar-h: 56px;
}

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body { padding-top: calc(var(--topbar-h) + 14px) !important; color: var(--ink); }
button, a, summary, .tooth-cell { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }

/* ---------- 上部バー（2画面の切替） ---------- */
.topbar {
    position: fixed; top: 0; left: 0; right: 0; z-index: 50;
    height: var(--topbar-h);
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 0 max(14px, env(safe-area-inset-left)) 0 max(14px, env(safe-area-inset-right));
    background: linear-gradient(180deg, rgba(255,255,255,.82), rgba(255,255,255,.62));
    -webkit-backdrop-filter: blur(20px) saturate(1.6); backdrop-filter: blur(20px) saturate(1.6);
    border-bottom: 1px solid rgba(255,255,255,.8);
    box-shadow: 0 6px 24px rgba(31, 38, 135, .08);
    view-transition-name: topbar;
}
.topbar .brand { font-weight: 700; font-size: .95rem; letter-spacing: .02em; color: var(--ink); white-space: nowrap; }
.topbar .brand small { display: block; font-weight: 500; font-size: .66rem; color: var(--muted); letter-spacing: .04em; }
.tabs { display: flex; padding: 3px; border-radius: 999px; background: rgba(15, 23, 42, .07); }
.tabs a {
    display: inline-flex; align-items: center; justify-content: center;
    min-height: 40px; padding: 0 16px; border-radius: 999px;
    font-size: .9rem; font-weight: 600; color: var(--muted); text-decoration: none; white-space: nowrap;
    transition: color .2s, background-color .25s, box-shadow .25s, transform .2s var(--ease-spring);
}
.tabs a:active { transform: scale(.95); }
.tabs a[aria-current="page"] { background: #fff; color: var(--ink); box-shadow: 0 2px 8px rgba(15, 23, 42, .14); view-transition-name: tab-pill; }
@media (max-width: 380px) { .topbar .brand small { display: none; } .tabs a { padding: 0 12px; } }

/* 旧ヘッダーは使わない */
.app-header { display: none !important; }
.app-container { max-width: 1080px; gap: 1rem; }

/* ---------- 2カラム（iPad以上）：左に歯列、右に判定 ---------- */
.stage { display: flex; flex-direction: column; gap: 1rem; }
@media (min-width: 820px) {
    .stage { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
    .stage > .chart-section { position: sticky; top: calc(var(--topbar-h) + 14px); }
}

.glass-panel { animation: panel-in .5s var(--ease-out) both; }
@keyframes panel-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- 歯列アーチ ---------- */
.dental-chart { overflow: visible !important; padding: .25rem 0 !important; }
.fdi-chart.arch { display: block; position: relative; width: 100%; max-width: 460px; margin: 0 auto; }
.fdi-chart.arch .quadrant { display: contents; }
.fdi-chart.arch .tooth-cell {
    position: absolute; left: 0; top: 0; margin: 0; flex: none; padding: 0;
    width: var(--w, 30px); height: var(--h, 40px);
    transform: translate(var(--x, 0), var(--y, 0)) rotate(var(--rot, 0deg)) scale(var(--sc, 1));
    border-radius: 12px; font-size: 1.02rem; font-weight: 600; font-family: inherit;
    background: linear-gradient(160deg, #ffffff 0%, #eef3f8 100%);
    border: 1px solid #cbd6e2; color: #33475b;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .10), inset 0 1px 0 #fff;
    transition: transform .38s var(--ease-spring), background .25s, border-color .25s, box-shadow .3s, color .25s;
    z-index: 1; cursor: pointer;
}
.fdi-chart.arch .tooth-cell > span { display: block; transform: rotate(calc(var(--rot, 0deg) * -1)); pointer-events: none; }
@media (hover: hover) { .fdi-chart.arch .tooth-cell:hover { --sc: 1.08; z-index: 3; box-shadow: 0 6px 14px rgba(15, 23, 42, .16), inset 0 1px 0 #fff; } }
.fdi-chart.arch .tooth-cell:active { --sc: .88; transition-duration: .08s; }
.fdi-chart.arch .tooth-cell:focus-visible { outline: 3px solid #2563eb; outline-offset: 2px; }

.fdi-chart.arch .tooth-cell.state-pontic {
    background: repeating-linear-gradient(135deg, rgba(231, 76, 60, .10) 0 5px, rgba(231, 76, 60, .02) 5px 10px);
    border: 2px dashed #e74c3c; color: #c0392b; box-shadow: 0 0 0 3px rgba(231, 76, 60, .12);
}
.fdi-chart.arch .tooth-cell.state-abutment {
    background: linear-gradient(160deg, #fbbf24 0%, #f59e0b 100%);
    border-color: #d98a06; color: #fff; text-shadow: 0 1px 1px rgba(120, 60, 0, .35);
    box-shadow: 0 4px 12px rgba(245, 158, 11, .45), inset 0 1px 0 rgba(255, 255, 255, .55);
}
.fdi-chart.arch .tooth-cell.just-set { animation: tooth-pop .45s var(--ease-spring); }
@keyframes tooth-pop { 0% { filter: brightness(1.35); } 100% { filter: none; } }

.arch-beam { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; overflow: visible; }
.arch-beam path { fill: none; stroke: #94a3b8; stroke-width: 9; stroke-linecap: round; stroke-linejoin: round; opacity: .55; transition: stroke .35s; }
.arch-beam.b-ok path { stroke: #4ade80; }
.arch-beam.b-check path { stroke: #fbbf24; }
.arch-beam.b-ng path { stroke: #f87171; }

.arch-label { position: absolute; transform: translate(-50%, -50%); font-size: .72rem; font-weight: 600; letter-spacing: .12em; color: #7b8a99; pointer-events: none; white-space: nowrap; }
.arch-label.side { font-size: .62rem; letter-spacing: .04em; opacity: .85; }

.chart-footer { margin-top: .6rem !important; align-items: center !important; padding: 0 .25rem !important; }
.chart-footer { flex-wrap: nowrap !important; }
.chart-footer .chart-instruction { flex: 1 1 0 !important; min-width: 0; font-size: .76rem; line-height: 1.45; color: var(--muted); }
.tool-row { display: flex; gap: .4rem; margin-left: auto; flex: 0 0 auto; }
.tool-row .secondary-btn { padding: .5rem .8rem; white-space: nowrap; }
.secondary-btn { min-height: 40px; border-radius: 10px; transition: transform .2s var(--ease-spring), background .2s, opacity .2s; }
.secondary-btn:active { transform: scale(.94); }
.secondary-btn:disabled { opacity: .4; cursor: default; }

/* ---------- 判定（ブリッジ）：可否＋理由1行＋材料 ---------- */
.result-section { gap: .75rem !important; }
.result-empty { opacity: 1 !important; }
.verdict {
    position: relative; overflow: hidden; border-radius: 18px; padding: 16px 16px 14px;
    background: rgba(255, 255, 255, .74); border: 1px solid rgba(255, 255, 255, .95);
    box-shadow: 0 8px 24px rgba(15, 23, 42, .08);
    transition: box-shadow .45s, border-color .45s;
}
.verdict::before { content: ''; position: absolute; inset: 0; opacity: 0; transition: opacity .45s; pointer-events: none; }
.verdict > * { position: relative; }
.result-ok .verdict { border-color: #86efac; box-shadow: 0 12px 34px rgba(22, 163, 74, .22); }
.result-ok .verdict::before { opacity: 1; background: linear-gradient(135deg, rgba(134, 239, 172, .55), rgba(220, 252, 231, .2) 70%); }
.result-check .verdict { border-color: #fcd34d; box-shadow: 0 12px 34px rgba(217, 119, 6, .2); }
.result-check .verdict::before { opacity: 1; background: linear-gradient(135deg, rgba(253, 224, 71, .5), rgba(254, 243, 199, .2) 70%); }
.result-ng .verdict { border-color: #fca5a5; box-shadow: 0 12px 34px rgba(220, 38, 38, .2); }
.result-ng .verdict::before { opacity: 1; background: linear-gradient(135deg, rgba(252, 165, 165, .55), rgba(254, 226, 226, .2) 70%); }

.result-section .verdict .status-badge {
    display: flex; align-items: center; gap: .5rem; margin: 0; padding: 0;
    background: none; box-shadow: none; border-radius: 0;
    font-size: 1.75rem; font-weight: 800; letter-spacing: .01em; line-height: 1.2; color: #7b8a99;
}
.result-section .verdict .status-badge svg { width: 1.35em; height: 1.35em; }
.result-ok .verdict .status-badge { color: var(--ok-ink); }
.result-ok .verdict .status-badge svg { color: var(--ok); }
.result-check .verdict .status-badge { color: var(--chk-ink); }
.result-check .verdict .status-badge svg { color: var(--chk); }
.result-ng .verdict .status-badge { color: var(--ng-ink); }
.result-ng .verdict .status-badge svg { color: var(--ng); }
.result-empty .verdict .status-badge { font-size: 1.15rem; font-weight: 700; }

.verdict.pop .status-badge { animation: verdict-in .5s var(--ease-spring) both; }
.verdict.pop .status-badge svg path { stroke-dasharray: 80; animation: icon-draw .7s .1s var(--ease-out) both; }
@keyframes verdict-in { from { opacity: 0; transform: translateY(10px) scale(.94); filter: blur(5px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes icon-draw { from { stroke-dashoffset: 80; } to { stroke-dashoffset: 0; } }

.verdict-reasons { margin-top: .45rem; display: flex; flex-direction: column; gap: .3rem; }
.verdict-reason { display: flex; gap: .45rem; align-items: flex-start; font-size: .95rem; line-height: 1.5; color: var(--ink); animation: fade-up .4s var(--ease-out) both; }
.verdict-reason .dot { flex: 0 0 auto; width: .6rem; height: .6rem; margin-top: .45rem; border-radius: 50%; background: #94a3b8; }
.verdict-reason.ok .dot { background: var(--ok); }
.verdict-reason.check .dot { background: var(--chk); }
.verdict-reason.ng .dot { background: var(--ng); }
.verdict-reason .txt { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.verdict-hint { margin-top: .35rem; font-size: .9rem; line-height: 1.6; color: var(--muted); }

.mat-chips { margin-top: .7rem; display: flex; flex-wrap: wrap; gap: .4rem; }
.mat-chips:empty { display: none; }
.mat-chips .cap { flex: 1 0 100%; font-size: .72rem; font-weight: 700; letter-spacing: .08em; color: var(--muted); }
.mat-chip {
    display: inline-flex; align-items: center; gap: .35rem; padding: .32rem .65rem; border-radius: 999px;
    font-size: .8rem; font-weight: 600; line-height: 1.3; background: #fff; border: 1px solid #d5dde6; color: var(--ink);
    animation: chip-in .45s var(--ease-spring) both; animation-delay: calc(var(--i, 0) * 45ms);
}
.mat-chip::before { content: ''; width: .5rem; height: .5rem; border-radius: 50%; background: #94a3b8; flex: 0 0 auto; }
.mat-chip.ok { background: #f0fdf4; border-color: #86efac; color: var(--ok-ink); }
.mat-chip.ok::before { background: var(--ok); }
.mat-chip.check { background: #fffbeb; border-color: #fcd34d; color: var(--chk-ink); }
.mat-chip.check::before { background: var(--chk); }
@keyframes chip-in { from { opacity: 0; transform: translateY(6px) scale(.9); } to { opacity: 1; transform: none; } }
@keyframes fade-up { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* 支台歯の生活歯／失活歯：2択ボタン */
.vital-section { padding: 0 !important; background: none !important; border: 0 !important; box-shadow: none !important; -webkit-backdrop-filter: none !important; backdrop-filter: none !important; animation: none; }
.vital-section[hidden] { display: none; }
.vital-section h2 { font-size: .8rem; font-weight: 700; letter-spacing: .04em; color: var(--muted); margin: 0 0 .4rem; }
.vital-section h2 small { font-weight: 500; letter-spacing: 0; }
.vital-rows { gap: .45rem !important; }
.vq-row { display: inline-flex; align-items: center; gap: .45rem; padding: .25rem .3rem .25rem .7rem; border-radius: 12px; background: rgba(255, 255, 255, .7); border: 1px solid #f3c56b; animation: chip-in .4s var(--ease-spring) both; }
.vq-row .no { font-weight: 700; font-size: .95rem; min-width: 1.6em; }
.vq-seg { display: inline-flex; padding: 2px; border-radius: 10px; background: rgba(15, 23, 42, .07); }
.vq-seg button {
    min-height: 38px; min-width: 58px; padding: 0 .6rem; border: 0; border-radius: 8px; background: transparent;
    font: inherit; font-size: .85rem; font-weight: 600; color: var(--muted); cursor: pointer;
    transition: background .2s, color .2s, box-shadow .2s, transform .2s var(--ease-spring);
}
.vq-seg button:active { transform: scale(.92); }
.vq-seg button[aria-pressed="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 5px rgba(15, 23, 42, .18); }
.hemi-section { margin-top: .2rem; }
.hemi-note, .vital-note { font-size: .78rem !important; }

/* 根拠・確認事項（折りたたみ） */
.detail-fold { border-radius: 14px; background: rgba(255, 255, 255, .55); border: 1px solid rgba(255, 255, 255, .9); }
.detail-fold > summary {
    list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: .5rem;
    min-height: 48px; padding: 0 1rem; font-weight: 600; font-size: .92rem; color: var(--ink); border-radius: 14px;
}
.detail-fold > summary::-webkit-details-marker { display: none; }
.detail-fold > summary::after { content: ''; width: .55rem; height: .55rem; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); transition: transform .3s var(--ease-out); margin-right: .2rem; }
.detail-fold[open] > summary::after { transform: rotate(-135deg); }
.detail-fold > summary .sub { font-weight: 500; font-size: .78rem; color: var(--muted); margin-left: .4rem; }
.detail-fold[open] > .result-details, .detail-fold[open] > .fold-in { animation: fade-up .35s var(--ease-out) both; }
.detail-fold .result-details { background: none; padding: .25rem 1rem 1rem; font-size: .92rem; }
.result-empty .detail-fold { display: none; }

.disclaimer-fold { margin-top: 0; }
.disclaimer-fold .disclaimer-section { background: none; border: 0; padding: .25rem 1rem 1rem; }
.disclaimer-fold .disclaimer-section h3 { display: none; }

.ad-slot { min-height: 80px; }

/* CAD/CAM側の歯の状態色（アーチ表示でも効かせる） */
.fdi-chart.arch .tooth-cell.s-natural  { background: #eef7ee; border-color: #8fc79a; }
.fdi-chart.arch .tooth-cell.s-missing  { background: #f1f3f4; border: 1px dashed #78909c; color: #78909c; }
.fdi-chart.arch .tooth-cell.s-pontic   { background: rgba(231, 76, 60, .08); border: 1px dashed #e74c3c; color: #c0392b; }
.fdi-chart.arch .tooth-cell.s-crown    { background: #fff6e0; border-color: #d4a24c; }
.fdi-chart.arch .tooth-cell.s-abutment { background: #e3edfa; border-color: #3f6fb5; }
.fdi-chart.arch .tooth-cell.s-implant  { background: #e0f2f1; border-color: #26a69a; }
.fdi-chart.arch .tooth-cell.s-denture  { background: #fbeee6; border-color: #d98e5f; }
.fdi-chart.arch .tooth-cell.is-picked {
    background: linear-gradient(160deg, #fbbf24 0%, #f59e0b 100%); border-color: #d98a06; color: #fff;
    box-shadow: 0 4px 12px rgba(245, 158, 11, .45), inset 0 1px 0 rgba(255, 255, 255, .55);
}
.hemi-section:not(.has-choice) .hemi-note { display: none; }
.hemi-row { white-space: nowrap; }
.hemi-row select { min-width: 0; flex: 1 1 auto; }

/* ---------- CAD/CAM 側 ---------- */
.wiz-steps { view-transition-name: wiz-steps; }
body.wiz .wstep.is-on { animation: step-in .42s var(--ease-out) both; }
@keyframes step-in { from { opacity: 0; transform: translateX(22px); } to { opacity: 1; transform: none; } }
.type-btn, .chip, .wiz-dot, .primary-btn, .seg-btn, .hint-chip { transition: transform .2s var(--ease-spring), background .2s, box-shadow .2s, border-color .2s, color .2s; }
.type-btn:active, .chip:active, .primary-btn:active, .seg-btn:active, .hint-chip:active { transform: scale(.94); }
.overall { animation: verdict-in .5s var(--ease-spring) both; border-left-width: 0 !important; padding: 16px !important; border-radius: 18px !important; border: 1px solid rgba(255,255,255,.95); box-shadow: 0 8px 24px rgba(15, 23, 42, .08); }
.overall.v-OK { background: linear-gradient(135deg, rgba(134, 239, 172, .6), rgba(240, 253, 244, .75) 70%) !important; border-color: #86efac; box-shadow: 0 12px 34px rgba(22, 163, 74, .22); }
.overall.v-COND { background: linear-gradient(135deg, rgba(253, 230, 138, .65), rgba(255, 251, 235, .75) 70%) !important; border-color: #fcd34d; box-shadow: 0 12px 34px rgba(202, 138, 4, .2); }
.overall.v-CHK { background: linear-gradient(135deg, rgba(253, 186, 116, .6), rgba(255, 247, 237, .75) 70%) !important; border-color: #fdba74; box-shadow: 0 12px 34px rgba(217, 119, 6, .2); }
.overall.v-NG { background: linear-gradient(135deg, rgba(252, 165, 165, .6), rgba(254, 242, 242, .75) 70%) !important; border-color: #fca5a5; box-shadow: 0 12px 34px rgba(220, 38, 38, .2); }
.overall-head .badge { font-size: 1.75rem !important; font-weight: 800; }
.overall-title { font-size: 1.05rem; font-weight: 700; color: var(--ink); }

.mx { margin-top: .8rem; display: flex; flex-direction: column; gap: .55rem; }
.mx-cap { font-size: .78rem; font-weight: 700; letter-spacing: .04em; color: var(--muted); }
.mx-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .4rem; }
.mx-rowlbl { font-size: .8rem; font-weight: 600; color: var(--ink); margin-bottom: -.2rem; }
.mx-cell {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .1rem;
    min-height: 62px; padding: .3rem .1rem; border-radius: 14px; border: 1px solid #d5dde6; background: #fff;
    font: inherit; color: var(--ink); cursor: pointer;
    animation: chip-in .45s var(--ease-spring) both; animation-delay: calc(var(--i, 0) * 45ms);
    transition: transform .2s var(--ease-spring), box-shadow .2s;
}
.mx-cell:active { transform: scale(.92); }
.mx-cell .k { font-size: 1.1rem; font-weight: 800; line-height: 1.1; }
.mx-cell .v { font-size: .74rem; font-weight: 700; line-height: 1.2; text-align: center; }
.mx-cell.v-OK { background: #f0fdf4; border-color: #86efac; color: var(--ok-ink); }
.mx-cell.v-COND { background: #fefce8; border-color: #fde047; color: #713f12; }
.mx-cell.v-CHK { background: #fff7ed; border-color: #fdba74; color: var(--chk-ink); }
.mx-cell.v-NG { background: #fef2f2; border-color: #fca5a5; color: var(--ng-ink); opacity: .85; }
.mx-note { font-size: .78rem; color: var(--muted); line-height: 1.5; }

@media (max-width: 600px) {
    body { padding-left: .6rem !important; padding-right: .6rem !important; padding-bottom: 1.2rem !important; }
    .glass-panel { padding: 1rem .8rem !important; }
    .result-section .verdict .status-badge { font-size: 1.6rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; transition-duration: .01ms !important; }
    html { scroll-behavior: auto; }
}

/* CAD/CAM：進行表示を薄く、結果画面は判定を先頭に */
.wiz-steps .wiz-dot { display: flex; flex-direction: row; align-items: center; justify-content: center; gap: .35rem; padding: .35rem .2rem; min-height: 44px; }
.wstep > h2 { font-size: 1.02rem; margin-bottom: .6rem; }
body.wiz section.wstep[data-wstep="4"].is-on { display: flex; flex-direction: column; }
section.wstep[data-wstep="4"] > h2 { order: 0; position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
section.wstep[data-wstep="4"] > #result { order: 1; }
section.wstep[data-wstep="4"] > .wiz-recap { order: 2; margin: .8rem 0 0; }
section.wstep[data-wstep="4"] > * { order: 3; }
section.wstep[data-wstep="4"] > #result { order: 1; }
section.wstep[data-wstep="4"] > .wiz-recap { order: 2; }

/* 判定に効いた前提（判定のすぐ下に1行） */
.premise { margin-top: .5rem; padding: .55rem .8rem; border-radius: 12px; background: rgba(255,255,255,.7); border: 1px dashed #b6c2cf; font-size: .82rem; line-height: 1.6; color: var(--ink); display: flex; flex-wrap: wrap; gap: .4rem .6rem; align-items: center; }

/* 2026-11-18 先生決定：無料公開・広告なし。広告枠は出さない（マークアップは残す） */
.ad-side, .ad-slot { display: none !important; }
/* 制作表記・外部送信の開示 */
.site-foot { max-width: 960px; margin: 1.2rem auto 2rem; padding: 0 16px; text-align: center; color: #607d8b; }
.site-foot-made { font-size: .85rem; margin: 0 0 .4rem; }
.site-foot-made a { color: #2c3e50; font-weight: 700; }
.site-foot-note { font-size: .72rem; line-height: 1.7; margin: 0; text-align: left; overflow-wrap: anywhere; }
