:root {
  color-scheme: light;
  --ink: #16313d;
  --muted: #5e737c;
  --navy: #0b4f6c;
  --teal: #047c70;
  --aqua: #d9f4ef;
  --line: #d6e2e6;
  --paper: #ffffff;
  --wash: #f2f7f8;
  --warning: #8a4d00;
  --warning-bg: #fff4dd;
  --danger: #a12a2a;
  --danger-bg: #fff0f0;
  font-family: "Noto Sans JP", "Yu Gothic", Meiryo, system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: transparent; }
body { margin: 0; color: var(--ink); background: var(--wash); font-size: 16px; line-height: 1.55; }
button, input, select { font: inherit; }
.app-shell { max-width: 1080px; margin: 0 auto; padding: 14px; }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.inputs { display: grid; gap: 14px; }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 18px; box-shadow: 0 6px 20px rgba(26, 67, 82, .055); }
.section-heading { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.section-heading > span { display: grid; width: 28px; height: 28px; place-items: center; border-radius: 8px; background: var(--navy); color: #fff; font-size: .85rem; font-weight: 800; }
h2 { margin: 0; font-size: 1.08rem; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 12px; }
.field { display: grid; align-content: start; grid-template-rows: auto auto auto; gap: 6px; color: #294752; font-size: .87rem; font-weight: 700; }
.field-grid > .full { grid-column: 1 / -1; }
.field-label { display: block; min-height: 1.55em; }
.field small, .custom-part small { display: block; color: var(--muted); font-size: .75rem; font-weight: 500; }
input, select { min-width: 0; width: 100%; height: 43px; border: 1px solid #b9cbd1; border-radius: 9px; padding: 9px 10px; background: #fff; color: var(--ink); }
input:focus, select:focus { outline: 3px solid rgba(4, 124, 112, .16); border-color: var(--teal); }
input:disabled, select:disabled { color: #7c8b91; background: #edf2f3; cursor: not-allowed; }
.input-with-unit { display: grid; grid-template-columns: 1fr minmax(95px, .45fr); gap: 6px; }
.symbol { font-family: "Times New Roman", Times, serif; font-style: italic; }
.field-help a { color: var(--navy); font-weight: 800; text-underline-offset: 2px; }
.details-box { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.details-box summary { cursor: pointer; color: var(--navy); font-size: .86rem; font-weight: 800; }
.details-content { padding-top: 12px; }
.field-help { margin: 0; color: var(--muted); font-size: .76rem; font-weight: 500; }
.section-note { margin: -6px 0 12px; color: var(--muted); font-size: .82rem; }
.parts-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.part-row { display: grid; grid-template-columns: 1fr 72px; align-items: center; gap: 8px; min-height: 46px; padding: 7px 8px 7px 10px; border: 1px solid var(--line); border-radius: 10px; }
.part-row label { font-size: .82rem; font-weight: 700; line-height: 1.35; }
.part-row input { min-height: 36px; padding: 6px 8px; text-align: center; }
.coefficient-list { display: grid; gap: 8px; padding: 12px 0 8px; }
.coefficient-item { display: grid; grid-template-columns: minmax(145px, .8fr) 58px 1.4fr; gap: 8px; padding-bottom: 8px; border-bottom: 1px dashed var(--line); font-size: .75rem; }
.coefficient-item strong:nth-child(2) { color: var(--teal); }
.custom-part { display: grid; grid-template-columns: 1fr 92px 92px; align-items: end; gap: 10px; margin-top: 14px; padding: 12px; border-radius: 11px; background: #eef4f6; }
.custom-part label { font-size: .8rem; font-weight: 800; }
.form-actions { display: flex; justify-content: flex-end; margin-top: 14px; }
.form-actions button { min-height: 42px; border: 1px solid #9db4bd; border-radius: 9px; padding: 8px 16px; color: var(--navy); background: #fff; font-weight: 800; cursor: pointer; }
.form-actions button:hover { background: var(--wash); }
.form-actions button:focus-visible { outline: 3px solid rgba(4, 124, 112, .16); border-color: var(--teal); }
.results { position: static; }
.hero-result { display: grid; grid-template-columns: 1fr auto; align-items: end; padding: 16px; border-radius: 12px; color: #fff; background: linear-gradient(135deg, #0b4f6c, #047c70); }
.hero-result p { grid-column: 1 / -1; margin: 0 0 4px; font-size: .82rem; font-weight: 700; opacity: .85; }
.hero-result strong { font-size: clamp(1.7rem, 4vw, 2.6rem); line-height: 1; }
.hero-result span { font-size: .84rem; opacity: .9; }
.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-top: 8px; }
.metric-grid article { min-width: 0; padding: 9px; border-radius: 9px; background: var(--wash); }
.metric-grid article > span { display: block; color: var(--muted); font-size: .69rem; white-space: nowrap; }
.metric-grid article > span .symbol { display: inline; color: inherit; font-size: inherit; }
.metric-grid strong { display: block; margin-top: 2px; font-size: .9rem; overflow-wrap: anywhere; }
.subsection-title { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 18px 0 8px; }
.subsection-title h3 { margin: 0; font-size: .95rem; }
.subsection-title span { color: var(--muted); font-size: .72rem; text-align: right; }
.breakdown { display: grid; gap: 7px; }
.breakdown-unavailable { margin: 0; padding: 10px 12px; border-radius: 9px; color: var(--muted); background: var(--wash); font-size: .78rem; }
.bar-row { display: grid; grid-template-columns: minmax(110px, 1fr) 2fr auto; align-items: center; gap: 8px; font-size: .75rem; }
.bar-track { height: 9px; overflow: hidden; border-radius: 99px; background: #e5edef; }
.bar-fill { height: 100%; min-width: 2px; border-radius: inherit; background: var(--teal); }
.bar-row:nth-child(2n) .bar-fill { background: #3c88a1; }
.method-details p { margin: 8px 0 0; font-size: .75rem; }
.method-values { display: grid; grid-template-columns: repeat(2, 1fr); gap: 5px 12px; padding-top: 10px; color: var(--muted); font-size: .75rem; }
.notice, .error-box { margin-bottom: 10px; padding: 10px 12px; border-radius: 9px; font-size: .82rem; }
.warning { color: var(--warning); background: var(--warning-bg); border: 1px solid #f1cf88; }
.error-box { color: var(--danger); background: var(--danger-bg); border: 1px solid #edb4b4; }

@media (max-width: 560px) {
  body { font-size: 16px; }
  .app-shell { padding: 10px; }
  .panel { padding: 14px; border-radius: 12px; }
  .field-grid, .parts-grid { grid-template-columns: 1fr; }
  .field-grid > .full { grid-column: auto; }
  .field-grid > .friction-help, .field-grid > .water-note { grid-column: 1 / -1; }
  .custom-part { grid-template-columns: 1fr 1fr; }
  .custom-part > div { grid-column: 1 / -1; }
  .coefficient-item { grid-template-columns: 1fr 46px; }
  .coefficient-item span { grid-column: 1 / -1; }
  .metric-grid { grid-template-columns: 1fr; }
  .form-actions button { width: 100%; }
  .bar-row { grid-template-columns: minmax(90px, 1fr) 1.25fr auto; }
}

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }
