:root {
  --bg: #f6f6f4;
  --card: #ffffff;
  --ink: #1b1b1a;
  --muted: #6d6d68;
  --line: #e4e3df;
  --accent: #2f5bea;
  --accent-ink: #ffffff;
  --ok: #1f9d55;
  --bad: #d64545;
  --radius: 12px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #141413; --card: #1e1e1c; --ink: #ecebe7; --muted: #9a9993; --line: #2e2e2b; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.5; }
a { color: inherit; }
h1 { font-size: 20px; margin: 0 0 4px; font-weight: 600; }
code { font-size: 13px; background: var(--line); padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.topbar { display: flex; align-items: center; justify-content: space-between; padding: 14px 24px; border-bottom: 1px solid var(--line); background: var(--card); }
.brand { font-weight: 700; text-decoration: none; letter-spacing: -0.01em; }
.topbar nav a { margin-left: 18px; text-decoration: none; color: var(--muted); }
.topbar nav a.on { color: var(--ink); font-weight: 600; }

.wrap { max-width: 760px; margin: 28px auto; padding: 0 20px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }

input[type=text], input[type=password], input[type=search], select, textarea {
  width: 100%; padding: 10px 12px; font: inherit; color: inherit;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
textarea { font-family: ui-monospace, Menlo, monospace; font-size: 12px; margin: 8px 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap;
  padding: 10px 16px; font: inherit; font-weight: 600; border-radius: 8px; cursor: pointer; text-decoration: none;
  border: 1px solid var(--line); background: var(--card); color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary.done { background: var(--ok); border-color: var(--ok); }
.btn.ghost { background: transparent; }
.btn.danger { background: transparent; color: var(--bad); border-color: transparent; }
.btn:hover { filter: brightness(0.96); }

.lbl { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.linkrow { display: flex; gap: 8px; }
.linkbox #link { font-size: 16px; font-weight: 500; }
.status-line { margin: 12px 0 0; color: var(--muted); font-size: 14px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); margin-right: 6px; vertical-align: 1px; }
.dot.ok { background: var(--ok); }
.dot.bad { background: var(--bad); }
.dot.pulse { background: var(--accent); animation: pulse 1.2s infinite ease-in-out; }
@keyframes pulse { 50% { opacity: 0.3; } }

.field { margin-bottom: 18px; }
.hint { margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.check { display: flex; gap: 8px; align-items: center; cursor: pointer; }
.saved { min-height: 20px; margin: 10px 0 0; font-size: 13px; color: var(--muted); }

.preview video, .preview img { width: 100%; border-radius: 8px; display: block; background: #000; }
.placeholder { padding: 48px 0; text-align: center; color: var(--muted); }
.row-actions { display: flex; justify-content: space-between; }

/* Library */
.lib-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 4px; }
.tabs a { padding: 6px 14px; border-radius: 7px; text-decoration: none; color: var(--muted); font-weight: 500; }
.tabs a.on { background: var(--bg); color: var(--ink); }
.search { flex: 1; max-width: 260px; }
.lib-list { list-style: none; margin: 0; padding: 0; }
.lib-item { display: flex; align-items: center; gap: 14px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; margin-bottom: 8px; }
.thumb { flex: 0 0 120px; height: 68px; border-radius: 6px; overflow: hidden; background: #000; display: flex; align-items: center; justify-content: center; }
.thumb video, .thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-ph { color: #bbb; font-size: 12px; }
.lib-info { flex: 1; min-width: 0; }
.lib-title { font-weight: 600; text-decoration: none; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lib-info p { margin: 2px 0 0; }
.tag { color: #b7791f; }
.tag.kept { color: var(--ok); }
.empty { text-align: center; padding: 48px 0; }

/* Viewer */
body.viewer { background: #0f0f0e; color: #ecebe7; --card: #1b1b19; --line: #2c2c29; --bg: #0f0f0e; --muted: #9a9993; }
.viewer-wrap { max-width: 1100px; margin: 0 auto; padding: 32px 20px; }
.media video, .media img { width: 100%; max-height: 78vh; display: block; border-radius: 10px; background: #000; object-fit: contain; }
.meta { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-top: 16px; }
.meta p { margin: 0; }
.message { max-width: 420px; margin: 12vh auto 0; text-align: center; }
.message input { margin: 14px 0 10px; }
.message .btn { width: 100%; }
.error { color: var(--bad); font-size: 14px; margin: 0 0 10px; }
.checks { list-style: none; padding: 0; text-align: left; font-size: 14px; }
.checks .ok { color: var(--ok); }
.checks .bad { color: var(--bad); }

@media (max-width: 560px) {
  .linkrow { flex-wrap: wrap; }
  .thumb { flex-basis: 84px; height: 50px; }
  .lib-item .btn { padding: 8px 10px; }
}
