:root {
  color-scheme: light;
  font-family: "Noto Sans CJK JP", "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, system-ui, sans-serif;
  color: var(--ink);
  background: var(--page);
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
  --ink: #18313a;
  --muted: #45616a;
  --page: #edf4f2;
  --line: #ccdcd7;
  --accent: #145a51;
  --accent-dark: #143e43;
  --accent-soft: #e4f1ec;
  --accent-line: #a7c8be;
  --accent-rule: #77bea9;
  --header-note: #daefe9;
  --input-line: #78928f;
  --error: #8a3025;
}
:root[data-mode="21"] {
  --ink: #2b2340;
  --muted: #5a4a6e;
  --page: #f3eff8;
  --line: #ded4e8;
  --accent: #5a3f83;
  --accent-dark: #413063;
  --accent-soft: #ede5f6;
  --accent-line: #cab7df;
  --accent-rule: #ba9cda;
  --header-note: #f0e7f8;
  --input-line: #9080a3;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
h1, h2, h3, p, dd, dl { margin: 0; }
button, input, select { font: inherit; }
button, summary { cursor: pointer; }
button:disabled { cursor: default; }
button, input, summary, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
a { color: var(--accent); text-underline-offset: .2em; }
.wrap {
  width: min(100%, 49rem);
  margin-inline: auto;
  padding-inline: max(1rem, env(safe-area-inset-left)) max(1rem, env(safe-area-inset-right));
}
.masthead { background: var(--accent-dark); color: white; border-bottom: 3px solid var(--accent-rule); }
.heading { display: flex; align-items: center; gap: .875rem; padding-block: 1.15rem; }
.heading img { border-radius: 14px; width: 46px; height: 46px; flex: 0 0 auto; }
h1 { font-size: clamp(1.15rem, 3.3vw, 1.6rem); font-weight: 800; line-height: 1.3; letter-spacing: .015em; }
h1 span { display: block; font-size: .69em; font-weight: 600; color: var(--header-note); margin-top: .18rem; }
main { padding-block: 1.1rem max(1.25rem, env(safe-area-inset-bottom)); }
h2 { font-size: 1rem; line-height: 1.35; }
.mode-section h2 { margin-bottom: .45rem; }
.mode-switch { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
.mode-switch button {
  display: flex; align-items: center; gap: .55rem; min-width: 0; min-height: 50px;
  padding: .45rem .72rem; border: 1px solid var(--accent-line); border-radius: .7rem;
  color: var(--ink); background: #fff; text-align: left; line-height: 1.3;
}
.mode-switch button b { font-family: system-ui, sans-serif; font-size: 1.35rem; }
.mode-switch button span { font-size: .83rem; font-weight: 700; }
.mode-switch button small { font-size: .8em; }
.mode-switch button[aria-pressed="true"] { background: var(--accent); color: white; border-color: var(--accent); }
.mode-switch .selected-mark { opacity: 0; margin-inline-start: auto; }
.mode-switch button[aria-pressed="true"] .selected-mark { opacity: 1; }
.registry {
  margin-top: .7rem; border: 1px solid var(--accent-line); border-radius: .82rem;
  background: #fff;
}
.registry > summary { padding: .65rem .85rem; overflow-wrap: anywhere; }
.registry-counter {
  display: inline-block; margin-inline-start: .55rem; padding: .1rem .42rem; border-radius: .35rem;
  color: #63430b; background: #fff0cf; font-size: .78rem;
}
.registry-body { display: grid; gap: .6rem; padding: 0 .85rem .8rem; }
.registry-body label { display: block; margin-bottom: .22rem; font-size: .9rem; font-weight: 750; }
.registry select, .registry-editor > input {
  width: 100%; min-width: 0; min-height: 44px; padding: .4rem .52rem;
  border: 1px solid var(--input-line); border-radius: .55rem; color: var(--ink); background: #fff;
}
.registry-message { color: var(--muted); font-size: .88rem; }
.registry-message:empty { display: none; }
.registered-values { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 9.25rem), 1fr)); gap: .35rem; }
.registered-values > div { border-radius: .45rem; background: var(--accent-soft); padding: .4rem .55rem; }
.registered-values dt { color: var(--muted); font-size: .78rem; }
.registered-values dd { font-weight: 750; overflow-wrap: anywhere; }
.registry-expiry { margin-top: .4rem; color: #63430b; background: #fff0cf; padding: .4rem .55rem; font-size: .86rem; border-radius: .4rem; }
.registry [data-level="expired"] { color: #7c2c22; background: #ffebe6; }
.registry-actions { display: flex; flex-wrap: wrap; gap: .45rem; }
.registry-actions:has(> button:not([hidden])) { margin-block: .08rem; }
.registry button {
  padding: .4rem .62rem; min-height: 44px; border: 1px solid var(--input-line);
  border-radius: .48rem; color: var(--accent); background: #fff;
  font-size: .85rem; font-weight: 700;
}
.registry .registry-save { color: #fff; background: var(--accent); border-color: var(--accent); }
.registry .registry-delete { color: var(--error); }
.registry button:disabled, .complete:disabled { opacity: .62; }
.registry-editor { padding-top: .45rem; border-top: 1px solid var(--line); }
.registry-editor label { margin-top: .55rem; }
.registry-editor .registry-actions { margin-top: .7rem; }
.registry-editor .field-error { margin-top: .13rem; }
.registry-settings { border-top: 1px solid var(--line); }
.registry-settings > summary { font-size: .86rem; }
.registry-settings .hint { margin: 0 0 .45rem; }
.entry-panel {
  margin-top: .8rem; border: 1px solid var(--accent-line); border-radius: .82rem;
  background: var(--accent-soft);
}
.entry-panel > summary { padding: .65rem .85rem; }
.entry-panel .panel-open-label, .entry-panel[open] .panel-closed-label { display: none; }
.entry-panel[open] .panel-open-label { display: inline; }
.entry-form { display: grid; gap: .55rem; padding: 0 .68rem .68rem; }
.card {
  margin: 0; padding: .62rem .81rem;
  border: 1px solid var(--line); border-radius: .65rem; background: #fff; min-width: 0;
}
.card label { display: block; font-size: .92rem; font-weight: 750; line-height: 1.45; }
label, input { scroll-margin-block: 5rem; }
.simple-field {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 14rem);
  align-items: center; gap: .4rem 1.2rem;
}
.hint { margin-top: .23rem; color: var(--muted); font-size: .79rem; line-height: 1.5; }
.limit-hint { padding-inline: .23rem; color: var(--accent); font-size: .86rem; font-weight: 750; }
.prior { border-left: 4px solid var(--accent-rule); }
.entry { min-width: 0; }
.moneybox {
  display: flex; align-items: center; gap: .3rem; padding-right: .65rem;
  background: #fff; border: 1px solid var(--input-line); border-radius: .6rem; min-width: 0;
}
.moneybox:focus-within { border-color: var(--accent); outline: 2px solid var(--accent); outline-offset: 1px; }
.moneybox:has([aria-invalid="true"]) { border-color: var(--error); }
.moneybox input {
  width: 100%; min-width: 0; min-height: 45px; padding: .35rem .13rem .35rem .65rem;
  border: 0; border-radius: .6rem; color: var(--ink); background: transparent;
  font-family: system-ui, sans-serif; font-size: 1.27rem;
  font-variant-numeric: tabular-nums; font-weight: 740; text-align: right;
}
.moneybox input:focus { outline: none; }
.moneybox span { color: var(--muted); font-size: .84rem; }
.field-error { margin-top: .28rem; color: var(--error); font-size: .82rem; font-weight: 700; }
.current { border-top: 2px solid var(--accent-rule); }
.ratio-field { min-inline-size: 0; padding-top: .28rem; }
.ratio-field legend { padding-inline: .22rem; font-size: .92rem; font-weight: 750; }
.ratio-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 22rem; gap: .35rem; }
.ratio-options label {
  display: flex; align-items: center; justify-content: center; gap: .35rem;
  min-height: 44px; margin: 0; padding: .25rem; border: 1px solid var(--input-line);
  border-radius: .5rem; cursor: pointer;
}
.ratio-options label:has(input:checked) { color: var(--accent); background: var(--accent-soft); border-color: var(--accent); }
.ratio-options input { flex: 0 0 auto; width: 1.05rem; height: 1.05rem; margin: 0; accent-color: var(--accent); }
.complete {
  min-height: 48px; padding: .54rem .7rem; margin-top: .15rem; border: 1px solid var(--accent-dark);
  border-radius: .6rem; background: var(--accent); color: white; font-weight: 800;
}
summary { min-height: 44px; padding-block: .66rem; color: var(--accent); font-weight: 750; }
.result { background: var(--accent-soft); border: 1px solid var(--accent-line); border-radius: .75rem; margin-top: .65rem; padding: clamp(.65rem, 2.3vw, 1.05rem); }
.result-heading { display: flex; justify-content: space-between; flex-wrap: wrap; align-items: baseline; gap: .3rem .7rem; margin-bottom: .55rem; }
.result h2 { font-size: clamp(1rem, 3.6vw, 1.24rem); line-height: 1.35; }
.result-state {
  color: var(--accent); background: #fff; padding: .16rem .44rem;
  border-radius: .33rem; font-size: .78rem; font-weight: 800;
}
.result:is([data-state="ready"], [data-state="reached"], [data-state="already-reached"]) .result-state { color: #fff; background: var(--accent); }
.result:is([data-state="practice"], [data-state="invalid"], [data-state="check"]) {
  background: #fbf2e7; border-color: #dac4ac;
}
.result:is([data-state="practice"], [data-state="invalid"], [data-state="check"]) .result-state {
  color: #6d3d0d; background: #f4e0cb;
}
.result-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .45rem; }
:root[data-mode="54"] .result-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.value-box {
  min-width: 0; padding: .65rem .7rem; background: #fff; border: 1px solid var(--accent-line);
  border-radius: .55rem;
}
.value-box dt { color: var(--muted); font-size: .86rem; font-weight: 750; }
.value-box dd {
  color: var(--accent); font: 780 clamp(1.38rem, 5.1vw, 2.15rem)/1.2 system-ui, sans-serif;
  letter-spacing: -.04em; font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere; margin-top: .2rem;
}
.value-box dd.long-value { font-size: clamp(.95rem, 3.9vw, 1.85rem); }
.value-box dd .yen { margin-inline-start: .22em; font-size: .52em; letter-spacing: normal; white-space: nowrap; }
.result-note, .result-check, .hold-message {
  font-size: .82rem; margin-top: .48rem; overflow-wrap: anywhere;
}
.result-check { color: var(--muted); }
.hold-message { color: #762e23; font-weight: 800; margin: 0 0 .48rem; }
.result-issues { display: flex; flex-wrap: wrap; gap: .25rem .45rem; padding: 0; margin: .3rem 0 0; list-style: none; }
.result-issues a {
  display: inline-flex; min-height: 44px; align-items: center; padding: .3rem .42rem;
  font-size: .81rem; line-height: 1.35; border-radius: .35rem; border: 1px solid var(--accent-line);
  background: #fff; text-decoration: underline;
}
.practice-banner, .runtime-warning {
  border-radius: .55rem; background: #fff0dd; border: 1px solid #d6b38e;
  color: #744415; padding: .55rem .8rem; font-weight: 800;
}
.practice-banner { margin-top: .7rem; }
.runtime-warning p { margin-top: .2rem; font-size: .91rem; font-weight: 500; }
.next {
  width: 100%; min-height: 49px; margin: .72rem 0; padding: .54rem .7rem;
  border: 1px solid var(--accent-line); border-radius: .65rem; background: #fff;
  color: var(--accent); font-size: .95rem; font-weight: 800;
}
.next:disabled { border-color: var(--line); background: var(--page); color: var(--muted); }
.help { border-top: 1px solid var(--line); }
.help-body { padding: .15rem 0 .65rem; font-size: .87rem; }
.help-body h3 { font-size: .92rem; margin-bottom: .18rem; }
.help-body p, .help-body button { margin-bottom: .55rem; }
.help-body button {
  min-height: 44px; border: 1px solid var(--input-line); border-radius: .45rem;
  padding: .38rem .72rem; background: #fff; color: var(--ink);
}
.help-body button:disabled { opacity: .65; }
.app-footer { font-size: .77rem; color: var(--muted); border-top: 1px solid var(--line); padding-top: .6rem; }
.app-footer p[data-status="attention"] { color: #764611; font-weight: 700; }
.app-footer a { display: inline-flex; align-items: center; min-height: 44px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}
@media (max-width: 38rem) {
  .simple-field { grid-template-columns: minmax(0, 1fr); }
  :root[data-mode="54"] .result-grid { grid-template-columns: minmax(0, 1fr); }
  :root[data-mode="54"] .value-box {
    display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .12rem .5rem;
  }
  .value-box { padding: .53rem .5rem; }
  .heading { padding-block: .85rem; }
  .heading img { width: 41px; height: 41px; }
}
@media (max-width: 23rem) {
  .mode-switch button { gap: .35rem; padding-inline: .45rem; }
  .mode-switch button small { display: block; }
  .value-box dt { font-size: .74rem; }
  .registry-counter { margin-inline-start: .32rem; }
  .registered-values > div { padding-inline: .35rem; }
}
@media print {
  body, .masthead { background: white; color: black; }
  .masthead h1 span { color: black; }
  .complete, .next, .help, .app-footer, .registry { display: none !important; }
  #limit[data-registered], #ratioField[data-registered] { visibility: hidden; }
  .result { break-inside: avoid; }
}
