:root {
  color-scheme: light;
  --photon-paper: #f5f4ef;
  --photon-surface: #fbfaf6;
  --photon-ink: #222824;
  --photon-muted: #687069;
  --photon-line: #cfd3cc;
  --photon-line-strong: #9fa79f;
  --photon-accent: #245b49;
  --photon-accent-soft: #e2ebe5;
  --photon-danger: #9b2f2f;
  --photon-danger-soft: #f8e9e7;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
}

* { box-sizing: border-box; }
button, input, select { font: inherit; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--photon-accent); outline-offset: 3px; }
h2, h3 { line-height: 1.35; }
h2 { margin: 0; font-size: clamp(1.2rem, 2vw, 1.48rem); }
h3 { margin: 0; font-size: 1rem; }

.photon-tool {
  display: grid;
  grid-template-columns: minmax(0, .92fr) minmax(0, 1.08fr);
  border: 1px solid var(--photon-line-strong);
  background: var(--photon-surface);
}

.photon-calculator,
.photon-results { min-width: 0; padding: 24px; }
.photon-calculator { border-right: 1px solid var(--photon-line); }
.section-heading { margin-bottom: 15px; }
.section-kicker { margin: 0 0 5px; }

.photon-mode-fieldset,
.photon-values-fieldset { margin: 17px 0 0; padding: 0; border: 0; }
.photon-mode-fieldset legend { margin-bottom: 8px; font-weight: 760; }
.photon-mode-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.photon-mode-option { position: relative; display: block; cursor: pointer; }
.photon-mode-option input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.photon-mode-option span {
  min-height: 50px;
  display: grid;
  place-items: center;
  padding: 7px 8px;
  border: 1px solid var(--photon-line);
  background: var(--photon-surface);
  color: var(--photon-muted);
  text-align: center;
  font-size: .86rem;
  font-weight: 700;
  line-height: 1.35;
}
.photon-mode-option input:checked + span { border-color: var(--photon-accent); background: var(--photon-accent-soft); color: var(--photon-accent); }
.photon-mode-option input:focus-visible + span { outline: 3px solid var(--photon-accent); outline-offset: 2px; }

.photon-input-area { display: grid; gap: 8px; }
.photon-input-label { display: block; margin-bottom: 5px; font-weight: 720; }
.photon-input-control { display: grid; grid-template-columns: minmax(0, 1fr) minmax(104px, .42fr); gap: 6px; }
.photon-input-control input,
.photon-unit-control select,
.photon-output-unit select {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  border: 1px solid var(--photon-line-strong);
  border-radius: 2px;
  padding: 9px 10px;
  color: var(--photon-ink);
  background: var(--photon-surface);
}
.photon-input-control input[aria-invalid="true"] { border-color: var(--photon-danger); background: #fff8f8; }
.photon-unit-control { min-width: 0; }
.photon-unit-control label { display: block; margin-bottom: 5px; color: var(--photon-muted); font-size: .78rem; font-weight: 700; }
.photon-field-help { margin: 4px 0 0; color: var(--photon-muted); font-size: .78rem; }
.photon-field-error { min-height: 1.25em; margin: 2px 0 0; color: var(--photon-danger); font-size: .82rem; }
.photon-form-error { margin: 12px 0 0; padding: 8px 10px; border-left: 4px solid var(--photon-danger); background: var(--photon-danger-soft); color: #762525; }
.photon-form-error[hidden] { display: none; }
.photon-form-actions { display: flex; gap: 8px; margin-top: 17px; }
.photon-button { min-height: 42px; border: 1px solid var(--photon-accent); border-radius: 2px; padding: 8px 15px; cursor: pointer; font-weight: 760; }
.photon-button-primary { background: var(--photon-accent); color: #fff; }
.photon-button-primary:hover { background: #1b4738; }
.photon-button-secondary { background: var(--photon-surface); color: var(--photon-accent); }
.photon-button:hover:not(:disabled) { border-color: var(--photon-ink); }

.photon-results-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.photon-status { flex: 0 0 auto; padding: 3px 8px; border: 1px solid var(--photon-line-strong); background: var(--photon-paper); color: var(--photon-muted); font-size: .75rem; font-weight: 760; }
.photon-status[data-state="ready"] { border-color: var(--photon-accent); background: var(--photon-accent-soft); color: var(--photon-accent); }
.photon-status[data-state="error"] { border-color: var(--photon-danger); background: var(--photon-danger-soft); color: var(--photon-danger); }
.photon-result-status { min-height: 3.2em; margin: 13px 0 0; color: #38413b; font-size: .9rem; overflow-wrap: anywhere; }
.photon-result-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 4px; }
.photon-result-item { min-width: 0; padding: 12px 11px; border: 1px solid var(--photon-line); background: var(--photon-paper); }
.photon-result-item-heading { display: grid; gap: 9px; }
.photon-result-item h3 { color: var(--photon-accent); font-size: .92rem; overflow-wrap: anywhere; }
.photon-output-unit { display: grid; gap: 3px; color: var(--photon-muted); font-size: .72rem; font-weight: 700; }
.photon-output-unit select { min-height: 36px; padding: 5px 7px; font-size: .84rem; }
.photon-result-value { display: block; min-height: 2.7em; margin-top: 12px; color: var(--photon-ink); font-size: clamp(1.12rem, 2.25vw, 1.58rem); line-height: 1.3; font-weight: 780; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.photon-result-si { min-height: 2.5em; margin: 6px 0 0; color: var(--photon-muted); font-size: .76rem; overflow-wrap: anywhere; }
.photon-result-equation { margin: 13px 0 0; padding-left: 11px; border-left: 3px solid var(--photon-line-strong); color: var(--photon-muted); font-size: .82rem; overflow-wrap: anywhere; }
.photon-results[data-state="error"] .photon-result-item { opacity: .7; }

.content-section { margin-top: 30px; padding-top: 25px; border-top: 1px solid var(--photon-line-strong); }
.photon-steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; margin: 0; padding: 0; border-block: 1px solid var(--photon-line); list-style: none; counter-reset: steps; }
.photon-steps li { position: relative; min-width: 0; padding: 35px 12px 13px; border-right: 1px solid var(--photon-line); counter-increment: steps; font-size: .88rem; overflow-wrap: anywhere; }
.photon-steps li:last-child { border-right: 0; }
.photon-steps li::before { content: counter(steps, decimal-leading-zero); position: absolute; top: 7px; left: 12px; color: var(--photon-accent); font-size: .75rem; font-weight: 800; }
.photon-example,
.photon-constants,
.photon-scope { margin-top: 18px; border: 1px solid var(--photon-line); }
.photon-example { padding: 12px 13px; background: var(--photon-accent-soft); }
.photon-example h3,
.photon-constants h3,
.photon-scope h3 { color: var(--photon-accent); font-size: .92rem; }
.photon-example p { margin: 6px 0 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.photon-formula-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid var(--photon-line); border-left: 1px solid var(--photon-line); }
.photon-formula-list article { min-width: 0; display: grid; gap: 3px; padding: 12px 13px; border-right: 1px solid var(--photon-line); border-bottom: 1px solid var(--photon-line); }
.photon-formula-list strong { overflow-wrap: anywhere; }
.photon-formula-list span { color: var(--photon-muted); font-size: .86rem; }
.photon-constants ul,
.photon-scope ul { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 0; padding: 0; list-style: none; }
.photon-constants li,
.photon-scope li { min-width: 0; padding: 10px 13px; border-top: 1px solid var(--photon-line); border-right: 1px solid var(--photon-line); color: var(--photon-muted); font-size: .84rem; overflow-wrap: anywhere; }
.photon-constants li:last-child,
.photon-scope li:last-child { border-right: 0; }

@media (max-width: 900px) {
  .photon-tool { grid-template-columns: 1fr; }
  .photon-calculator { border-right: 0; border-bottom: 1px solid var(--photon-line); }
}

@media (max-width: 700px) {
  .photon-result-grid,
  .photon-formula-list,
  .photon-constants ul,
  .photon-scope ul { grid-template-columns: 1fr; }
  .photon-constants li,
  .photon-scope li { border-right: 0; }
  .photon-constants li:first-child,
  .photon-scope li:first-child { border-top: 1px solid var(--photon-line); }
}

@media (max-width: 600px) {
  .photon-calculator,
  .photon-results { padding: 17px 14px; }
  .photon-mode-options { grid-template-columns: 1fr; }
  .photon-mode-option span { min-height: 43px; padding: 6px; font-size: .84rem; }
  .photon-input-control { grid-template-columns: minmax(0, 1fr) 96px; }
  .photon-form-actions { display: grid; grid-template-columns: 1fr; }
  .photon-button { width: 100%; }
  .photon-results-heading { gap: 8px; }
  .photon-status { max-width: 46%; overflow-wrap: anywhere; text-align: center; }
  .photon-steps { grid-template-columns: 1fr; }
  .photon-steps li { border-right: 0; border-bottom: 1px solid var(--photon-line); }
  .photon-steps li:last-child { border-bottom: 0; }
}

@media (max-width: 390px) {
  .photon-input-control { grid-template-columns: 1fr; }
  .photon-unit-control label { margin-top: 2px; }
  .photon-result-item { padding-inline: 9px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
