:root {
  --bg: #f4f7fb;
  --panel: rgba(255, 255, 255, 0.88);
  --panel-soft: #f4f7ff;
  --text: #14213d;
  --muted: #64748b;
  --primary: #635bff;
  --primary-dark: #4338ca;
  --accent: #0ea5e9;
  --accent-soft: rgba(14, 165, 233, 0.12);
  --border: rgba(148, 163, 184, 0.24);
  --shadow: 0 24px 60px rgba(15, 23, 42, 0.12);
  --shadow-soft: 0 12px 30px rgba(15, 23, 42, 0.08);
  --radius: 24px;
  --success-bg: #ecfdf5;
  --success-text: #065f46;
  --warning-bg: #fff7ed;
  --warning-text: #9a3412;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  font-family: "Inter", sans-serif;
  color: var(--text);
  background: linear-gradient(135deg, #f8fbff 0%, #eff4ff 45%, #f8f5ff 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: -20% -10% auto;
  height: 28rem;
  background:
    radial-gradient(circle at top left, rgba(99, 91, 255, 0.16), transparent 0 38%),
    radial-gradient(circle at top right, rgba(14, 165, 233, 0.14), transparent 0 32%),
    radial-gradient(circle at center, rgba(236, 72, 153, 0.08), transparent 0 26%);
  pointer-events: none;
  z-index: -1;
}

img {
  max-width: 100%;
  display: block;
}

.container {
  width: min(1120px, calc(100% - 2rem));
  margin: 0 auto;
}

.page-shell {
  padding-bottom: 2rem;
}

.hero {
  padding: 1.2rem 0 2rem;
}

.topbar {
  position: sticky;
  top: 0.75rem;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.8rem;
  color: inherit;
  text-decoration: none;
}

.brand__mark {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  color: white;
  box-shadow: 0 12px 24px rgba(99, 91, 255, 0.28);
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: var(--muted);
}

.topbar__links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  align-items: center;
  justify-content: flex-end;
}

.topbar__links a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  padding: 0.4rem 0.1rem;
  white-space: nowrap;
  transition: color 0.2s ease, background 0.2s ease;
}

.topbar__links a:hover {
  color: var(--primary-dark);
}

.topbar__links a[aria-current="page"] {
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  background: rgba(99, 91, 255, 0.12);
  color: var(--primary-dark);
}

.topbar__tag {
  display: inline-flex;
  align-items: center;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 700;
}

.topbar__toggle {
  display: none;
  margin-left: auto;
}

.hero__content {
  display: grid;
  grid-template-columns: 1.25fr 0.95fr;
  gap: 1.5rem;
  align-items: stretch;
}

.hero__content > div:first-child {
  padding: 1rem 0;
}

.hero h1 {
  margin: 0.25rem 0 0.8rem;
  max-width: 12ch;
  font-size: clamp(2.4rem, 4vw, 3.8rem);
  line-height: 1.02;
  letter-spacing: -0.04em;
}

.hero__text,
.section-text {
  max-width: 640px;
  line-height: 1.65;
  color: var(--muted);
}

.hero__text {
  font-size: 1.04rem;
}

.hero__actions,
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.hero__actions,
.toolbar {
  margin-top: 1rem;
}

.hero__panel,
.panel {
  position: relative;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  backdrop-filter: blur(14px);
}

.hero__panel::after,
.panel::after {
  content: "";
  position: absolute;
  right: -2rem;
  bottom: -3.5rem;
  width: 10rem;
  height: 10rem;
  background: radial-gradient(circle, rgba(99, 91, 255, 0.16), transparent 70%);
  pointer-events: none;
}

.hero__panel {
  padding: 1.3rem;
}

.hero__panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.hero__note {
  margin: 1rem 0 0;
  padding: 0.9rem 1rem;
  border-radius: 16px;
  border: 1px solid rgba(99, 91, 255, 0.12);
  background: linear-gradient(135deg, rgba(99, 91, 255, 0.08), rgba(14, 165, 233, 0.09));
  color: #334155;
  line-height: 1.55;
}

.auth-landing {
  display: grid;
  min-height: 100vh;
  align-items: center;
}

.auth-landing__main {
  display: grid;
  place-items: center;
  padding: 2rem 0;
}

.auth-landing__panel {
  width: min(42rem, 100%);
  padding: 1.4rem;
}

.auth-landing__panel h1 {
  margin: 0.35rem 0 0.8rem;
  font-size: clamp(2.2rem, 4vw, 3.3rem);
  line-height: 1.05;
  letter-spacing: -0.04em;
}

.auth-landing__panel .brand {
  margin-bottom: 1rem;
}

.main-layout {
  padding: 0.5rem 0 3rem;
}

.panel {
  padding: 1.25rem;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.76rem;
  font-weight: 800;
  color: var(--primary);
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1rem;
}

.section-heading--compact {
  margin-bottom: 0.75rem;
}

.section-heading h2,
.panel h3,
.hero__panel h2 {
  margin: 0.35rem 0 0;
}

.section-text {
  margin: 0.45rem 0 0;
}

.stats-grid,
.card-grid,
.form-grid,
.status-grid {
  display: grid;
  gap: 1rem;
}

.stats-grid,
.status-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 1rem;
}

.stat-card,
.status-tile {
  padding: 1rem;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, #ffffff 0%, #f7faff 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.stat-card {
  position: relative;
}

.stat-card::before {
  content: "";
  display: block;
  width: 0.7rem;
  height: 0.7rem;
  margin-bottom: 0.6rem;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
}

.stat-card span,
.status-tile strong {
  display: block;
  font-size: 1.1rem;
  font-weight: 800;
}

.stat-card span {
  font-size: 1.95rem;
  letter-spacing: -0.04em;
}

.stat-card p {
  margin: 0.25rem 0 0;
  color: var(--muted);
}

.status-label {
  display: block;
  margin-bottom: 0.3rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.info-banner {
  margin: 1rem 0 0;
  padding: 0.9rem 1rem;
  border-radius: 14px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
  box-shadow: var(--shadow-soft);
}

.info-banner--success {
  background: var(--success-bg);
  border-color: #a7f3d0;
  color: var(--success-text);
}

.info-banner--warning {
  background: var(--warning-bg);
  border-color: #fed7aa;
  color: var(--warning-text);
}

.action-banner {
  margin: 0 0 1rem;
}

.upload-progress {
  margin: 0 0 1rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-soft);
}

.upload-progress__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.6rem;
}

.upload-progress__label {
  font-weight: 700;
  color: var(--text);
}

.progress-track {
  width: 100%;
  height: 0.65rem;
  overflow: hidden;
  border-radius: 999px;
  background: #e2e8f0;
}

.progress-fill {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  transition: width 0.18s ease;
}

body.modal-open {
  overflow: hidden;
}

.custom-modal[hidden] {
  display: none !important;
}

.custom-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.custom-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(6px);
}

.custom-modal__dialog {
  position: relative;
  z-index: 1;
  width: min(34rem, calc(100vw - 1rem));
  max-height: calc(100vh - 2rem);
  overflow: auto;
}

.custom-modal__dialog::after {
  display: none;
}

.custom-modal__form {
  display: grid;
  gap: 0.9rem;
  margin-top: 1rem;
}

.custom-modal__field {
  display: grid;
  gap: 0.35rem;
  font-size: 0.94rem;
  font-weight: 700;
}

.custom-modal__field input,
.custom-modal__field textarea,
.custom-modal__field select {
  width: 100%;
  border: 1px solid #d2dbe7;
  border-radius: 14px;
  padding: 0.82rem 0.92rem;
  font: inherit;
  background: white;
}

.custom-modal__field textarea {
  resize: vertical;
}

.custom-modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
}

.recent-panel {
  margin-top: 1.5rem;
}

.family-access-panel {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.family-users-list {
  display: grid;
  gap: 0.75rem;
}

.family-user-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
}

.family-user-card strong,
.family-user-card span {
  display: block;
}

.family-user-card span {
  color: var(--muted);
  font-size: 0.9rem;
}

.chooser-bar {
  align-items: center;
}

.chooser-label {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--muted);
}

.chooser-select {
  min-width: 12rem;
  border: 1px solid #d2dbe7;
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
  font: inherit;
  background: white;
}

.recent-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.recent-card {
  padding: 1rem;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, #ffffff 0%, #f9fbff 100%);
  box-shadow: var(--shadow-soft);
}

.recent-card h4 {
  margin: 0 0 0.35rem;
}

.recent-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.archive-form {
  padding: 1rem;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.8);
  box-shadow: var(--shadow-soft);
}

.archive-form h3 {
  margin-bottom: 0.9rem;
}

.archive-form label {
  display: block;
  margin-bottom: 0.9rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.archive-form input,
.archive-form textarea,
.archive-form select {
  width: 100%;
  margin-top: 0.35rem;
  border: 1px solid #d2dbe7;
  border-radius: 14px;
  padding: 0.82rem 0.92rem;
  font: inherit;
  background: white;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.archive-form input:focus-visible,
.archive-form textarea:focus-visible,
.archive-form select:focus-visible {
  outline: none;
  border-color: rgba(99, 91, 255, 0.58);
  box-shadow: 0 0 0 4px rgba(99, 91, 255, 0.12);
}

.archive-form textarea {
  resize: vertical;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: none;
  border-radius: 999px;
  padding: 0.78rem 1rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition:
    transform 0.18s ease,
    background 0.2s ease,
    box-shadow 0.2s ease,
    opacity 0.2s ease,
    border-color 0.2s ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.button--primary {
  background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
  color: white;
  box-shadow: 0 12px 24px rgba(99, 91, 255, 0.24);
}

.button--primary:hover {
  background: linear-gradient(135deg, var(--primary-dark) 0%, #6d28d9 100%);
  box-shadow: 0 16px 28px rgba(99, 91, 255, 0.3);
}

.button--secondary {
  background: rgba(255, 255, 255, 0.88);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
}

.button--secondary:hover {
  border-color: rgba(99, 91, 255, 0.3);
}

.button--danger {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
  box-shadow: none;
}

.button--danger:hover {
  background: #fecaca;
}

.button--small {
  padding: 0.55rem 0.8rem;
  font-size: 0.85rem;
}

.file-button {
  position: relative;
}

.archive-sections {
  margin-top: 1.7rem;
}

.stack {
  display: grid;
  gap: 1rem;
}

.card-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.archive-card {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
  box-shadow: var(--shadow-soft);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.archive-card:hover,
.status-tile:hover,
.highlight-tile:hover {
  transform: translateY(-3px);
  border-color: rgba(99, 91, 255, 0.24);
  box-shadow: 0 18px 38px rgba(15, 23, 42, 0.12);
}

.archive-card__body {
  padding: 1rem;
}

.archive-card__body h4 {
  margin: 0 0 0.45rem;
  font-size: 1.05rem;
}

.archive-card__body p {
  color: var(--muted);
  margin: 0.35rem 0;
  line-height: 1.5;
}

.archive-card__actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.7rem;
  flex-wrap: wrap;
}

.card-admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.85rem;
}

.card-footnote {
  margin-top: 0.7rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.photo-grid {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.photo-card img {
  aspect-ratio: 4 / 3;
  object-fit: cover;
  width: 100%;
  background: linear-gradient(135deg, #dbeafe, #ede9fe);
}

.badge {
  display: inline-flex;
  border-radius: 999px;
  padding: 0.28rem 0.6rem;
  font-size: 0.74rem;
  font-weight: 700;
  background: #eef2ff;
  border: 1px solid rgba(99, 91, 255, 0.12);
  color: var(--primary-dark);
}

.badge--new {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #065f46;
}

.badge--admin {
  background: #fff7ed;
  border-color: #fdba74;
  color: #9a3412;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}

.link-chip {
  display: inline-flex;
  margin-top: 0.45rem;
  color: var(--primary);
  font-weight: 700;
  text-decoration: none;
}

.link-chip:hover {
  color: var(--primary-dark);
}

.empty-state {
  padding: 1.1rem;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: 16px;
  background: #fafcff;
}

.empty-state__icon {
  display: block;
  margin-bottom: 0.45rem;
  font-size: 1.5rem;
}

@media (max-width: 960px) {
  .topbar,
  .section-heading,
  .chooser-bar,
  .archive-card__actions,
  .family-user-card {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar {
    position: static;
  }

  .topbar__toggle {
    display: inline-flex;
    align-self: flex-end;
  }

  .topbar__links {
    width: 100%;
    justify-content: flex-start;
    gap: 0.55rem;
  }

  .topbar__links[data-collapsible="true"] {
    display: none;
  }

  .topbar--nav-open .topbar__links[data-collapsible="true"] {
    display: flex;
  }

  .topbar__links a {
    padding: 0.5rem 0.75rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.74);
    border: 1px solid var(--border);
  }

  .hero__content,
  .form-grid,
  .status-grid {
    grid-template-columns: 1fr;
  }

  .custom-modal__dialog {
    width: min(36rem, calc(100vw - 1rem));
  }
}

@media (max-width: 600px) {
  .container {
    width: min(100% - 0.75rem, 1120px);
  }

  .hero {
    padding-top: 0.6rem;
    padding-bottom: 1rem;
  }

  .panel,
  .hero__panel,
  .archive-form,
  .topbar {
    padding: 0.95rem;
    border-radius: 18px;
  }

  .hero h1,
  .auth-landing__panel h1 {
    max-width: none;
    font-size: clamp(2rem, 10vw, 2.8rem);
  }

  .recent-list,
  .card-grid,
  .photo-grid,
  .stats-grid,
  .status-grid {
    grid-template-columns: 1fr;
  }

  .topbar__links,
  .toolbar,
  .hero__actions,
  .chooser-bar,
  .custom-modal__actions,
  .card-admin-actions,
  .topbar__toggle {
    width: 100%;
  }

  .topbar__links a,
  .hero__actions .button,
  .toolbar .button,
  .toolbar .file-button,
  .chooser-select,
  .custom-modal__actions .button {
    width: 100%;
  }

  .topbar__links a {
    text-align: center;
  }

  .chooser-select {
    min-width: 0;
  }

  .auth-landing__main,
  .custom-modal {
    padding: 0.75rem;
  }

  .custom-modal__dialog {
    width: calc(100vw - 0.75rem);
    max-height: calc(100vh - 0.75rem);
  }

  .custom-modal__actions {
    flex-direction: column-reverse;
  }
}