/* ---- tools ---- */
.tool-hero .wrap { display: flex; flex-direction: column; gap: 14px; }
.tool-hero h1 { font-size: clamp(32px, 4.6vw, 52px); }
.tool-answer { max-width: 780px; font-size: 19px; }
.crumbs { font-size: 15px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; }
.crumbs a { color: var(--muted); }
.tool-main { padding-bottom: 24px; }

.tool-grid { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.tool-grid > * { flex: 1 1 340px; min-width: 0; }
.tool-panel { background: var(--white); border: 1px solid var(--line); border-radius: 16px; padding: 24px; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.tool-panel h2 { font-size: 24px; }
.tool-panel h3 { font-size: 19px; }
.tool-form { display: flex; flex-direction: column; gap: 16px; }
.tool-form .field label, .tool-form legend { font-weight: 600; font-size: 16px; }
.tool-form fieldset { border: 0; margin: 0; padding: 0; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.tool-form .help { font-size: 14px; color: var(--muted); }
.field-row { display: flex; flex-wrap: wrap; gap: 12px; }
.field-row > .field { flex: 1 1 140px; min-width: 0; }
.field-row > .field.narrow-field { flex: 0 1 150px; }
.tool-form input[type=text], .tool-form input[type=number], .tool-form select { min-height: 46px; padding: 10px 12px; }
.tool-form input.mono, .mono { font-family: var(--mono); }
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg label { position: relative; display: inline-flex; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg label > span { display: inline-block; padding: 9px 14px; border: 1px solid #7B8C97; border-radius: 10px; background: var(--white); cursor: pointer; font-weight: 500; font-size: 15px; }
.seg label > input:checked + span { background: var(--ink); color: var(--white); border-color: var(--ink); }
.seg label > input:focus-visible + span { outline: 3px solid #1D6FD8; outline-offset: 2px; }
#st-amounts { display: flex; flex-direction: column; gap: 12px; }
#st-amounts:empty { display: none; }
.tool-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.btn-tool { background: var(--accent); color: var(--white); }
.btn-tool:hover { background: var(--accent-dark); color: var(--white); }
.examples { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 14px; color: var(--muted); }
.examples button { font: inherit; font-size: 14px; font-family: var(--mono); background: var(--ground); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; cursor: pointer; color: var(--ink); }
.examples button:hover { border-color: var(--accent); background: var(--tint); }

.result-big { display: flex; flex-wrap: wrap; gap: 12px; }
.result-big .readout { flex: 1 1 120px; }
.result-big .readout b { font-size: 26px; }
.result-big .readout.main { background: var(--tint); border-color: #9CC9BC; }
.steps { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 12px; color: var(--text); }
.steps li { padding-left: 4px; min-width: 0; }
.steps li::marker { font-family: var(--mono); color: var(--accent); font-size: 14px; }
.steps .katex-display { margin: 6px 0; overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.math-scroll { overflow-x: auto; overflow-y: hidden; max-width: 100%; }
.tool-panel .katex-display { overflow-x: auto; overflow-y: hidden; }
.tool-out:empty { display: none; }
.tool-error { background: #FBE9E7; color: var(--error); border: 1px solid #E5AFA9; padding: 12px 14px; border-radius: 12px; font-weight: 500; }
.note-box { background: var(--ground); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; font-size: 15px; color: var(--text); }

table.tt { border-collapse: collapse; width: 100%; font-size: 16px; }
table.tt th, table.tt td { border-bottom: 1px solid var(--line); padding: 10px 10px; text-align: left; vertical-align: middle; }
table.tt thead th { font-size: 14px; color: var(--muted); font-weight: 600; }
table.tt tbody th { font-weight: 600; white-space: nowrap; }
table.tt td.num, table.tt th.num { text-align: right; font-family: var(--mono); font-size: 15px; white-space: nowrap; }
@media (max-width: 640px) { table.tt { font-size: 15px; } table.tt th, table.tt td { padding: 8px 6px; } table.tt tbody th { white-space: normal; } }
.table-wrap { overflow-x: auto; max-width: 100%; }

.tool-explain { display: flex; flex-direction: column; gap: 18px; max-width: 820px; }
.tool-explain h2 { margin-top: 12px; }
.tool-explain p, .tool-explain li { color: var(--text); }
.tool-explain ul, .tool-explain ol { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 8px; }
.tool-explain .katex-display { overflow-x: auto; overflow-y: hidden; }

.tool-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; list-style: none; margin: 0; padding: 0; }
.tool-cards li { display: flex; }
.tool-card { flex: 1; display: flex; flex-direction: column; gap: 6px; background: var(--white); border: 1px solid var(--line); border-radius: 14px; padding: 20px; text-decoration: none; color: var(--ink); }
.tool-card:hover { border-color: var(--accent); color: var(--ink); box-shadow: 0 2px 0 var(--accent); }
.tool-card .tag { font-family: var(--mono); font-size: 13px; color: var(--accent); text-transform: uppercase; letter-spacing: 0.05em; }
.tool-card .name { font-family: var(--display); font-weight: 700; font-size: 20px; line-height: 1.2; }
.tool-card .note { font-size: 15px; color: var(--muted); }

/* score calculator */
.score-badge { display: flex; align-items: center; gap: 18px; background: var(--ink); color: var(--on-dark); border-radius: 16px; padding: 20px; }
.score-badge .big { font-family: var(--display); font-weight: 700; font-size: 64px; line-height: 1; color: var(--yellow); }
.score-badge p { color: var(--on-dark-muted); font-size: 15px; }
.score-badge strong { color: var(--white); }
.meter { position: relative; height: 14px; background: var(--ground); border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.meter > i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--accent); border-radius: 999px; }
.meter > b { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--ink); opacity: 0.45; }
.frq-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
.frq-grid .field label { font-size: 14px; }

/* periodic table */
.pt-controls { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: flex-end; }
.pt-controls .field { min-width: 220px; }
.pt-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: 14px; background: var(--white); padding: 10px; }
table.pt { border-collapse: separate; border-spacing: 3px; table-layout: fixed; min-width: 900px; width: 100%; }
table.pt caption { text-align: left; font-size: 14px; color: var(--muted); padding: 0 4px 6px; }
table.pt th { font-family: var(--mono); font-weight: 500; font-size: 12px; color: var(--muted); padding: 2px; }
table.pt th.rowh { width: 28px; text-align: right; padding-right: 6px; }
table.pt th.rowh.f { font-size: 10px; width: 28px; writing-mode: horizontal-tb; }
table.pt td { padding: 0; height: 56px; }
table.pt tr.gap td { height: 12px; }
.el { width: 100%; height: 100%; min-height: 54px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; border: 1px solid rgba(14, 27, 42, 0.18); border-radius: 6px; background: #EEF2F1; color: var(--ink); font: inherit; cursor: pointer; padding: 2px; line-height: 1.1; }
.el .z { font-family: var(--mono); font-size: 10px; align-self: flex-start; padding-left: 2px; }
.el .s { font-family: var(--display); font-weight: 700; font-size: 17px; }
.el .v { font-family: var(--mono); font-size: 9.5px; white-space: nowrap; overflow: hidden; max-width: 100%; }
.el.dark-text { color: var(--white); border-color: rgba(255, 255, 255, 0.25); }
.el.nodata { background: repeating-linear-gradient(45deg, #F6F8F7, #F6F8F7 4px, #E7ECEA 4px, #E7ECEA 8px); color: var(--muted); }
.el:hover { outline: 2px solid var(--ink); outline-offset: 0; }
.el:focus-visible { outline: 3px solid #1D6FD8; outline-offset: 1px; position: relative; z-index: 1; }
.el[aria-pressed="true"] { outline: 3px solid var(--yellow); outline-offset: 0; box-shadow: 0 0 0 5px var(--ink); position: relative; z-index: 1; }
.fmark { font-family: var(--mono); font-size: 10px; color: var(--muted); display: flex; align-items: center; justify-content: center; height: 100%; border: 1px dashed var(--line); border-radius: 6px; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; font-size: 14px; color: var(--text); }
.legend .ramp { display: flex; align-items: center; gap: 8px; }
.legend .bar { width: 200px; max-width: 50vw; height: 14px; border-radius: 4px; border: 1px solid var(--line); }
.legend .sw { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw i { width: 16px; height: 16px; border-radius: 4px; display: inline-block; border: 1px solid rgba(14, 27, 42, 0.2); }
.el-panel { display: flex; flex-direction: column; gap: 12px; }
.el-head { display: flex; gap: 16px; align-items: center; }
.el-tile { width: 84px; height: 84px; flex: none; border-radius: 12px; background: var(--ink); color: var(--white); display: flex; flex-direction: column; align-items: center; justify-content: center; }
.el-tile b { font-family: var(--display); font-size: 34px; line-height: 1; }
.el-tile span { font-family: var(--mono); font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
dl.props { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin: 0; }
dl.props div { background: var(--ground); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
dl.props dt { font-size: 13px; color: var(--muted); }
dl.props dd { margin: 0; font-family: var(--mono); font-size: 16px; overflow-wrap: anywhere; }

/* formula sheet */
.fs-toc { display: flex; flex-wrap: wrap; gap: 8px; }
.fs-toc a { background: var(--white); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; text-decoration: none; font-size: 15px; font-weight: 500; }
.fs-section { display: flex; flex-direction: column; gap: 14px; scroll-margin-top: 16px; }
.fs-section > h2 { font-size: 28px; border-bottom: 2px solid var(--ink); padding-bottom: 6px; }
.fs-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; list-style: none; margin: 0; padding: 0; }
.fs-item { background: var(--white); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; display: flex; flex-direction: column; gap: 8px; break-inside: avoid; min-width: 0; }
.fs-item h3 { font-size: 17px; font-family: var(--body); font-weight: 600; }
.fs-item .eq { overflow-x: auto; overflow-y: hidden; font-size: 17px; }
.fs-item .eq .katex-display { margin: 4px 0; }
.fs-item dl { margin: 0; font-size: 14.5px; color: var(--text); display: grid; grid-template-columns: max-content 1fr; gap: 3px 10px; }
.fs-item dt { font-weight: 600; }
.fs-item dt .katex { font-weight: normal; }
.fs-item dd { margin: 0; }
.fs-item .where { font-size: 14px; }
.const-table td:first-child { min-width: 160px; }

@media (max-width: 640px) {
  .tool-panel { padding: 18px; }
  .tool-answer { font-size: 17px; }
  .score-badge .big { font-size: 52px; }
  .fs-list { grid-template-columns: 1fr; }
  .fs-item dl { grid-template-columns: 1fr; }
  .fs-item dd { margin-bottom: 4px; }
}

@media print {
  .site-header, .site-footer, .no-print, .crumbs, .band, #ai-widget, .ai-widget, .fs-toc, .tool-actions { display: none !important; }
  body { background: #fff; font-size: 11pt; }
  .section, .section-sm { padding: 8px 0; }
  .tool-hero h1 { font-size: 22pt; }
  .tool-answer { font-size: 11pt; }
  .fs-section > h2 { font-size: 15pt; }
  .fs-list { display: block; columns: 2; column-gap: 14px; }
  .fs-item { border: 1px solid #999; border-radius: 6px; padding: 8px 10px; margin-bottom: 8px; page-break-inside: avoid; }
  .fs-item .eq { overflow: visible; }
  a { color: #000; text-decoration: none; }
  .fs-item .where { display: none; }
}
