:root {
  color-scheme: light;
  --navy: #163b43;
  --navy-deep: #102f37;
  --teal: #1f6b63;
  --teal-dark: #17544e;
  --teal-soft: #e3f0eb;
  --cream: #f7f5ed;
  --paper: #fffefa;
  --ink: #142f35;
  --muted: #3f5558;
  --line: #cfdcd6;
  --line-strong: #8fa9a1;
  --gold: #6e4f0c;
  --gold-soft: #fbf1d5;
  --red: #8a2f2b;
  --red-soft: #fff0e8;
  --shadow: 0 8px 22px rgba(21, 58, 65, .07);
  --tap: 52px;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--cream);
  font-size: 18px;
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--cream);
  font-size: 18px;
  line-height: 1.75;
  overflow-wrap: anywhere;
}

button,
input,
select {
  font: inherit;
}

button,
a,
input,
select,
summary {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: var(--teal-dark);
  text-decoration-thickness: .08em;
  text-underline-offset: .2em;
}

:focus-visible {
  outline: 3px solid #b5600f;
  outline-offset: 3px;
  border-radius: 4px;
}

.screen-title:focus:not(:focus-visible) {
  outline: none;
}

.skip-link {
  position: absolute;
  z-index: 30;
  top: .5rem;
  left: .5rem;
  padding: .65rem .9rem;
  transform: translateY(-160%);
  color: #fff;
  background: var(--navy-deep);
  border-radius: .5rem;
}

.skip-link:focus {
  transform: translateY(0);
}

/* ---------- header / footer ---------- */

.site-header {
  color: #f8faf6;
  background: var(--navy);
  border-bottom: 4px solid #4c9585;
}

.header-inner,
.footer-inner,
.site-main {
  width: min(100% - 1.5rem, 760px);
  margin-inline: auto;
}

.header-inner {
  display: flex;
  min-height: 68px;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding-block: .5rem;
}

.brand {
  display: inline-flex;
  min-width: 0;
  min-height: 48px;
  align-items: center;
  gap: .6rem;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  place-items: center;
  color: var(--navy-deep);
  background: #e2eee5;
  border-radius: 14px 14px 14px 5px;
  font-family: serif;
  font-size: 1.15rem;
  font-weight: 800;
}

.brand-copy {
  display: grid;
  min-width: 0;
  line-height: 1.4;
}

.brand-copy strong {
  font-size: 1rem;
}

.brand-copy small {
  color: #cfe1da;
  font-size: .85rem;
}

.unofficial-badge {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: baseline;
  gap: .1rem;
  margin: 0;
  padding: .3rem .7rem;
  color: var(--navy-deep);
  background: #fff3cf;
  border-radius: 999px;
  font-size: .9rem;
  line-height: 1.4;
}

.unofficial-badge strong {
  font-weight: 800;
}

.site-footer {
  color: #e2ece7;
  background: var(--navy-deep);
}

.footer-inner {
  display: grid;
  gap: .5rem;
  padding-block: 1.2rem 1.6rem;
  font-size: 1rem;
}

.footer-inner p {
  margin: 0;
}

.footer-inner a {
  color: #bfe8d6;
}

.footer-inner summary {
  min-height: 48px;
  padding-block: .6rem;
  cursor: pointer;
}

.site-main {
  min-height: calc(100vh - 160px);
  padding-block: .75rem 3rem;
}

/* ---------- app navigation ---------- */

.app-nav {
  position: sticky;
  z-index: 20;
  top: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .35rem;
  margin: 0 0 1rem;
  padding: .4rem;
  background: rgba(255, 254, 250, .97);
  border: 1px solid var(--line);
  border-radius: 1rem;
  box-shadow: 0 4px 14px rgba(25, 63, 67, .08);
}

/* .app-nav scope keeps these values above the later generic .button rule. */
.app-nav .button-nav {
  min-width: 0;
  min-height: 48px;
  padding: .4rem .3rem;
  color: var(--navy-deep);
  background: transparent;
  border: 0;
  border-radius: .7rem;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.3;
  flex-wrap: wrap;
  align-content: center;
}

/* Each label word stays whole, so narrow screens break as 自分の/記録. */
.nav-word {
  white-space: nowrap;
}

.app-nav .button-nav[aria-current="page"] {
  color: #fff;
  background: var(--navy);
}

.live-notice:empty {
  display: none;
}

.live-notice {
  margin: 0 0 1rem;
  padding: .7rem 1rem;
  color: var(--teal-dark);
  background: var(--teal-soft);
  border: 1px solid #a9cfc1;
  border-radius: .8rem;
  font-weight: 700;
}

.live-notice.live-error {
  color: #6e2622;
  background: var(--red-soft);
  border-color: #e1a998;
}

.issue-banner,
.issue-alert {
  display: grid;
  gap: .6rem;
  margin: 0 0 1rem;
  padding: 1rem;
  color: #5c2420;
  background: var(--red-soft);
  border: 2px solid #d99a88;
  border-radius: 1rem;
}

.issue-banner p,
.issue-alert p {
  margin: 0;
}

/* ---------- screens ---------- */

.screen {
  display: grid;
  gap: 1.1rem;
}

.screen-heading {
  display: grid;
  gap: .4rem;
}

.kicker {
  margin: 0;
  color: var(--teal-dark);
  font-size: 1rem;
  font-weight: 700;
}

.screen-title {
  margin: 0;
  color: var(--navy-deep);
  font-size: clamp(1.6rem, 6vw, 2.1rem);
  line-height: 1.35;
  letter-spacing: -.02em;
}

.screen-lead {
  margin: 0;
  color: var(--muted);
}

.card {
  min-width: 0;
  padding: 1.15rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 1rem;
  box-shadow: var(--shadow);
}

.card > p {
  margin: 0 0 .6rem;
}

.card > p:last-child {
  margin-bottom: 0;
}

.card-title {
  margin: 0 0 .5rem;
  color: var(--navy-deep);
  font-size: 1.25rem;
  line-height: 1.45;
}

.sub-title {
  margin: 1rem 0 .3rem;
  font-size: 1.1rem;
}

.small-text {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.7;
}

/* ---------- buttons ---------- */

.button {
  display: inline-flex;
  min-height: var(--tap);
  align-items: center;
  justify-content: center;
  padding: .6rem 1.2rem;
  border: 2px solid transparent;
  border-radius: .9rem;
  cursor: pointer;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
}

.button-primary {
  color: #fff;
  background: var(--teal-dark);
  border-color: var(--teal-dark);
}

.button-primary:hover {
  background: var(--navy-deep);
  border-color: var(--navy-deep);
}

.button-secondary {
  color: var(--navy-deep);
  background: var(--paper);
  border-color: var(--line-strong);
}

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

.button-danger {
  color: var(--red);
  background: var(--paper);
  border-color: #d39383;
}

.button-text {
  min-height: 48px;
  padding: .4rem .2rem;
  color: var(--teal-dark);
  background: transparent;
  border: 0;
  text-decoration: underline;
  text-underline-offset: .2em;
  justify-content: flex-start;
}

.button-switch {
  flex: 1 1 0;
  min-width: 0;
  color: var(--navy-deep);
  background: var(--paper);
  border-color: var(--line-strong);
}

.button-switch[aria-pressed="true"] {
  color: #fff;
  background: var(--navy);
  border-color: var(--navy);
}

.button-row,
.after-links,
.home-links,
.detail-links {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
}

.home-links .button,
.after-links .button {
  flex: 1 1 14rem;
}

.step-nav {
  display: flex;
  flex-wrap: wrap-reverse;
  gap: .75rem;
  margin-top: .3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.step-nav .button-secondary {
  flex: 0 1 auto;
}

.step-nav .button-primary {
  flex: 1 1 16rem;
}

.home-start .button,
.flow-card .button,
.resume-card .button,
.task-editor .button-primary {
  width: 100%;
  margin-top: .4rem;
}

/* ---------- home ---------- */

.urgent-strip {
  display: grid;
  gap: .1rem;
  padding: .85rem 1rem;
  color: #5c2420;
  background: var(--red-soft);
  border-left: 6px solid #b4543f;
  border-radius: .8rem;
}

.urgent-strip p {
  margin: 0;
  font-weight: 700;
}

.urgent-strip .button-text {
  color: #7a2c26;
}

.resume-card {
  border: 2px solid var(--teal);
  background: #f2f9f5;
}

.save-state-line {
  padding: .5rem .75rem;
  color: var(--teal-dark);
  background: var(--teal-soft);
  border-radius: .6rem;
  font-size: 1rem;
  font-weight: 700;
}

.save-state-line.is-off {
  color: var(--gold);
  background: var(--gold-soft);
}

.flow-list {
  display: grid;
  gap: .75rem;
  margin: 0 0 .6rem;
  padding: 0;
  list-style: none;
}

.flow-item {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: .75rem;
  align-items: start;
}

.flow-number,
.stepper-number {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  color: #fff;
  background: var(--teal);
  border-radius: 50%;
  font-weight: 800;
  line-height: 1;
}

.flow-copy {
  display: grid;
}

.flow-copy span {
  color: var(--muted);
  font-size: 1rem;
}

/* ---------- stepper ---------- */

.stepper-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .3rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.stepper-item {
  display: grid;
  justify-items: center;
  gap: .2rem;
  color: var(--muted);
  font-size: .95rem;
  line-height: 1.3;
  text-align: center;
}

.stepper-item .stepper-number {
  width: 32px;
  height: 32px;
  color: var(--muted);
  background: #e8eeeb;
  border: 2px solid var(--line-strong);
}

.stepper-item.is-past .stepper-number {
  color: var(--teal-dark);
  background: var(--teal-soft);
  border-color: var(--teal);
}

.stepper-item.is-current {
  color: var(--navy-deep);
  font-weight: 800;
}

.stepper-item.is-current .stepper-number {
  color: #fff;
  background: var(--navy);
  border-color: var(--navy);
}

/* ---------- choices ---------- */

.choice-fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.choice-legend {
  margin-bottom: .5rem;
  padding: 0;
  color: var(--navy-deep);
  font-size: 1.2rem;
  font-weight: 800;
}

.choice-help {
  margin: -.2rem 0 .6rem;
  color: var(--muted);
  font-size: 1rem;
}

.choice-list {
  display: grid;
  gap: .55rem;
}

.choice-card {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: .75rem;
  align-items: start;
  min-height: 60px;
  padding: .8rem 1rem;
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: .9rem;
  cursor: pointer;
}

.choice-card:hover {
  border-color: var(--line-strong);
}

.choice-card.is-selected {
  background: #eef7f2;
  border-color: var(--teal);
}

.choice-input {
  width: 26px;
  height: 26px;
  margin: .15rem 0 0;
  accent-color: var(--teal-dark);
}

.choice-copy {
  display: grid;
  gap: .1rem;
  min-width: 0;
}

.choice-title {
  font-weight: 800;
  line-height: 1.5;
}

.choice-detail,
.choice-extra {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.6;
}

.choice-extra {
  color: var(--teal-dark);
  font-weight: 700;
}

/* ---------- guidance ---------- */

.guidance {
  border-left: 6px solid #6fa392;
}

.guidance-urgent {
  color: #5c2420;
  background: #fff6ee;
  border-color: #e4b9a5;
  border-left-color: #b4543f;
}

.guidance-urgent .card-title {
  color: #6e2622;
}

.guidance-attention {
  background: var(--gold-soft);
  border-left-color: #b88a2b;
}

.hint {
  padding: .9rem 1rem;
  background: #f1f6f3;
  box-shadow: none;
}

/* ---------- step 3 ---------- */

.fact-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: .2rem .9rem;
  margin: 0;
}

.fact-list dt {
  color: var(--muted);
  font-weight: 700;
}

.fact-list dd {
  margin: 0;
}

.check-list {
  margin: 0;
  padding-left: 1.3rem;
}

.check-list li {
  margin-block: .3rem;
}

.card > .agency-note {
  margin-top: .8rem;
  padding: .7rem .85rem;
  background: var(--gold-soft);
  border-radius: .7rem;
  font-size: 1rem;
}

.official-go {
  display: grid;
  gap: .4rem;
  margin-top: 1rem;
}

.official-go p {
  margin: 0;
}

.official-link {
  display: flex;
  flex-wrap: wrap;
  min-height: 48px;
  align-items: center;
  gap: .2rem .6rem;
  margin-top: .4rem;
  padding: .55rem .9rem;
  color: var(--teal-dark);
  background: #f2f8f5;
  border: 2px solid #a9cfc1;
  border-radius: .8rem;
  font-weight: 700;
  text-decoration: none;
}

.official-link:hover {
  background: var(--teal-soft);
}

.link-label {
  flex: 1 1 auto;
}

.link-domain {
  color: var(--muted);
  font-size: .95rem;
  font-weight: 400;
}

.external-mark {
  font-weight: 800;
}

.official-primary {
  min-height: 56px;
  color: #fff;
  background: var(--teal-dark);
  border-color: var(--teal-dark);
  font-size: 1.1rem;
}

.official-primary .link-domain {
  color: #d8eee6;
}

.official-primary:hover {
  color: #fff;
  background: var(--navy-deep);
}

.secondary-link {
  background: transparent;
  border-style: dashed;
}

.detail-links {
  align-items: center;
  margin-top: .4rem;
}

.link-unavailable {
  color: var(--muted);
}

/* ---------- editor / records ---------- */

.task-editor {
  display: grid;
  gap: .35rem;
  padding: 1.1rem;
  background: var(--paper);
  border: 2px solid var(--line);
  border-radius: 1rem;
}

.form-label {
  margin-top: .4rem;
  font-weight: 800;
}

.state-select,
.date-input {
  width: 100%;
  min-height: var(--tap);
  padding: .5rem .75rem;
  color: var(--ink);
  background: #fff;
  border: 2px solid var(--line-strong);
  border-radius: .7rem;
  font-size: 1.05rem;
}

.date-field {
  display: grid;
  gap: .25rem;
}

.field-help {
  margin: .1rem 0 0;
  color: var(--muted);
  font-size: 1rem;
}

.storage-panel .button-row {
  margin-top: .6rem;
}

.record-group {
  display: grid;
  gap: .5rem;
}

.record-group-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .2rem .75rem;
}

.record-group-head .card-title {
  margin: 0;
}

.record-agency-name {
  color: var(--muted);
  font-size: 1rem;
}

.record-row {
  display: grid;
  gap: .35rem;
  padding-top: .75rem;
  border-top: 1px solid var(--line);
}

.record-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: .4rem .75rem;
}

.record-title {
  display: grid;
}

.record-plain {
  color: var(--muted);
  font-size: 1rem;
}

.record-dates {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: .1rem .9rem;
  margin: 0;
  font-size: 1rem;
}

.record-dates dt {
  color: var(--muted);
}

.record-dates dd {
  margin: 0;
  font-weight: 700;
}

.record-empty,
.expiry-line {
  margin: 0;
  font-size: 1rem;
}

.record-empty {
  color: var(--muted);
}

.expiry-line {
  padding: .5rem .75rem;
  background: var(--teal-soft);
  border-radius: .6rem;
}

.progress-chip,
.status-chip {
  display: inline-block;
  padding: .2rem .7rem;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.5;
}

.chip-idle,
.chip-unknown {
  color: #3c4f52;
  background: #edf0ee;
  border-color: #c9d3cf;
}

.chip-progress,
.chip-observed {
  color: #17544e;
  background: #e3f0eb;
  border-color: #9fc8b9;
}

.chip-done,
.chip-announced {
  color: #fff;
  background: var(--teal-dark);
}

.chip-attention,
.chip-stale {
  color: #5e430b;
  background: var(--gold-soft);
  border-color: #d7b867;
}

.chip-failed {
  color: #6e2622;
  background: var(--red-soft);
  border-color: #e1a998;
}

/* ---------- status ---------- */

.checked-banner {
  background: #eef6f2;
  box-shadow: none;
}

.checked-banner p:first-child {
  font-weight: 800;
}

.kind-switch {
  display: flex;
  gap: .5rem;
}

.layer-list {
  display: grid;
  gap: .6rem;
  margin: 0 0 .6rem;
  padding: 0;
  list-style: none;
}

.layer-row {
  padding: .7rem .8rem;
  background: #fafbf8;
  border: 1px solid var(--line);
  border-radius: .8rem;
}

.layer-row > p {
  margin: .3rem 0 0;
}

.layer-head {
  display: grid;
  gap: .3rem;
}

.layer-name {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 .6rem;
}

.layer-name span {
  color: var(--muted);
  font-size: 1rem;
}

.layer-head .status-chip {
  justify-self: start;
}

.layer-details summary {
  display: flex;
  min-height: 48px;
  align-items: center;
  color: var(--teal-dark);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
}

.layer-details[open] summary {
  margin-bottom: .3rem;
}

.layer-details .fact-list {
  font-size: 1rem;
}

.source-list {
  display: grid;
  gap: .5rem;
  margin: .3rem 0 0;
  padding: 0;
  list-style: none;
}

.source-item {
  display: grid;
}

/* ---------- important ---------- */

.note-card .check-list li {
  margin-block: .45rem;
}

/* ---------- noscript / 404 ---------- */

.noscript-card {
  max-width: 760px;
  margin: 1rem auto 3rem;
  padding: clamp(1rem, 5vw, 2rem);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 1rem;
  box-shadow: var(--shadow);
}

.noscript-card h1 {
  color: var(--navy-deep);
  font-size: clamp(1.6rem, 5vw, 2rem);
}

.noscript-card h2 {
  margin-top: 1.5rem;
  color: var(--navy-deep);
  font-size: 1.2rem;
}

.noscript-card li {
  margin-block: .5rem;
}

.eyebrow {
  margin: 0 0 .35rem;
  color: var(--teal-dark);
  font-size: 1rem;
  font-weight: 800;
}

/* ---------- small screens ---------- */

@media (max-width: 520px) {
  .header-inner,
  .footer-inner,
  .site-main {
    width: min(100% - 1rem, 760px);
  }

  .brand-copy small {
    display: none;
  }

  .brand-copy strong {
    font-size: .95rem;
  }

  .unofficial-badge span {
    display: none;
  }

  .card,
  .task-editor {
    padding: 1rem .9rem;
  }

  .step-nav .button {
    flex: 1 1 100%;
  }

  .button-row .button {
    flex: 1 1 100%;
  }
}

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