:root {
  color-scheme: light;
  --paper: #f4f0e8;
  --ink: #171717;
  --muted: #6f6a61;
  --line: rgba(23, 23, 23, 0.16);
  --panel: rgba(255, 255, 255, 0.42);
  --white: #fffef9;
  --danger: #9b2c24;
  --shadow: 0 18px 55px rgba(27, 24, 20, 0.11);
  --radius-lg: 28px;
  --radius-md: 18px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: Inter, "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
}

* { box-sizing: border-box; }

html { background: var(--paper); }

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 92% 2%, rgba(255,255,255,.82), transparent 30%),
    linear-gradient(180deg, #f7f3eb 0%, var(--paper) 100%);
  color: var(--ink);
  min-height: 100vh;
}

button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--ink); outline-offset: 4px; }

.app-shell {
  width: min(100%, 1120px);
  margin: 0 auto;
  padding: calc(18px + var(--safe-top)) 22px calc(28px + var(--safe-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.06em;
}

.brand-copy { display: grid; gap: 2px; }
.brand-copy strong { font-size: 15px; letter-spacing: .18em; }
.brand-copy small { color: var(--muted); font-size: 11px; letter-spacing: .04em; }

.connect-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: transparent;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #a7a199;
}
.connect-button.connected .status-dot { background: #1f7a4f; }
.connect-button:disabled { opacity: .55; cursor: wait; }

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(220px, .55fr);
  grid-template-areas:
    "copy camera"
    "expiry camera";
  gap: 26px 42px;
  padding: clamp(48px, 8vw, 94px) 0 clamp(54px, 8vw, 90px);
}

.hero-copy { grid-area: copy; align-self: end; }
.eyebrow {
  margin: 0 0 13px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .2em;
}

h1 {
  margin: 0;
  max-width: 760px;
  font-size: clamp(54px, 9.5vw, 126px);
  line-height: .91;
  letter-spacing: -.075em;
  font-weight: 780;
}

.headline-line {
  display: block;
  white-space: nowrap;
}

.hero-description {
  margin: 28px 0 0;
  color: var(--muted);
  font-size: clamp(14px, 1.8vw, 18px);
  line-height: 1.9;
}

.camera-button {
  grid-area: camera;
  align-self: center;
  justify-self: center;
  display: grid;
  justify-items: center;
  gap: 14px;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.camera-ring {
  display: grid;
  place-items: center;
  width: clamp(184px, 26vw, 286px);
  aspect-ratio: 1;
  border: 2px solid var(--ink);
  border-radius: 50%;
  transition: transform .2s ease, background .2s ease;
}

.camera-lens {
  width: 72%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--ink);
  box-shadow: inset 0 0 0 2px var(--ink);
  transition: transform .2s ease, background .2s ease;
}
.camera-button:hover .camera-ring { transform: scale(1.025); background: rgba(255,255,255,.45); }
.camera-button:active .camera-lens { transform: scale(.92); }
.camera-button:disabled { opacity: .42; cursor: not-allowed; }
.camera-label { font-size: 13px; font-weight: 800; letter-spacing: .18em; }

.expiry-strip {
  grid-area: expiry;
  display: flex;
  align-items: center;
  gap: 18px;
  width: fit-content;
  padding-top: 22px;
  border-top: 1px solid var(--ink);
}
.expiry-strip > div { display: flex; align-items: baseline; gap: 4px; }
.expiry-number { font-size: 52px; line-height: .8; font-weight: 800; letter-spacing: -.08em; }
.expiry-unit { font-size: 11px; font-weight: 800; letter-spacing: .13em; }
.expiry-strip p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.55; }

.library {
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 18px;
  margin-bottom: 22px;
}
.section-heading h2 { margin: 0; font-size: clamp(28px, 4vw, 48px); letter-spacing: -.055em; }
.section-actions { display: flex; gap: 12px; }
.text-button {
  padding: 0 0 4px;
  border: 0;
  border-bottom: 1px solid currentColor;
  background: transparent;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}
.text-button:disabled { opacity: .35; cursor: not-allowed; }

.summary-bar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 320px;
  text-align: center;
}
.empty-symbol {
  display: grid;
  place-items: center;
  width: 78px;
  height: 78px;
  margin-bottom: 20px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  font-size: 48px;
  font-weight: 200;
}
.empty-state p { margin: 0 0 8px; font-weight: 800; }
.empty-state small { max-width: 370px; color: var(--muted); line-height: 1.7; }

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

.photo-card { min-width: 0; }
.photo-frame {
  position: relative;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius-md);
  background: #ddd8cf;
}
.photo-image { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity .25s ease; }
.photo-image.loaded { opacity: 1; }
.photo-placeholder {
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, #ded9d0 20%, #ece8df 40%, #ded9d0 60%);
  background-size: 220% 100%;
  animation: shimmer 1.4s linear infinite;
}
.photo-image.loaded + .days-badge ~ .photo-placeholder { display: none; }
.days-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(19,19,19,.82);
  color: white;
  font-size: 11px;
  font-weight: 800;
  backdrop-filter: blur(8px);
}
.days-badge.urgent { background: rgba(142, 43, 34, .9); }
.photo-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 3px 0;
}
.photo-date { color: var(--muted); font-size: 11px; }
.photo-actions { display: flex; align-items: center; gap: 10px; }
.keep-button, .trash-button {
  border: 0;
  background: transparent;
  font-size: 11px;
  font-weight: 850;
  letter-spacing: .08em;
  cursor: pointer;
}
.keep-button { padding: 4px 0; border-bottom: 1px solid currentColor; }
.trash-button { color: var(--muted); padding: 4px 0; }

.principle { padding: clamp(62px, 10vw, 110px) 0; text-align: center; }
.principle blockquote { margin: 0; font-size: clamp(28px, 5.3vw, 66px); line-height: 1.22; letter-spacing: -.055em; font-weight: 720; }

footer {
  display: flex;
  justify-content: space-between;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .15em;
}

.capture-dialog, .confirm-dialog {
  width: min(calc(100% - 28px), 620px);
  max-height: calc(100vh - 28px);
  padding: 0;
  border: 0;
  border-radius: 26px;
  background: var(--white);
  color: var(--ink);
  box-shadow: 0 28px 90px rgba(0,0,0,.25);
}
.capture-dialog::backdrop, .confirm-dialog::backdrop { background: rgba(18,17,15,.62); backdrop-filter: blur(8px); }
.dialog-card { padding: 18px; }
.dialog-card.compact { padding: 30px; }
.dialog-image-wrap { position: relative; overflow: hidden; aspect-ratio: 4/3; border-radius: 18px; background: #ddd; }
.dialog-image-wrap img { width: 100%; height: 100%; object-fit: contain; background: #181818; }
.preview-badge { position: absolute; top: 14px; left: 14px; padding: 8px 11px; border-radius: 999px; background: rgba(255,255,255,.9); font-size: 11px; font-weight: 800; }
.dialog-copy { padding: 22px 4px 18px; }
.dialog-copy h2 { margin: 0 0 10px; font-size: 28px; letter-spacing: -.04em; }
.dialog-copy p:not(.eyebrow) { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.7; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1.3fr; gap: 10px; }
.dialog-actions button { min-height: 50px; border-radius: 999px; font-weight: 800; cursor: pointer; }
.secondary-button { border: 1px solid var(--line); background: transparent; }
.primary-button { border: 1px solid var(--ink); background: var(--ink); color: white; }
.danger-button { border: 1px solid var(--danger); background: var(--danger); color: white; }

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 16px;
  background: rgba(244,240,232,.84);
  backdrop-filter: blur(12px);
}
.loading-overlay[hidden] { display: none; }
.loader { width: 42px; height: 42px; border: 3px solid rgba(23,23,23,.16); border-top-color: var(--ink); border-radius: 50%; animation: spin .8s linear infinite; }
.loading-overlay p { margin: 0; font-size: 13px; font-weight: 800; }

.toast {
  position: fixed;
  z-index: 120;
  left: 50%;
  bottom: calc(22px + var(--safe-bottom));
  transform: translate(-50%, 24px);
  max-width: calc(100% - 36px);
  padding: 12px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: white;
  font-size: 12px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

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

@keyframes shimmer { to { background-position-x: -220%; } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 820px) {
  .hero {
    grid-template-columns: 1fr;
    grid-template-areas: "copy" "camera" "expiry";
  }
  .camera-button { margin-top: 18px; }
  .camera-ring { width: min(58vw, 260px); }
  .expiry-strip { justify-self: center; }
  .photo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .app-shell { padding-left: 14px; padding-right: 14px; }
  .brand-copy small { display: none; }
  .connect-button { padding: 0 12px; }
  .hero { padding-top: 44px; }
  h1 { font-size: clamp(44px, 15.5vw, 84px); }
  .hero-description br { display: none; }
  .library { padding: 22px 14px; border-radius: 22px; }
  .section-heading { align-items: start; }
  .section-actions { flex-direction: column; align-items: flex-end; }
  .photo-grid { gap: 18px 10px; }
  .photo-meta { align-items: flex-start; flex-direction: column; gap: 7px; }
  .photo-actions { width: 100%; justify-content: space-between; }
  .empty-state { min-height: 280px; padding: 0 20px; }
  .dialog-card { padding: 10px; }
  .dialog-card.compact { padding: 24px 18px; }
  .dialog-copy { padding-left: 8px; padding-right: 8px; }
}

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

/* Public distribution additions */
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.icon-text-button {
  min-height: 42px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.28);
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}
.how-it-works {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  margin: 0 0 26px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--line);
}
.how-it-works > div {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 72px;
  padding: 16px 20px;
  background: rgba(255,255,255,.46);
}
.how-it-works span {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border: 1px solid var(--ink);
  border-radius: 50%;
  font-size: 11px;
  font-weight: 850;
}
.how-it-works p { margin: 0; font-size: 13px; font-weight: 800; }
footer nav { display: flex; gap: 16px; }
footer a { color: inherit; text-decoration: none; border-bottom: 1px solid transparent; }
footer a:hover { border-bottom-color: currentColor; }
footer b { font-weight: 800; }
.dialog-actions.single-action { grid-template-columns: 1fr; }

.legal-page { min-height: 100vh; }
.legal-shell {
  width: min(calc(100% - 36px), 760px);
  margin: 0 auto;
  padding: calc(44px + var(--safe-top)) 0 calc(64px + var(--safe-bottom));
}
.legal-back { display: inline-block; margin-bottom: 64px; color: var(--ink); font-size: 13px; font-weight: 800; text-decoration: none; }
.legal-shell h1 { max-width: none; font-size: clamp(46px, 9vw, 84px); line-height: .95; }
.legal-updated { margin: 20px 0 52px; color: var(--muted); font-size: 12px; }
.legal-shell section { padding: 26px 0; border-top: 1px solid var(--line); }
.legal-shell h2 { margin: 0 0 12px; font-size: 20px; letter-spacing: -.03em; }
.legal-shell p { margin: 0 0 12px; color: var(--muted); font-size: 14px; line-height: 1.9; }
.legal-shell p:last-child { margin-bottom: 0; }
.legal-shell a { color: var(--ink); }
.legal-shell code { padding: 2px 5px; border-radius: 5px; background: rgba(23,23,23,.07); color: var(--ink); }

@media (max-width: 560px) {
  .topbar { align-items: flex-start; }
  .topbar-actions { flex-direction: column-reverse; align-items: flex-end; gap: 7px; }
  .icon-text-button { min-height: 34px; padding: 0 10px; }
  .connect-button { min-height: 38px; }
  .how-it-works { grid-template-columns: 1fr; }
  .how-it-works > div { min-height: 58px; }
  footer { align-items: flex-start; gap: 18px; }
  footer nav { flex-direction: column; gap: 8px; text-align: right; }
}
