:root {
  color-scheme: dark;
  --bg: #0f1620;
  --card: #182233;
  --border: #263349;
  --text: #e8edf5;
  --muted: #8fa0b8;
  --accent: #2a8ad9;
  --feed-font-scale: 1;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

#login-view {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
  text-align: center;
}

#login-view h1 { margin: 0 0 8px; font-size: 22px; }
#login-view p { color: var(--muted); margin: 0 0 16px; max-width: 320px; }

header {
  position: sticky;
  top: 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  z-index: 10;
}

header .tabs { display: flex; gap: 8px; }

header button.tab {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 15px;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
}

header button.tab.active { color: var(--text); background: var(--card); }

header .logout {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
}

main { max-width: 640px; margin: 0 auto; padding: 12px 16px 80px; }

.hidden { display: none !important; }

.post-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  margin-bottom: 10px;
}

.post-card .meta {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 6px;
}

.post-media-single .post-media-item {
  display: block;
  width: 100%;
  max-height: 420px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 8px;
  background: #000;
}

.post-media-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-bottom: 8px;
}

.post-media-grid .post-media-item {
  width: 100%;
  height: 160px;
  object-fit: cover;
  border-radius: 8px;
  background: #000;
}

.video-thumb {
  position: relative;
  overflow: hidden;
}

.post-media-single .video-thumb { height: 240px; }
.post-media-grid .video-thumb { height: 160px; }

.video-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

.video-thumb .play-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-left: 3px;
}

.post-card .text .text-link {
  color: var(--accent);
  text-decoration: underline;
}

.post-card .text {
  white-space: pre-wrap;
  font-size: calc(15px * var(--feed-font-scale));
  line-height: 1.4;
  margin-bottom: 8px;
}

.post-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.post-card a.open-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
  margin-right: auto;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
}

.icon-btn:hover { color: var(--text); }

.unread-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 4px 0 12px;
}

.unread-divider::before,
.unread-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--accent);
  opacity: 0.4;
}

#load-more {
  width: 100%;
  padding: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  cursor: pointer;
  margin-top: 8px;
}

.channel-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 8px;
}

.channel-row .remove {
  background: none;
  border: none;
  color: #e06868;
  cursor: pointer;
  font-size: 14px;
}

#add-channel-form {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

#add-channel-form input {
  flex: 1;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 15px;
}

#add-channel-form button {
  padding: 10px 16px;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: white;
  font-size: 15px;
  cursor: pointer;
}

.empty-state { color: var(--muted); text-align: center; padding: 40px 12px; }

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 14px;
}

.font-size-control {
  display: flex;
  gap: 6px;
}

.font-size-control button {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 14px;
  cursor: pointer;
}

.post-media-item.clickable { cursor: zoom-in; }

#lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

#lightbox-content {
  max-width: 92vw;
  max-height: 88vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

#lightbox-content img,
#lightbox-content video {
  max-width: 92vw;
  max-height: 88vh;
  object-fit: contain;
  border-radius: 6px;
}

.lightbox-btn {
  position: absolute;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: #fff;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-close { top: 16px; right: 16px; }
.lightbox-prev { left: 16px; top: 50%; transform: translateY(-50%); }
.lightbox-next { right: 16px; top: 50%; transform: translateY(-50%); }
