:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --page: #F7F4EF;
  --card: #FFFFFF;
  --text: #1F2A30;
  --muted: #44545B;
  --primary: #2F6F73;
  --primary-text: #FFFFFF;
  --accent: #E8A87C;
  --band: #DCE9E8;
  --border: #D4D9D7;
  --soft-border: #E6E6E2;
  --surface-muted: #F2F0EB;
  --danger-text: #1F2A30;
}

html[data-theme="night"] {
  color-scheme: dark;
  --page: #0F1418;
  --card: #182027;
  --text: #C9D1D6;
  --muted: #B6C0C5;
  --primary: #24575B;
  --primary-text: #E6EEEF;
  --accent: #B98A66;
  --band: #202D32;
  --border: #46545B;
  --soft-border: #35434A;
  --surface-muted: #20292E;
  --danger-text: #C9D1D6;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--page); }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
}

button, input { font: inherit; }

button {
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:disabled { cursor: default; opacity: 1; }

button:focus-visible, input:focus-visible, label:has(input:focus-visible) .switch-ui {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.app-shell {
  width: min(100%, 480px);
  min-height: 100svh;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: 27px; line-height: 1.2; letter-spacing: -0.025em; }
h2 { margin-bottom: 12px; }
p { margin-bottom: 14px; }

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.04em;
}

.welcome-screen { display: flex; flex-direction: column; justify-content: space-between; }
.welcome-content { padding-top: clamp(42px, 12vh, 118px); }
.welcome-content h1 { max-width: 15ch; font-size: clamp(30px, 8vw, 38px); }
.welcome-content p { max-width: 42ch; }
.welcome-content .lead { margin: 22px 0 18px; font-size: 19px; line-height: 1.48; }
.no-account { margin-top: 23px; font-weight: 650; }
.welcome-button { margin-top: 12px; }
.button-support { margin: 9px 0 0; color: var(--muted); text-align: center; font-size: 14px; }
.health-note { margin: 32px 0 0; color: var(--muted); font-size: 13px; line-height: 1.45; }

.screen-heading { margin: 20px 0 24px; }
.supporting-copy { margin: 14px 0 0; color: var(--muted); }
.field-label { display: block; margin: 0 0 7px; font-weight: 650; }
.field-label span { color: var(--muted); font-weight: 400; }
.text-input {
  display: block;
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  color: var(--text);
}
.text-input::placeholder { color: var(--muted); opacity: 1; }
.button-config-list { display: grid; gap: 12px; margin: 21px 0 20px; }
.button-config {
  min-width: 0;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--soft-border);
  border-radius: 14px;
  background: var(--card);
}
.button-config legend { padding: 0 4px; color: var(--muted); font-size: 13px; }
.config-row { display: grid; grid-template-columns: minmax(104px, 0.78fr) minmax(0, 1.5fr); align-items: center; gap: 10px; }
.switch-label { position: relative; display: flex; min-height: 48px; align-items: center; gap: 9px; cursor: pointer; }
.switch-label input, .benefit-toggle > input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  clip-path: inset(50%);
}
.switch-ui {
  position: relative;
  display: inline-block;
  flex: 0 0 48px;
  width: 48px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 99px;
  background: var(--surface-muted);
}
.switch-ui::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--muted);
  content: "";
}
.switch-label:has(input:checked) .switch-ui,
.benefit-toggle:has(input:checked) .switch-ui { border-color: var(--primary); background: var(--primary); }
.switch-label:has(input:checked) .switch-ui::after,
.benefit-toggle:has(input:checked) .switch-ui::after { left: 23px; background: var(--primary-text); }
.switch-state { font-size: 13px; }
.button-name { min-height: 48px; }
.field-support { margin: 7px 0 0; color: var(--muted); font-size: 14px; }
.saved-note { padding-left: 4px; }
.field-error { margin: 7px 0 0; color: var(--text); font-size: 14px; }
.has-error { border-color: var(--accent); }
.has-error .text-input { border-color: var(--accent); }
.form-error { margin: 0 0 15px; padding: 12px; border: 1px solid var(--accent); border-radius: 12px; background: var(--band); }

.primary-button, .secondary-button, .danger-button, .text-button, .shortcut-button {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  text-align: center;
  text-decoration: none;
}
.primary-button {
  padding: 12px 18px;
  border: 1px solid var(--primary);
  background: var(--primary);
  color: var(--primary-text);
  font-weight: 700;
}
.primary-button:disabled { border-color: var(--primary); background: var(--primary); color: var(--primary-text); }
.secondary-button {
  padding: 10px 16px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-weight: 650;
}
.danger-button {
  padding: 10px 16px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--danger-text);
  font-weight: 700;
}
.text-button {
  padding: 7px 8px;
  border: 0;
  background: transparent;
  color: var(--primary);
  font-weight: 650;
}
html[data-theme="night"] .text-button { color: #A5D7D4; }
.full-button { width: 100%; }
.text-button.full-button { justify-content: center; }

.panel-screen { padding-top: max(16px, env(safe-area-inset-top)); padding-bottom: 104px; }
.panel-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 6px 0 20px; }
.panel-header h1 { margin: 0; font-size: 25px; }
.header-actions { display: flex; align-items: center; gap: 4px; }
.icon-button {
  display: inline-flex;
  width: 48px;
  min-width: 48px;
  height: 48px;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--card);
  color: var(--text);
}
.icon { display: block; width: 24px; height: 24px; flex: 0 0 auto; }
.moon-button .icon { width: 22px; height: 22px; }
.adjust-link { white-space: nowrap; }
.notice-band { margin: 0 0 16px; padding: 15px; border-radius: 14px; background: var(--band); }
.notice-band p:last-of-type { margin-bottom: 8px; }
.notice-title { font-weight: 700; }
.storage-warning { border: 1px solid var(--accent); }
.care-list { display: grid; gap: 14px; }
.care-card, .benefits-card, .history-section {
  padding: 16px;
  border: 1px solid var(--soft-border);
  border-radius: 17px;
  background: var(--card);
}
.care-card.just-registered { outline: 3px solid var(--accent); outline-offset: 1px; }
.care-title-row { display: flex; align-items: center; gap: 9px; }
.care-title-row .icon { width: 21px; height: 21px; color: var(--primary); }
.care-title-row h2 { margin: 0; font-size: 18px; line-height: 1.3; }
.time-block { min-height: 63px; margin: 14px 0 12px; }
.last-time { margin: 0; font-size: 28px; line-height: 1.2; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.elapsed-time { margin: 5px 0 0; color: var(--muted); font-size: 16px; }
.register-button { width: 100%; min-height: 64px; font-size: 17px; }
.card-links { display: grid; justify-items: start; gap: 0; margin: 7px 0 -6px; }
.card-links .text-button { justify-content: flex-start; min-height: 48px; text-align: left; }
.delete-link { color: var(--muted); font-size: 14px; }
.benefits-card { margin-top: 17px; }
.benefits-card h2, .history-section h2 { margin: 0 0 4px; font-size: 19px; }
.benefits-card > .field-support { margin-bottom: 8px; }
.benefit-toggle {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 48px;
  align-items: center;
  gap: 12px;
  min-height: 72px;
  padding: 12px 0;
  border-top: 1px solid var(--soft-border);
  cursor: pointer;
}
.benefit-toggle > span:first-child { display: grid; gap: 2px; }
.benefit-toggle strong { font-size: 16px; }
.benefit-toggle small { color: var(--muted); font-size: 14px; line-height: 1.4; }
.benefit-toggle .switch-ui { grid-column: 2; grid-row: 1; justify-self: end; }
.benefit-toggle input { grid-column: 2; grid-row: 1; }
.history-section { margin-top: 17px; }
.history-section > p { margin: 12px 0 0; color: var(--muted); }
.counts-line { color: var(--text) !important; }
.event-list { margin: 12px 0 0; padding: 0; list-style: none; }
.event-list li { display: flex; min-height: 54px; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid var(--soft-border); }
.event-list li > span { font-variant-numeric: tabular-nums; }
.event-list .text-button { flex: 0 0 auto; }
.copy-button { margin: 14px 0 0; }
.panel-footer { margin: 26px 0 0; padding-top: 4px; text-align: center; }
.panel-footer .health-note { margin: 0 0 7px; }

.toast {
  position: fixed;
  z-index: 10;
  right: max(12px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  left: max(12px, env(safe-area-inset-left));
  display: flex;
  width: min(calc(100% - 24px), 480px);
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-inline: auto;
  padding: 9px 12px 9px 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
  box-shadow: 0 5px 24px rgb(0 0 0 / 15%);
}
.toast-undo { min-width: 80px; min-height: 44px; border: 0; border-radius: 10px; background: var(--band); color: var(--text); font-weight: 700; }

.backdrop, .confirm-backdrop {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-top: 24px;
  background: rgb(0 0 0 / 44%);
}
.bottom-sheet {
  position: relative;
  width: min(100%, 480px);
  max-height: min(90svh, 850px);
  overflow-y: auto;
  padding: 16px 18px max(20px, env(safe-area-inset-bottom));
  border-radius: 22px 22px 0 0;
  background: var(--page);
  color: var(--text);
  box-shadow: 0 -8px 32px rgb(0 0 0 / 18%);
}
.sheet-handle { width: 42px; height: 4px; margin: 0 auto 17px; border-radius: 99px; background: var(--border); }
.bottom-sheet h2 { max-width: calc(100% - 52px); margin: 0 0 18px; font-size: 22px; }
.close-sheet { position: absolute; top: 11px; right: 14px; font-size: 28px; line-height: 1; }
.shortcut-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin: 0 0 13px; }
.shortcut-button { min-height: 54px; padding: 10px; border: 1px solid var(--border); background: var(--card); color: var(--text); font-weight: 650; }
.day-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 15px 0; padding: 0; border: 0; }
.day-choice label { display: flex; min-height: 48px; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--border); border-radius: 12px; background: var(--card); }
.time-input { margin-bottom: 9px; }
.manual-time-form .field-error { margin-bottom: 10px; }
.manual-time-form .primary-button { margin-top: 8px; }
.about-sheet p { margin-bottom: 14px; }
.about-sheet .secondary-button { margin-top: 7px; }
.about-sheet .danger-button { margin-top: 7px; }
.about-sheet .text-button { margin-top: 4px; }
.confirm-backdrop { z-index: 30; align-items: center; padding: 20px; background: rgb(0 0 0 / 58%); }
.confirm-dialog { width: min(100%, 390px); padding: 20px; border-radius: 18px; background: var(--card); box-shadow: 0 10px 40px rgb(0 0 0 / 28%); }
.confirm-dialog h2 { margin: 0 0 11px; font-size: 21px; }
.confirm-dialog p { margin-bottom: 16px; color: var(--muted); }
.confirm-dialog .secondary-button { margin-top: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

html[data-theme="night"] .register-button { min-height: 88px; }
html[data-theme="night"] .last-time { font-size: 36px; }
html[data-theme="night"] .care-title-row h2 { font-size: 20px; }

@media (min-width: 600px) {
  .app-shell { margin-block: 20px; min-height: calc(100svh - 40px); border-radius: 20px; }
  .panel-screen { padding-top: 25px; }
  .welcome-content { padding-top: 90px; }
  .backdrop { align-items: center; padding-bottom: 24px; }
  .bottom-sheet { border-radius: 22px; padding-bottom: 24px; }
}

@media (max-width: 365px) {
  .app-shell { padding-inline: 12px; }
  .config-row { grid-template-columns: 1fr; gap: 5px; }
  .switch-label { min-height: 44px; }
  .panel-header h1 { font-size: 22px; }
  .adjust-link { padding-inline: 4px; font-size: 14px; }
}

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