:root {
  --bg: #f6f6f4;
  --surface: #ffffff;
  --text: #1c1c1a;
  --muted: #6b6b66;
  --border: #dcdcd6;
  --accent: #2f5fd0;
  --accent-text: #ffffff;
  --danger: #b3261e;
  --ok: #1b7a3a;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151514;
    --surface: #202020;
    --text: #eeeeea;
    --muted: #9a9a94;
    --border: #3a3a37;
    --accent: #7d9cf0;
    --accent-text: #11131a;
    --danger: #f2877f;
    --ok: #6fcf8e;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1 { margin: 0 0 .5rem; font-size: 1.4rem; }
h1 small { font-weight: 400; color: var(--muted); font-size: .9rem; margin-left: .5rem; }

.card {
  max-width: 24rem;
  margin: 12vh auto 0;
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}
form { display: grid; gap: .9rem; }
label { display: grid; gap: .25rem; font-size: .9rem; color: var(--muted); }
input[type="email"], input[type="password"], input[inputmode="numeric"] {
  font: inherit;
  padding: .6rem .7rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}
input:focus-visible, button:focus-visible, .button:focus-visible, .thumb:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button, .button {
  font: inherit;
  display: inline-block;
  padding: .55rem 1rem;
  color: var(--accent-text);
  background: var(--accent);
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}
button:disabled { opacity: .6; cursor: default; }
.secondary { color: var(--text); background: transparent; border-color: var(--border); }
.danger { color: var(--danger); background: transparent; border-color: var(--danger); }

.hint { color: var(--muted); font-size: .9rem; margin: .25rem 0 .75rem; }
.center { text-align: center; }
.msg { min-height: 1.2em; margin: 0; font-size: .9rem; }
.msg.error { color: var(--danger); }
.msg.ok { color: var(--ok); }

.qr { display: block; width: 200px; height: 200px; margin: .5rem auto; image-rendering: pixelated; background: #fff; padding: 8px; border-radius: 8px; }
.secret { word-break: break-all; font-size: .9rem; }
.secret span { color: var(--muted); }

/* gallery */
.bar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .75rem 1rem; border-bottom: 1px solid var(--border); background: var(--surface); }
.bar h1 { margin: 0; }
.bar-right { display: flex; align-items: center; gap: .75rem; }
.who { color: var(--muted); font-size: .85rem; }

.drop { max-width: 60rem; margin: 1rem auto; padding: 1rem; text-align: center; border: 2px dashed var(--border); border-radius: 12px; }
.drop.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.drop p { margin: .25rem 0; }

.uploads { list-style: none; margin: .75rem 0 0; padding: 0; display: grid; gap: .4rem; text-align: left; }
.uploads li { display: grid; grid-template-columns: 1fr auto; gap: .1rem .75rem; align-items: center; font-size: .85rem; }
.uploads progress { grid-column: 1 / -1; width: 100%; height: .4rem; }
.uploads .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.uploads .state { color: var(--muted); }
.uploads .state.error { color: var(--danger); }
.uploads .state.ok { color: var(--ok); }

#app-msg { max-width: 60rem; margin: 0 auto; padding: 0 1rem; }

.grid {
  max-width: 80rem;
  margin: 1rem auto 3rem;
  padding: 0 1rem;
  display: grid;
  gap: .5rem;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.thumb { padding: 0; border: 0; border-radius: 8px; overflow: hidden; background: var(--surface); aspect-ratio: 1; cursor: pointer; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

dialog { width: min(96vw, 70rem); max-height: 94vh; padding: 0; border: 0; border-radius: 12px; background: var(--surface); color: var(--text); }
dialog::backdrop { background: rgb(0 0 0 / .75); }
dialog img { display: block; width: 100%; max-height: 78vh; object-fit: contain; background: #000; }
.lb-bar { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: space-between; align-items: center; padding: .75rem 1rem; }
#lb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; color: var(--muted); font-size: .9rem; }
.lb-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* folders */
.folders { max-width: 80rem; margin: 1rem auto 0; padding: 0 1rem; display: flex; flex-wrap: wrap; gap: .5rem; }
.chip { display: inline-flex; gap: .4rem; align-items: baseline; padding: .35rem .85rem; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; }
.chip .n { color: var(--muted); font-size: .8rem; }
.chip[aria-pressed="true"] { color: var(--accent-text); background: var(--accent); border-color: var(--accent); }
.chip[aria-pressed="true"] .n { color: inherit; opacity: .85; }
.tools { max-width: 80rem; margin: .75rem auto 0; padding: 0 1rem; display: flex; flex-wrap: wrap; gap: .5rem; }
.tools button { padding: .35rem .8rem; font-size: .9rem; }
.selbar { max-width: 80rem; margin: .75rem auto 0; padding: .6rem 1rem; display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.selbar .inline { display: inline-flex; flex-direction: row; align-items: center; gap: .4rem; }
select { font: inherit; padding: .4rem .5rem; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 8px; }
.thumb { position: relative; }
.thumb.selected { outline: 3px solid var(--accent); outline-offset: -3px; }
.thumb.selected::after { content: "\2713"; position: absolute; top: 6px; right: 6px; width: 1.5rem; height: 1.5rem; line-height: 1.5rem; text-align: center; border-radius: 50%; color: var(--accent-text); background: var(--accent); font-size: .95rem; }

/* sharing */
.chip .tag { font-size: .7rem; padding: 0 .4rem; border: 1px solid currentColor; border-radius: 999px; opacity: .8; }
.chip .from { color: var(--muted); font-size: .8rem; }
.chip[aria-pressed="true"] .from { color: inherit; opacity: .85; }
.group-label { align-self: center; margin-left: .75rem; color: var(--muted); font-size: .85rem; }
.shared-note { max-width: 80rem; margin: .75rem auto 0; padding: .5rem 1rem; color: var(--muted); font-size: .9rem; }
dialog.panel { width: min(94vw, 30rem); padding: 1.25rem; }
dialog.panel h2 { margin: 0 0 .5rem; font-size: 1.15rem; }
.people { list-style: none; margin: .5rem 0 1rem; padding: 0; display: grid; gap: .4rem; }
.people li { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .4rem .6rem; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; word-break: break-all; }
.people li.muted { color: var(--muted); justify-content: center; }
.people button { padding: .25rem .7rem; font-size: .85rem; }
dialog.panel form { margin-bottom: .5rem; }
dialog.panel > button { margin-top: .5rem; }
