:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --ink: #1b1f2a;
  --muted: #5a6476;
  --line: #dbe1ee;
  --brand: #2251d1;
  --brand-soft: #e7eeff;
  --danger: #bc2f3f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: radial-gradient(circle at 10% 0%, #f0f5ff 0%, var(--bg) 42%);
  color: var(--ink);
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

/* ── Layout shell (wide for multi-column) ── */

.page-shell {
  max-width: 1800px;
  margin: 0 auto;
  padding: 12px 20px 32px;
}

/* ── Topbar: compact, inline title + subtitle ── */

.topbar {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 16px;
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.topbar h1 {
  margin: 0;
  font-size: 1.05rem;
  white-space: nowrap;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

/* ── Tabs: compact ── */

.tabs {
  margin-top: 8px;
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.tabs a {
  text-decoration: none;
  color: var(--muted);
  background: #eef2fb;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 0.82rem;
}

.tabs a.active {
  color: var(--brand);
  background: var(--brand-soft);
  border-color: #c9d8ff;
}

/* ── Content area ── */

.content {
  margin-top: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  min-height: 300px;
}

/* ── Shared form / toolbar ── */

.toolbar,
.form-grid,
.inline-controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.form-grid {
  margin-bottom: 14px;
}

label {
  display: grid;
  gap: 4px;
  font-size: 0.85rem;
  color: var(--muted);
}

input,
select,
button {
  font: inherit;
}

input,
select {
  min-width: 150px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  background: #fff;
}

button {
  border: 1px solid #c8d3ed;
  background: #f6f9ff;
  color: #1f335f;
  border-radius: 9px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 0.85rem;
}

button.primary {
  border-color: #244fcc;
  background: #2a5fe9;
  color: #fff;
}

button.danger {
  border-color: #dba4aa;
  color: var(--danger);
  background: #fff2f3;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-sm {
  padding: 4px 8px;
  font-size: 0.8rem;
}

/* ── Status bar ── */

#status-bar {
  margin-top: 6px;
}

#status-bar:empty {
  display: none;
}

.meta {
  color: var(--muted);
  font-size: 0.85rem;
}

.message {
  margin-top: 6px;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 0.85rem;
}

.message.info {
  background: #eef3ff;
  color: #26408d;
  border: 1px solid #cfdbfd;
}

.message.error {
  background: #fff0f1;
  color: #842533;
  border: 1px solid #f1b7bf;
}

/* ── Generic list / card ── */

.list {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.card {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #fff;
}

.card h3 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.empty {
  padding: 14px;
  border: 1px dashed #ccd7ef;
  border-radius: 10px;
  color: var(--muted);
  background: #fafcff;
}

/* ── Feed toolbar: all controls in one line ── */

.feed-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.feed-count {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}

.feed-filter-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.feed-filter-inline label {
  display: flex !important;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  white-space: nowrap;
}

.feed-filter-inline input {
  min-width: 50px !important;
  width: 65px;
  padding: 3px 6px;
  font-size: 0.8rem;
}

/* ── Feed list: multi-column ── */

.feed-list {
  column-count: 1;
  column-gap: 16px;
}

/* ── Feed row: compact single-line ── */

.feed-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  border-bottom: 1px solid #f0f3f8;
  font-size: 0.82rem;
  line-height: 1.4;
  break-inside: avoid;
}

.feed-row:hover {
  background: #f6f9ff;
}

.gallery-tag {
  display: inline-block;
  min-width: 40px;
  max-width: 40px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 2px 4px;
  border-radius: 4px;
  color: #fff;
  flex-shrink: 0;
}

.feed-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.84rem;
}

.feed-title:visited {
  color: #94a3b8;
}

.feed-title:hover {
  color: var(--brand);
  text-decoration: underline;
}

.feed-rec {
  flex-shrink: 0;
  font-weight: 700;
  color: #dc2626;
  font-size: 0.82rem;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  min-width: 48px;
}

.feed-meta-item {
  flex-shrink: 0;
  color: var(--muted);
  font-size: 0.75rem;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  min-width: 40px;
}

.feed-time {
  flex-shrink: 0;
  color: #94a3b8;
  font-size: 0.72rem;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  min-width: 72px;
}

/* ── Guide section ── */

.guide-section h2 {
  font-size: 1.1rem;
  margin: 0 0 12px;
  color: var(--ink);
}

.guide-section h3 {
  font-size: 1rem;
  margin: 16px 0 6px;
  color: var(--ink);
}

.guide-section p,
.guide-section li {
  font-size: 0.92rem;
  color: var(--muted);
  line-height: 1.6;
  margin: 4px 0;
}

.guide-section ul {
  padding-left: 20px;
  margin: 6px 0;
}

/* ── Responsive ── */

@media (min-width: 1000px) {
  .feed-list {
    column-count: 2;
  }
}

@media (min-width: 1400px) {
  .feed-list {
    column-count: 3;
  }
}

@media (max-width: 640px) {
  .page-shell {
    padding: 8px 10px 24px;
  }

  .topbar {
    flex-direction: column;
    gap: 4px;
  }

  .content {
    padding: 8px;
  }

  input,
  select {
    min-width: 100%;
  }

  .feed-toolbar {
    gap: 6px;
  }

  .feed-row {
    font-size: 0.78rem;
    gap: 4px;
  }

  .gallery-tag {
    min-width: 36px;
    max-width: 36px;
    font-size: 0.6rem;
  }
}

/* ── Scrap star button ── */

.scrap-star {
  background: none;
  border: none;
  color: #d1d5db;
  font-size: 1rem;
  cursor: pointer;
  padding: 0 2px;
  flex-shrink: 0;
  line-height: 1;
}

.scrap-star:hover {
  color: #fbbf24;
}

.scrap-star.scrapped {
  color: #f59e0b;
}

/* ── Gallery name input ── */

.gallery-name-input {
  min-width: 120px;
  width: 180px;
  font-size: 0.9rem;
}
