:root {
  --bg: #f6f7f9; --fg: #1d2330; --muted: #6b7385; --card: #fff; --line: #e3e6ec;
  --accent: #2f6fde; --ok: #1f8a4c; --err: #c23b3b; --radius: 8px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #14171d; --fg: #e6e9ef; --muted: #9098a9; --card: #1c2028; --line: #2c323d; }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 system-ui, sans-serif; background: var(--bg); color: var(--fg); }
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 1.6rem; margin: .2em 0 .8em; }
h2 { font-size: 1.1rem; margin: 0 0 .3em; }
main { max-width: 960px; margin: 0 auto; padding: 1.5rem; }
.muted { color: var(--muted); font-size: .9em; }

.top { display: flex; justify-content: space-between; align-items: center;
       padding: .7rem 1.5rem; background: var(--card); border-bottom: 1px solid var(--line); }
.top nav { display: flex; gap: .5rem; align-items: center; }
.top form { margin: 0; }
.brand { font-weight: 700; color: var(--fg); }
.sep { color: var(--muted); }

.card { display: block; background: var(--card); border: 1px solid var(--line);
        border-radius: var(--radius); padding: 1.2rem; margin-bottom: 1.2rem; }
.narrow { max-width: 420px; margin: 3rem auto; }
.grid { list-style: none; padding: 0; margin: 0; display: grid; gap: 1rem;
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.project { display: flex; flex-direction: column; color: var(--fg); margin: 0; }
.project:hover { border-color: var(--accent); }
.row { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin: .8rem 0; }
.row input:not([type=file]) { flex: 1; min-width: 10rem; }
.actions { display: flex; gap: .8rem; align-items: center; margin-top: .8rem; }

label { display: block; font-size: .9em; margin-bottom: .3rem; }
input, select, button { font: inherit; color: inherit; padding: .45rem .6rem;
  border: 1px solid var(--line); border-radius: 6px; background: var(--bg); }
input[readonly] { color: var(--muted); }
form > input { width: 100%; margin-bottom: 1rem; }
button { background: var(--accent); border-color: var(--accent); color: #fff; cursor: pointer; }
button:disabled { opacity: .5; cursor: default; }
button.link { background: none; border: none; color: var(--accent); padding: 0; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: .85em; }
td, th { padding: .25rem .4rem .25rem 0; }
td input { width: 100%; }

.flash { padding: .6rem .9rem; border-radius: 6px; margin-bottom: 1rem; border: 1px solid; }
.flash:empty { display: none; }
.flash.ok { color: var(--ok); border-color: var(--ok); }
.flash.error { color: var(--err); border-color: var(--err); }

textarea { font: inherit; color: inherit; width: 100%; padding: .45rem .6rem; resize: vertical;
           border: 1px solid var(--line); border-radius: 6px; background: var(--bg); }
.who { display: flex; gap: 1rem; align-items: center; }
.badge { display: inline-block; margin-left: .4rem; padding: 0 .45rem; border-radius: 999px;
         font-size: .75rem; background: var(--accent); color: #fff; vertical-align: middle; }
button.secondary { background: none; color: var(--accent); }
button.link.danger { color: var(--err); font-size: .85em; }
.mono, code { font-family: ui-monospace, monospace; }
.key-once { border-color: var(--ok); }
.key-once input { flex: 1; }
table.users td { vertical-align: top; padding: .6rem .6rem .6rem 0; border-top: 1px solid var(--line); }
ul.keys { list-style: none; margin: 0; padding: 0; }

.thumbs { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
button.thumb { display: flex; flex-direction: column; gap: .3rem; padding: .4rem; text-align: left;
               background: var(--bg); color: var(--fg); border: 1px solid var(--line); cursor: pointer; }
button.thumb:hover, button.thumb.selected { border-color: var(--accent); }
button.thumb.selected { box-shadow: 0 0 0 2px var(--accent); }
button.thumb img { width: 100%; aspect-ratio: 1; object-fit: contain; border-radius: 4px; }
.caption { font-size: .8em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 1rem; }

img.preview { display: block; max-width: 100%; max-height: 420px; border-radius: 6px; margin: .5rem 0; }
figure { margin: 0; }
figure img { width: 100%; aspect-ratio: 1; object-fit: contain; background: var(--bg);
             border: 1px solid var(--line); border-radius: 6px; }
figcaption { font-size: .85em; }
#preview { margin-top: 1rem; }
