:root {
  --bg: #f6f5f2; --panel: #ffffff; --ink: #1d1d1f; --muted: #6b6b70; --line: #e4e2dc;
  --accent: #2f5d50; --accent-ink: #ffffff; --danger: #b3261e; --ok: #2e7d32; --warn: #a15c00;
  --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #141416; --panel: #1d1d20; --ink: #ececee; --muted: #9a9aa2; --line: #2e2e33;
    --accent: #7fb8a6; --accent-ink: #10201b; color-scheme: dark; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.45; }
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
.loading { padding: 2rem; color: var(--muted); }

.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 1.25rem 1rem; display: flex; flex-direction: column; gap: .25rem; }
.brand { font-weight: 700; font-size: 1.05rem; margin-bottom: .75rem; }
.side a.nav { display: block; padding: .5rem .65rem; border-radius: 8px; color: var(--ink); text-decoration: none; }
.side a.nav.active, .side a.nav:hover { background: var(--bg); }
.side .bottom { margin-top: auto; font-size: .85rem; color: var(--muted); display: grid; gap: .5rem; }
main { padding: 1.5rem 2rem 4rem; max-width: 1100px; width: 100%; min-width: 0; }
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { flex-direction: row; flex-wrap: wrap; align-items: center; border-right: 0; border-bottom: 1px solid var(--line); padding: .75rem 1rem; }
  .brand { margin: 0 .75rem 0 0; }
  .side .bottom { margin: 0 0 0 auto; }
  main { padding: 1rem 1rem 4rem; }
}

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; margin-bottom: 1rem; }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem 1rem; }
@media (max-width: 700px) { .grid2 { grid-template-columns: 1fr; } }
label { display: grid; gap: .3rem; font-size: .85rem; color: var(--muted); }
input, select, textarea { font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: .5rem .6rem; width: 100%; }
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button, .btn { font: inherit; cursor: pointer; border-radius: 8px; padding: .5rem .9rem; border: 1px solid var(--line); background: var(--panel); color: var(--ink); text-decoration: none; display: inline-block; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.danger { color: var(--danger); }
button.small { padding: .25rem .55rem; font-size: .85rem; }
button:disabled { opacity: .5; cursor: default; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .55rem .5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .8rem; color: var(--muted); font-weight: 600; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--bg); }
.table-wrap { overflow-x: auto; }
td input { min-width: 80px; padding: .35rem .45rem; }
.muted { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 2rem 1rem; }

.badge { display: inline-block; font-size: .75rem; padding: .1rem .5rem; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.badge.ok { color: var(--ok); border-color: currentColor; }
.badge.warn { color: var(--warn); border-color: currentColor; }
.badge.err { color: var(--danger); border-color: currentColor; }

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: .5rem .8rem; color: var(--muted); }
.tabs button.on { color: var(--ink); border-bottom-color: var(--accent); }

.images { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .75rem; }
.img { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--bg); display: grid; }
.img img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.img .meta { padding: .4rem; display: grid; gap: .35rem; }
.drop { border: 2px dashed var(--line); border-radius: var(--radius); padding: 1.25rem; text-align: center; color: var(--muted); }
.drop.over { border-color: var(--accent); color: var(--accent); }

.auth { max-width: 380px; margin: 10vh auto; }
.stickybar { position: sticky; bottom: 0; background: var(--bg); padding: .75rem 0; border-top: 1px solid var(--line); display: flex; gap: .75rem; justify-content: flex-end; flex-wrap: wrap; }

#toast { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: .55rem 1rem; border-radius: 8px; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 90vw; }
#toast.show { opacity: 1; }

/* description preview */
.pv { border: 1px solid var(--line); border-radius: 8px; background: var(--bg); margin-top: -.25rem; }
.pv-tabs { display: flex; gap: .25rem; padding: .35rem .4rem 0; }
.pv-tabs button { border: 0; background: none; padding: .3rem .6rem; font-size: .8rem; color: var(--muted); border-radius: 6px 6px 0 0; }
.pv-tabs button.on { background: var(--panel); color: var(--ink); }
.pv-out { background: var(--panel); padding: .75rem .9rem; border-radius: 0 0 8px 8px; max-height: 320px; overflow: auto; font-size: .92rem; }
.pv-html > :first-child { margin-top: 0; } .pv-html > :last-child { margin-bottom: 0; }
.pv-text { white-space: pre-wrap; font-family: inherit; }
