/* Account and device pages. Same tokens, themes and control conventions as the
   library (library.css): light-dark() colors, data-theme from reader-theme.js,
   unbordered fill controls, a 44px surface top bar and the sponge icon. */
:root,
:root[data-theme='dark'] {
  color-scheme: dark;
  --canvas: light-dark(#fdfcfa, #0c0a08);
  --surface: light-dark(#f5f2ed, #15120f);
  --raised: light-dark(#ebe6de, #201b16);
  --text: light-dark(#1c1814, #f6f1e9);
  --muted: light-dark(#5e564c, #b9afa3);
  --accent: light-dark(#a34a07, #f5a142);
  --accent-hover: light-dark(#843b05, #f8b667);
  --accent-contrast: light-dark(#ffffff, #1a0f02);
  --accent-soft: light-dark(#fcebd5, #35271a);
  --line: light-dark(#e0d9ce, #2f2a24);
  --soft-line: light-dark(#ece7df, #241f1a);
  --input-line: light-dark(#8b8277, #6e655a);
  --error: light-dark(#b3261e, #ffb5a8);
  --error-soft: light-dark(#fbe4e1, #3a1d18);
  --selection: light-dark(#fbd9ad, #7a4a14);
  --selection-text: light-dark(#1c1814, #fff4e5);
  --control-fill: var(--raised);
  --control-fill-hover: color-mix(in oklab, var(--raised), var(--text) 7%);
  --field-fill: var(--surface);
  --radius: 6px;
  --group-radius: 10px;
  --control-radius: 6px;
  --control-height: 34px;
  --field-height: 40px;
  --text-caption: 0.75rem;
  --text-label: 0.8125rem;
  --text-control: 0.8125rem;
  --ui-font-sans: system-ui, -apple-system, 'Segoe UI Variable', 'Segoe UI', Roboto, sans-serif;
  --ui-font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-family: var(--ui-font-sans);
  font-synthesis: none;
  background: var(--canvas);
  color: var(--text);
  scrollbar-color: var(--input-line) var(--surface);
  scrollbar-width: thin;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
:root[data-theme='light'] {
  color-scheme: light;
}
:root[data-theme='system'] {
  color-scheme: light dark;
}
:root[data-theme='sepia'] {
  color-scheme: light;
  --canvas: #f4e6cb;
  --surface: #ecdabb;
  --raised: #e2cda9;
  --text: #3a2a17;
  --muted: #69533a;
  --accent: #99460a;
  --accent-hover: #7c3807;
  --accent-soft: #ecd0a2;
  --line: #d6c09a;
  --soft-line: #e5d3b3;
  --input-line: #95805c;
  --selection: #ebc78a;
  --selection-text: #3a2a17;
  --error-soft: #f1d0bf;
}
*,
*::before,
*::after {
  box-sizing: border-box;
}
body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--canvas);
}
button,
input,
textarea {
  font: inherit;
  color: inherit;
}
button,
a,
input,
textarea,
summary {
  -webkit-tap-highlight-color: transparent;
}
::selection {
  background: var(--selection);
  color: var(--selection-text);
}
a {
  color: var(--text);
  text-decoration: none;
}
button {
  cursor: pointer;
}
button:disabled {
  cursor: default;
  opacity: 0.55;
}
button[aria-busy='true'] {
  cursor: progress;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
input,
textarea {
  caret-color: var(--accent);
}
[hidden] {
  display: none !important;
}
h1,
h2,
p {
  margin: 0;
}
h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.3;
  text-wrap: balance;
}
h2 {
  font-size: 0.9375rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.35;
}
p {
  color: var(--muted);
  line-height: 1.6;
  text-wrap: pretty;
}
.fine {
  font-size: var(--text-label);
  color: var(--muted);
  line-height: 1.55;
}
code {
  font-family: var(--ui-font-mono);
  font-size: 0.875em;
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: var(--raised);
  color: var(--text);
}

/* ---------- Icon and top bar ---------- */
.app-icon {
  display: block;
  flex: 0 0 auto;
  inline-size: 32px;
  block-size: 32px;
}
.app-icon[data-size='small'] {
  inline-size: 26px;
  block-size: 26px;
}
.app-icon[data-size='large'] {
  inline-size: 56px;
  block-size: 56px;
}
.top-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  padding: 0 max(10px, env(safe-area-inset-right)) 0 max(0px, env(safe-area-inset-left));
  background: var(--surface);
}
.top-home {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  align-self: stretch;
  padding: 0 14px;
  border-radius: var(--radius);
  font-size: 0.9375rem;
  font-weight: 700;
  letter-spacing: -0.015em;
}
.top-home:focus-visible {
  outline-offset: -4px;
}
.account-nav {
  display: flex;
  align-items: center;
  gap: 2px;
}

/* ---------- Controls: unbordered fills, like the library ---------- */
button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--control-height);
  padding: 0 12px;
  border: 0;
  border-radius: var(--control-radius);
  background: transparent;
  font-size: var(--text-control);
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  text-decoration: none;
  transition:
    background-color 120ms ease,
    color 120ms ease;
}
.primary {
  background: var(--accent);
  color: var(--accent-contrast);
}
.primary:hover:not(:disabled) {
  background: var(--accent-hover);
  color: var(--accent-contrast);
}
.secondary {
  background: var(--control-fill);
  color: var(--text);
}
.secondary:hover:not(:disabled) {
  background: var(--control-fill-hover);
}
.quiet {
  color: var(--muted);
}
.quiet:hover:not(:disabled) {
  background: var(--control-fill);
  color: var(--text);
}
.text-button {
  min-height: 0;
  padding: 2px 0;
  color: var(--accent);
}
.text-button:hover:not(:disabled) {
  color: var(--accent-hover);
}
.full {
  width: 100%;
  min-height: var(--field-height);
}
label {
  display: block;
  font-size: var(--text-label);
  font-weight: 600;
  color: var(--text);
}
input[type='password'],
input[type='text'],
input[type='email'],
textarea {
  display: block;
  width: 100%;
  min-height: var(--field-height);
  padding: 9px 12px;
  border: 0;
  border-radius: var(--control-radius);
  background: var(--field-fill);
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--text);
  font-size: max(16px, 0.9375rem); /* 16px keeps iOS from zooming on focus */
  line-height: 1.4;
  transition: box-shadow 120ms ease;
}
input[type='password']:hover,
input[type='text']:hover,
input[type='email']:hover {
  box-shadow: inset 0 0 0 1px var(--input-line);
}
input[type='password']:focus-visible,
input[type='text']:focus-visible,
input[type='email']:focus-visible,
textarea:focus-visible {
  outline: none;
  box-shadow:
    inset 0 0 0 1px var(--accent),
    0 0 0 3px color-mix(in oklab, var(--accent), transparent 72%);
}
input::placeholder {
  color: var(--muted);
  opacity: 0.8;
}
.one-time-code,
.device-code {
  font-family: var(--ui-font-mono);
  letter-spacing: 0.16em;
  font-variant-numeric: tabular-nums;
}
.device-code {
  text-transform: uppercase;
}
.stack {
  display: grid;
  gap: 8px;
}
.stack > button,
.stack > .checkbox {
  margin-top: 6px;
}
.actions,
.code-actions,
.key-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.code-actions {
  justify-content: center;
  gap: 2px;
}
.checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 400;
  cursor: pointer;
}
.checkbox input {
  inline-size: 18px;
  block-size: 18px;
  margin: 0;
  accent-color: var(--accent);
}

/* ---------- Page frame ---------- */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: clamp(32px, 9vh, 96px) max(20px, env(safe-area-inset-right)) 56px max(20px, env(safe-area-inset-left));
}
main:focus {
  outline: none;
}
main > section {
  width: 100%;
}
.notice {
  width: min(560px, 100%);
  margin-bottom: 20px;
  padding: 10px 14px;
  border-radius: var(--control-radius);
  background: var(--accent-soft);
  color: var(--text);
  font-size: var(--text-label);
  line-height: 1.5;
}
.notice.error {
  background: var(--error-soft);
  color: var(--error);
}
.footer {
  padding: 20px max(20px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom));
  text-align: center;
}
.footer p {
  font-size: var(--text-caption);
}
.footer a {
  color: var(--muted);
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-underline-offset: 0.2em;
}
.footer a:hover {
  color: var(--text);
}
.skip {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 10;
  padding: 8px 12px;
  border-radius: var(--control-radius);
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: var(--text-label);
  font-weight: 600;
}
.skip:focus {
  top: 6px;
}

/* ---------- Status, sign-in, key and device screens: one centered column ---------- */
.state,
.auth {
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.state {
  max-width: 560px;
  align-items: flex-start;
  padding-top: clamp(0px, 6vh, 64px);
}
.state > p,
.lede {
  line-height: 1.7;
}
.auth > .app-icon,
.state > .app-icon {
  margin-bottom: 4px;
}
.auth > .lede {
  margin-top: -6px;
}
/* The page a "Save to Sponge" link is waiting to save: its whole address, up to three lines. */
.save-waiting {
  display: -webkit-box;
  overflow: hidden;
  color: var(--text);
  font-weight: 500;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}
#email-sign-in {
  margin-top: 8px;
}
/* Cloudflare Turnstile's check (app.js): it shows, and takes room, only while Cloudflare asks for a click. */
.human-check {
  display: flex;
  justify-content: center;
}
.human-check.asking {
  margin-top: 12px;
}
.sent {
  color: var(--text);
  font-size: 0.9375rem;
  margin-bottom: 6px;
}
.other-ways {
  border-radius: var(--group-radius);
  background: var(--surface);
}
.other-ways > summary {
  padding: 12px 14px;
  font-size: var(--text-label);
  font-weight: 600;
  color: var(--muted);
}
.other-ways > summary:hover {
  color: var(--text);
}
.other-ways-body {
  display: grid;
  gap: 10px;
  padding: 2px 14px 14px;
}
.other-ways[data-only] {
  background: none;
}
.other-ways[data-only] > .other-ways-body {
  padding: 0;
}
.create-account {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding-top: 4px;
  font-size: var(--text-label);
}
.secret {
  resize: none;
  font-family: var(--ui-font-mono);
  font-size: 0.875rem;
  overflow-wrap: anywhere;
}
summary {
  display: flex;
  align-items: center;
  gap: 8px;
  list-style: none;
  cursor: pointer;
  border-radius: var(--group-radius);
}
summary::-webkit-details-marker {
  display: none;
}
summary::before {
  content: '';
  inline-size: 6px;
  block-size: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 160ms ease;
}
details[open] > summary::before {
  transform: rotate(45deg);
}
summary:focus-visible {
  outline-offset: -2px;
}

/* ---------- Device confirmation ---------- */
.pair-start {
  display: grid;
  gap: 10px;
}
.pair-review {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 14px;
}
.code-match {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--group-radius);
  background: var(--surface);
  font-size: var(--text-label);
  color: var(--muted);
}
.code-chip {
  padding: 5px 10px;
  border-radius: var(--control-radius);
  background: var(--accent-soft);
  color: var(--text);
  font-family: var(--ui-font-mono);
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: 0.14em;
}
.pair-review .actions {
  margin-top: 2px;
}
.pair-review .primary {
  min-height: var(--field-height);
  padding: 0 22px;
}

/* ---------- Account settings: grouped fills, no rules ---------- */
.page {
  max-width: 640px;
  display: flex;
  flex-direction: column;
  gap: 36px;
}
.page-heading,
.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.page-heading p {
  margin-top: 4px;
}
.section-heading {
  align-items: center;
  margin-bottom: 10px;
  padding-inline: 2px;
}
.section-heading p {
  margin-top: 2px;
}
.item-list,
.empty,
.group {
  margin: 0;
  border-radius: var(--group-radius);
  background: var(--surface);
}
.item-list {
  list-style: none;
  padding: 0;
}
.item-list:empty {
  display: none;
}
.item-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 56px;
  padding: 10px 8px 10px 14px;
}
.item-list li + li {
  box-shadow: inset 0 1px 0 var(--soft-line);
}
.item-title {
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.item-detail {
  margin-top: 2px;
  font-size: var(--text-label);
  line-height: 1.4;
}
.disconnected {
  font-size: var(--text-label);
  color: var(--muted);
  padding-right: 6px;
}
.empty {
  padding: 14px;
  font-size: var(--text-label);
}
.group {
  padding: 14px;
}
.inline-form {
  display: grid;
  gap: 8px;
}
.field-row {
  display: flex;
  gap: 8px;
}
.field-row input {
  flex: 1;
  min-width: 0;
}
.field-row button {
  min-height: var(--field-height);
}
.proof .group {
  display: grid;
  gap: 8px;
  background: var(--accent-soft);
}
.proof .inline-form {
  margin-top: 6px;
}
.proof .actions {
  margin-top: 4px;
}
.group input,
.proof input {
  background: var(--canvas);
}
.disclosure {
  padding: 0;
}
.disclosure > summary {
  padding: 12px 14px;
  font-size: var(--text-label);
  font-weight: 600;
}
.details-body {
  display: grid;
  justify-items: start;
  gap: 12px;
  padding: 0 14px 14px;
}
.details-body p {
  font-size: var(--text-label);
}

/* ---------- Small screens ---------- */
@media (max-width: 560px) {
  main {
    padding-top: 28px;
  }
  .top-home span {
    display: none;
  }
  .page {
    gap: 28px;
  }
  .page-heading {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
  }
  .page-heading .button {
    min-height: var(--field-height);
  }
  .field-row {
    flex-direction: column;
  }
  .pair-review .actions,
  .pair-review .actions .primary {
    width: 100%;
  }
  .pair-review .actions {
    flex-direction: column;
  }
  .pair-review .actions button {
    width: 100%;
    min-height: var(--field-height);
  }
}
@media (pointer: coarse) {
  :root {
    --control-height: 40px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
  }
}

/* Sponge Plus: the free plan's cloud items as a thin amber meter (docs/billing.md). */
.plan-meter {
  block-size: 4px;
  margin-block: 4px 10px;
  overflow: hidden;
  border-radius: 2px;
  background: var(--raised, rgb(127 127 127 / 0.2));
}
.plan-meter span {
  display: block;
  block-size: 100%;
  background: var(--accent);
}

/* Inside the iPhone app: Get Plus with Restore Purchases, and the subscription's fine print (docs/billing.md). */
.plan-buttons {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
}
.apple-terms {
  margin-top: 8px;
  font-size: 0.75rem;
}
.apple-terms a {
  color: inherit;
}
