:root {
  color-scheme: light;
  --redshift-paper: #f5f4ef;
  --redshift-surface: #fbfaf6;
  --redshift-ink: #222824;
  --redshift-muted: #687069;
  --redshift-line: #cfd3cc;
  --redshift-line-strong: #9fa79f;
  --redshift-accent: #245b49;
  --redshift-accent-soft: #e2ebe5;
  --redshift-warm: #a36b35;
  --redshift-warm-soft: #f1e7d9;
  --redshift-danger: #9b2f2f;
  --redshift-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; }

html,
body { max-width: 100%; overflow-x: hidden; }

button,
input,
select { font: inherit; }

a { color: inherit; }

:focus-visible {
  outline: 3px solid var(--redshift-accent);
  outline-offset: 3px;
}

h2,
h3 { line-height: 1.4; }

h2 { margin: 0; font-size: clamp(1.2rem, 2vw, 1.48rem); }

h3 { margin: 0; font-size: 1rem; }

.redshift-tool,
.calculator-panel,
.info-panel,
.input-row,
.result-list,
.examples-grid,
.formula-list { min-width: 0; }

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

.calculator-panel,
.info-panel { padding: 25px; }

.calculator-panel { border-right: 1px solid var(--redshift-line); }

.section-heading { margin-bottom: 15px; }

.section-kicker {
  margin: 0 0 5px;
  color: var(--redshift-accent);
  font-size: 0.76rem;
  font-weight: 780;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

fieldset {
  margin: 20px 0 0;
  padding: 0;
  border: 0;
}

legend {
  margin-bottom: 11px;
  font-weight: 760;
}

.input-row {
  display: grid;
  gap: 5px;
}

.input-row + .input-row { margin-top: 18px; }

.input-label {
  display: block;
  font-size: 0.84rem;
  font-weight: 760;
}

.value-with-unit {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(128px, auto);
  gap: 7px;
  min-width: 0;
}

.value-with-unit input,
.value-with-unit select {
  width: 100%;
  min-width: 0;
  min-height: 45px;
  padding: 8px 10px;
  border: 1px solid var(--redshift-line-strong);
  border-radius: 0;
  color: var(--redshift-ink);
  background: #fff;
}

.value-with-unit input:focus,
.value-with-unit select:focus,
.result-unit-control select:focus {
  border-color: var(--redshift-accent);
  outline: 3px solid var(--redshift-accent-soft);
  outline-offset: 0;
}

.value-with-unit input[aria-invalid="true"] {
  border-color: var(--redshift-danger);
  background: #fff8f8;
}

.field-help {
  margin: 0;
  color: var(--redshift-muted);
  font-size: 0.73rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.field-error {
  min-height: 1.25em;
  margin: 0;
  color: var(--redshift-danger);
  font-size: 0.78rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.form-error {
  margin: 15px 0 0;
  padding: 10px 12px;
  border-left: 4px solid var(--redshift-danger);
  background: var(--redshift-danger-soft);
  color: var(--redshift-danger);
  font-size: 0.84rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.form-error[hidden] { display: none; }

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 19px;
}

.button {
  min-height: 46px;
  padding: 9px 17px;
  border: 1px solid var(--redshift-accent);
  border-radius: 0;
  cursor: pointer;
  font-weight: 760;
}

.button-primary {
  color: #fff;
  background: var(--redshift-accent);
}

.button-primary:hover { background: #1d4d3e; }

.button-secondary {
  color: var(--redshift-accent);
  background: transparent;
}

.button-secondary:hover { background: var(--redshift-accent-soft); }

.result-box {
  margin-top: 20px;
  padding: 17px;
  border: 1px solid var(--redshift-line-strong);
  background: #fff;
}

.result-box[data-state="ready"] { border-color: var(--redshift-accent); }

.result-box[data-state="error"] { border-color: var(--redshift-danger); }

.compact-heading { margin-bottom: 10px; }

.result-status {
  min-height: 2.9em;
  margin: 0;
  color: var(--redshift-muted);
  font-size: 0.82rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.result-list {
  display: grid;
  margin: 14px 0 0;
  border-top: 1px solid var(--redshift-line);
  border-left: 1px solid var(--redshift-line);
}

.result-list > div {
  display: grid;
  grid-template-columns: minmax(112px, 0.74fr) minmax(0, 1.26fr);
  min-width: 0;
  border-right: 1px solid var(--redshift-line);
  border-bottom: 1px solid var(--redshift-line);
}

.result-list dt,
.result-list dd { min-width: 0; padding: 11px 12px; }

.result-list dt {
  color: var(--redshift-muted);
  font-size: 0.8rem;
  font-weight: 760;
}

.result-list dd {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
  margin: 0;
  color: var(--redshift-accent);
  font-size: 0.95rem;
  font-weight: 780;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
  text-align: right;
}

.result-unit-control {
  display: inline-grid;
  flex: 0 0 104px;
  gap: 3px;
  color: var(--redshift-muted);
  font-size: 0.68rem;
  font-weight: 700;
  text-align: left;
}

.result-unit-control select {
  width: 100%;
  min-height: 34px;
  padding: 4px 6px;
  border: 1px solid var(--redshift-line-strong);
  border-radius: 0;
  color: var(--redshift-ink);
  background: #fff;
  font-size: 0.8rem;
}

.shift-type {
  margin: 15px 0 0;
  padding: 10px 12px;
  border-left: 4px solid var(--redshift-accent);
  background: var(--redshift-accent-soft);
  color: var(--redshift-accent);
  font-weight: 780;
  overflow-wrap: anywhere;
}

.shift-type[data-kind="blue"] {
  border-left-color: #315b8c;
  background: #e8eef7;
  color: #234b79;
}

.shift-type[data-kind="zero"] {
  border-left-color: var(--redshift-line-strong);
  background: var(--redshift-paper);
  color: var(--redshift-muted);
}

.result-equation {
  margin: 13px 0 0;
  padding-left: 11px;
  border-left: 3px solid var(--redshift-line-strong);
  color: var(--redshift-muted);
  font-size: 0.8rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.steps-list {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  border-block: 1px solid var(--redshift-line);
  list-style: none;
  counter-reset: steps;
}

.steps-list li {
  position: relative;
  min-width: 0;
  padding: 32px 12px 12px;
  border-bottom: 1px solid var(--redshift-line);
  counter-increment: steps;
  font-size: 0.86rem;
  overflow-wrap: anywhere;
}

.steps-list li:last-child { border-bottom: 0; }

.steps-list li::before {
  content: counter(steps, decimal-leading-zero);
  position: absolute;
  top: 7px;
  left: 12px;
  color: var(--redshift-accent);
  font-size: 0.75rem;
  font-weight: 800;
}

.direction-guide,
.scope-note {
  margin-top: 19px;
  padding: 15px 16px;
  border: 1px solid var(--redshift-line);
}

.direction-guide { background: var(--redshift-surface); }

.direction-guide h3,
.scope-note h3 { color: var(--redshift-accent); font-size: 0.92rem; }

.direction-guide ul {
  margin: 8px 0 0;
  padding-left: 1.2em;
}

.direction-guide li { margin-top: 4px; overflow-wrap: anywhere; }

.scope-note {
  border-color: #d8c6ad;
  background: var(--redshift-warm-soft);
}

.scope-note p {
  margin: 7px 0 0;
  font-size: 0.8rem;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.content-section { margin-top: 43px; }

.examples-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--redshift-line);
  border-left: 1px solid var(--redshift-line);
}

.example-card {
  min-width: 0;
  padding: 14px 15px;
  border-right: 1px solid var(--redshift-line);
  border-bottom: 1px solid var(--redshift-line);
}

.example-card h3 { font-size: 0.92rem; }

.example-card p {
  margin: 7px 0 0;
  font-size: 0.8rem;
  line-height: 1.6;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.example-red { background: var(--redshift-accent-soft); }

.example-blue { background: #e8eef7; }

.example-zero { background: var(--redshift-paper); }

.formula-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 17px;
  border-top: 1px solid var(--redshift-line);
  border-left: 1px solid var(--redshift-line);
}

.formula-list article {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 14px 15px;
  border-right: 1px solid var(--redshift-line);
  border-bottom: 1px solid var(--redshift-line);
}

.formula-list strong { overflow-wrap: anywhere; }

.formula-list span {
  color: var(--redshift-muted);
  font-size: 0.81rem;
  line-height: 1.55;
}

.notes-box {
  margin-top: 20px;
  padding: 16px 17px;
  border: 1px solid var(--redshift-line);
  background: var(--redshift-surface);
}

.notes-box h3 { color: var(--redshift-accent); font-size: 0.92rem; }

.notes-box ul {
  margin: 10px 0 0;
  padding-left: 1.25em;
}

.notes-box li { margin-top: 5px; overflow-wrap: anywhere; }

@media (max-width: 760px) {
  .redshift-tool { grid-template-columns: 1fr; }

  .calculator-panel {
    border-right: 0;
    border-bottom: 1px solid var(--redshift-line);
  }
}

@media (max-width: 700px) {
  .examples-grid,
  .formula-list { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .calculator-panel,
  .info-panel { padding: 19px 14px; }

  .form-actions { display: grid; grid-template-columns: 1fr; }

  .button { width: 100%; }

  .result-list > div { grid-template-columns: minmax(96px, 0.72fr) minmax(0, 1.28fr); }

  .result-list dt,
  .result-list dd { padding: 9px 8px; }
}

@media (max-width: 380px) {
  .value-with-unit { grid-template-columns: 1fr; }

  .result-list > div { grid-template-columns: 1fr; }

  .result-list dt { padding-bottom: 4px; }

  .result-list dd { justify-content: flex-start; padding-top: 4px; text-align: left; }
}

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