/* Ueckert Family — clean, iOS-Photos-inspired, warm. No frameworks. */
:root {
  color-scheme: light dark;
  --bg: #faf7f2;            /* warm off-white */
  --bg-elev: #ffffff;
  --bg-sunk: #f1ece4;
  --ink: #1d1a17;
  --ink-2: #5c534b;         /* secondary text, 7:1 on --bg */
  --ink-3: #7a7068;         /* tertiary text, 4.6:1 on --bg */
  --line: rgba(60, 40, 20, .10);
  --accent: #c2410c;        /* warm terracotta, 5.2:1 on white */
  --accent-press: #9a3412;
  --accent-soft: #fdeee4;
  --on-accent: #fff;
  --glass: rgba(250, 247, 242, .72);
  --shadow-1: 0 1px 2px rgba(40, 25, 10, .06), 0 2px 8px rgba(40, 25, 10, .06);
  --shadow-2: 0 8px 30px rgba(40, 25, 10, .14);
  --r-card: 18px; --r-ctl: 12px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px);
  --topbar-h: 52px; --tabbar-h: 58px;
  --pad: max(16px, var(--sal));
  --row-h: 128px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141110; --bg-elev: #1f1b19; --bg-sunk: #2a2522;
    --ink: #f5efe9; --ink-2: #c9bfb6; --ink-3: #a1968c;
    --line: rgba(255, 240, 225, .10);
    --accent: #fb8c5a; --accent-press: #fdba8c; --accent-soft: rgba(251, 140, 90, .14); --on-accent: #1a0f08;
    --glass: rgba(20, 17, 16, .72);
    --shadow-1: 0 1px 2px rgba(0,0,0,.4); --shadow-2: 0 10px 34px rgba(0,0,0,.5);
  }
}
@media (min-width: 760px) { :root { --row-h: 210px; --pad: 32px; } }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--bg); }
body { margin: 0; font: 17px/1.45 var(--font); letter-spacing: -.01em; background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; }
body.noscroll { overflow: hidden; }
.hidden { display: none !important; }
a { color: var(--accent); }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 2px; border-radius: 8px; }

/* ---------- Top bar (frosted) ---------- */
.topbar { position: sticky; top: 0; z-index: 30; padding-top: var(--sat); background: var(--glass);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); border-bottom: .5px solid var(--line); }
.topbar-inner { height: var(--topbar-h); display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 max(12px, var(--sar)) 0 max(12px, var(--sal)); max-width: 1280px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 9px; color: var(--ink); text-decoration: none; font-weight: 650; font-size: 17px; letter-spacing: -.02em; }
.brand img { border-radius: 8px; }
.auth-box { display: flex; align-items: center; gap: 8px; }
.chip { font-size: 13px; font-weight: 500; padding: 4px 10px; border-radius: 999px; background: var(--bg-sunk); color: var(--ink-2); white-space: nowrap; }
.chip.unlocked { background: var(--accent-soft); color: var(--accent); }

/* ---------- Tab bar: bottom on phones, segmented control on desktop ---------- */
.tabbar { position: fixed; z-index: 40; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-around;
  padding: 6px max(8px, var(--sar)) calc(6px + var(--sab)) max(8px, var(--sal)); background: var(--glass);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); border-top: .5px solid var(--line); }
.tab { flex: 1; max-width: 140px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0; min-height: 46px; color: var(--ink-3);
  text-decoration: none; font-size: 11px; font-weight: 600; letter-spacing: 0; border-radius: 12px; transition: color .2s; }
.tab svg { width: 26px; height: 26px; }
.tab.active { color: var(--accent); }
.tab.active svg rect, .tab.active svg path:not([d^="M21 16"]) { fill: color-mix(in srgb, currentColor 16%, transparent); }
@media (min-width: 760px) {
  .tabbar { top: calc(var(--sat) + 9px); bottom: auto; left: 50%; right: auto; transform: translateX(-50%); padding: 3px; gap: 2px; border: 0;
    background: var(--bg-sunk); -webkit-backdrop-filter: none; backdrop-filter: none; border-radius: 12px; z-index: 31; }
  .tab { flex-direction: row; gap: 6px; max-width: none; min-height: 34px; padding: 6px 14px; font-size: 14px; color: var(--ink-2); border-radius: 9px; }
  .tab svg { width: 18px; height: 18px; }
  .tab.active { background: var(--bg-elev); color: var(--ink); box-shadow: var(--shadow-1); }
  .tab.active svg rect, .tab.active svg path { fill: none; }
}

/* ---------- Content ---------- */
.content { max-width: 1280px; margin: 0 auto; padding: 0 0 calc(var(--tabbar-h) + var(--sab) + 90px); }
@media (min-width: 760px) { .content { padding-bottom: 110px; } }
.view { animation: fadeUp .35s var(--ease) both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.page-head { display: flex; align-items: flex-end; gap: 8px; padding: 22px var(--pad) 14px; flex-wrap: wrap; }
.page-head .titles { flex: 1; min-width: 0; }
.large-title { margin: 0; font-size: 34px; line-height: 1.1; font-weight: 750; letter-spacing: -.03em; overflow-wrap: anywhere; }
.subtitle { margin: 4px 0 0; color: var(--ink-3); font-size: 15px; }
.back { flex-basis: 100%; display: inline-flex; align-items: center; gap: 2px; margin: -8px 0 4px -6px; color: var(--accent); text-decoration: none; font-size: 17px; min-height: 44px; width: max-content; }
.back svg { width: 22px; height: 22px; stroke-width: 2.4; }
.note { margin: 0 var(--pad) 18px; padding: 12px 14px; border-radius: 14px; background: var(--accent-soft); color: var(--ink-2); font-size: 15px; }
.linkish { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.empty { text-align: center; color: var(--ink-3); padding: 48px 16px; }
.meta { color: var(--ink-3); font-size: 14px; }
.error { color: #dc2626; margin: 0 0 10px; font-size: 15px; }
.footer { text-align: center; color: var(--ink-3); font-size: 13px; padding: 36px 16px 0; }

/* ---------- Controls ---------- */
input[type=text], input[type=password], textarea, select {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-ctl); font: inherit; font-size: 16px; /* 16px: no iOS zoom */
  background: var(--bg-sunk); color: var(--ink); margin-bottom: 10px; min-height: 48px; transition: border-color .15s, background .15s; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); background: var(--bg-elev); }
::placeholder { color: var(--ink-3); }
select { appearance: none; -webkit-appearance: none; padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23998877' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 18px; }
textarea { resize: vertical; min-height: 96px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1 1 200px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 48px; padding: 12px 20px; border: 0; border-radius: 14px;
  background: var(--accent); color: var(--on-accent); font: inherit; font-size: 16px; font-weight: 650; cursor: pointer; text-decoration: none;
  touch-action: manipulation; transition: transform .12s var(--ease), background .15s, opacity .15s; }
.btn:active { transform: scale(.97); }
.btn:hover { background: var(--accent-press); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.btn-sm { min-height: 36px; padding: 7px 14px; font-size: 15px; border-radius: 999px; }
.btn-quiet { background: var(--bg-sunk); color: var(--ink); }
.btn-quiet:hover { background: color-mix(in srgb, var(--bg-sunk) 80%, var(--ink) 8%); }
.btn-soft { background: var(--accent-soft); color: var(--accent); }
.btn-soft:hover { background: color-mix(in srgb, var(--accent-soft) 70%, var(--accent) 12%); }
.btn-light { background: rgba(255,255,255,.95); color: #1d1a17; }
.btn-light:hover { background: #fff; }
.btn-ghost-light { background: rgba(255,255,255,.14); color: #fff; }
.btn-ghost-light:hover { background: rgba(255,255,255,.22); }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--bg-sunk); color: var(--ink-2); font-size: 16px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.icon-btn.light { background: rgba(255,255,255,.16); color: #fff; width: 44px; height: 44px; }
.card { background: var(--bg-elev); border-radius: var(--r-card); padding: 16px; box-shadow: var(--shadow-1); }

/* ---------- Collections (album cards) ---------- */
.collections { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 22px 14px; padding: 0 var(--pad); }
@media (min-width: 760px) { .collections { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 30px 22px; } }
.ccard { display: block; color: inherit; text-decoration: none; transition: transform .2s var(--ease); }
.ccard:active { transform: scale(.97); }
.ccard .cover { aspect-ratio: 1; border-radius: var(--r-card); overflow: hidden; background: var(--bg-sunk); box-shadow: var(--shadow-1);
  display: flex; align-items: center; justify-content: center; font-size: 40px; position: relative; }
.ccard .cover img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity .35s, transform .5s var(--ease); }
.ccard .cover img.loaded { opacity: 1; }
@media (hover: hover) { .ccard:hover .cover img { transform: scale(1.04); } }
.ccard .cinfo { padding: 9px 2px 0; }
.ccard .cname { font-weight: 650; font-size: 16px; letter-spacing: -.015em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ccard .meta { font-size: 14px; }
.ccard.all .cover { background: linear-gradient(145deg, #f6b17a, #c2410c); }

/* ---------- Justified photo grid (edge to edge on phones) ---------- */
.gallery { display: flex; flex-wrap: wrap; gap: 2px; padding: 0; }
.gallery::after { content: ""; flex-grow: 999999; }
@media (min-width: 760px) { .gallery { gap: 6px; padding: 0 var(--pad); } }
.tile { --ar: 1; position: relative; display: block; flex-grow: calc(var(--ar) * 100); flex-basis: calc(var(--ar) * var(--row-h)); aspect-ratio: var(--ar);
  max-height: calc(var(--row-h) * 1.9); overflow: hidden; background: var(--bg-sunk); }
@media (min-width: 760px) { .tile { border-radius: 10px; } }
.tile img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity .35s, transform .4s var(--ease); }
.tile img.loaded { opacity: 1; }
@media (hover: hover) { .tile:hover img { transform: scale(1.03); } }
.tile:active img { opacity: .8; }
.tile .noimg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 28px; }
.tile .badge { position: absolute; top: 6px; right: 6px; background: rgba(0,0,0,.5); color: #fff; font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 6px; letter-spacing: .02em; }

/* ---------- Messages ---------- */
.composer { margin: 0 var(--pad) 18px; }
.composer-actions { display: flex; justify-content: flex-end; }
.messages { display: flex; flex-direction: column; gap: 10px; padding: 0 var(--pad); max-width: 760px; }
.msg { display: grid; grid-template-columns: 40px 1fr; gap: 12px; background: var(--bg-elev); border-radius: var(--r-card); padding: 14px 16px; box-shadow: var(--shadow-1); animation: fadeUp .3s var(--ease) both; }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px; color: #fff; }
.msg .who { font-weight: 650; }
.msg .body { white-space: pre-wrap; margin-top: 2px; overflow-wrap: anywhere; }

/* ---------- Floating + button ---------- */
.fab { position: fixed; z-index: 41; right: max(18px, var(--sar)); bottom: calc(var(--tabbar-h) + var(--sab) + 16px); height: 56px; min-width: 56px; padding: 0 20px 0 16px;
  display: inline-flex; align-items: center; gap: 6px; border: 0; border-radius: 999px; background: var(--accent); color: var(--on-accent);
  font: inherit; font-weight: 700; font-size: 16px; box-shadow: 0 10px 28px color-mix(in srgb, var(--accent) 45%, transparent); cursor: pointer;
  touch-action: manipulation; transition: transform .15s var(--ease); animation: pop .35s var(--ease) both; }
.fab svg { stroke-width: 2.6; }
.fab:active { transform: scale(.94); }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }
@media (min-width: 760px) { .fab { bottom: 28px; right: 28px; } }

/* ---------- Bottom sheets (upload + login) ---------- */
dialog { border: 0; padding: 20px; color: var(--ink); background: var(--bg-elev); }
dialog::backdrop { background: rgba(10, 6, 3, .42); animation: fade .25s ease both; }
@keyframes fade { from { opacity: 0; } }
dialog.sheet { width: 100%; max-width: 640px; margin: auto auto 0; border-radius: 24px 24px 0 0; max-height: 92vh; max-height: 92dvh; overflow-y: auto;
  padding: 8px max(18px, var(--sal)) calc(18px + var(--sab)) max(18px, var(--sar)); overscroll-behavior: contain; box-shadow: var(--shadow-2); }
dialog.sheet[open] { animation: sheetUp .38s var(--ease) both; }
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }
dialog.sheet-small { max-width: 480px; }
@media (min-width: 760px) {
  dialog.sheet { margin: auto; border-radius: 24px; padding-top: 18px; }
  dialog.sheet[open] { animation: popIn .28s var(--ease) both; }
  .grabber { display: none; }
}
@keyframes popIn { from { transform: scale(.96); opacity: 0; } }
.grabber { width: 38px; height: 5px; border-radius: 3px; background: var(--line); background: color-mix(in srgb, var(--ink) 18%, transparent); margin: 2px auto 12px; }
dialog h2 { margin: 0 0 6px; font-size: 22px; font-weight: 750; letter-spacing: -.02em; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sheet-head h2 { margin: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.dialog-actions .btn { flex: 1; }
.field-label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-3); margin: 0 0 6px 2px; text-transform: uppercase; letter-spacing: .04em; }
.file-drop { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 120px; padding: 18px;
  border: 1.5px dashed color-mix(in srgb, var(--accent) 45%, transparent); border-radius: var(--r-card); background: var(--accent-soft);
  color: var(--accent); font-weight: 600; text-align: center; cursor: pointer; margin: 4px 0 12px; transition: background .2s; }
.file-drop .big { width: 34px; height: 34px; }
.file-drop.drag { background: color-mix(in srgb, var(--accent-soft) 60%, var(--accent) 15%); }
.file-drop input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.sheet-actions { display: flex; justify-content: flex-end; gap: 8px; position: sticky; bottom: calc(-18px - var(--sab)); background: var(--bg-elev);
  padding: 12px 0 calc(4px + var(--sab)); margin-bottom: calc(-1 * var(--sab)); }
.sheet-actions .btn { flex: 1; }
.upload-list { list-style: none; margin: 0 0 6px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.upload-item { display: grid; grid-template-columns: 52px 1fr; gap: 12px; align-items: center; background: var(--bg-sunk); border-radius: 14px; padding: 8px; }
.upload-item .uthumb { width: 52px; height: 52px; border-radius: 10px; background: var(--bg-elev) center / cover no-repeat; display: flex; align-items: center; justify-content: center; }
.upload-item .uname { font-size: 15px; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upload-item .ustatus { font-size: 13px; color: var(--ink-3); }
.upload-item.done .ustatus { color: #15803d; }
.upload-item.dup .ustatus, .upload-item.skip .ustatus { color: #a16207; }
.upload-item.fail .ustatus { color: #dc2626; }
@media (prefers-color-scheme: dark) {
  .upload-item.done .ustatus { color: #4ade80; } .upload-item.dup .ustatus, .upload-item.skip .ustatus { color: #facc15; } .upload-item.fail .ustatus, .error { color: #f87171; }
}
.upload-item .ubar { height: 4px; background: color-mix(in srgb, var(--ink) 10%, transparent); border-radius: 4px; overflow: hidden; margin-top: 5px; }
.upload-item .ubar > div { height: 100%; width: 0; background: var(--accent); border-radius: 4px; transition: width .2s var(--ease); }
.upload-item .uact { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.upload-item .uact .btn { min-height: 34px; padding: 6px 12px; font-size: 14px; border-radius: 999px; }

/* ---------- Viewer (always dark) ---------- */
.viewer { position: fixed; inset: 0; z-index: 60; background: #000; color: #fff; display: flex; flex-direction: column; animation: fade .2s ease both; }
.vw-top { display: flex; align-items: center; gap: 10px; padding: calc(6px + var(--sat)) max(10px, var(--sar)) 6px max(10px, var(--sal)); }
.vw-top .spacer { width: 44px; }
.vw-counter { flex: 1; text-align: center; font-size: 15px; font-weight: 600; opacity: .85; }
.vw-stage { position: relative; flex: 1; min-height: 0; overflow: hidden; display: flex; align-items: center; justify-content: center; touch-action: none; }
.vw-stage img { max-width: 100%; max-height: 100%; object-fit: contain; user-select: none; -webkit-user-select: none; -webkit-touch-callout: default; transform-origin: center center; will-change: transform; }
.vw-stage img.anim { transition: transform .26s var(--ease), opacity .26s; }
.vw-loading { position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%); font-size: 12px; background: rgba(0,0,0,.55); padding: 3px 10px; border-radius: 10px; opacity: .85; }
.vw-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 48px; border-radius: 50%; border: 0; background: rgba(255,255,255,.14);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); color: #fff; font-size: 28px; cursor: pointer; }
.vw-prev { left: max(12px, var(--sal)); } .vw-next { right: max(12px, var(--sar)); }
@media (hover: none) { .vw-nav { display: none; } }
.vw-bottom { padding: 10px max(16px, var(--sal)) calc(14px + var(--sab)) max(16px, var(--sar)); text-align: center; }
.vw-caption { font-size: 17px; font-weight: 600; overflow-wrap: anywhere; }
.vw-meta { color: rgba(255,255,255,.65); font-size: 14px; margin: 2px 0 12px; }
.vw-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.vw-actions .btn { min-height: 44px; border-radius: 999px; font-size: 15px; }
.vw-actions #vw-share { background: #fff; color: #111; }
.vw-manage { display: flex; gap: 8px; justify-content: center; align-items: center; flex-wrap: wrap; margin-top: 10px; font-size: 14px; color: rgba(255,255,255,.75); }
.vw-manage select { width: auto; max-width: 58vw; margin: 0 0 0 6px; background-color: rgba(255,255,255,.12); color: #fff; border-color: transparent; min-height: 40px; padding: 6px 36px 6px 12px; border-radius: 999px; font-size: 15px; }
.vw-manage select option { color: #111; }
.vw-manage .btn { min-height: 40px; padding: 6px 14px; font-size: 14px; border-radius: 999px; }
.vw-hint { font-size: 12px; color: rgba(255,255,255,.55); margin: 10px 0 0; }

.toast { position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--sab) + 84px); transform: translateX(-50%); z-index: 100; max-width: min(90vw, 460px);
  padding: 12px 18px; border-radius: 14px; text-align: center; font-size: 15px; font-weight: 550; color: #fff; background: rgba(28, 24, 21, .9);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); box-shadow: var(--shadow-2); animation: fadeUp .25s var(--ease) both; }
@media (min-width: 760px) { .toast { bottom: 100px; } }

@media (max-width: 380px) { .brand span { display: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
