/* picloud — a light table for family photos. Photos carry the colour; the interface stays
   neutral grey so they read true. The one loud element is the month/year type in the timeline. */

:root {
  color-scheme: light dark;
  --bg: #E8E9EC;
  --surface: #F7F7F8;
  --surface-2: #DCDEE2;
  --ink: #1B2130;
  --muted: #5B6372;
  --line: #C9CCD2;
  --accent: #0E7C86;
  --accent-ink: #FFFFFF;
  --danger: #B42318;
  --fav: #E8A800;
  --tile: #D3D5DA;
  --gap: 2px;
  --radius: 10px;
  --bar-h: 56px;
  --tabbar-h: 0px;
  --font: ui-sans-serif, -apple-system, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: ui-sans-serif, -apple-system, "SF Pro Display", "Segoe UI Variable Display", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181C;
    --surface: #202329;
    --surface-2: #2A2E35;
    --ink: #E5E7EB;
    --muted: #9AA1AD;
    --line: #353A42;
    --accent: #4CB8C0;
    --accent-ink: #0B1F21;
    --danger: #F97066;
    --tile: #262A30;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--font);
  font-feature-settings: "tnum" 0;
  -webkit-font-smoothing: antialiased;
}
body.no-scroll { overflow: hidden; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
h1, h2, h3 { margin: 0; font-family: var(--font-display); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.icon { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---- buttons & fields */

button, .chip {
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  text-decoration: none;
  min-height: 38px;
}
button:hover { border-color: var(--muted); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
button.danger { background: transparent; color: var(--danger); border-color: currentColor; }
button.primary .icon, button.danger .icon { width: 18px; height: 18px; }

.icon-btn {
  border: 0;
  background: transparent;
  padding: 8px;
  min-height: 40px;
  min-width: 40px;
  justify-content: center;
  border-radius: 999px;
  color: inherit;
}
.icon-btn:hover { background: color-mix(in srgb, currentColor 12%, transparent); }

.field { display: grid; gap: 4px; font-size: 14px; color: var(--muted); }
.field input, input:not([type=checkbox]):not([type=file]) {
  font: inherit;
  font-size: 16px; /* no zoom on iOS */
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  width: 100%;
}
.check-field { display: flex; gap: 10px; align-items: center; font-size: 15px; }
.check-field input { width: 18px; height: 18px; accent-color: var(--accent); }
.form-error { color: var(--danger); min-height: 1.5em; margin: 0; font-size: 14px; }
.muted { color: var(--muted); }

/* ---- sign in */

.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: min(360px, 100%);
  display: grid;
  gap: 16px;
  background: var(--surface);
  padding: 32px 28px 28px;
  border-radius: 16px;
}
.brand-large { font-size: 44px; font-weight: 300; letter-spacing: -0.03em; margin-bottom: 8px; }
.login-card button { justify-content: center; min-height: 46px; }

/* ---- shell */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--bar-h);
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.brand { font-size: 20px; font-weight: 300; letter-spacing: -0.02em; color: var(--ink); text-decoration: none; }
.nav { display: flex; gap: 2px; flex: 1; }
.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  font-size: 15px;
}
.nav-link .icon { width: 20px; height: 20px; }
.nav-link:hover { color: var(--ink); }
.nav-link.active { color: var(--ink); background: var(--surface); }
.nav-link.secondary { margin-left: auto; }
.nav-link.secondary ~ .nav-link.secondary { margin-left: 0; }
.topbar-actions { display: flex; gap: 8px; }

main { padding: 0 0 calc(32px + var(--tabbar-h)); outline: none; }

/* Phones: brand + actions on top, tabs at the bottom. */
@media (max-width: 760px) {
  :root { --tabbar-h: calc(58px + env(safe-area-inset-bottom)); }
  /* No backdrop-filter here: it would make the top bar the containing block of the fixed
     tab bar inside it, pinning the tabs to the top. */
  .topbar { justify-content: space-between; background: var(--bg); backdrop-filter: none; -webkit-backdrop-filter: none; }
  .nav {
    position: fixed;
    z-index: 30;
    left: 0; right: 0; bottom: 0;
    height: var(--tabbar-h);
    padding: 4px 4px env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-top: 1px solid var(--line);
    justify-content: space-around;
    gap: 0;
  }
  .nav-link { flex-direction: column; gap: 2px; font-size: 11px; padding: 6px 4px; flex: 1; border-radius: 10px; }
  .nav-link.secondary { margin-left: 0; }
  .nav-link.active { background: transparent; color: var(--accent); }
  .upload-btn span { display: none; }
  .upload-btn { padding: 8px 10px; }
}

/* ---- page head */

.page-head { padding: 12px 16px 8px; display: grid; gap: 10px; }
.page-title { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-note { margin: 0; color: var(--muted); font-size: 14px; }
.filters { display: flex; gap: 6px; }
.chip { padding: 4px 14px; min-height: 32px; font-size: 14px; color: var(--muted); background: transparent; }
.chip.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.notice { margin: 0 16px 12px; padding: 10px 14px; border-radius: var(--radius); background: var(--surface); color: var(--muted); font-size: 14px; }
.empty { padding: 48px 16px; color: var(--muted); text-align: center; max-width: 34em; margin: 0 auto; }

/* ---- timeline: the month type is the one loud element */

.month-group { margin-bottom: 4px; }
.month {
  position: sticky;
  top: var(--bar-h);
  z-index: 5;
  padding: 20px 16px 10px;
  display: flex;
  align-items: baseline;
  gap: 10px;
  background: linear-gradient(var(--bg) 70%, color-mix(in srgb, var(--bg) 0%, transparent));
  font-weight: 300;
  line-height: 1;
}
.month-name { font-size: clamp(26px, 5vw, 40px); letter-spacing: -0.03em; text-transform: lowercase; }
.month-name::first-letter { text-transform: uppercase; }
.month-year {
  font-size: clamp(26px, 5vw, 40px);
  letter-spacing: -0.03em;
  color: var(--muted);
  font-feature-settings: "tnum" 1;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
  gap: var(--gap);
}
@media (min-width: 760px) { .grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); padding: 0 16px; } }
@media (max-width: 420px) { .grid { grid-template-columns: repeat(3, 1fr); } }

.tile {
  position: relative;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: var(--tile);
  overflow: hidden;
  display: block;
  min-height: 0;
  cursor: pointer;
  -webkit-touch-callout: none;
  user-select: none;
}
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .15s ease; }
.tile img.broken { visibility: hidden; }
.tile .badge {
  position: absolute; right: 6px; bottom: 6px;
  display: inline-flex; align-items: center; gap: 3px;
  color: #fff; font-size: 12px; font-weight: 600; font-feature-settings: "tnum" 1;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .7);
}
.tile .badge .icon { width: 14px; height: 14px; fill: #fff; stroke: none; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .6)); }
.tile .fav { position: absolute; left: 6px; bottom: 6px; color: var(--fav); }
.tile .fav .icon { width: 16px; height: 16px; fill: var(--fav); stroke: none; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .5)); }
.tile .check {
  position: absolute; top: 6px; left: 6px;
  width: 24px; height: 24px; border-radius: 50%;
  border: 2px solid #fff;
  background: rgba(0, 0, 0, .25);
  display: grid; place-items: center;
  opacity: 0;
  transition: opacity .1s;
}
.tile .check .icon { width: 16px; height: 16px; stroke: #fff; stroke-width: 3; opacity: 0; }
@media (hover: hover) { .tile:hover .check { opacity: 1; } }
.selecting .tile .check { opacity: 1; }
.tile.selected img { transform: scale(.86); border-radius: 6px; }
.tile.selected { background: color-mix(in srgb, var(--accent) 22%, var(--bg)); }
.tile.selected .check { background: var(--accent); border-color: var(--accent); opacity: 1; }
.tile.selected .check .icon { opacity: 1; }

.sentinel { padding: 32px; text-align: center; color: var(--muted); font-size: 14px; min-height: 1px; }
.sentinel.done { padding: 0; }

/* ---- selection bar */

.selection-bar {
  position: fixed;
  z-index: 35;
  left: 50%;
  bottom: calc(16px + var(--tabbar-h));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 6px;
  background: var(--ink);
  color: var(--bg);
  border-radius: 999px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .28);
  max-width: calc(100vw - 16px);
}
.sel-count { font-weight: 600; font-size: 15px; white-space: nowrap; padding-right: 4px; font-feature-settings: "tnum" 1; }
.sel-actions { display: flex; gap: 4px; }
.sel-action { background: transparent; color: inherit; border-color: color-mix(in srgb, currentColor 35%, transparent); }
.sel-action.danger { color: var(--danger); }
@media (max-width: 520px) { .sel-action span { display: none; } .sel-action { padding: 8px 10px; } }

/* ---- folders */

.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; font-size: 14px; color: var(--muted); }
.crumb { color: var(--muted); text-decoration: none; background: none; border: 0; padding: 2px 4px; min-height: 0; font-size: 14px; border-radius: 4px; }
.crumb:hover { color: var(--ink); }
.crumb:last-child { color: var(--ink); }
.crumb-sep { opacity: .5; }
.folder-tools { display: flex; flex-wrap: wrap; gap: 8px; }
.folder-tools button { font-size: 14px; min-height: 34px; padding: 5px 12px; }
.folder-tools .icon { width: 18px; height: 18px; }
.ro-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 13px; font-weight: 500; letter-spacing: 0;
  color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px 2px 8px;
}
.ro-badge .icon { width: 15px; height: 15px; }

.folder-grid, .picker-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
  padding: 4px 16px 20px;
}
.folder-tile {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  border: 1px solid transparent;
  text-align: left;
  min-height: 0;
  width: 100%;
}
.folder-tile:hover { border-color: var(--line); }
.folder-icon { grid-row: span 2; width: 28px; height: 28px; color: var(--accent); }
.folder-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-count { font-size: 13px; color: var(--muted); font-feature-settings: "tnum" 1; }
@media (max-width: 520px) {
  .folder-grid { grid-template-columns: 1fr 1fr; }
  .folder-tile { grid-template-columns: 1fr; row-gap: 2px; }
  .folder-icon { grid-row: auto; width: 24px; height: 24px; margin-bottom: 4px; }
}

/* ---- dialogs */

dialog.sheet {
  border: 0;
  border-radius: 16px;
  padding: 0;
  width: min(440px, calc(100vw - 24px));
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
}
dialog.sheet::backdrop { background: rgba(10, 12, 16, .55); }
dialog.sheet form { display: grid; gap: 14px; padding: 22px 22px 18px; }
dialog.sheet h2 { font-size: 20px; font-weight: 600; }
dialog.sheet p { margin: 0; color: var(--muted); }
.actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 4px; }
.actions .spacer { flex: 1; }
dialog.picker { width: min(620px, calc(100vw - 24px)); }
.picker-body { display: grid; gap: 10px; max-height: min(60vh, 520px); overflow: auto; }
.picker .picker-list { padding: 0; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.picker .folder-tile { background: var(--bg); }

/* ---- lightbox (always dark: photos are judged on black) */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: #000;
  color: #F2F3F5;
  display: grid;
  grid-template-columns: 1fr 0;
  grid-template-rows: auto 1fr;
  outline: none;
}
.lightbox.show-info { grid-template-columns: 1fr min(340px, 100vw); }
.lb-bar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: max(6px, env(safe-area-inset-top)) 8px 6px;
  background: linear-gradient(rgba(0, 0, 0, .65), rgba(0, 0, 0, 0));
  z-index: 2;
}
.lb-title { flex: 1; font-size: 15px; color: #C9CDD3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-actions { display: flex; gap: 2px; }
.lb-fav.on .icon { fill: var(--fav); stroke: var(--fav); }
.lb-body { position: relative; min-height: 0; overflow: hidden; }
.lb-stage { position: absolute; inset: 0; display: grid; place-items: center; touch-action: pan-y pinch-zoom; }
.lb-stage img, .lb-stage video { max-width: 100%; max-height: 100%; object-fit: contain; display: block; user-select: none; }
.lb-stage video { width: 100%; height: 100%; }
.lb-prev, .lb-next { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(0, 0, 0, .35); color: #fff; }
.lb-prev { left: 8px; }
.lb-next { right: 8px; }
.lb-prev:disabled, .lb-next:disabled { display: none; }
@media (hover: none) { .lb-prev, .lb-next { display: none; } }
.lb-info { overflow: auto; background: #121417; padding: 20px; display: none; }
.show-info .lb-info { display: block; }
.lb-info h2 { font-size: 16px; font-weight: 600; word-break: break-all; margin-bottom: 16px; }
.lb-info dl { display: grid; gap: 4px 0; margin: 0; }
.lb-info dt { font-size: 13px; color: #8E95A1; margin-top: 10px; }
.lb-info dd { margin: 0; font-feature-settings: "tnum" 1; }
.lb-info a { color: #6CCBD2; }
@media (max-width: 760px) {
  .lightbox.show-info { grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; }
  .lb-info { max-height: 45vh; padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
}

/* ---- uploads */

.drop-overlay {
  position: fixed; inset: 10px; z-index: 60;
  border: 3px dashed var(--accent);
  border-radius: 18px;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  display: grid; place-items: center;
  pointer-events: none;
}
.drop-overlay p { display: flex; gap: 10px; align-items: center; font-size: 20px; color: var(--accent); }
.upload-panel {
  position: fixed;
  z-index: 40;
  right: 16px;
  bottom: calc(16px + var(--tabbar-h));
  width: min(380px, calc(100vw - 32px));
  max-height: 50vh;
  overflow: auto;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, .25);
  padding: 10px 14px 12px;
}
.upload-head { display: flex; align-items: center; justify-content: space-between; font-size: 15px; }
.upload-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.upload-list li { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; font-size: 13px; }
.upload-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-list progress { grid-column: 1 / -1; width: 100%; height: 4px; accent-color: var(--accent); }
.upload-status { color: var(--muted); grid-row: 1; grid-column: 2; }
.upload-list li.failed .upload-status { color: var(--danger); }
.upload-list li.ok progress { accent-color: var(--accent); }

/* ---- toasts */

#toasts {
  position: fixed;
  z-index: 70;
  left: 50%;
  bottom: calc(76px + var(--tabbar-h));
  transform: translateX(-50%);
  display: grid;
  gap: 8px;
  width: max-content;
  max-width: calc(100vw - 32px);
}
.toast {
  display: flex; align-items: center; gap: 14px;
  background: var(--ink); color: var(--bg);
  padding: 10px 12px 10px 16px;
  border-radius: 12px;
  font-size: 15px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
}
.toast button { background: transparent; color: var(--accent); border: 0; font-weight: 600; min-height: 0; padding: 2px 4px; }
@media (prefers-color-scheme: dark) { .toast button { color: #0E7C86; } }

/* ---- system & settings */

.system, .settings {
  display: grid;
  gap: 12px;
  padding: 4px 16px 24px;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  align-items: start;
  max-width: 1100px;
}
.panel { background: var(--surface); border-radius: 14px; padding: 18px; display: grid; gap: 12px; align-content: start; }
.panel h2 { font-size: 17px; font-weight: 600; }
.panel h3 { font-size: 15px; font-weight: 600; margin-top: 8px; }
.disk { display: grid; gap: 6px; }
.disk-head { display: flex; justify-content: space-between; gap: 12px; font-feature-settings: "tnum" 1; font-size: 15px; }
.disk .muted { font-size: 13px; }
.meter { display: block; height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.meter-fill { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.meter.warn .meter-fill { background: var(--danger); }
.stats { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; }
.stats dt { color: var(--muted); }
.stats dd { margin: 0; text-align: right; font-feature-settings: "tnum" 1; }
.scan-status { margin: 0; font-size: 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.user-list { list-style: none; margin: 0; padding: 0; display: grid; }
.user-list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.user-name { font-weight: 600; flex: 1; }
.user-list button { font-size: 14px; min-height: 32px; padding: 4px 12px; }
.tag { font-size: 12px; color: var(--accent); border: 1px solid currentColor; border-radius: 99px; padding: 1px 8px; }
.add-user { display: grid; gap: 12px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
