:root {
  color-scheme: light;
  --ivory: #f8f6f2;
  --paper: #fff;
  --ink: #242135;
  --muted: #625d70;
  --violet: #4a3b9c;
  --deep: #332767;
  --lilac: #eee9f4;
  --line: #ddd7e4;
  --error: #9a204b;
  --display: Fraunces, Georgia, serif;
  --sans: Inter, system-ui, sans-serif;
  font-family: var(--sans);
  color: var(--ink);
  background: var(--ivory);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body, h1, h2, p { margin: 0; }
.wrap { width: min(1040px, calc(100% - 72px)); margin-inline: auto; }

.site-header { border-bottom: 1px solid var(--line); }
.site-header .wrap {
  min-height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand { display: block; width: 148px; height: auto; }
.home-link { color: var(--deep); padding-block: 12px; font-size: 14px; text-underline-offset: 3px; }

main { padding-block: clamp(30px, 6vw, 72px) 56px; }
.intro { margin-bottom: 25px; }
h1 {
  font: 450 clamp(38px, 6vw, 64px)/1.02 var(--display);
  letter-spacing: -0.045em;
}
.intro p { margin-top: 12px; color: var(--muted); font-size: 17px; line-height: 1.55; }

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 0.86fr) minmax(0, 1.14fr);
  grid-template-areas: "form result" "explanation result";
  gap: 16px;
  align-items: start;
}
.form-card, .result-card, .explanation {
  min-width: 0;
  padding: clamp(21px, 3.25vw, 33px);
  border-radius: 18px;
}
.form-card, .explanation {
  border: 1px solid var(--line);
  background: var(--paper);
}

.form-card { grid-area: form; box-shadow: 0 8px 22px #33276708; }
.form-card label { display: block; margin-bottom: 9px; font-size: 15px; font-weight: 650; }
.dose-field {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 60px;
  padding-inline: 14px;
  border: 1px solid #b8aec8;
  border-radius: 10px;
  background: #fdfcfe;
}
.dose-field:focus-within { border-color: var(--violet); box-shadow: 0 0 0 3px #4a3b9c26; }
.dose-field:has([aria-invalid="true"]) { border-color: var(--error); }
.dose-field input {
  flex: 1;
  width: 0;
  padding-block: 9px;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
  font: 600 27px/1.1 var(--sans);
  font-variant-numeric: tabular-nums;
}
.dose-field input::placeholder { color: #796f87; opacity: 1; }
.dose-field > span { color: var(--muted); font-weight: 600; font-size: 15px; }
.input-error { margin-top: 8px; color: var(--error); font-size: 14px; line-height: 1.45; }
.submit {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 50px;
  margin-top: 16px;
  padding: 10px 14px;
  border: 0;
  border-radius: 10px;
  background: var(--violet);
  color: #fff;
  font: 650 15px/1.35 var(--sans);
  text-align: left;
  cursor: pointer;
}
.submit:hover { background: var(--deep); }
.submit:focus-visible, .home-link:focus-visible { outline: 3px solid var(--deep); outline-offset: 4px; }
.submit > span { font-size: 21px; line-height: 1; }

.result-card {
  grid-area: result;
  padding-bottom: clamp(18px, 3vw, 28px);
  color: #fff;
  background: radial-gradient(ellipse at 105% -5%, #544696 0%, transparent 67%), var(--deep);
  box-shadow: 0 14px 32px #33276722;
}
.result-card h2, .explanation h2 { font: 520 23px/1.2 var(--display); letter-spacing: -0.025em; }
.result-live { margin-top: 13px; }
.result-summary { color: #f1ebff; font-size: 15px; line-height: 1.5; }
.setting-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 9px 16px;
}
.setting-value { display: flex; align-items: baseline; gap: 9px; }
#setting {
  font: 650 clamp(50px, 7.5vw, 76px)/0.98 var(--sans);
  letter-spacing: -0.06em;
  font-variant-numeric: tabular-nums;
}
#setting-unit { color: #f1ebff; font-size: 16px; }
.requested-dose {
  display: grid;
  gap: 3px;
  min-width: 0;
  font-size: 13px;
  color: #ebe5fa;
}
.requested-dose strong { color: #fff; font-size: 16px; overflow-wrap: anywhere; }
.result-detail { margin-top: 13px; color: #f1ebff; font-size: 15px; line-height: 1.5; }
.result-detail strong { color: #fff; }

.dial-visual {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  container-type: inline-size;
  aspect-ratio: 3.5;
  margin-top: 20px;
  border-radius: 12px;
  background: #fcfcfc;
}
.pen-photo {
  position: absolute;
  width: 225%;
  left: -116.5%;
  top: -187.5%;
}
.pen-photo img { display: block; width: 100%; height: auto; }
.dial-window {
  position: absolute;
  left: 76.98%;
  top: 43.95%;
  width: 4.67%;
  height: 5.65%;
  overflow: hidden;
  border-radius: 22% 9% 9% 18%;
  background: linear-gradient(#b8bbb8, #f3f5ec 35%, #f5f6ef 65%, #b8bbb8);
  box-shadow: inset 0 0 2px #2f2c3266;
  color: #202120;
  font-size: clamp(9px, 4.1cqw, 18px);
}
.dial-scale {
  position: absolute;
  inset-inline: 0;
  top: 50%;
  text-align: center;
  font-family: var(--sans);
  font-style: italic;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.dial-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.12em;
  height: 0.7em;
  line-height: 1;
}
.dial-mark::before { content: ""; width: 0.25em; height: 1px; background: currentColor; }
.dial-mark span { min-width: 1.5ch; }
.dial-mark:has(span:empty)::before { width: 0.34em; }
.dial-window::after {
  position: absolute;
  inset: 0;
  content: "";
  pointer-events: none;
  background: linear-gradient(#30342f30, transparent 26%, transparent 74%, #30342f30);
}
.dial-visual[data-active="true"] .dial-window {
  outline: 1px solid #4a3b9caa;
  outline-offset: -1px;
}

.explanation { grid-area: explanation; }
.explanation > p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.58;
}
.explanation > p strong { color: var(--ink); font-weight: 650; }
.example {
  display: grid;
  gap: 4px;
  margin-top: 13px;
  padding: 10px 12px;
  border-radius: 9px;
  background: #f2edf7;
  color: var(--deep);
  font-size: 13px;
  line-height: 1.45;
}
.example-label { color: #574974; }
.example span { margin-inline: 3px; }

@media (max-width: 720px) {
  .wrap { width: calc(100% - 32px); }
  .site-header .wrap { min-height: 60px; }
  .brand { width: 126px; }
  main { padding-bottom: 32px; }
  .intro { margin-bottom: 16px; }
  .intro p { margin-top: 9px; font-size: 16px; }
  .workspace {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "form" "result" "explanation";
    gap: 12px;
  }
  .result-card h2, .explanation h2 { font-size: 21px; }
  .dial-visual { margin-top: 14px; }
}
