:root {
  --bg: #0b0b0d;
  --panel: #131317;
  --panel-2: #191920;
  --line: #26262e;
  --text: #ecebe8;
  --muted: #8d8d99;
  --accent: #f5c542;
  --accent-dim: #6d5518;
  --danger: #f0623f;
  --radius: 12px;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
  --sans: "Segoe UI", Inter, system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  min-height: 100%;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background-image:
    radial-gradient(80rem 40rem at 15% -10%, rgba(245, 197, 66, 0.06), transparent 60%),
    radial-gradient(60rem 30rem at 110% 10%, rgba(120, 120, 255, 0.05), transparent 60%);
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.035;
  z-index: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E");
}

.top, main, .foot { position: relative; z-index: 1; }

.top {
  padding: 2.2rem 1.5rem 1.1rem;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 14px rgba(245, 197, 66, 0.65);
  animation: pulse 3.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

h1 {
  margin: 0;
  font-family: var(--mono);
  font-size: 1.35rem;
  letter-spacing: -0.02em;
  font-weight: 600;
}

h1 span { color: var(--accent); }

.tagline {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
  letter-spacing: 0.02em;
  text-transform: lowercase;
}

main {
  flex: 1;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1.5rem 2rem;
}

.search {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 0.9rem;
}

.search input {
  flex: 1;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--mono);
  font-size: 1.05rem;
  padding: 0.95rem 1.1rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search input::placeholder { color: #4e4e58; }

.search input:focus {
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px rgba(245, 197, 66, 0.08);
}

button {
  font-family: var(--mono);
  font-size: 0.85rem;
  cursor: pointer;
  border-radius: var(--radius);
  border: 1px solid transparent;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

button:active { transform: translateY(1px); }

button:disabled { cursor: progress; opacity: 0.7; }

.search button {
  background: var(--accent);
  color: #17130a;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0 1.6rem;
  text-transform: uppercase;
}

.search button:hover:not(:disabled) { background: #ffd75e; }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1.2rem;
  padding: 0.75rem 1rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

.filters label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--mono);
  font-size: 0.74rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.filters input,
.filters select {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 7px;
  padding: 0.4rem 0.5rem;
  font-family: var(--mono);
  font-size: 0.8rem;
  outline: none;
}

.filters input { width: 6.5rem; }
.filters select { min-width: 6.5rem; }

.filters .toggle { cursor: pointer; user-select: none; }
.filters .toggle input[type="checkbox"] {
  width: 0.95rem;
  height: 0.95rem;
  padding: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.filters input:focus,
.filters select:focus { border-color: var(--accent-dim); }

.status-line {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
  margin: 0 0 1rem;
  min-height: 1.2em;
}

.status-line.working { color: var(--accent); }
.status-line.error { color: var(--danger); }

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

#count {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
}

.toolbar-actions { display: flex; gap: 0.5rem; }

.ghost {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 0.5rem 0.85rem;
  font-size: 0.78rem;
}

.ghost:hover:not(:disabled) {
  border-color: var(--accent-dim);
  color: var(--accent);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(216px, 1fr));
  gap: 1rem;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.card:hover {
  border-color: #3a3a46;
  transform: translateY(-2px);
}

.card-retiring {
  opacity: 0;
  transform: scale(0.92) translateY(6px);
  border-color: var(--danger);
  transition: opacity 0.45s ease, transform 0.45s ease, border-color 0.2s ease;
  pointer-events: none;
}

.thumb {
  position: relative;
  aspect-ratio: 9 / 16;
  background: #08080a;
  overflow: hidden;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.badge {
  position: absolute;
  font-family: var(--mono);
  font-size: 0.68rem;
  padding: 0.16rem 0.4rem;
  border-radius: 5px;
  background: rgba(8, 8, 10, 0.82);
  backdrop-filter: blur(4px);
  letter-spacing: 0.02em;
}

.badge.views { top: 0.45rem; left: 0.45rem; color: var(--accent); }
.badge.time { bottom: 0.45rem; right: 0.45rem; color: #e7e7ea; }

.body { padding: 0.65rem 0.7rem 0.75rem; display: flex; flex-direction: column; gap: 0.5rem; flex: 1; }

.title {
  font-size: 0.82rem;
  line-height: 1.32;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.meta {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.meta .channel { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.actions {
  margin-top: auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
}

.actions button {
  padding: 0.5rem 0.4rem;
  font-size: 0.72rem;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  letter-spacing: 0.03em;
}

.actions .copy:hover:not(:disabled) { border-color: var(--accent-dim); color: var(--accent); }

.actions .dl {
  background: rgba(245, 197, 66, 0.1);
  border-color: rgba(245, 197, 66, 0.32);
  color: var(--accent);
  font-weight: 600;
}

.actions .dl:hover:not(:disabled) { background: rgba(245, 197, 66, 0.18); }

.actions .post {
  grid-column: 1 / -1;
  background: rgba(122, 170, 255, 0.1);
  border-color: rgba(122, 170, 255, 0.32);
  color: #a8c8ff;
  font-weight: 600;
}

.actions .post:hover:not(:disabled) { background: rgba(122, 170, 255, 0.2); }

.actions .prep {
  grid-column: 1 / -1;
  background: rgba(166, 132, 255, 0.09);
  border-color: rgba(166, 132, 255, 0.28);
  color: #c3aaff;
}

.actions .prep:hover:not(:disabled) { background: rgba(166, 132, 255, 0.18); }

.publish-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.9rem;
  flex-wrap: wrap;
  padding: 0.7rem 0.9rem;
  margin-bottom: 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  font-family: var(--mono);
  font-size: 0.76rem;
  color: var(--muted);
}

.publish-bar .state-ok { color: var(--accent); }
.publish-bar .state-bad { color: var(--danger); }

.publish-bar a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px dotted var(--accent-dim);
}

.empty {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 2.5rem 1.5rem;
  text-align: center;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.7;
}

.empty strong { color: var(--text); font-weight: 600; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 2rem;
  transform: translate(-50%, 1.5rem);
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.78rem;
  padding: 0.6rem 1rem;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 30;
  max-width: min(90vw, 30rem);
  text-align: center;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { border-color: rgba(240, 98, 63, 0.5); color: #ffb4a2; }

.foot {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1rem 1.5rem 1.4rem;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  font-family: var(--mono);
  font-size: 0.7rem;
  color: #55555f;
  border-top: 1px solid #17171c;
}

@media (max-width: 620px) {
  .top { padding: 1.5rem 1rem 0.8rem; }
  main { padding: 0 1rem 1.5rem; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.7rem; }
  .actions { grid-template-columns: 1fr; }
  .foot { padding: 1rem; }
}
