*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f0f1a;
  --surface: #1a1a2e;
  --surface2: #232340;
  --accent: #e94560;
  --text: #eee;
  --text2: #999;
  --radius: 12px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}

/* Header */
.header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--surface2);
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px 0;
}

.header-top h1 {
  font-size: 18px;
  font-weight: 600;
}

.header-bottom {
  display: flex;
  gap: 8px;
  padding: 8px 16px 10px;
  overflow-x: auto;
}

/* Add link form */
.add-link-form {
  display: flex;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.link-input {
  flex: 1;
  min-width: 0;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--surface2);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  outline: none;
}

.link-input:focus {
  border-color: var(--accent);
}

.link-input::placeholder {
  color: var(--text2);
}

/* Header layout */
.header-top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Language picker */
.lang-picker {
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--surface2);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  outline: none;
  min-height: 36px;
}

.lang-picker:focus {
  border-color: var(--accent);
}

.login-screen .lang-picker {
  min-height: 44px;
  font-size: 15px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.2s;
  color: #fff;
  background: var(--accent);
  min-height: 44px;
}

.btn:active { opacity: 0.7; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
  min-height: 36px;
}

.btn-ghost {
  background: transparent;
  color: var(--accent);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--surface2);
  color: var(--text);
}

/* Main content */
.main {
  padding: 16px;
  padding-bottom: calc(72px + var(--safe-bottom));
  max-width: 600px;
  margin: 0 auto;
}

/* Login screen */
.login-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80dvh;
  gap: 24px;
  text-align: center;
}

.login-screen h2 {
  font-size: 24px;
  font-weight: 700;
}

.login-screen p {
  color: var(--text2);
  max-width: 300px;
  line-height: 1.5;
}

/* Video cards */
.video-card {
  background: var(--surface);
  border-radius: var(--radius);
  margin-bottom: 12px;
  overflow: hidden;
}

.video-card-header {
  display: flex;
  gap: 12px;
  padding: 12px;
}

.video-thumb {
  width: 120px;
  height: 68px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--surface2);
}

.video-info {
  flex: 1;
  min-width: 0;
}

.video-info h3 {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.video-channel {
  font-size: 12px;
  color: var(--text2);
  margin-top: 4px;
}

.video-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 8px;
  font-size: 11px;
  color: var(--text2);
  margin-top: 2px;
}

.video-meta span::before {
  content: '';
}

.video-meta span + span::before {
  content: '·  ';
}

/* Summary section */
.video-summary {
  padding: 0 12px 12px;
}

.summary-content {
  background: var(--surface2);
  border-radius: 8px;
  padding: 12px;
  font-size: 14px;
  line-height: 1.6;
}

.summary-content h4 {
  font-size: 13px;
  color: var(--accent);
  margin-bottom: 6px;
  font-weight: 600;
}

.summary-content p {
  margin-bottom: 10px;
}

.summary-content ul {
  padding-left: 18px;
  margin-bottom: 10px;
}

.summary-content li {
  margin-bottom: 4px;
  font-size: 13px;
}

.summary-content .takeaway {
  font-style: italic;
  color: var(--text2);
  font-size: 13px;
  border-top: 1px solid rgba(255,255,255,0.1);
  padding-top: 8px;
}

.summary-actions {
  padding: 0 12px 12px;
}

/* Bottom navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--surface2);
  display: flex;
  padding-bottom: var(--safe-bottom);
  z-index: 10;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 0;
  color: var(--text2);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  background: none;
  min-height: 44px;
}

.nav-item.active { color: var(--accent); }
.nav-item svg { width: 22px; height: 22px; }

/* Spinner */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--surface2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Loading state */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  gap: 12px;
  color: var(--text2);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text2);
}

.empty-state p {
  margin-bottom: 16px;
  line-height: 1.5;
}

/* Digest view */
.digest-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.digest-date {
  font-size: 14px;
  color: var(--text2);
}

.channel-group {
  margin-bottom: 20px;
}

.channel-group-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--surface2);
}

/* Live badges */
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin-top: 4px;
}

.badge-live {
  background: #e00;
  color: #fff;
}

.badge-upcoming {
  background: var(--surface2);
  color: var(--text2);
}

.badge-was-live {
  background: var(--surface2);
  color: var(--text2);
}

/* Status messages */
.status-msg {
  text-align: center;
  padding: 12px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 12px;
}

.status-msg.success { background: rgba(76, 175, 80, 0.15); color: #81c784; }
.status-msg.error { background: rgba(233, 69, 96, 0.15); color: var(--accent); }

/* Step labels & hints */
.step-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  margin-bottom: 8px;
}

.hint {
  font-size: 12px;
  color: var(--text2);
  opacity: 0.7;
  margin-top: 8px;
}

/* Feed stats */
.feed-stats {
  font-size: 13px;
  color: var(--text2);
  padding: 8px 0 12px;
  border-bottom: 1px solid var(--surface2);
  margin-bottom: 12px;
}

/* Digest explainer */
.digest-explainer {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text2);
  margin-bottom: 16px;
}

.digest-explainer strong {
  color: var(--text);
}

/* Digest stats */
.digest-stats {
  font-size: 12px;
  color: var(--text2);
}

/* Video links */
.video-link {
  color: inherit;
  text-decoration: none;
}

.video-link:hover {
  color: var(--accent);
}

/* Detailed summary (collapsible) */
.detailed-block {
  margin: 0 12px 12px;
  border: 1px solid var(--surface2);
  border-radius: 8px;
  overflow: hidden;
}

.detailed-toggle {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  list-style: none;
  background: var(--surface2);
  min-height: 44px;
}

.detailed-toggle::-webkit-details-marker { display: none; }

.detailed-toggle::before {
  content: '▶';
  font-size: 10px;
  margin-right: 8px;
  transition: transform 0.2s;
}

.detailed-block[open] .detailed-toggle::before {
  transform: rotate(90deg);
}

.detailed-content {
  padding: 12px;
  font-size: 14px;
  line-height: 1.7;
  background: var(--surface);
}

.detailed-content h4 {
  margin-top: 14px;
  margin-bottom: 6px;
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
}

.detailed-content h4:first-child {
  margin-top: 0;
}

.detailed-content p {
  margin-bottom: 8px;
}

.detailed-content ul, .detailed-content ol {
  padding-left: 18px;
  margin-bottom: 8px;
}

.detailed-content li {
  margin-bottom: 4px;
  line-height: 1.5;
}

.detailed-content strong {
  color: var(--text);
}
