:root {
  --bg: #f7f4ee; --surface: #fffdf9; --ink: #1d1b18; --muted: #6f6a61; --line: #e3ddd2;
  --accent: #9a3b26; --accent-ink: #fff; --good: #2f6b4f; --warn: #a1661b; --danger: #a12b2b;
  --serif: "Iowan Old Style", "Charter", "Palatino Linotype", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161513; --surface: #1f1d1a; --ink: #ece7de; --muted: #9b958a; --line: #33302b;
    --accent: #e0835f; --accent-ink: #1b1209; --good: #7cc29e; --warn: #e2b46a; --danger: #ef8a8a;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration-color: color-mix(in srgb, currentColor 35%, transparent); text-underline-offset: 2px; }
a:hover { color: var(--accent); }
h1, h2, .brand { font-family: var(--serif); font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 1.9rem; line-height: 1.15; margin: 0 0 .4rem; }
h2 { font-size: 1.15rem; margin: 1.8rem 0 .6rem; }
code { font: .85em var(--mono); background: color-mix(in srgb, var(--ink) 7%, transparent); padding: .1em .35em; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

header.top { display: flex; align-items: center; gap: 1.5rem; padding: .9rem max(16px, calc(50vw - 600px)); border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 5; }
.brand { font-size: 1.35rem; text-decoration: none; }
header nav { display: flex; gap: 1.1rem; flex: 1; }
header nav a { text-decoration: none; color: var(--muted); }
header nav a[aria-current] { color: var(--ink); font-weight: 600; }
main { max-width: 1200px; margin: 0 auto; padding: 1.5rem 16px 4rem; }

input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: .55rem .7rem; width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); border-color: var(--accent); }
input[type=checkbox] { width: auto; }
input[type=file] { padding: .45rem; }
textarea { font-family: var(--mono); font-size: .9rem; }
button, .button { display: inline-block; background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 8px; padding: .55rem 1rem; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; }
button:hover, .button:hover { filter: brightness(1.08); color: var(--accent-ink); }
button.link { background: none; color: var(--muted); padding: 0; font-weight: 400; }
button.link:hover { color: var(--ink); filter: none; }
button.danger:not(.link) { background: var(--danger); }
.danger.link { color: var(--danger); }
label { display: grid; gap: .25rem; font-size: .9rem; color: var(--muted); }
label small { font-size: .8rem; }
label.check { display: flex; align-items: center; gap: .45rem; color: var(--ink); }
.stack { display: grid; gap: .8rem; }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .8rem; align-items: end; }
form.inline { display: flex; flex-wrap: wrap; gap: .6rem; align-items: end; margin: .7rem 0; }
form.inline label { flex: 1 1 180px; }
fieldset { border: 1px solid var(--line); border-radius: 8px; display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; padding: .6rem .9rem; }
legend { color: var(--muted); font-size: .9rem; padding: 0 .3rem; }

.flash { background: color-mix(in srgb, var(--good) 14%, var(--surface)); border: 1px solid color-mix(in srgb, var(--good) 35%, transparent); padding: .6rem .9rem; border-radius: 8px; }
.flash.error { background: color-mix(in srgb, var(--danger) 12%, var(--surface)); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }

.filters { display: grid; grid-template-columns: 1fr auto auto; gap: .6rem; }
.filters input { font-size: 1rem; }
.count { margin: .7rem 0 1rem; font-size: .9rem; }
.grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1.6rem 1.2rem; }
.card { display: block; text-decoration: none; }
.cover { position: relative; aspect-ratio: 2 / 3; border-radius: 4px; overflow: hidden; background: var(--line); box-shadow: 0 1px 2px rgb(0 0 0 / .12), 0 6px 18px -8px rgb(0 0 0 / .35); }
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card:hover .cover { transform: translateY(-2px); }
.gen { height: 100%; padding: 14px 12px; display: flex; flex-direction: column; justify-content: space-between; color: #fff;
  background: linear-gradient(160deg, hsl(var(--h) 38% 34%), hsl(calc(var(--h) + 30) 42% 22%)); font-family: var(--serif); }
.gen span { font-size: 1.05rem; line-height: 1.2; font-weight: 600; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; }
.gen small { opacity: .8; font-size: .8rem; }
.cover .bar { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; border-radius: 0; background: rgb(0 0 0 / .35); }
.cover .bar i { background: var(--accent); }
.meta { display: grid; gap: .1rem; padding-top: .55rem; font-size: .88rem; }
.meta strong { font-weight: 600; line-height: 1.25; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.meta span { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.formats em { font-style: normal; font: 600 .68rem var(--mono); text-transform: uppercase; letter-spacing: .03em; border: 1px solid var(--line); border-radius: 3px; padding: 0 .3em; margin-right: .25rem; }
.empty { text-align: center; padding: 4rem 1rem; color: var(--muted); }
.pager { display: flex; justify-content: space-between; margin-top: 2rem; }

.bar { height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); }

.work { display: grid; grid-template-columns: 240px 1fr; gap: 2.5rem; align-items: start; }
.work .cover.big { position: sticky; top: 5rem; }
.work .kind { text-transform: uppercase; letter-spacing: .08em; font-size: .75rem; color: var(--muted); margin: 0 0 .3rem; }
.work .authors { font-size: 1.1rem; margin: 0 0 .5rem; }
.work .desc { max-width: 65ch; color: var(--muted); }
.progress, .files, .tokens { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; }
.progress li { display: grid; grid-template-columns: 9rem 1fr 4rem auto; gap: .8rem; align-items: center; }
.progress .dev { font-weight: 600; }
.progress .pct { text-align: right; font-variant-numeric: tabular-nums; }
.files li { display: flex; flex-wrap: wrap; gap: .4rem .9rem; align-items: center; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.fmt { font: 700 .8rem var(--mono); text-transform: uppercase; min-width: 3.5rem; }
.role { font-size: .85rem; flex: 1; }
.role.derived { color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.chip { background: color-mix(in srgb, var(--accent) 14%, var(--surface)); color: var(--ink); font-weight: 500; padding: .3rem .7rem; border-radius: 999px; }
.chips form.inline { margin: 0; }
details { margin-top: 1.6rem; border-top: 1px solid var(--line); padding-top: 1rem; }
summary { cursor: pointer; font-weight: 600; }
details form { margin-top: 1rem; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 1.1rem 1.3rem; margin: 1rem 0; }
.panel h2 { margin-top: 0; }
.panel.highlight { border-color: var(--accent); }
.code { font: 700 2rem var(--mono); letter-spacing: .15em; margin: .3rem 0; word-break: break-all; }
.code.small { font-size: 1rem; letter-spacing: 0; }
.device .head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: .5rem; }
.device .head h2 { margin: 0; }
.device .actions { display: flex; justify-content: flex-end; }
.warn { color: var(--warn); font-style: normal; }
.tokens li { display: flex; gap: .8rem; align-items: baseline; flex-wrap: wrap; }
.tokens form { margin-left: auto; }
table.events { width: 100%; border-collapse: collapse; font-size: .9rem; }
.events td { padding: .45rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.events td:first-child { white-space: nowrap; width: 1%; }

.login { max-width: 320px; margin: 18vh auto 0; text-align: center; }
.login .brand { font-size: 2.4rem; margin-bottom: .5rem; }

#drop { position: fixed; inset: 0; background: color-mix(in srgb, var(--bg) 80%, transparent); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 20; }
#drop div { border: 2px dashed var(--accent); border-radius: 16px; padding: 3rem 4rem; font: 600 1.3rem var(--serif); background: var(--surface); }
#drop[hidden] { display: none; }

@media (max-width: 720px) {
  header.top { gap: .8rem; flex-wrap: wrap; }
  header nav { order: 3; flex-basis: 100%; overflow-x: auto; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters input { grid-column: 1 / -1; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 1.2rem .9rem; }
  .work { grid-template-columns: 1fr; gap: 1.2rem; }
  .work .cover.big { position: static; width: 150px; }
  .progress li { grid-template-columns: 1fr 3.5rem; }
  .progress .bar { grid-column: 1 / -1; grid-row: 2; }
  .progress li > .muted { grid-column: 1 / -1; }
}
