:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --text: #111113;
  --muted: #6b6b73;
  --line: #e7e7ea;
  --soft: #f3f3f5;
  --accent: #111113;
  --accent-text: #ffffff;
  --ok: #157f3c;
  --ok-bg: #e8f6ed;
  --warn: #8a5a00;
  --warn-bg: #fdf4e3;
  --err: #b42318;
  --err-bg: #fdecea;
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 "Inter", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
a { color: inherit; }

.wrap { max-width: 980px; margin: 0 auto; padding: 0 20px 80px; }

header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 0; margin-bottom: 8px;
}
.brand { font-weight: 700; letter-spacing: -0.2px; display: flex; align-items: center; gap: 10px; }
.brand-dot { width: 10px; height: 10px; border-radius: 99px; background: var(--text); }
.link-btn { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 6px 0; }
.link-btn:hover { color: var(--text); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.tab {
  background: none; border: 0; padding: 10px 14px; cursor: pointer; color: var(--muted); font-weight: 500;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--text); }

.segmented { display: inline-flex; background: var(--soft); border-radius: 10px; padding: 3px; margin-bottom: 14px; }
.seg { border: 0; background: none; padding: 7px 14px; border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 500; font-size: 14px; }
.seg.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px #0000001a; }
.row.row-3 { grid-template-columns: 1fr 1fr auto; }

/* ---------- new article form ---------- */
.composer { padding: 20px; margin-bottom: 28px; }
.composer h2 { font-size: 15px; margin: 0 0 14px; font-weight: 600; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
input[type="text"], input[type="url"], input[type="password"], select {
  height: 42px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); padding: 0 12px; outline: none; width: 100%;
}
input:focus, select:focus { border-color: #b9b9c0; box-shadow: 0 0 0 3px #11111310; }
.row { display: grid; grid-template-columns: 1fr 1fr auto auto; gap: 12px; align-items: end; margin-top: 12px; }
.cat-wrap { display: flex; gap: 6px; }
.icon-btn {
  width: 42px; flex: 0 0 42px; height: 42px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); cursor: pointer; color: var(--muted);
}
.icon-btn:hover { color: var(--text); }

.toggle { display: flex; align-items: center; gap: 10px; height: 42px; cursor: pointer; user-select: none; white-space: nowrap; }
.toggle input { display: none; }
.toggle .track {
  width: 38px; height: 22px; border-radius: 99px; background: #d9d9de; position: relative; transition: background .15s;
}
.toggle .track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 99px; background: #fff;
  transition: transform .15s; box-shadow: 0 1px 2px #0003;
}
.toggle input:checked + .track { background: var(--accent); }
.toggle input:checked + .track::after { transform: translateX(16px); }

.btn {
  height: 42px; padding: 0 18px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); cursor: pointer; font-weight: 500; white-space: nowrap;
}
.btn:hover { background: var(--soft); }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn.primary:hover { opacity: .9; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn.danger { color: var(--err); }

.form-error { color: var(--err); font-size: 13px; margin-top: 10px; min-height: 0; }

/* ---------- list ---------- */
.list-head { display: flex; align-items: baseline; justify-content: space-between; margin: 0 2px 12px; }
.list-head h2 { font-size: 15px; margin: 0; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.item { display: grid; grid-template-columns: 132px 1fr; gap: 18px; padding: 16px; margin-bottom: 12px; }
.thumb {
  width: 132px; height: 132px; border-radius: 10px; background: var(--soft); overflow: hidden;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.item-title { font-weight: 600; font-size: 16px; line-height: 1.35; margin: 0 0 4px; cursor: pointer; }
.item-title:hover { text-decoration: underline; text-decoration-color: #c4c4ca; }
.item-source { font-size: 13px; color: var(--muted); word-break: break-all; margin: 0 0 4px; }
.meta { font-size: 12.5px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.dot::before { content: "·"; margin-right: 6px; }

.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; padding: 3px 9px; border-radius: 99px; }
.badge.working { background: var(--warn-bg); color: var(--warn); }
.badge.error { background: var(--err-bg); color: var(--err); }
.badge.done { background: var(--ok-bg); color: var(--ok); }
.spinner { width: 10px; height: 10px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 99px; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.err-text { color: var(--err); font-size: 13px; margin-top: 8px; }
.post-preview {
  margin-top: 10px; font-size: 13.5px; color: #3a3a40; white-space: pre-line;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; cursor: pointer;
}
.post-preview.open { -webkit-line-clamp: unset; }

.actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.media { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.sep { width: 1px; background: var(--line); margin: 0 4px; }

.empty { text-align: center; padding: 48px 20px; color: var(--muted); }

.pager { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 20px; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 13.5px;
  opacity: 0; pointer-events: none; transition: all .18s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* video preview modal */
.modal { position: fixed; inset: 0; background: #000b; display: none; align-items: center; justify-content: center; padding: 20px; z-index: 10; }
.modal.open { display: flex; }
.modal video { max-height: 88vh; max-width: 100%; border-radius: 12px; background: #000; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login .card { width: 100%; max-width: 360px; padding: 28px; }
.login h1 { font-size: 18px; margin: 0 0 4px; }
.login p { margin: 0 0 20px; color: var(--muted); font-size: 14px; }
.login form { display: flex; flex-direction: column; gap: 10px; }

.thumb.portrait { height: 165px; }

@media (max-width: 760px) {
  .row, .row.row-3 { grid-template-columns: 1fr; }
  .thumb.portrait { height: 320px; }
  .item { grid-template-columns: 1fr; }
  .thumb { width: 100%; height: 200px; }
}
