:root {
  color-scheme: light dark;
  --page: light-dark(#edf3ef, #0e1512);
  --surface: light-dark(#fbfcfa, #17201c);
  --surface-soft: light-dark(#e6f0eb, #21332b);
  --text: light-dark(#17342b, #edf7f2);
  --muted: light-dark(#5c6e67, #b6c7c0);
  --line: light-dark(#c9d8d1, #34463f);
  --brand: light-dark(#246b57, #7bd0b2);
  --brand-text: light-dark(#ffffff, #0b221a);
  --danger: light-dark(#9a3636, #ffaaaa);
  --shadow: light-dark(rgba(22, 53, 43, 0.13), rgba(0, 0, 0, 0.36));
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--page);
  color: var(--text);
}

html[data-contrast="strong"] {
  --page: light-dark(#ffffff, #000000);
  --surface: light-dark(#ffffff, #080808);
  --surface-soft: light-dark(#f2f6f4, #171717);
  --text: light-dark(#071b14, #ffffff);
  --muted: light-dark(#304a40, #e4eee9);
  --line: light-dark(#355d4f, #d8eee5);
  --brand: light-dark(#075b43, #8ff0cc);
}

html[data-text-size="large"] { font-size: 18px; }
html[data-text-size="extra"] { font-size: 20px; }
html[data-text-size="large"] h1 { font-size: clamp(32px, 8vw, 42px); }
html[data-text-size="extra"] h1 { font-size: clamp(35px, 9vw, 46px); }
html[data-text-size="large"] .request-button { font-size: 20px; }
html[data-text-size="extra"] .request-button { font-size: 22px; }
html[data-text-size="large"] .message-main { font-size: 30px; }
html[data-text-size="extra"] .message-main { font-size: 34px; }

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--page); }

body { min-height: 100vh; margin: 0; background: var(--page); }

.privacy-shell { display: block; min-height: 100vh; }
.privacy-content { padding: 28px 20px 48px; }
.privacy-return { display: inline-flex; align-items: center; text-decoration: none; }

button, input, textarea, select { font: inherit; }

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

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  left: 12px;
  top: -60px;
  z-index: 20;
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--brand);
  color: var(--brand-text);
}

.skip-link:focus { top: 12px; }

.app-shell {
  width: min(100%, 520px);
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto 1fr auto;
  background: var(--surface);
  box-shadow: 0 0 48px var(--shadow);
  overflow-x: clip;
}

.topbar {
  min-width: 0;
  min-height: 66px;
  padding: max(10px, env(safe-area-inset-top)) 18px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.brand {
  min-width: 0;
  min-height: 44px;
  border: 0;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}

.brand > span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: var(--brand);
  color: var(--brand-text);
  font-size: 12px;
  letter-spacing: 0.04em;
}

.phase-pill {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 9px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

main { width: 100%; min-width: 0; padding: 24px 20px 32px; }

.screen,
.request-grid,
.request-button { min-width: 0; max-width: 100%; }

.screen[hidden] { display: none; }
[hidden] { display: none !important; }

h1, h2, p { margin-top: 0; }

h1 {
  max-width: 430px;
  margin-bottom: 10px;
  font-size: clamp(28px, 7vw, 38px);
  line-height: 1.12;
  font-weight: 650;
  letter-spacing: -0.025em;
}

h2 { font-size: 22px; line-height: 1.25; }

.eyebrow {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

.intro { margin-bottom: 24px; color: var(--muted); line-height: 1.5; }

.request-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.request-button {
  min-height: 112px;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 8px;
  background: var(--surface-soft);
  color: var(--text);
  font-size: 17px;
  font-weight: 650;
  line-height: 1.3;
  text-align: left;
  cursor: pointer;
}

.request-button small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.personal-request { border-color: var(--brand); }

.request-button:last-child:nth-child(odd) { grid-column: 1 / -1; min-height: 76px; }

.home-links { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.home-links .text-button:last-child:nth-child(odd) { grid-column: 1 / -1; }

.text-button,
.back-button {
  min-height: 48px;
  border: 0;
  padding: 8px 4px;
  background: transparent;
  color: var(--brand);
  font-weight: 650;
  cursor: pointer;
}

.back-button { margin: -8px 0 12px -4px; text-align: left; }

.privacy-note,
.settings-panel {
  margin-top: 22px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.privacy-note strong { display: block; margin-bottom: 4px; color: var(--text); }

.pending-bridge {
  width: 100%;
  margin: 0 0 18px;
  border: 1px solid var(--brand);
  border-radius: 16px;
  padding: 15px 16px;
  display: grid;
  gap: 4px;
  background: var(--surface-soft);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.pending-bridge span,
.pending-bridge small { color: var(--muted); font-size: 12px; }
.pending-bridge strong { font-size: 17px; line-height: 1.35; }

form { display: grid; gap: 10px; }

label {
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}

input,
textarea,
select {
  width: 100%;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 13px 14px;
  background: var(--surface-soft);
  color: var(--text);
}

.check-row {
  min-height: 52px;
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
}

.check-row input {
  width: 24px;
  min-height: 24px;
  margin: 0;
  accent-color: var(--brand);
}

textarea { resize: vertical; line-height: 1.45; }

.primary-button,
.secondary-button,
.danger-button {
  width: 100%;
  min-height: 54px;
  border-radius: 14px;
  padding: 12px 16px;
  font-weight: 700;
  cursor: pointer;
}

.primary-button { border: 1px solid var(--brand); background: var(--brand); color: var(--brand-text); }
.secondary-button { border: 1px solid var(--line); background: transparent; color: var(--text); }
.danger-button { border: 1px solid var(--danger); background: transparent; color: var(--danger); }
.primary-button:disabled,
.secondary-button:disabled,
.danger-button:disabled { opacity: 0.55; cursor: wait; }

form .primary-button { margin-top: 10px; }

.button-stack { display: grid; gap: 10px; }

.message-card {
  margin: 22px 0;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 24px 20px;
  background: var(--surface-soft);
}

.message-main { margin-bottom: 12px; font-size: 26px; line-height: 1.3; font-weight: 650; }
.message-detail { margin-bottom: 0; color: var(--muted); line-height: 1.5; }
.microcopy { margin: 14px 0 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.microcopy a { color: var(--brand); }

.recipient-chip {
  margin: 20px 0 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 13px 15px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  background: var(--surface-soft);
}

.recipient-chip span,
.field-heading { color: var(--muted); font-size: 13px; font-weight: 700; text-transform: uppercase; }
.field-heading { margin: 20px 0 8px; letter-spacing: 0.04em; }

.share-preview {
  margin: 0 0 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  overflow: auto;
  background: var(--surface-soft);
  color: var(--text);
  font: inherit;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.timer-card {
  margin: 22px 0;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 28px 20px;
  display: grid;
  gap: 10px;
  place-items: center;
  background: var(--surface-soft);
  text-align: center;
}

.timer-card span { color: var(--muted); }
.timer-card strong { font-size: clamp(52px, 16vw, 84px); font-variant-numeric: tabular-nums; letter-spacing: -0.04em; }

.status-card {
  margin: 20px 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px;
  display: grid;
  gap: 8px;
  background: var(--surface-soft);
}

.status-card span { color: var(--muted); font-size: 13px; font-weight: 700; text-transform: uppercase; }
.status-card strong { font-size: 22px; line-height: 1.35; }
.status-card p { margin: 0; color: var(--muted); line-height: 1.5; }

.premium-benefits {
  margin: 20px 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  background: var(--surface-soft);
}

.premium-benefits h2 { margin-bottom: 10px; }
.premium-benefits ul { margin: 0; padding-left: 22px; }
.premium-benefits li { margin: 8px 0; line-height: 1.45; }

.plan-grid { display: grid; gap: 12px; margin: 20px 0; }

.plan-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  display: grid;
  gap: 9px;
  background: var(--surface-soft);
}

.plan-card > span { color: var(--muted); font-size: 13px; font-weight: 700; text-transform: uppercase; }
.plan-card > strong { font-size: 22px; line-height: 1.3; }
.plan-card > p { margin: 0; color: var(--muted); line-height: 1.45; }
.plan-card .primary-button { margin-top: 6px; }
.subscription-disclosure { margin: 18px 0; color: var(--muted); font-size: 13px; line-height: 1.5; }

.premium-manager { margin: 20px 0; border: 1px solid var(--line); border-radius: 18px; padding: 18px; }
.premium-manager > p { color: var(--muted); line-height: 1.45; }
.manager-list { display: grid; gap: 9px; margin: 14px 0; }
.manager-item { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; padding: 10px; border-radius: 12px; background: var(--surface-soft); }
.manager-item strong { min-width: 0; overflow-wrap: anywhere; }
.manager-item button { min-height: 40px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--text); }
.manager-item button[aria-pressed="true"] { border-color: var(--brand); color: var(--brand); font-weight: 700; }
.manager-item .remove-manager-item { color: var(--danger); }
.manager-form { margin-top: 14px; }
.inline-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; }
.premium-manager[data-locked="true"] .manager-form { display: none; }
.premium-manager[data-locked="true"] .remove-manager-item { display: none; }

.app-shell[data-mode="supporter"] .bottom-nav { display: none; }
.app-shell[data-mode="supporter"] main { padding-bottom: max(32px, env(safe-area-inset-bottom)); }

.phrase-list { display: grid; gap: 12px; margin-bottom: 20px; }

.empty-state,
.phrase-card {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
  background: var(--surface-soft);
}

.empty-state { color: var(--muted); line-height: 1.5; }
.phrase-card h2 { margin-bottom: 7px; font-size: 18px; }
.phrase-card p { margin-bottom: 14px; color: var(--muted); line-height: 1.45; }
.phrase-controls { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 7px; }
.phrase-controls button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.phrase-controls button:disabled { opacity: 0.38; cursor: default; }
.phrase-controls .remove-phrase { color: var(--danger); }
.settings-panel h2 { color: var(--text); }

.support-card-display {
  margin: 20px 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  background: var(--surface-soft);
}

.support-card-display dt { margin-top: 16px; color: var(--muted); font-size: 13px; font-weight: 700; text-transform: uppercase; }
.support-card-display dt:first-child { margin-top: 0; }
.support-card-display dd { margin: 5px 0 0; line-height: 1.5; white-space: pre-line; }

.settings-panel h2 { margin-bottom: 14px; }
.settings-panel > * + * { margin-top: 12px; }
details { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 12px 0; }
summary { min-height: 44px; display: flex; align-items: center; color: var(--text); cursor: pointer; }
details p { margin: 8px 0 0; }

.bottom-nav {
  position: sticky;
  bottom: 0;
  z-index: 5;
  padding: 8px 10px max(8px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(14px);
}

.bottom-nav button {
  min-width: 0;
  min-height: 48px;
  border: 0;
  border-radius: 12px;
  padding: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  overflow-wrap: anywhere;
  cursor: pointer;
}

.bottom-nav button[aria-current="page"] { background: var(--surface-soft); color: var(--brand); }

dialog {
  width: 100vw;
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0;
  border: 0;
  padding: max(24px, env(safe-area-inset-top)) 22px max(24px, env(safe-area-inset-bottom));
  background: var(--surface);
  color: var(--text);
}

dialog::backdrop { background: var(--surface); }

.display-panel {
  width: min(100%, 620px);
  min-height: calc(100dvh - 48px);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
}

.display-panel h2 { margin-bottom: 20px; font-size: clamp(38px, 10vw, 68px); line-height: 1.12; }
.display-panel p:not(.eyebrow) { margin-bottom: 36px; color: var(--muted); font-size: clamp(20px, 5vw, 30px); line-height: 1.4; white-space: pre-line; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(82px + env(safe-area-inset-bottom));
  z-index: 30;
  width: min(calc(100% - 32px), 460px);
  transform: translateX(-50%);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 13px 16px;
  background: var(--text);
  color: var(--surface);
  text-align: center;
  box-shadow: 0 12px 30px var(--shadow);
}

.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;
}

@media (max-width: 360px) {
  .topbar { padding-inline: 12px; gap: 8px; }
  .brand { gap: 8px; }
  .phase-pill { padding-inline: 7px; font-size: 11px; }
  main { padding-inline: 15px; }
  .bottom-nav { padding-inline: 6px; gap: 2px; }
  .bottom-nav button { padding-inline: 2px; font-size: 12px; }
  .request-grid { grid-template-columns: 1fr; }
  .request-button, .request-button:last-child:nth-child(odd) { min-height: 72px; grid-column: auto; }
  .home-links { grid-template-columns: 1fr; }
  .home-links .text-button:last-child:nth-child(odd) { grid-column: auto; }
  .phrase-controls { grid-template-columns: 1fr; }
}

@media (min-width: 700px) {
  body { padding: 24px; }
  .app-shell { min-height: calc(100vh - 48px); border: 1px solid var(--line); border-radius: 28px; overflow: hidden; }
}

@media (prefers-reduced-motion: no-preference) {
  .toast { animation: toast-in 160ms ease-out; }
  @keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }
}
