:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e3e6eb;
  --text: #1b1f24;
  --muted: #687280;
  --accent: #2f6fed;
  --accent-text: #ffffff;
  --danger: #d23b3b;
  --warn: #b7791f;
  --ok: #2f9e6a;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418;
    --surface: #1a1e24;
    --border: #2c323b;
    --text: #e8ebef;
    --muted: #8f99a6;
    --accent: #5b8cff;
    --danger: #ef6b6b;
    --warn: #e0a84a;
    --ok: #4cc38a;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--accent); text-decoration: none; }
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 24px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}
.logo { font-weight: 700; color: var(--text); font-size: 16px; }
#userbox { display: flex; gap: 12px; align-items: center; color: var(--muted); }
main { max-width: 1400px; margin: 0 auto; padding: 24px; }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 16px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; margin-bottom: 16px;
}
.auth-card { max-width: 380px; margin: 60px auto; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
label { display: block; margin-bottom: 12px; }
label > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
input, select, textarea {
  width: 100%; padding: 8px 10px; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
button, .btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; font: inherit; font-weight: 500; cursor: pointer;
  border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
button:hover, .btn:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.danger { color: var(--danger); }
button:disabled { opacity: .5; cursor: default; }
.link-btn { background: none; border: none; color: var(--accent); padding: 0; }

.projects { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.project-card { display: block; color: var(--text); }
.project-card:hover { border-color: var(--accent); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); }
.badge { display: inline-block; min-width: 18px; padding: 0 6px; border-radius: 9px; font-size: 11px; text-align: center; background: var(--border); }
.badge.err { background: var(--danger); color: #fff; }
.badge.warn { background: var(--warn); color: #fff; }

.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); max-height: 70vh; }
table { border-collapse: collapse; width: max-content; min-width: 100%; }
th, td { border-bottom: 1px solid var(--border); padding: 0; text-align: left; vertical-align: middle; }
th { position: sticky; top: 0; background: var(--surface); font-size: 12px; color: var(--muted); padding: 8px; font-weight: 600; z-index: 1; }
td input, td select { border: none; border-radius: 0; background: transparent; padding: 8px; min-width: 110px; }
td.wide input { min-width: 260px; }
td.check, th.check { width: 36px; text-align: center; }
td.check input, th.check input { width: auto; min-width: 0; }
td.thumb { width: 52px; padding: 4px; }
td.thumb img, td.thumb video { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; display: block; background: var(--bg); }
td.has-error input, td.has-error select { box-shadow: inset 0 -2px 0 var(--danger); }
td.has-warn input { box-shadow: inset 0 -2px 0 var(--warn); }
tr:hover td { background: color-mix(in srgb, var(--accent) 4%, transparent); }

.dropzone {
  border: 2px dashed var(--border); border-radius: var(--radius); padding: 36px; text-align: center;
  color: var(--muted); cursor: pointer; transition: .15s;
}
.dropzone.over { border-color: var(--accent); color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent); }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-top: 16px; }
.media-item { position: relative; border: 2px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); cursor: pointer; }
.media-item.selected { border-color: var(--accent); }
.media-item img, .media-item video { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: var(--bg); }
.media-item .meta { padding: 6px 8px; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-item .kind { position: absolute; top: 6px; left: 6px; background: rgba(0,0,0,.6); color: #fff; font-size: 11px; padding: 1px 6px; border-radius: 4px; }
.progress { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; margin-top: 12px; }
.progress > div { height: 100%; background: var(--accent); transition: width .2s; }

.issues { list-style: none; padding: 0; margin: 0; }
.issues li { padding: 8px 0; border-bottom: 1px solid var(--border); display: flex; gap: 10px; }
.issues .tag { font-size: 11px; padding: 1px 6px; border-radius: 4px; color: #fff; height: fit-content; }
.tag.err { background: var(--danger); }
.tag.warn { background: var(--warn); }
.ok-text { color: var(--ok); font-weight: 600; }

.feed-url { display: flex; gap: 8px; }
.feed-url input { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }

dialog {
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text);
  padding: 20px; width: min(720px, 92vw); max-height: 86vh;
}
dialog::backdrop { background: rgba(0,0,0,.4); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } main { padding: 16px; } }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; z-index: 50; max-width: 90vw;
}
.toast.error { background: var(--danger); color: #fff; }
