/* HomeCloud — a quiet light table for your photographs. */

:root {
  --bg: #f1f2ee;
  --surface: #fafaf8;
  --ink: #1b2420;
  --muted: #5e6963;
  --line: #d8dbd3;
  --accent: #2f44c8;
  --accent-ink: #ffffff;
  --accent-soft: #e3e6f8;
  --danger: #b3261e;
  --tile: #dfe2db;
  --shadow: 0 8px 30px rgba(20, 30, 25, .18);
  --serif: Georgia, "Iowan Old Style", "Palatino Linotype", "Noto Serif", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --nav-w: 14.5rem;
  --bar-h: 3.5rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101311;
    --surface: #171b18;
    --ink: #e7ebe6;
    --muted: #9aa49d;
    --line: #2a302b;
    --accent: #93a1ff;
    --accent-ink: #0e1330;
    --accent-soft: #1f2447;
    --danger: #ff9b92;
    --tile: #1f2521;
    --shadow: 0 8px 30px rgba(0, 0, 0, .5);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 var(--sans);
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { display: block; }
a { color: var(--accent); }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

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

/* ---------- buttons & fields ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  min-height: 2.5rem; padding: 0 1rem;
  border: 1px solid var(--line); border-radius: 4px;
  background: var(--surface); color: var(--ink);
  text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.quiet { border-color: transparent; background: transparent; }
.btn.quiet:hover { background: var(--accent-soft); }
.btn[disabled] { opacity: .5; cursor: default; }
.iconbtn {
  display: inline-grid; place-items: center; width: 2.5rem; height: 2.5rem;
  border: 0; border-radius: 50%; background: transparent; color: inherit;
}
.iconbtn:hover { background: var(--accent-soft); }
.iconbtn.on { color: var(--accent); }

.field { display: grid; gap: .3rem; margin-bottom: 1rem; }
.field > span { font-size: .85rem; color: var(--muted); }
input[type=text], input[type=password], input[type=search], select {
  width: 100%; min-height: 2.6rem; padding: 0 .75rem;
  border: 1px solid var(--line); border-radius: 4px; background: var(--surface);
}
input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.err { color: var(--danger); min-height: 1.4em; margin: 0 0 .75rem; }

/* ---------- sign-in ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.auth-box { width: min(26rem, 100%); }
.wordmark { font: 400 2.6rem/1 var(--serif); letter-spacing: -.02em; color: var(--accent); margin: 0 0 .5rem; }
.auth-box .lede { margin: 0 0 2rem; color: var(--muted); max-width: 24rem; }
.auth-box .btn { width: 100%; justify-content: center; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--nav-w) minmax(0, 1fr); min-height: 100vh; }
.nav {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  padding: 1.25rem 1rem 1rem 1.5rem; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 1.5rem;
}
.nav .wordmark { font-size: 1.6rem; margin: 0; }
.nav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .1rem; }
.nav a.navlink {
  display: flex; align-items: center; gap: .7rem; min-height: 2.5rem;
  padding: 0 .75rem; margin-left: -.75rem; border-left: 2px solid transparent;
  color: var(--muted); text-decoration: none;
}
.nav a.navlink:hover { color: var(--ink); }
.nav a.navlink[aria-current=page] { color: var(--ink); border-left-color: var(--accent); background: linear-gradient(90deg, var(--accent-soft), transparent); font-weight: 600; }
.nav .grow { flex: 1; }
.meter { font-size: .82rem; color: var(--muted); }
.meter .bar { height: 4px; background: var(--line); margin: .4rem 0; border-radius: 2px; overflow: hidden; }
.meter .bar > i { display: block; height: 100%; background: var(--accent); }

.main { min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--bar-h);
  display: flex; align-items: center; gap: .5rem; padding: 0 1.25rem;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.topbar .menu { display: none; }
.search { flex: 1; max-width: 30rem; position: relative; }
.search .icon { position: absolute; left: .7rem; top: 50%; translate: 0 -50%; color: var(--muted); pointer-events: none; }
.search input { padding-left: 2.4rem; border-radius: 999px; }
.topbar .spacer { flex: 1; }
.who { color: var(--muted); font-size: .85rem; padding: 0 .25rem; }

.selbar {
  position: absolute; inset: 0; z-index: 2; display: flex; align-items: center; gap: .25rem;
  padding: 0 1rem; background: var(--accent); color: var(--accent-ink);
}
.selbar .count { font-weight: 600; margin-right: auto; padding-left: .25rem; }
.selbar .iconbtn:hover { background: rgba(255,255,255,.18); }
.selbar .label { display: none; }
.selbar button.act { display: inline-flex; align-items: center; gap: .4rem; border: 0; background: transparent; color: inherit; min-height: 2.5rem; padding: 0 .7rem; border-radius: 4px; }
.selbar button.act:hover { background: rgba(255,255,255,.18); }
@media (min-width: 1100px) { .selbar .label { display: inline; } }

.view { padding: 1.5rem 1.5rem 6rem; }
.view-head { display: flex; align-items: baseline; gap: 1rem; flex-wrap: wrap; margin: 0 0 1.5rem; }
.view-head h1 { font: 400 2.1rem/1.1 var(--serif); letter-spacing: -.01em; margin: 0; overflow-wrap: anywhere; }
.view-head .sub { color: var(--muted); }
.view-head .tools { margin-left: auto; display: flex; gap: .5rem; flex-wrap: wrap; }
.crumbs { display: flex; flex-wrap: wrap; align-items: baseline; gap: .1rem .25rem; font: 400 2.1rem/1.1 var(--serif); }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--ink); }
.crumbs .sep { color: var(--line); }
.crumbs .here { color: var(--ink); }

/* ---------- timeline ---------- */
.day { display: grid; grid-template-columns: 7rem minmax(0, 1fr); gap: 1.25rem; margin-bottom: 2rem; content-visibility: auto; contain-intrinsic-size: auto 300px; }
.day-head { position: sticky; top: calc(var(--bar-h) + .75rem); align-self: start; display: flex; flex-direction: column; line-height: 1; }
.day-num { font: 400 3.4rem/.9 var(--serif); letter-spacing: -.03em; font-variant-numeric: oldstyle-nums; }
.day-meta { display: flex; flex-direction: column; gap: .15rem; margin-top: .55rem; font-size: .82rem; color: var(--muted); }
.day-meta b { font-weight: 600; color: var(--ink); }
.day-grid { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.row { display: flex; gap: 3px; }

.tile {
  position: relative; flex: none; overflow: hidden; background: var(--tile);
  border-radius: 2px; cursor: pointer; user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
.tile img { width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .18s; -webkit-touch-callout: none; }
.tile img.in { opacity: 1; }
.tile .ph { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: .8rem; text-transform: none; }
.tile .shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,.35), transparent 40%); opacity: 0; transition: opacity .12s; pointer-events: none; }
.tile:hover .shade, .selecting .tile .shade { opacity: 1; }
.tile .check {
  position: absolute; left: .4rem; top: .4rem; width: 1.6rem; height: 1.6rem; padding: 0;
  display: grid; place-items: center; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.95); background: rgba(0,0,0,.18); color: #fff;
  opacity: 0; transition: opacity .12s;
}
.tile:hover .check, .selecting .tile .check, .tile .check:focus-visible { opacity: 1; }
.tile .check .icon { width: .95rem; height: .95rem; stroke-width: 3; opacity: 0; }
.tile.sel { outline: 3px solid var(--accent); outline-offset: -3px; }
.tile.sel img { transform: scale(.9); border-radius: 2px; }
.tile.sel .check { background: var(--accent); border-color: var(--accent); opacity: 1; }
.tile.sel .check .icon { opacity: 1; }
.tile img { transition: opacity .18s, transform .12s; }
.tile .badge { position: absolute; right: .4rem; bottom: .35rem; display: flex; align-items: center; gap: .2rem; color: #fff; font-size: .78rem; font-weight: 600; text-shadow: 0 1px 3px rgba(0,0,0,.7); pointer-events: none; }
.tile .badge .icon { width: .9rem; height: .9rem; }
.tile .fav { position: absolute; left: .45rem; bottom: .35rem; color: #fff; filter: drop-shadow(0 1px 2px rgba(0,0,0,.7)); pointer-events: none; }
.tile .fav .icon { width: 1rem; height: 1rem; }
.tile.trashed img { filter: grayscale(.6) brightness(.8); }

.empty { max-width: 28rem; padding: 3rem 0; color: var(--muted); }
.empty h2 { font: 400 1.6rem/1.2 var(--serif); color: var(--ink); margin: 0 0 .5rem; }
.empty p { margin: 0 0 1.25rem; }
.sentinel { height: 1px; }
.loading { color: var(--muted); padding: 1rem 0; }

/* ---------- albums & folders ---------- */
.stacks { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: 2rem 1.5rem; padding-bottom: 1rem; }
.stack { display: block; text-decoration: none; color: inherit; }
.stack .prints { position: relative; aspect-ratio: 1; margin: 0 .35rem .35rem 0; }
.stack .prints::before, .stack .prints::after { content: ""; position: absolute; inset: 0; border: 1px solid var(--line); background: var(--surface); border-radius: 2px; }
.stack .prints::before { translate: .35rem .35rem; }
.stack .prints::after { translate: .17rem .17rem; }
.stack .cover { position: absolute; inset: 0; z-index: 1; background: var(--tile); border-radius: 2px; overflow: hidden; display: grid; place-items: center; color: var(--muted); }
.stack .cover img { width: 100%; height: 100%; object-fit: cover; }
.stack:hover .cover, .stack:focus-visible .cover { outline: 2px solid var(--accent); }
.stack .name { margin-top: .9rem; font: 400 1.1rem/1.25 var(--serif); overflow-wrap: anywhere; }
.stack .count { color: var(--muted); font-size: .85rem; }
.stack.folder .prints::before, .stack.folder .prints::after { display: none; }
.stack.folder .prints { margin: 0; }
.stack.folder .cover { border-radius: 2px 14px 2px 2px; }
.stack.new .cover { background: transparent; border: 1.5px dashed var(--muted); }
.section-title { font: 400 1.15rem/1.2 var(--serif); color: var(--muted); margin: 2rem 0 1rem; }

/* ---------- viewer ---------- */
.viewer {
  position: fixed; inset: 0; z-index: 60; background: #0b0c0b; color: #f1f3f0;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto minmax(0, 1fr);
  animation: vin .14s ease-out;
}
@keyframes vin { from { opacity: 0; } to { opacity: 1; } }
.viewer .vbar { grid-column: 1 / -1; display: flex; align-items: center; gap: .15rem; padding: .5rem .75rem; padding-top: max(.5rem, env(safe-area-inset-top)); background: linear-gradient(#000a, transparent); z-index: 2; }
.viewer .vtitle { flex: 1; min-width: 0; padding: 0 .5rem; }
.viewer .vtitle b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer .vtitle span { color: #aab2ac; font-size: .82rem; }
.viewer .iconbtn:hover { background: rgba(255,255,255,.14); }
.viewer .iconbtn.on { color: #ff8fa3; }
.viewer .stage { position: relative; display: grid; place-items: center; min-height: 0; margin-top: -3.6rem; touch-action: pan-y; }
.viewer .stage img, .viewer .stage video { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; }
.viewer .stage video { width: 100%; height: 100%; background: #000; }
.viewer .nav-btn { position: absolute; top: 50%; translate: 0 -50%; width: 3rem; height: 3rem; background: rgba(0,0,0,.35); color: #fff; z-index: 2; }
.viewer .nav-btn.prev { left: .75rem; }
.viewer .nav-btn.next { right: .75rem; }
.viewer .nav-btn:hover { background: rgba(0,0,0,.6); }
.viewer .spin { position: absolute; color: #aab2ac; }
.viewer .info { width: 20rem; max-width: 100vw; background: var(--surface); color: var(--ink); padding: 4.5rem 1.25rem 1.5rem; overflow-y: auto; grid-row: 1 / -1; grid-column: 2; }
.viewer .info h2 { font: 400 1.3rem/1.2 var(--serif); margin: 0 0 1rem; overflow-wrap: anywhere; }
.viewer .info dl { margin: 0; display: grid; grid-template-columns: 6rem 1fr; gap: .6rem .75rem; }
.viewer .info dt { color: var(--muted); font-size: .85rem; }
.viewer .info dd { margin: 0; overflow-wrap: anywhere; }
.viewer.has-info .vbar { grid-column: 1; }
@media (max-width: 800px) {
  .viewer .info { position: absolute; right: 0; top: 0; bottom: 0; z-index: 3; box-shadow: var(--shadow); }
  .viewer .nav-btn { display: none; }
}

/* ---------- dialogs ---------- */
dialog { border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); padding: 0; width: min(28rem, calc(100vw - 2rem)); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(10, 14, 12, .55); }
dialog form { padding: 1.5rem; }
dialog h2 { font: 400 1.4rem/1.2 var(--serif); margin: 0 0 1rem; }
dialog p { margin: 0 0 1rem; color: var(--muted); }
.dlg-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1.25rem; }
.picklist { list-style: none; margin: 0 0 .5rem; padding: 0; max-height: 18rem; overflow-y: auto; border-top: 1px solid var(--line); }
.picklist li button { display: flex; width: 100%; justify-content: space-between; align-items: center; gap: 1rem; min-height: 2.8rem; padding: 0 .5rem; border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left; }
.picklist li button:hover { background: var(--accent-soft); }
.picklist .n { color: var(--muted); font-size: .85rem; }

/* ---------- upload panel, toasts ---------- */
.uploads { position: fixed; right: 1rem; bottom: 1rem; z-index: 50; width: min(22rem, calc(100vw - 2rem)); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--shadow); overflow: hidden; }
.uploads header { display: flex; align-items: center; gap: .25rem; padding: .35rem .5rem .35rem 1rem; border-bottom: 1px solid var(--line); }
.uploads header b { flex: 1; font-weight: 600; }
.uploads ul { list-style: none; margin: 0; padding: 0; max-height: 14rem; overflow-y: auto; }
.uploads li { padding: .5rem 1rem; font-size: .85rem; border-bottom: 1px solid var(--line); }
.uploads li:last-child { border-bottom: 0; }
.uploads li .nm { display: flex; justify-content: space-between; gap: 1rem; }
.uploads li .nm span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.uploads li .st { color: var(--muted); flex: none; }
.uploads li.error .st { color: var(--danger); }
.uploads li progress { width: 100%; height: 4px; margin-top: .3rem; accent-color: var(--accent); }
.toasts { position: fixed; left: 50%; translate: -50% 0; bottom: 1.25rem; z-index: 80; display: grid; gap: .5rem; justify-items: center; pointer-events: none; }
.toast { background: var(--ink); color: var(--bg); padding: .6rem 1rem; border-radius: 4px; box-shadow: var(--shadow); max-width: min(32rem, 92vw); pointer-events: auto; }
.toast.bad { background: var(--danger); color: #fff; }
.dropzone { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; background: color-mix(in srgb, var(--accent) 82%, transparent); color: var(--accent-ink); font: 400 2rem var(--serif); pointer-events: none; }

/* ---------- settings ---------- */
.panel { max-width: 40rem; margin-bottom: 3rem; }
.panel h2 { font: 400 1.4rem/1.2 var(--serif); margin: 0 0 1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.panel .row-item { display: flex; align-items: center; gap: .75rem; padding: .6rem 0; border-bottom: 1px solid var(--line); }
.panel .row-item .grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.panel .row-item small { display: block; color: var(--muted); }
.panel .inline { display: flex; gap: .5rem; flex-wrap: wrap; align-items: end; }
.panel .inline .field { margin: 0; flex: 1; min-width: 10rem; }
.tag { font-size: .75rem; padding: .1rem .5rem; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); margin-left: .4rem; }

.jump { max-height: 24rem; overflow-y: auto; }
.jump h3 { font: 400 1.1rem var(--serif); margin: 1rem 0 .4rem; }
.jump .months { display: flex; flex-wrap: wrap; gap: .35rem; }
.jump .months button { border: 1px solid var(--line); background: transparent; border-radius: 4px; min-height: 2.2rem; padding: 0 .7rem; }
.jump .months button:hover { background: var(--accent-soft); border-color: var(--accent); }
.jump .months small { color: var(--muted); margin-left: .3rem; }

/* ---------- small screens ---------- */
@media (max-width: 860px) {
  .shell { display: block; }
  .nav { position: fixed; z-index: 40; inset: 0 auto 0 0; width: min(18rem, 86vw); height: 100%; background: var(--bg); translate: -100%; transition: translate .18s; box-shadow: var(--shadow); }
  body.nav-open .nav { translate: 0; }
  .scrim { position: fixed; inset: 0; z-index: 30; background: rgba(10,14,12,.5); }
  .topbar { padding: 0 .5rem; }
  .topbar .menu { display: inline-grid; }
  .who { display: none; }
  .view { padding: 1rem .75rem 6rem; }
  .view-head h1, .crumbs { font-size: 1.7rem; }
  .day { grid-template-columns: 1fr; gap: .4rem; margin-bottom: 1.25rem; }
  .day-head { position: static; flex-direction: row; align-items: baseline; gap: .6rem; }
  .day-num { font-size: 2rem; }
  .day-meta { flex-direction: row; gap: .4rem; margin: 0; font-size: .85rem; }
  .btn .txt { display: none; }
  .btn.primary { padding: 0 .75rem; }
  .stacks { grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); gap: 1.5rem 1rem; }
  .topbar .spacer { display: none; }
  .search { max-width: none; }
  .tile .check { width: 1.5rem; height: 1.5rem; }
  .selbar button.act .label { display: none; }
}

/* touch screens have no hover: the select circles appear once selecting starts */
@media (hover: none) {
  .tile:hover .check { opacity: 0; }
  .selecting .tile .check { opacity: 1; }
  .tile:hover .shade { opacity: 0; }
  .selecting .tile .shade { opacity: 1; }
}

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