/* Shared foundation for the gallery and account pages. Each page defines its colour tokens
   (--bg, --fg, --muted, --line, --surface, --accent, --accent-fg, --focus, --danger). */

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

:root {
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --radius: 10px;
  --gutter: 16px;
}

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html.has-dialog { overflow: hidden; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

img { display: block; max-width: 100%; }
button, input, textarea, select { font: inherit; color: inherit; }
h1, h2, h3, p { margin: 0; }
a { color: inherit; }

[hidden] { display: none !important; }

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--fg);
  font-weight: 500; font-size: 15px; letter-spacing: 0.01em;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background-color .15s, border-color .15s, opacity .15s;
}
.btn:hover { border-color: var(--muted); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn-primary:hover { border-color: var(--accent); filter: brightness(1.06); }
.btn-quiet { background: transparent; border-color: transparent; }
.btn-quiet:hover { border-color: var(--line); }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger.btn-solid { background: var(--danger); color: #fff; }
.btn-block { width: 100%; }
.btn.is-busy { pointer-events: none; opacity: .7; }

.link-btn {
  padding: 0; border: 0; background: none; color: var(--fg);
  text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font-size: inherit;
}

/* Forms */
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field label { font-size: 14px; font-weight: 500; }
.field .hint { font-size: 13px; color: var(--muted); }
.input {
  width: 100%; min-height: 46px; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--fg); font-size: 16px;
}
.input:focus-visible { outline-offset: 0; border-color: var(--focus); }
.form-error { color: var(--danger); font-size: 14px; margin: -4px 0 14px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; margin-bottom: 16px; }
.check input { width: 18px; height: 18px; margin-top: 3px; accent-color: var(--accent); }

/* Dialogs */
dialog.sheet {
  width: min(440px, calc(100% - 32px));
  padding: 28px; border: 1px solid var(--line); border-radius: 16px;
  background: var(--surface); color: var(--fg);
  box-shadow: 0 24px 64px rgba(0, 0, 0, .25);
}
dialog.sheet::backdrop { background: rgba(10, 10, 10, .45); }
dialog.sheet h2 { font-size: 20px; margin-bottom: 10px; }
dialog.sheet p { color: var(--muted); margin-bottom: 20px; }
.sheet-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }

/* Toasts */
.toasts {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%); z-index: 100;
  display: grid; gap: 8px; width: min(480px, calc(100% - 32px));
  pointer-events: none;
}
.toast {
  padding: 12px 16px; border-radius: 12px;
  background: var(--fg); color: var(--bg);
  font-size: 15px; box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
  animation: toast-in .2s ease-out;
}
.toast.is-error { background: var(--danger); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--muted);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

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