:root {
  color-scheme: light;
  --bg: #f7f5ef;
  --surface: rgba(255, 255, 255, 0.86);
  --surface-solid: #ffffff;
  --ink: #111319;
  --muted: #68707c;
  --line: rgba(17, 19, 25, 0.1);
  --accent: #147f88;
  --accent-soft: #e6f4f3;
  --warm: #e4583e;
  --good: #2f9e6d;
  --warn: #cc8519;
  --danger: #c94b4b;
  --shadow: 0 18px 48px rgba(24, 30, 37, 0.12);
  --radius: 8px;
  --page-pad: clamp(14px, 4vw, 28px);
  --bottom-space: calc(94px + env(safe-area-inset-bottom, 0px));
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root.dark {
  color-scheme: dark;
  --bg: #0d0f14;
  --surface: rgba(25, 28, 35, 0.88);
  --surface-solid: #171a21;
  --ink: #f3f4f1;
  --muted: #a4acb8;
  --line: rgba(255, 255, 255, 0.12);
  --accent: #6fd6c7;
  --accent-soft: rgba(111, 214, 199, 0.14);
  --warm: #ff7f5f;
  --shadow: 0 20px 56px rgba(0, 0, 0, 0.36);
}

* {
  box-sizing: border-box;
}

html {
  width: 100%;
  min-width: 100%;
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  width: 100%;
  min-width: 100%;
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 12% 0%, rgba(20, 127, 136, 0.12), transparent 28rem),
    linear-gradient(145deg, var(--bg), color-mix(in srgb, var(--bg), #ffffff 18%));
  color: var(--ink);
}

button,
input,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

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

.app-shell {
  position: relative;
  width: 100%;
  min-width: 100%;
  min-height: 100dvh;
  margin: 0;
  padding: calc(12px + env(safe-area-inset-top, 0px)) var(--page-pad) var(--bottom-space);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 0 0 12px;
  background: color-mix(in srgb, var(--bg), transparent 24%);
  backdrop-filter: blur(18px);
}

.topbar h1,
h2,
h3,
p {
  margin: 0;
}

.topbar h1 {
  font-size: clamp(1.4rem, 6vw, 2rem);
  line-height: 1;
}

.eyebrow,
.small-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.avatar-button,
.icon-button,
.primary-icon {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line);
}

.avatar-button img {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  object-fit: cover;
}

.primary-icon {
  background: var(--accent);
  color: #fff;
  box-shadow: none;
}

.header-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

.screen-stack {
  display: block;
  width: 100%;
}

.screen {
  display: none;
  width: 100%;
  min-width: 0;
}

.screen.is-active {
  display: block;
  padding-bottom: 18px;
}

.hero-strip,
.event-header,
.sync-card,
.review-status,
.panel,
.detail-panel {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.hero-strip {
  display: grid;
  gap: 18px;
  min-height: clamp(210px, 42vw, 360px);
  padding: clamp(18px, 5vw, 32px);
  align-content: end;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.04), rgba(0, 0, 0, 0.54)),
    url("https://images.unsplash.com/photo-1507525428034-b723cf961d3e?auto=format&fit=crop&w=1600&q=82") center/cover;
  color: #fff;
}

.hero-strip .eyebrow {
  color: rgba(255, 255, 255, 0.78);
}

.hero-strip h2 {
  max-width: min(100%, 18ch);
  margin-top: 6px;
  font-size: clamp(2rem, 8.5vw, 4.4rem);
  line-height: 0.98;
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  gap: 8px;
  border-radius: 999px;
  padding: 0 18px;
  font-weight: 850;
  white-space: nowrap;
}

.primary-button {
  background: var(--ink);
  color: var(--bg);
}

.secondary-button {
  background: color-mix(in srgb, var(--accent), transparent 84%);
  color: var(--accent);
}

.ghost-button {
  background: transparent;
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line);
}

.danger-button {
  width: 100%;
  background: color-mix(in srgb, var(--danger), transparent 86%);
  color: var(--danger);
}

.sync-card,
.review-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 16px 0;
  padding: 16px;
}

.section-heading,
.panel-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin: 26px 2px 12px;
}

.section-heading span,
.panel-title span,
.event-header p,
.detail-panel span,
.setting-row span,
.invite-card p {
  color: var(--muted);
  font-size: 0.9rem;
}

.event-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  width: 100%;
}

.event-card {
  display: grid;
  grid-template-columns: clamp(92px, 27vw, 132px) minmax(0, 1fr);
  gap: 14px;
  width: 100%;
  min-height: 126px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-solid);
  color: var(--ink);
  text-align: left;
  box-shadow: 0 10px 24px rgba(24, 30, 37, 0.08);
}

.event-card > span {
  min-width: 0;
}

.event-card img {
  width: 100%;
  height: 100%;
  min-height: 106px;
  border-radius: 7px;
  object-fit: cover;
}

.event-card h3 {
  overflow-wrap: anywhere;
  font-size: clamp(1.1rem, 4.8vw, 1.45rem);
  line-height: 1.08;
}

.event-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0;
}

.status-pill,
.event-meta span,
.photo-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 850;
}

.status-pill.complete {
  color: var(--good);
  background: color-mix(in srgb, var(--good), transparent 86%);
}

.status-pill.pending {
  color: var(--warn);
  background: color-mix(in srgb, var(--warn), transparent 84%);
}

.event-progress {
  display: grid;
  grid-template-columns: minmax(72px, 1fr) auto;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 0.82rem;
}

.bar {
  height: 6px;
  overflow: hidden;
  border-radius: 99px;
  background: color-mix(in srgb, var(--muted), transparent 82%);
}

.bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.event-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px;
}

.event-header h2 {
  margin: 4px 0;
  font-size: clamp(1.5rem, 6vw, 2.4rem);
  line-height: 1.04;
}

.segmented {
  display: flex;
  gap: 6px;
  width: 100%;
  margin: 14px 0;
  padding: 5px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}

.segmented button {
  flex: 1 0 auto;
  min-height: 36px;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-weight: 850;
  padding: 0 12px;
}

.segmented button.is-selected {
  background: var(--ink);
  color: var(--bg);
}

.day-group {
  margin-top: 20px;
}

.day-group h3 {
  margin: 0 2px 10px;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 3px;
  width: 100%;
  overflow: hidden;
  border-radius: var(--radius);
}

.photo-tile {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--surface-solid);
}

.photo-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 180ms ease;
}

.photo-tile:active img,
.photo-tile:hover img {
  transform: scale(1.04);
}

.photo-badge {
  position: absolute;
  left: 6px;
  bottom: 6px;
  background: rgba(0, 0, 0, 0.58);
  color: #fff;
}

.photo-actions {
  position: absolute;
  inset: auto 6px 6px 6px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  opacity: 0;
  transition: opacity 160ms ease;
}

.photo-tile:focus-within .photo-actions,
.photo-tile:hover .photo-actions {
  opacity: 1;
}

.photo-actions button {
  min-height: 30px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: #111;
  font-size: 0.74rem;
  font-weight: 900;
}

.progress-ring {
  display: grid;
  flex: 0 0 58px;
  width: 58px;
  height: 58px;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--accent) 0deg, color-mix(in srgb, var(--muted), transparent 82%) 0deg);
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 900;
}

.details-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin: 14px 0;
}

.detail-panel,
.panel {
  padding: 16px;
}

.panel {
  margin-top: 14px;
}

.panel-action {
  width: 100%;
  margin-top: 14px;
}

.panel-title {
  margin: 0 0 12px;
}

.invite-card,
.setting-row,
.member-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.profile-header {
  display: block;
}

.profile-identity {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.profile-identity span {
  min-width: 0;
}

.profile-identity img {
  width: clamp(56px, 16vw, 76px);
  height: clamp(56px, 16vw, 76px);
  flex: 0 0 auto;
  border-radius: 999px;
  object-fit: cover;
}

.profile-identity h2 {
  margin: 4px 0;
  overflow-wrap: anywhere;
  font-size: clamp(1.5rem, 6vw, 2.4rem);
  line-height: 1.04;
}

#profileScreen .panel:last-child {
  margin-bottom: 18px;
}

.invite-card {
  align-items: flex-start;
}

.qr {
  display: grid;
  grid-template-columns: repeat(4, 12px);
  grid-auto-rows: 12px;
  gap: 4px;
  flex: 0 0 auto;
  padding: 12px;
  border-radius: 8px;
  background: #fff;
}

.qr span {
  background: #111;
  border-radius: 2px;
}

.qr span:nth-child(3n),
.qr span:nth-child(5n) {
  opacity: 0.18;
}

.member-list {
  display: grid;
  gap: 10px;
}

.member-row {
  justify-content: space-between;
}

.member-person {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.member-person img {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 999px;
  object-fit: cover;
}

.folder-map {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.folder-map span {
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 850;
}

.setting-row {
  justify-content: space-between;
  align-items: center;
  min-width: 0;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.setting-row > div {
  min-width: 0;
}

.setting-row strong,
.setting-row span {
  display: block;
  overflow-wrap: anywhere;
}

.setting-row:last-child {
  border-bottom: 0;
}

.switch input {
  position: absolute;
  opacity: 0;
}

.switch span {
  display: block;
  width: 50px;
  height: 30px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--muted), transparent 75%);
  padding: 3px;
}

.switch span::after {
  content: "";
  display: block;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  transition: transform 160ms ease;
}

.switch input:checked + span {
  background: var(--accent);
}

.switch input:checked + span::after {
  transform: translateX(20px);
}

.bottom-nav {
  position: fixed;
  z-index: 1000;
  left: var(--page-pad);
  right: var(--page-pad);
  bottom: max(10px, env(safe-area-inset-bottom, 0px));
  display: grid !important;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  min-height: 64px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-solid), transparent 8%);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
  visibility: visible;
  opacity: 1;
}

#profileScreen.is-active {
  padding-bottom: 18px;
}

.bottom-nav button {
  display: grid;
  min-width: 0;
  place-items: center;
  gap: 2px;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: clamp(0.65rem, 2.5vw, 0.76rem);
  font-weight: 850;
}

.bottom-nav span {
  font-size: 1.1rem;
}

.bottom-nav button.is-active {
  background: var(--ink);
  color: var(--bg);
}

.sheet-backdrop,
.viewer {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  background: rgba(0, 0, 0, 0.48);
}

.sheet-backdrop.is-open,
.viewer.is-open {
  display: block;
}

.sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  gap: 14px;
  max-height: 92dvh;
  padding: 10px 18px calc(18px + env(safe-area-inset-bottom, 0px));
  border-radius: 18px 18px 0 0;
  background: var(--surface-solid);
  color: var(--ink);
}

.grabber {
  width: 42px;
  height: 5px;
  margin: 0 auto 4px;
  border-radius: 99px;
  background: color-mix(in srgb, var(--muted), transparent 70%);
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--ink);
  padding: 12px;
}

textarea {
  min-height: 84px;
  resize: vertical;
}

.field-row,
.drive-choice {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

#connectDriveButton {
  width: 100%;
  margin-bottom: 10px;
}

.viewer {
  background: #050608;
  color: #fff;
  touch-action: none;
}

.viewer img {
  position: absolute;
  inset: 50% auto auto 50%;
  width: 100%;
  max-height: 74dvh;
  object-fit: contain;
  transform: translate(-50%, -50%) scale(var(--zoom, 1));
  transition: transform 160ms ease;
}

.viewer-top {
  position: absolute;
  top: calc(12px + env(safe-area-inset-top, 0px));
  left: 12px;
  right: 12px;
  z-index: 2;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 12px;
}

.viewer-top span {
  display: block;
  color: rgba(255, 255, 255, 0.68);
  font-size: 0.82rem;
}

.viewer-actions {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  z-index: 2;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.viewer-nav {
  position: absolute;
  top: 50%;
  z-index: 2;
  width: 44px;
  height: 68px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 2rem;
}

.viewer-nav.left {
  left: 8px;
}

.viewer-nav.right {
  right: 8px;
}

.metadata-drawer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 4;
  max-height: 46dvh;
  overflow: auto;
  padding: 10px 18px calc(20px + env(safe-area-inset-bottom, 0px));
  border-radius: 18px 18px 0 0;
  background: var(--surface-solid);
  color: var(--ink);
  transform: translateY(100%);
  transition: transform 180ms ease;
}

.metadata-drawer.is-open {
  transform: translateY(0);
}

dl {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px 16px;
  margin: 14px 0 0;
}

dt {
  color: var(--muted);
  font-weight: 850;
}

dd {
  margin: 0;
  text-align: right;
}

.toast {
  position: fixed;
  left: var(--page-pad);
  right: var(--page-pad);
  bottom: calc(164px + env(safe-area-inset-bottom, 0px));
  z-index: 70;
  padding: 12px 14px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  text-align: center;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (min-width: 560px) {
  .event-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .details-grid,
  .field-row,
  .drive-choice {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .photo-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
  }

  .sheet,
  .metadata-drawer {
    left: 50%;
    right: auto;
    width: min(100%, 560px);
    transform: translateX(-50%);
  }

  .metadata-drawer {
    transform: translate(-50%, 100%);
  }

  .metadata-drawer.is-open {
    transform: translate(-50%, 0);
  }
}

@media (max-width: 420px) {
  .setting-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .setting-row .ghost-button {
    width: 100%;
  }

  .setting-row .switch {
    align-self: flex-end;
  }
}

@media (min-width: 900px) {
  .event-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .photo-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
}

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