:root {
  color-scheme: light;
  --bg-base: #ffffff;
  --bg-card: #f9fafb;
  --ink: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --radius: 4px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg-base: #111827;
  --bg-card: #1f2937;
  --ink: #f9fafb;
  --muted: #9ca3af;
  --border: #374151;
  --accent: #3b82f6;
  --accent-hover: #60a5fa;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: var(--bg-base);
  line-height: 1.5;
}

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 20px 40px;
}

/* Top status bar */
.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  margin-bottom: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.hero > div:first-child {
  display: none;
}

.hero-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: transparent;
  padding: 0;
  border: none;
  box-shadow: none;
}

.hero-card-header {
  display: flex;
  align-items: center;
  gap: 24px;
  margin-bottom: 0;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  font-size: 13px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f59e0b;
}

.status[data-state="open"] .status-dot {
  background: #22c55e;
}

.status[data-state="closed"] .status-dot {
  background: #ef4444;
}

.stat-grid {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.stat-grid > div {
  display: flex;
  align-items: center;
  gap: 4px;
}

.stat-grid > div:not(:last-child)::after {
  content: "·";
  margin-left: 6px;
  color: var(--border);
}

.stat-label {
  margin: 0;
}

.stat-value {
  margin: 0;
  font-weight: 600;
  color: var(--ink);
}

.theme-toggle {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: var(--radius);
  background: var(--bg-base);
  border: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--muted);
}

.theme-toggle:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.theme-icon {
  display: none;
}

[data-theme-mode="light"] .theme-icon-light,
:root:not([data-theme-mode]) .theme-icon-auto,
[data-theme-mode="auto"] .theme-icon-auto,
[data-theme-mode="dark"] .theme-icon-dark {
  display: inline;
}

/* Main layout: sidebar left, feed right */
.layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 20px;
}

.section-header {
  display: none;
}

/* Settings panel */
.settings {
  order: -1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.settings-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

textarea,
input {
  font-family: inherit;
  font-size: 13px;
  padding: 8px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-base);
  color: var(--ink);
}

textarea:focus,
input:focus {
  outline: none;
  border-color: var(--accent);
}

textarea {
  resize: none;
}

.button-row {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

button {
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius);
  padding: 8px 14px;
  cursor: pointer;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  border-color: var(--muted);
  color: var(--ink);
}

.note {
  margin-top: 12px;
  font-size: 12px;
  color: var(--muted);
}

.note p {
  margin: 0;
}

/* Feed toolbar */
.feed-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.btn-clear {
  padding: 6px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-clear:hover {
  border-color: #ef4444;
  color: #ef4444;
}

/* Tab bar */
.tab-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tab-bar:empty {
  display: none;
}

.tab-btn {
  padding: 6px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}

.tab-btn:hover {
  border-color: var(--accent);
  color: var(--ink);
}

.tab-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.tab-btn .tab-count {
  margin-left: 4px;
  opacity: 0.7;
}

/* Feed */
.feed-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.post-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: grid;
  gap: 8px;
}

.post-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.post-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  background: var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  flex-shrink: 0;
}

.post-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius);
}

.post-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.post-title strong {
  font-size: 13px;
  font-weight: 600;
}

.post-title span {
  font-size: 12px;
  color: var(--muted);
}

.post-body {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  font-size: 12px;
  color: var(--muted);
}

.post-meta a {
  color: var(--accent);
  text-decoration: none;
}

.post-meta a:hover {
  text-decoration: underline;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.tag {
  padding: 2px 6px;
  border-radius: var(--radius);
  font-size: 11px;
  background: var(--border);
  color: var(--muted);
}

/* Responsive */
@media (max-width: 768px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .settings {
    order: 0;
  }

  .hero {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
  }

  .hero-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .hero-card-header {
    width: 100%;
    justify-content: space-between;
  }

  .stat-grid {
    flex-wrap: wrap;
  }
}
