:root {
  --bg: #f6f4ef; --surface: #fff; --ink: #1d1b18; --muted: #6e695f; --line: #e3ded3;
  --accent: #c2410c; --accent-ink: #fff; --danger: #b91c1c; --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #15140f; --surface: #1f1d18; --ink: #ede9df; --muted: #9d978a; --line: #34312a;
          --accent: #f97316; --accent-ink: #1a0d03; --danger: #ef4444; color-scheme: dark; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: inherit; }
h1 { font-size: 1.75rem; margin: 0 0 1rem; letter-spacing: -.01em; }
h1 small { font-size: .9rem; color: var(--muted); font-weight: 500; margin-left: .25rem; }
h2 { font-size: 1.15rem; margin: 2rem 0 .75rem; }
main { max-width: 1100px; margin: 0 auto; padding: 1.5rem 16px 4rem; }
.muted { color: var(--muted); } .small { font-size: .85rem; }

/* header */
.top { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; padding: .75rem 16px;
  background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 800; text-decoration: none; font-size: 1.15rem; letter-spacing: -.02em; }
.brand::before { content: "●"; color: var(--accent); margin-right: .35rem; }
.top nav { display: flex; gap: .25rem; flex: 1; overflow-x: auto; }
.top nav a, .me a { text-decoration: none; padding: .4rem .7rem; border-radius: 999px; white-space: nowrap; font-size: .95rem; }
.top nav a:hover, .me a:hover { background: var(--bg); }
.top a.on { background: var(--ink); color: var(--bg); }
.me { display: flex; align-items: center; gap: .25rem; }
.me form { margin: 0; }
button.link { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; font-size: .95rem; padding: .4rem .7rem; }
button.link:hover { color: var(--ink); }
@media (max-width: 700px) { .top nav { order: 3; flex-basis: 100%; } .me { margin-left: auto; } }

/* forms */
label { display: flex; flex-direction: column; gap: .3rem; font-weight: 600; font-size: .9rem; }
label.check { flex-direction: row; align-items: center; gap: .5rem; font-weight: 500; }
input, select, textarea { font: inherit; font-weight: 400; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: .55rem .7rem; width: 100%; }
input[type=checkbox] { width: auto; accent-color: var(--accent); }
input[type=file] { padding: .4rem; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.narrow { max-width: 420px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .3rem; font: inherit; font-weight: 600;
  padding: .55rem 1rem; border-radius: 8px; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger { color: var(--danger); margin-left: auto; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.flash, .error { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; }
.flash { background: color-mix(in srgb, var(--accent) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); }
.error { background: color-mix(in srgb, var(--danger) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent); }

/* login */
.auth { max-width: 380px; margin: 12vh auto 0; background: var(--surface); padding: 2rem;
  border: 1px solid var(--line); border-radius: var(--radius); }
.auth h1 { margin-bottom: .25rem; }

/* home tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1rem; }
.tile { display: flex; flex-direction: column; gap: .2rem; padding: 1.25rem; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; transition: transform .12s, border-color .12s; }
.tile:hover { transform: translateY(-2px); border-color: var(--accent); }
.tile-icon { font-size: 2rem; }
.tile-name { font-weight: 700; font-size: 1.2rem; margin-top: .4rem; }
.tile-count { color: var(--muted); }
.tile-recent { color: var(--muted); font-size: .82rem; margin-top: .5rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* category */
.bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.bar h1 { margin: 0; }
.filters { display: flex; gap: .5rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.filters input[type=search] { flex: 1 1 220px; width: auto; }
.filters select { width: auto; }
.empty { color: var(--muted); padding: 3rem 0; text-align: center; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  text-decoration: none; display: flex; flex-direction: column; transition: border-color .12s; }
.card:hover { border-color: var(--accent); }
.card img, .card .noimg { width: 100%; aspect-ratio: 3/4; object-fit: cover; }
.card img { display: block; }
.noimg { display: grid; place-items: center; font-size: 2.5rem; background: var(--bg); opacity: .8; }
.card-body { padding: .7rem .8rem .85rem; display: flex; flex-direction: column; gap: .15rem; }
.card-body strong { line-height: 1.3; }
.meta { color: var(--muted); font-size: .82rem; }

/* item form */
.crumbs { margin: 0 0 .5rem; } .crumbs a { color: var(--muted); text-decoration: none; }
.item-form { display: grid; grid-template-columns: 240px 1fr; gap: 2rem; align-items: start; }
.cover { display: flex; flex-direction: column; gap: .75rem; }
.cover img, .noimg.big { width: 100%; aspect-ratio: 3/4; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--line); }
.noimg.big { font-size: 4rem; }
@media (max-width: 700px) { .item-form { grid-template-columns: 1fr; } .cover { max-width: 220px; } }

/* admin dropdown editor */
h3 { font-size: 1rem; margin: 0 0 .75rem; }
h3 small { color: var(--muted); font-weight: 500; font-size: .8rem; margin-left: .25rem; }
.dd-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1rem; align-items: start; }
.dd { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; scroll-margin-top: 80px; }
.dd.dirty { border-color: var(--accent); }
.dd-list { list-style: none; margin: 0 0 1rem; padding: 0; display: flex; flex-direction: column; gap: .35rem; }
.dd-list li { display: flex; align-items: center; gap: .35rem; }
.dd-list li.dragging { opacity: .4; }
.dd-list input[name="new[]"] { padding: .4rem .55rem; flex: 1; min-width: 0; }
.grip { color: var(--muted); cursor: grab; width: 1.2rem; text-align: center; user-select: none; font-size: .8rem; flex: none; }
.blank .grip { cursor: default; }
.uses { font-size: .75rem; color: var(--muted); min-width: 2rem; text-align: center; background: var(--bg); border-radius: 999px; padding: .1rem .4rem; flex: none; }
.icon { background: none; border: 1px solid transparent; border-radius: 6px; color: var(--muted); cursor: pointer;
  width: 1.9rem; height: 1.9rem; font-size: .85rem; flex: none; }
.icon:hover { border-color: var(--line); color: var(--ink); }
.icon.del:hover { color: var(--danger); }
.filters .opt-filter { flex: 0 1 170px; }
