:root {
  --bg: #ffffff;
  --bg-subtle: #f7f7f8;
  --surface: #ffffff;
  --surface-raised: #f4f4f5;
  --border: #ececef;
  --border-strong: #d9d9de;
  --text: #18181b;
  --text-muted: #6b6b76;
  --text-faint: #a1a1aa;
  --accent: #e5322a;
  --accent-hover: #c92a22;
  --accent-soft: rgba(229, 50, 42, 0.09);
  --danger: #dc2626;
  --success: #16a34a;
  --success-soft: rgba(22, 163, 74, 0.12);
  --overlay: rgba(17, 17, 20, 0.4);
  --focus-ring: 0 0 0 3px rgba(229, 50, 42, 0.28);
  --shadow-sm: 0 1px 2px rgba(24, 24, 27, 0.05);
  --shadow-md: 0 6px 20px rgba(24, 24, 27, 0.09);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 10px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --pill: 999px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
  --space-12: 48px;
  --space-16: 64px;
  --ic-x: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3' stroke-linecap='round'%3E%3Cline x1='18' y1='6' x2='6' y2='18'/%3E%3Cline x1='6' y1='6' x2='18' y2='18'/%3E%3C/svg%3E");
  --ic-check: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
}

:root[data-theme="dark"] {
  --bg: #0b0b0d;
  --bg-subtle: #151517;
  --surface: #1b1b1e;
  --surface-raised: #26262a;
  --border: #2b2b30;
  --border-strong: #3c3c43;
  --text: #fafafa;
  --text-muted: #a1a1aa;
  --text-faint: #71717a;
  --accent: #ff453a;
  --accent-hover: #ff5a50;
  --accent-soft: rgba(255, 69, 58, 0.14);
  --danger: #ff6b6b;
  --success: #4ade80;
  --success-soft: rgba(74, 222, 128, 0.16);
  --overlay: rgba(0, 0, 0, 0.6);
  --focus-ring: 0 0 0 3px rgba(255, 69, 58, 0.45);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.55);
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    --bg: #0b0b0d;
    --bg-subtle: #151517;
    --surface: #1b1b1e;
    --surface-raised: #26262a;
    --border: #2b2b30;
    --border-strong: #3c3c43;
    --text: #fafafa;
    --text-muted: #a1a1aa;
    --text-faint: #71717a;
    --accent: #ff453a;
    --accent-hover: #ff5a50;
    --accent-soft: rgba(255, 69, 58, 0.14);
    --danger: #ff6b6b;
    --success: #4ade80;
    --success-soft: rgba(74, 222, 128, 0.16);
    --overlay: rgba(0, 0, 0, 0.6);
    --focus-ring: 0 0 0 3px rgba(255, 69, 58, 0.45);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.55);
  }
}

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

* {
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none;
  }
}

html {
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
}

h1, h2, h3, h4 {
  color: var(--text);
  margin: 0 0 0.5em;
}

h1 { font-size: clamp(1.75rem, 1.4rem + 1.2vw, 2.25rem); font-weight: 700; letter-spacing: -0.03em; }
h2 { font-size: clamp(1.35rem, 1.2rem + 0.6vw, 1.6rem); font-weight: 700; letter-spacing: -0.03em; }
h3 { font-size: clamp(1.1rem, 1.02rem + 0.3vw, 1.25rem); font-weight: 600; letter-spacing: -0.02em; }

a {
  color: var(--accent);
}

.hidden {
  display: none !important;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 2000;
  padding: .6rem 1rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  font-weight: 600;
  text-decoration: none;
  transform: translateY(-150%);
  transition: transform .15s ease;
}
.skip-link:focus {
  transform: translateY(0);
  outline: none;
  box-shadow: var(--focus-ring);
}

.container {
  width: 100%;
  margin-inline: auto;
  padding-inline: var(--space-4);
}
.container--narrow { max-width: 540px; }
.container--app { max-width: 720px; }
.container--wide { max-width: 1200px; }

@media (min-width: 768px) {
  .container { padding-inline: var(--space-6); }
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.btn,
button.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: 0 var(--space-4);
  border: 1px solid transparent;
  border-radius: var(--radius);
  font: inherit;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  background: var(--surface-raised);
  color: var(--text);
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}

.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn--primary {
  background: var(--accent);
  color: #ffffff;
}

.btn--secondary {
  background: var(--surface-raised);
  color: var(--text);
  border-color: var(--border);
}

.btn--danger {
  background: var(--danger);
  color: #ffffff;
}

.btn--ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

input,
textarea,
select {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-faint);
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  background: var(--overlay);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.modal {
  width: 100%;
  max-width: 420px;
  max-height: calc(100vh - 2rem);
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
  background: var(--surface);
  color: var(--text);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 2rem;
}
@media (min-width: 768px) {
  .modal { max-width: 480px; }
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0.2rem 0.6rem;
  border-radius: var(--pill);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.app-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 56px;
  padding: 0 var(--space-4);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

:root .theme-dark-only { display: none; }
:root[data-theme="dark"] .theme-light-only { display: none; }
:root[data-theme="dark"] .theme-dark-only { display: block; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-light-only { display: none; }
  :root:not([data-theme="light"]) .theme-dark-only { display: block; }
}

.pwd-rules li {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--text-faint);
  transition: color 0.1s;
}
.pwd-rules li[data-ok="true"] { color: var(--success); }
.pwd-rules li[data-ok="false"].touched { color: var(--danger); }
.pwd-rules li::before {
  content: "";
  width: 0.95em;
  height: 0.95em;
  flex: none;
  background: currentColor;
  -webkit-mask: var(--ic-x) center / contain no-repeat;
  mask: var(--ic-x) center / contain no-repeat;
}
.pwd-rules li[data-ok="true"]::before {
  -webkit-mask-image: var(--ic-check);
  mask-image: var(--ic-check);
}

.pwd-toggle svg { width: 1.15em; height: 1.15em; display: block; }
.pwd-toggle .icon-eye-off { display: none; }
.pwd-toggle.revealed .icon-eye { display: none; }
.pwd-toggle.revealed .icon-eye-off { display: block; }

.icon-x { width: 1em; height: 1em; display: block; }

.theme-toggle--floating {
  position: fixed;
  top: calc(var(--space-4) + env(safe-area-inset-top));
  right: var(--space-4);
  z-index: 50;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--pill);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.theme-toggle svg { width: 20px; height: 20px; }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}

.float-bar {
  position: fixed;
  left: 50%;
  bottom: calc(14px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  width: max-content;
  max-width: calc(100vw - 24px);
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--pill);
  box-shadow: var(--shadow-md);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  view-transition-name: app-footer;
}
.float-bar.hidden { display: none; }

.gbar-indicator {
  position: absolute;
  top: 6px;
  bottom: 6px;
  left: 0;
  width: 0;
  border-radius: var(--pill);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  transform: translateX(0);
  transition: transform .34s cubic-bezier(.34, 1.4, .5, 1), width .34s cubic-bezier(.34, 1.4, .5, 1);
  pointer-events: none;
  z-index: 0;
}

.gbar-slot {
  position: relative;
  display: flex;
  z-index: 1;
}
.gbar-btn {
  flex: 1;
  min-width: 68px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 52px;
  width: auto;
  margin: 0;
  padding: .45rem .9rem;
  background: none;
  border: none;
  border-radius: var(--pill);
  text-decoration: none;
  color: var(--text-muted);
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
}
.gbar-btn svg { width: 22px; height: 22px; display: block; flex: none; }
.gbar-label {
  font-size: .68rem;
  font-weight: 600;
  line-height: 1;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gbar-btn.active { color: var(--accent); }
.gbar-btn.following { color: var(--accent); }
.gbar-btn.hidden { display: none; }
.gbar-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--pill); }

.gallery-header {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 0.9rem 1.25rem;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.75rem;
  z-index: 10;
  view-transition-name: app-header;
}
.gh-left { display: flex; align-items: center; min-width: 0; }
.gh-center {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-width: 0;
}
.gh-right { display: flex; align-items: center; justify-content: flex-end; }
.gallery-header h1 { font-size: 1.1rem; margin: 0; font-weight: 600; letter-spacing: -0.01em; line-height: 0; }
.brand-logo { height: 36px; width: auto; display: block; }
.wordmark {
  font-weight: 800; letter-spacing: -0.035em; color: var(--text);
  line-height: 1; font-size: 1.3rem; white-space: nowrap; display: inline-block;
}
.wordmark .dot { color: var(--accent); }
.wordmark--lg { font-size: 1.95rem; }
.gh-event-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 480px) {
  .gallery-header { padding: 0.75rem 1rem; }
  .brand-logo { height: 32px; }
}

@view-transition { navigation: auto; }

@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) { animation: none !important; }
}

@media (hover: hover) and (pointer: fine) {
  .btn--primary:hover:not(:disabled) { background: var(--accent-hover); }
  .btn--secondary:hover:not(:disabled) { border-color: var(--border-strong); }
  .btn--ghost:hover:not(:disabled) { border-color: var(--border-strong); }
  .card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: var(--border-strong);
  }
  .theme-toggle:hover { border-color: var(--border-strong); }
  .gbar-btn:hover { color: var(--text); }
}
