:root { font-family: "Hiragino Sans", "Yu Gothic", system-ui, sans-serif; color: #17364e; --blue: #2f5fb7; --line: #c3d2e0; }
* { box-sizing: border-box; }
body { margin: 0; background: linear-gradient(#f2f8ff, #fff 42%); }
.lab { width: min(100%, 720px); margin: auto; padding: 12px max(12px, env(safe-area-inset-right)) calc(18px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
.eyebrow { margin: 0 0 3px; color: var(--blue); font-size: 11px; font-weight: 800; letter-spacing: .08em; }
h1 { margin: 0 0 6px; font-size: 21px; }
.lead { margin: 0 0 10px; color: #5a6b83; font-size: 13px; line-height: 1.55; }

.tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.tabs button { flex: 1 1 0; min-height: 44px; border: 1px solid var(--line); border-radius: 11px; background: #fff; color: #17364e; font: inherit; font-size: 12.5px; font-weight: 700; cursor: pointer; touch-action: manipulation; }
.tabs button.active { border-color: var(--blue); color: #fff; background: var(--blue); }

.scene-wrap { width: 100%; border: 1px solid var(--line); border-radius: 14px; background: #f4f8fd; overflow: hidden; }
.scene { position: relative; width: 100%; height: min(58vh, 380px); touch-action: none; }
.scene canvas { display: block; width: 100%; height: 100%; cursor: grab; }
.scene-message { position: absolute; top: 50%; left: 50%; width: min(86%, 24rem); margin: 0; padding: 12px 16px; transform: translate(-50%, -50%); border-radius: 11px; background: #ffffffee; color: #41546c; text-align: center; font-size: 13px; line-height: 1.6; }

.panel { display: grid; gap: 9px; margin-top: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.panel label { display: grid; gap: 4px; color: #61728a; font-size: 12px; font-weight: 700; }
.panel select { min-height: 44px; padding: 0 10px; border: 1px solid var(--line); border-radius: 11px; background: #fff; color: #17364e; font: inherit; font-size: 15px; }
.panel output { color: var(--blue); font-size: 15px; font-weight: 800; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.filters button { flex: 1 1 auto; min-height: 44px; padding: 0 10px; border: 1px solid var(--line); border-radius: 11px; background: #fff; color: #17364e; font: inherit; font-size: 12.5px; font-weight: 700; cursor: pointer; touch-action: manipulation; }
.filters button.on { border-color: var(--blue); color: #fff; background: var(--blue); }
.dims { display: grid; gap: 8px; }

input[type="range"] { width: 100%; min-height: 44px; background: transparent; -webkit-appearance: none; appearance: none; accent-color: var(--blue); touch-action: manipulation; }
input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 99px; background: #dbe5f2; }
input[type="range"]::-moz-range-track { height: 6px; border-radius: 99px; background: #dbe5f2; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 28px; height: 28px; margin-top: -11px; border: 3px solid #fff; border-radius: 50%; background: var(--blue); box-shadow: 0 1px 4px #17384b55; cursor: pointer; }
input[type="range"]::-moz-range-thumb { width: 22px; height: 22px; border: 3px solid #fff; border-radius: 50%; background: var(--blue); box-shadow: 0 1px 4px #17384b55; cursor: pointer; }

.result { margin-top: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 13px; background: #fff; }
.lead-in { margin: 0 0 8px; font-size: 14px; font-weight: 700; }
.legend { display: grid; gap: 6px; margin-bottom: 4px; }
.legend span { display: flex; align-items: flex-start; gap: 7px; font-size: 12.5px; line-height: 1.5; }
.legend i { flex: 0 0 14px; width: 14px; height: 14px; margin-top: 2px; border-radius: 4px; }
.value-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; padding: 5px 0; border-bottom: 1px dashed #e2e9f2; }
.value-row:last-of-type { border-bottom: 0; }
.value-row span { min-width: 68px; color: #61728a; font-size: 12px; font-weight: 700; }
.value-row b { font-size: 17px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.value-row b.answer { color: var(--blue); font-size: 20px; }
.note { margin: 8px 0 0; color: #55657d; font-size: 12.5px; line-height: 1.7; }
.note.hint { padding: 8px 10px; border-radius: 9px; background: #fff6e2; color: #7a5a12; }
.formula { margin: 8px 0 0; padding: 9px 11px; border-radius: 9px; background: #eef3ff; color: #1c4482; font-size: 13.5px; font-weight: 700; text-align: center; }

@media (max-width: 420px) {
  h1 { font-size: 19px; }
  .tabs button { font-size: 11.5px; }
  .scene { height: min(52vh, 320px); }
  .value-row b.answer { font-size: 18px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
