/* Web AI診断 … 「検査成績書・健康診断票」のような紙の帳票をイメージしたデザイン */
:root {
  color-scheme: light;
  --desk: #dfe7ea;      /* 机（ページの背景） */
  --paper: #ffffff;     /* 用紙 */
  --ink: #15233c;       /* 文字（紺のインク） */
  --soft: #51617b;      /* 補足の文字 */
  --rule: #9db2cb;      /* 罫線 */
  --cell: #edf2f8;      /* 見出し欄の薄い青 */
  --seal: #bf3322;      /* 朱肉の赤（AI側） */
  --hand: #1f726b;      /* 人の手側の緑 */
  --warn: #8a5a00;
  --gothic: "BIZ UDPGothic", "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  --mincho: "BIZ UDPMincho", "Hiragino Mincho ProN", "Yu Mincho", serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--desk); color: var(--ink); font: 16px/1.75 var(--gothic); overflow-wrap: anywhere; }
a { color: #1c4fa0; }
h1, h2, h3, p, ul, table { margin: 0; }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid #1c4fa0; outline-offset: 2px; }

.top { padding: 10px 16px; font-size: 13px; max-width: 992px; margin: 0 auto; }
.top a { color: var(--ink); text-decoration: none; }
.top a:hover { text-decoration: underline; }
main { max-width: 992px; margin: 0 auto; padding: 0 16px 40px; display: grid; gap: 24px; }
main > * { min-width: 0; }

/* 受付欄 */
.intake { padding: 20px 0 4px; display: grid; gap: 14px; }
.intake h1 { font: 700 clamp(34px, 6vw, 52px)/1.2 var(--mincho); letter-spacing: .06em; }
.lead { max-width: 42em; }
.ask { background: var(--paper); border: 2px solid var(--ink); padding: 16px; display: grid; gap: 8px; }
.ask label { font-weight: 700; font-size: 14px; }
.ask-row { display: flex; gap: 10px; flex-wrap: wrap; }
.ask input { flex: 1 1 260px; min-width: 0; padding: 12px; font-size: 17px; border: 1px solid var(--ink); background: #fbfdff; border-radius: 0; }
.ask-row button { flex: 0 0 auto; padding: 12px 28px; font-weight: 700; background: var(--ink); color: #fff; border: 0; cursor: pointer; }
.ask-row button:hover { background: #27406b; }
.ask-row button:disabled { background: var(--soft); cursor: wait; }
.hint { font-size: 13px; color: var(--soft); }
.eg { border: 0; background: none; padding: 4px 2px; color: #1c4fa0; text-decoration: underline; cursor: pointer; font-size: 13px; margin-right: 8px; }
.error { background: #fff; border: 2px solid var(--seal); color: #8f2012; padding: 12px 16px; }
.wait { background: var(--paper); border: 1px solid var(--rule); padding: 14px 16px; display: grid; gap: 10px; }
.wait-bar { display: block; height: 6px; background: linear-gradient(90deg, var(--ink) 0 30%, transparent 30%) 0 0 / 200% 100% var(--cell); animation: run 1.4s linear infinite; }
@keyframes run { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* 用紙 */
.sheet { background: var(--paper); border: 1px solid var(--rule); padding: clamp(16px, 4vw, 40px); display: grid; gap: 18px; }
.sheet > * { min-width: 0; }
.sheet h2 { font: 700 20px/1.4 var(--gothic); border-bottom: 2px solid var(--ink); padding-bottom: 4px; margin-top: 14px; }
.sheet h2:first-child { margin-top: 0; }
.sheet h3 { font-size: 15px; margin-top: 6px; }
.small { font-size: 13px; color: var(--soft); }
.notes { padding-left: 1.3em; display: grid; gap: 6px; }

/* 表（帳票の罫線） */
.scroll { overflow-x: auto; }
.grid { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 1.6; }
.grid th, .grid td { border: 1px solid var(--rule); padding: 7px 10px; text-align: left; vertical-align: top; }
.grid th { background: var(--cell); font-weight: 700; }
.grid tbody th { width: 11.5em; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.r { text-align: right !important; }

/* 診断書の頭 */
.head { display: grid; grid-template-columns: 1fr auto; gap: 8px 24px; align-items: start; }
.head h2 { font: 700 30px/1.3 var(--mincho); letter-spacing: .3em; border: 0; margin: 0; padding: 0; }
.target { font-size: 14px; }
.target b { display: block; font-size: 17px; line-height: 1.5; }
.seal { width: 116px; height: 116px; border: 4px solid currentColor; border-radius: 50%; display: grid; place-content: center; text-align: center; font: 700 21px/1.15 var(--mincho); transform: rotate(-8deg); outline: 1px solid currentColor; outline-offset: -10px; }
.seal.ai { color: var(--seal); } .seal.mid { color: #5b5f69; } .seal.man { color: var(--hand); }

/* 点数と目盛り */
.score { border: 2px solid var(--ink); padding: 18px 20px; display: grid; grid-template-columns: auto 1fr; gap: 10px 32px; align-items: center; }
.score > * { min-width: 0; }
.pt { font: 700 80px/1 var(--gothic); font-variant-numeric: tabular-nums; white-space: nowrap; }
.pt small { font-size: 22px; margin-left: 4px; }
.score .lab { font-size: 13px; color: var(--soft); }
.verdict { font-size: 20px; font-weight: 700; line-height: 1.5; }
.ruler { grid-column: 1 / -1; padding-top: 26px; }
.ruler-bar { position: relative; display: grid; grid-template-columns: repeat(5, 1fr); height: 18px; border: 1px solid var(--ink); }
.ruler-bar span { border-right: 1px solid var(--ink); }
.ruler-bar span:nth-child(5) { border: 0; }
.ruler-bar span:nth-child(1) { background: #7fb3ad; } .ruler-bar span:nth-child(2) { background: #c3dbd8; } .ruler-bar span:nth-child(3) { background: #eceef1; } .ruler-bar span:nth-child(4) { background: #f0c5bd; } .ruler-bar span:nth-child(5) { background: #dd7b6d; }
.needle { position: absolute; top: -24px; width: 2px; height: 44px; background: var(--ink); margin-left: -1px; }
.needle::before { content: ""; position: absolute; top: 0; left: 50%; border: 8px solid transparent; border-top: 11px solid var(--ink); transform: translateX(-50%); }
.ruler-num { display: flex; justify-content: space-between; font-size: 12px; font-variant-numeric: tabular-nums; }
.ruler-lab { display: grid; grid-template-columns: repeat(5, 1fr); font-size: 12px; text-align: center; color: var(--soft); line-height: 1.3; }

/* 部位別 */
.bar { display: block; position: relative; height: 12px; background: var(--cell); min-width: 90px; border: 1px solid var(--rule); }
.bar i { position: absolute; inset: 0 auto 0 0; background: var(--seal); }
.bar.man i { background: var(--hand); }

/* 判断のポイント */
.ev { border: 1px solid var(--rule); display: grid; grid-template-columns: 104px 1fr; }
.ev + .ev { border-top: 0; }
.ev-pt { background: var(--cell); border-right: 1px solid var(--rule); padding: 12px 6px; text-align: center; font-weight: 700; font-size: 18px; line-height: 1.3; font-variant-numeric: tabular-nums; color: var(--seal); white-space: nowrap; }
.ev-pt small { white-space: normal; }
.ev-pt small { display: block; font-weight: 400; font-size: 11px; color: var(--soft); }
.ev.man .ev-pt { color: var(--hand); }
.ev-body { padding: 10px 14px; min-width: 0; display: grid; gap: 4px; }
.ev-body b { font-size: 15px; }
.ev-body p { font-size: 14px; line-height: 1.65; }
.sample { font: 12px/1.6 var(--mono); background: #f6f8fb; padding: 4px 8px; color: #33425c; }

/* 印（状態） */
.tag { display: inline-block; font-size: 12px; line-height: 1.5; padding: 0 7px; border: 1px solid currentColor; white-space: nowrap; font-weight: 700; }
.tag.ok { color: var(--hand); } .tag.ng { color: var(--seal); } .tag.warn { color: var(--warn); } .tag.info { color: #1c4fa0; }
.ver { font-weight: 700; font-variant-numeric: tabular-nums; }

/* 折りたたみ */
details { border: 1px solid var(--rule); }
details + details { margin-top: -19px; }
summary { cursor: pointer; padding: 11px 14px; font-weight: 700; background: var(--cell); }
summary small { font-weight: 400; color: var(--soft); margin-left: 8px; }
.fold { padding: 14px; display: grid; gap: 12px; }
.fold > * { min-width: 0; }
pre { margin: 0; font: 12px/1.6 var(--mono); background: #f6f8fb; padding: 10px; overflow: auto; max-height: 320px; white-space: pre-wrap; }

.acts { display: flex; flex-wrap: wrap; gap: 10px; }
.acts button, .acts a { border: 1px solid var(--ink); background: #fff; color: var(--ink); padding: 8px 16px; font-size: 14px; cursor: pointer; text-decoration: none; }
.acts button:hover, .acts a:hover { background: var(--cell); }
.alert { border: 2px solid var(--warn); padding: 10px 14px; font-size: 14px; }
.foot { text-align: center; font-size: 13px; padding: 10px 16px 40px; }

@media (max-width: 620px) {
  .head { grid-template-columns: 1fr auto; }
  .head h2 { font-size: 24px; letter-spacing: .15em; }
  .seal { width: 88px; height: 88px; font-size: 16px; border-width: 3px; outline-offset: -8px; }
  .score { grid-template-columns: 1fr; }
  .pt { font-size: 68px; }
  .verdict { font-size: 18px; }
  .ev { grid-template-columns: 64px 1fr; }
  .ev-pt { font-size: 16px; }
  .ruler-lab { font-size: 10px; }
  .ask-row button { flex: 1 1 100%; }
  /* 表は「見出しの下に内容」の形に並べ替える */
  .grid.kv tr { display: block; border: 1px solid var(--rule); border-bottom: 0; }
  .grid.kv tr:last-child { border-bottom: 1px solid var(--rule); }
  .grid.kv th, .grid.kv td { display: block; width: auto; border: 0; }
  .grid tbody th { width: auto; }
  .grid.kv th { padding: 4px 10px; font-size: 13px; }
  .grid.wide { min-width: 560px; }
}
@media (prefers-reduced-motion: reduce) { .wait-bar { animation-duration: 6s; } }
@media print {
  body { background: #fff; font-size: 12px; }
  .top, .intake, .about, .foot, .acts { display: none; }
  main { display: block; padding: 0; max-width: none; }
  .sheet { border: 0; padding: 0; }
  details > summary { break-after: avoid; }
  .ev, tr { break-inside: avoid; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
