/* Shoebox - graphite pro-tool theme. Photos are the only colour on screen;
   chrome is hairlines, small radii and one quiet accent. */
:root {
  --bg: #0b0b0d;
  --bg-2: #0f0f12;
  --panel: #141418;
  --panel-2: #1a1a1f;
  --line: #222228;
  --line-2: #2c2c34;
  --text: #ececef;
  --text-2: #b4b4bc;
  --muted: #7c7c86;
  --accent: #7b9cff;
  --accent-2: #5b7ff0;
  --danger: #f0716a;
  --tile: #17171b;
  --r: 6px;
  --r-lg: 10px;
  --tile-size: 168px;
  --row-h: 190px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --shadow: 0 0 0 1px rgba(255, 255, 255, .04), 0 12px 40px rgba(0, 0, 0, .55);
  --mono: Inter, system-ui, sans-serif;   /* numbers use tabular figures, not a mono face */
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 13.5px/1.45 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "cv11", "ss01", "tnum";
  -webkit-font-smoothing: antialiased;
}
::selection { background: color-mix(in srgb, var(--accent) 35%, transparent); }
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }

.ic { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

button {
  font: inherit; font-weight: 500; color: var(--text-2); background: var(--panel);
  border: 1px solid var(--line-2); border-radius: var(--r); padding: 6px 11px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, transform .1s;
}
button:hover { color: var(--text); border-color: #3a3a44; background: var(--panel-2); }
button:active { transform: translateY(.5px); }
button:disabled { opacity: .45; cursor: default; }
button.primary { background: var(--text); border-color: var(--text); color: #0b0b0d; }
button.primary:hover { background: #fff; border-color: #fff; color: #000; }
button.ghost { background: transparent; border-color: transparent; }
button.ghost:hover { background: var(--panel); }
button.danger { color: var(--danger); }
button.danger:hover { border-color: color-mix(in srgb, var(--danger) 50%, transparent); }
.icon-btn { padding: 6px; background: transparent; border-color: transparent; color: var(--text-2); }
.icon-btn:hover { background: rgba(255, 255, 255, .06); border-color: transparent; }

input[type=password], input[type=text], input[type=search] {
  font: inherit; color: var(--text); background: var(--bg-2);
  border: 1px solid var(--line-2); border-radius: var(--r); padding: 8px 11px; width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder { color: var(--muted); }
input:focus { outline: none; border-color: color-mix(in srgb, var(--accent) 70%, transparent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
kbd {
  font: 500 11px/1 var(--mono); color: var(--muted); border: 1px solid var(--line-2);
  border-bottom-width: 2px; border-radius: 4px; padding: 3px 5px; background: var(--panel);
}

/* ---------- login ---------- */
.login {
  min-height: 100%; display: grid; place-items: center; padding: 16px;
  background:
    radial-gradient(900px 500px at 50% -10%, rgba(123, 156, 255, .10), transparent 60%),
    var(--bg);
}
.login form {
  width: min(340px, 100%); background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 30px 28px 24px; box-shadow: var(--shadow); display: grid; gap: 12px;
}
.login .mark { width: 34px; height: 34px; margin-bottom: 6px; }
.login h1 { margin: 0; font-size: 19px; font-weight: 600; letter-spacing: -.01em; }
.login p.sub { margin: -6px 0 6px; color: var(--muted); }
.login button.primary { justify-content: center; padding: 9px; }
.login .err { color: var(--danger); min-height: 1.2em; margin: 0; font-size: 12.5px; }

/* brand mark: a stack of three photos */
.mark {
  display: inline-block; width: 18px; height: 18px; flex: none; border-radius: 4px; position: relative;
  background: linear-gradient(135deg, #8fb0ff, #5b7ff0);
  box-shadow: 3px -3px 0 -1px #2a2f45, 6px -6px 0 -2px #1d2030;
}

/* ---------- app shell ---------- */
.app { display: grid; grid-template-columns: 232px 1fr; height: 100%; }
.side {
  border-right: 1px solid var(--line); padding: 14px 10px 10px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 1px; background: var(--bg-2);
}
.brand {
  display: flex; align-items: center; gap: 11px; font-weight: 600; font-size: 14.5px;
  letter-spacing: -.01em; padding: 8px 10px 18px;
}
.side h3 {
  font-size: 11.5px; font-weight: 500; color: var(--muted);
  margin: 18px 10px 6px;
}
.nav {
  display: flex; justify-content: space-between; align-items: center; gap: 8px; width: 100%; text-align: left;
  border: 0; background: transparent; padding: 6px 10px; border-radius: var(--r); color: var(--text-2); font-weight: 450;
}
.nav > span:first-child { display: flex; align-items: center; gap: 10px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav > span:first-child .ic { color: var(--muted); }
.nav .n { font: 400 11.5px var(--mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.nav:hover { background: rgba(255, 255, 255, .04); color: var(--text); border: 0; }
.nav.on { background: rgba(255, 255, 255, .07); color: var(--text); }
.nav.on > span:first-child .ic { color: var(--accent); }
.nav .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.nav.out { margin-top: 2px; color: var(--muted); }
.side .grow { flex: 1; min-height: 16px; }
.usage { font: 400 11px var(--mono); color: var(--muted); padding: 10px; }
.usage .bar { height: 3px; background: var(--line); border-radius: 2px; margin-top: 7px; overflow: hidden; }
.usage .bar i { display: block; height: 100%; background: var(--text-2); border-radius: 2px; }

.main { overflow-y: auto; position: relative; scroll-behavior: auto; }
.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px;
  padding: 10px 22px; min-height: 56px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(140%) blur(14px); -webkit-backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.top h2 {
  margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -.01em; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.top .count { font: 400 12px var(--mono); color: var(--muted); margin-left: 10px; }
.menu-btn { display: none; }

.searchwrap { position: relative; display: flex; align-items: center; width: clamp(170px, 24vw, 300px); }
.top h2 { min-width: 120px; }
@media (max-width: 980px) { .zoom { display: none; } }
.searchwrap .ic { position: absolute; left: 10px; color: var(--muted); pointer-events: none; }
.searchwrap input { padding-left: 32px; padding-right: 30px; height: 32px; }
.searchwrap kbd { position: absolute; right: 8px; pointer-events: none; }
.searchwrap input:focus ~ kbd, .searchwrap input:not(:placeholder-shown) ~ kbd { display: none; }
input[type=search]::-webkit-search-cancel-button { filter: invert(.6); }

.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--r); padding: 2px; background: var(--bg-2); }
.seg button { border: 0; background: transparent; padding: 4px 6px; color: var(--muted); border-radius: 4px; }
.seg button.on { background: var(--panel-2); color: var(--text); box-shadow: 0 0 0 1px var(--line-2); }

.zoom { width: 84px; accent-color: var(--text-2); }
input[type=range].zoom { -webkit-appearance: none; appearance: none; height: 16px; background: transparent; }
.zoom::-webkit-slider-runnable-track { height: 3px; border-radius: 2px; background: var(--line-2); }
.zoom::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; margin-top: -4.5px; border-radius: 50%; background: var(--text-2); border: 0; }
.zoom::-moz-range-track { height: 3px; border-radius: 2px; background: var(--line-2); }
.zoom::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--text-2); border: 0; }

/* ---------- grid ---------- */
.content { padding: 4px 22px 80px; }
.month {
  position: sticky; top: var(--top-h, 56px); z-index: 3; display: flex; align-items: baseline; gap: 10px;
  margin: 0 -22px; padding: 18px 22px 10px; font-size: 13px; font-weight: 600; letter-spacing: -.005em;
  background: linear-gradient(var(--bg) 70%, transparent);
}
.month span { font: 400 11px var(--mono); color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--tile-size), 1fr)); gap: 3px; }

.tile {
  position: relative; aspect-ratio: 1; background: var(--tile); border-radius: 3px;
  overflow: hidden; cursor: pointer; border: 0; padding: 0; display: block; color: inherit;
}
.tile:hover { background: var(--tile); }
.tile img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  opacity: 0; transform: scale(1.015);
  transition: opacity .45s var(--ease), transform .6s var(--ease), filter .25s;
}
.tile img.in { opacity: 1; transform: none; }
.tile::before {      /* bottom shade, shown on hover so captions read on any photo */
  content: ''; position: absolute; inset: 0; z-index: 1; pointer-events: none; opacity: 0;
  background: linear-gradient(transparent 55%, rgba(0, 0, 0, .65));
  transition: opacity .25s;
}
.tile:hover::before { opacity: 1; }
.tile .cap {
  position: absolute; left: 9px; right: 9px; bottom: 7px; z-index: 2; color: #fff; text-align: left;
  font-size: 11.5px; line-height: 1.3; opacity: 0; transform: translateY(4px);
  transition: opacity .25s, transform .25s var(--ease);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.tile:hover .cap { opacity: 1; transform: none; }
.tile .ext {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-size: 11px; font-weight: 500; color: var(--muted);
}
.tile .badge {
  position: absolute; right: 7px; top: 7px; z-index: 2; display: grid; place-items: center;
  width: 22px; height: 22px; border-radius: 50%; background: rgba(0, 0, 0, .5); color: #fff;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.tile .badge .ic { width: 12px; height: 12px; }
.tile .fav { position: absolute; left: 7px; top: 7px; z-index: 2; color: #fff; filter: drop-shadow(0 1px 3px rgba(0, 0, 0, .6)); }
.tile .fav .ic { width: 14px; height: 14px; fill: #fff; }
.tile .why {
  position: absolute; left: 7px; top: 7px; z-index: 2; background: rgba(0, 0, 0, .6); color: #fff;
  font-size: 11px; font-weight: 500; line-height: 1; padding: 4px 7px; border-radius: 4px;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.tile.sel { box-shadow: inset 0 0 0 2px var(--accent); }
.tile.sel img { transform: scale(.9); border-radius: 3px; }
.tile .tick {
  position: absolute; right: 7px; bottom: 7px; z-index: 2; width: 20px; height: 20px; border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, .8); background: rgba(0, 0, 0, .25); display: grid; place-items: center; color: transparent;
  transition: background .15s, border-color .15s;
}
.tile .tick .ic { width: 12px; height: 12px; stroke-width: 2.4; }
.tile.sel .tick { background: var(--accent); border-color: var(--accent); color: #fff; }

/* natural (justified) layout: each tile grows in proportion to its aspect ratio */
.grid.natural { display: flex; flex-wrap: wrap; gap: 3px; }
.grid.natural .tile { aspect-ratio: auto; height: var(--row-h); flex-grow: var(--ar); flex-basis: calc(var(--ar) * var(--row-h)); max-width: calc(var(--ar) * var(--row-h) * 1.6); }
.grid.natural::after { content: ''; flex-grow: 9999; }

.empty {
  margin: 80px auto; max-width: 440px; text-align: center; color: var(--muted);
  border: 1px dashed var(--line-2); border-radius: 14px; padding: 46px 28px; line-height: 1.6;
}
.empty .ic { width: 30px; height: 30px; stroke-width: 1.3; color: var(--text-2); margin-bottom: 12px; }
.empty strong { display: block; color: var(--text); font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.empty b { color: var(--text-2); font-weight: 500; }

/* ---------- drop overlay ---------- */
.drop {
  position: fixed; inset: 0; z-index: 50; display: none; place-items: center; pointer-events: none;
  background: rgba(8, 8, 10, .72); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.drop::before { content: ''; position: absolute; inset: 14px; border: 1.5px dashed color-mix(in srgb, var(--accent) 70%, transparent); border-radius: 18px; }
.drop.on { display: grid; animation: fade .15s; }
.drop div { display: grid; justify-items: center; gap: 6px; }
.drop .ic { width: 34px; height: 34px; color: var(--accent); stroke-width: 1.4; margin-bottom: 6px; }
.drop b { font-size: 18px; font-weight: 600; letter-spacing: -.01em; }
.drop span { color: var(--muted); }
@keyframes fade { from { opacity: 0; } }

/* ---------- upload panel ---------- */
.up {
  position: fixed; right: 18px; bottom: 18px; z-index: 40; width: min(340px, calc(100% - 32px));
  background: color-mix(in srgb, var(--panel) 92%, transparent); border: 1px solid var(--line-2);
  border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 12px 14px 12px;
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  display: none;
}
.up.on { display: block; animation: rise .25s var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.up .head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.up .head b { font-weight: 600; font-size: 13px; }
.up .bar { height: 3px; background: var(--line); border-radius: 2px; margin: 10px 0 8px; overflow: hidden; }
.up .bar i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 2px; transition: width .25s; }
.up .stats { font: 400 11px/1.5 var(--mono); color: var(--muted); }
.up ul { list-style: none; margin: 8px 0 0; padding: 0; font-size: 12px; max-height: 140px; overflow-y: auto; }
.up li { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; color: var(--text-2); }
.up li span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up li span:last-child { font-family: var(--mono); color: var(--muted); }
.up li.fail span:last-child { color: var(--danger); }

/* ---------- photo viewer: see viewer.css ---------- */

/* ---------- AI panel ---------- */
.ai {
  margin: 8px 4px; padding: 12px; border: 1px solid var(--line); border-radius: var(--r-lg);
  background: linear-gradient(180deg, rgba(123, 156, 255, .06), transparent 70%), var(--panel);
  font-size: 12px; color: var(--muted); display: grid; gap: 9px;
}
.ai[hidden] { display: none; }
.ai .hd { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 600; font-size: 12.5px; }
.ai .hd .ic { color: var(--accent); }
.ai button { justify-content: center; font-size: 12px; padding: 6px 10px; }
.ai .meta { font: 400 10.5px/1.5 var(--mono); }
.ai .err { color: var(--danger); }
.ai .prog { height: 2px; background: var(--line); border-radius: 2px; overflow: hidden; }
.ai .prog i { display: block; height: 100%; width: 40%; background: var(--accent); animation: slide 1.2s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(250%); } }

/* ---------- cleanup selection bar ---------- */
.selbar {
  position: sticky; top: var(--top-h, 56px); z-index: 4; display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 10px 22px; background: color-mix(in srgb, var(--bg-2) 90%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--line);
}
.selbar[hidden] { display: none; }
.selbar .grow { flex: 1; color: var(--muted); font-size: 12.5px; }
.selbar:not([hidden]) ~ .content .month { top: calc(var(--top-h, 56px) + var(--sel-h, 53px)); }

/* ---------- suggestions ---------- */
.sugs { display: grid; gap: 14px; max-width: 920px; margin-top: 18px; }
.sug {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; display: grid; gap: 12px;
  transition: border-color .2s;
}
.sug:hover { border-color: var(--line-2); }
.sug .t { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 14.5px; letter-spacing: -.01em; }
.sug .t .ic { color: var(--accent); }
.sug .meta { color: var(--muted); font-size: 12px; margin-top: 3px; }
.sug .meta .m { font-family: var(--mono); font-size: 11px; }
.sug .strip { display: grid; grid-template-columns: repeat(6, 1fr); gap: 3px; border-radius: 6px; overflow: hidden; }
.sug .strip img { width: 100%; aspect-ratio: 1; object-fit: cover; background: var(--tile); display: block; }
.sug .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.sug input { flex: 1; min-width: 160px; width: auto; }

/* ---------- phone ---------- */
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .side {
    position: fixed; inset: 0 auto 0 0; width: 264px; z-index: 30;
    transform: translateX(-100%); transition: transform .25s var(--ease); box-shadow: var(--shadow);
  }
  .side.open { transform: none; }
  .menu-btn { display: inline-flex; margin-left: -6px; }
  .top { flex-wrap: wrap; padding: 8px 14px; padding-top: max(8px, env(safe-area-inset-top)); }
  .searchwrap { width: 100%; order: 5; }
  .searchwrap kbd { display: none; }
  .content { padding: 0 2px 80px; }
  .month { margin: 0 -2px; padding: 16px 14px 8px; }
  .selbar { padding: 8px 14px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 2px; }
  .grid.natural .tile { height: 120px; flex-basis: calc(var(--ar) * 120px); max-width: none; }
  .tile { border-radius: 0; }
  .tile .cap { display: none; }
  .top .hide-sm { display: none; }
  .sugs { padding: 0 12px; }
  .sug .strip { grid-template-columns: repeat(4, 1fr); }
  .sug .strip img:nth-child(n+5) { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; animation-duration: 0s !important; }
}

/* version label (sidebar footer, login card) */
.ver { font: 400 10.5px var(--mono); color: var(--muted); opacity: .7; padding: 0 10px 4px; margin: 0; }
.login .ver { padding: 0; text-align: center; }

/* ---------- Albums page ---------- */
.album-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 22px 16px; padding-top: 20px; }
.album-grid .acard { grid-template-rows: auto auto; }

/* ---------- phone tab bar (mobile first: the main nav lives under the thumb) ---------- */
.tabbar { display: none; }
@media (max-width: 760px) {
  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; display: grid; grid-template-columns: repeat(5, 1fr);
    align-items: center; height: calc(62px + env(safe-area-inset-bottom)); padding: 0 6px env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--bg) 86%, transparent); border-top: 1px solid var(--line);
    backdrop-filter: saturate(150%) blur(18px); -webkit-backdrop-filter: saturate(150%) blur(18px);
  }
  .tabbar button {
    position: relative; flex-direction: column; justify-content: center; gap: 3px; height: 54px; padding: 0;
    border: 0; background: transparent; color: var(--muted); font-size: 10.5px; font-weight: 500; border-radius: 12px;
  }
  .tabbar button .ic { width: 22px; height: 22px; }
  .tabbar button.on { color: var(--text); }
  .tabbar button.on .ic { stroke-width: 2; }
  .tabbar button:hover { background: transparent; }
  .tabbar .add { justify-self: center; width: 48px; height: 48px; border-radius: 50%; background: var(--text); color: var(--bg); }
  .tabbar .add:hover { background: var(--text); color: var(--bg); }
  .tabbar .add .ic { width: 22px; height: 22px; stroke-width: 2.2; }
  .tabbar .tdot { position: absolute; top: 8px; left: calc(50% + 8px); width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px var(--bg); }
  .tabbar .tdot[hidden] { display: none; }

  /* room for the tab bar; uploads float above it */
  .content { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  .up { bottom: calc(74px + env(safe-area-inset-bottom)); }
  #pickFolder { display: none; }               /* Add lives in the tab bar */
  .top { min-height: 52px; }
  .top h2 { font-size: 20px; letter-spacing: -.02em; }
  .icon-btn { padding: 9px; }                  /* 36px+ tap targets */
  .icon-btn .ic { width: 18px; height: 18px; }
  .album-grid { grid-template-columns: repeat(2, 1fr); gap: 18px 10px; padding: 16px 8px 0; }
  .selbar button { padding: 9px 12px; }
}
