:root {
  --bg: #ffffff; --bg2: #f2f2f7; --card: #ffffff; --text: #000; --muted: #8e8e93; --line: #d1d1d6;
  --blue: #007aff; --red: #ff3b30;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #000; --bg2: #1c1c1e; --card: #1c1c1e; --text: #fff; --muted: #8e8e93; --line: #38383a; --blue: #0a84ff; --red: #ff453a; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
button { font: inherit; }
.hidden { display: none !important; }

/* Sign-in */
.login { max-width: 360px; margin: 12vh auto; padding: 24px; }
.login h1 { font-size: 34px; margin: 0 0 24px; }
.field { width: 100%; padding: 12px 14px; margin-bottom: 10px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--text); font-size: 16px; }
.primary { width: 100%; padding: 12px; border: 0; border-radius: 10px; background: var(--blue); color: #fff; font-size: 16px; cursor: pointer; }
.error { color: var(--red); margin-top: 12px; }

/* Layout */
header { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px; padding: 10px 20px;
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(20px); border-bottom: 1px solid var(--line); }
header h1 { font-size: 22px; margin: 0; flex: 1; }
.tabs { display: inline-flex; background: var(--bg2); border-radius: 9px; padding: 2px; }
.tabs button { border: 0; background: transparent; color: var(--text); padding: 6px 16px; border-radius: 7px; cursor: pointer; }
.tabs button.on { background: var(--card); box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.link { border: 0; background: none; color: var(--blue); cursor: pointer; padding: 0; text-decoration: none; }
.muted { color: var(--muted); }

/* Photos */
.month { font-size: 20px; margin: 18px 16px 8px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 2px; padding: 2px; }
.grid .tile { aspect-ratio: 1; background: var(--bg2); overflow: hidden; cursor: pointer; position: relative; }
.grid img { width: 100%; height: 100%; object-fit: cover; display: block; }
.grid .badge { position: absolute; right: 6px; bottom: 4px; color: #fff; font-size: 12px; text-shadow: 0 0 3px #000; }
.empty { padding: 60px 20px; text-align: center; color: var(--muted); }
.viewer { position: fixed; inset: 0; z-index: 10; background: #000; display: flex; flex-direction: column; }
.viewer .bar { display: flex; align-items: center; gap: 16px; padding: 12px 20px; color: #fff; }
.viewer .bar .title { flex: 1; }
.viewer .bar a, .viewer .bar button { color: #fff; text-decoration: none; }
.viewer .stage { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 0; }
.viewer img { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer .nav { position: absolute; top: 50%; border: 0; background: rgba(255,255,255,.15); color: #fff; font-size: 28px;
  width: 44px; height: 44px; border-radius: 22px; cursor: pointer; }
.viewer .prev { left: 16px; } .viewer .next { right: 16px; }

/* Files */
.files { max-width: 900px; margin: 0 auto; padding: 12px 20px 60px; }
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 8px 0 16px; }
.crumbs .sep { color: var(--muted); }
.toolbar { display: flex; gap: 16px; margin-bottom: 12px; }
.list { background: var(--card); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row .icon { width: 28px; text-align: center; font-size: 22px; }
.row .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.row .meta { color: var(--muted); font-size: 13px; white-space: nowrap; }
.row .actions { display: flex; gap: 12px; }
.row .actions .danger { color: var(--red); }
.preview { display: block; max-width: 100%; max-height: 70vh; margin: 16px auto; border-radius: 12px; }
.button { display: inline-block; width: auto; padding: 12px 20px; text-decoration: none; }
.searchbar { padding: 12px 16px 0; }
.search { max-width: 640px; margin: 0 auto 4px; display: block; }
.albums { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; }
.album { color: inherit; text-decoration: none; }
.album .cover { aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--bg2); }
.album .cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.album-name { margin-top: 6px; font-weight: 600; }
.album-pick { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.4); border-radius: 6px; padding: 4px; }
.viewer .bar .extra { display: inline-flex; gap: 12px; }
.drop { outline: 2px dashed var(--blue); outline-offset: -6px; }
.progress { margin-bottom: 12px; color: var(--muted); }

@media (max-width: 640px) {
  header { padding: 10px 16px; flex-wrap: wrap; row-gap: 8px; }
  header .tabs { order: 3; width: 100%; display: flex; }
  header .tabs button { flex: 1; padding: 6px 4px; font-size: 14px; }
  .files { padding: 8px 16px 60px; }
  .row { flex-wrap: wrap; }
  .row .name { flex: 1 1 calc(100% - 52px); }
  .row .meta { order: 3; width: 100%; padding-left: 40px; }
  .row .actions { order: 4; width: 100%; padding-left: 40px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
  .viewer .nav { display: none; }
}
