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

:root {
  --bg: #111;
  --bg-card: #1a1a1a;
  --bg-card-hover: #222;
  --bg-modal: #1e1e1e;
  --text: #e0e0e0;
  --text-dim: #888;
  --accent: #4a9eff;
  --accent-hover: #6ab4ff;
  --border: #333;
  --danger: #e05555;
  --success: #4caf50;
  --radius: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* --- Header --- */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

header h1 {
  font-size: 18px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

header h1 .sep { color: var(--text-dim); }

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.status-dot.online { background: var(--success); box-shadow: 0 0 6px var(--success); }
.status-dot.offline { background: var(--text-dim); }
.status-dot.running { background: var(--accent); box-shadow: 0 0 6px var(--accent); animation: pulse 1.5s infinite; }

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

.icon-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 6px;
  border-radius: 4px;
  font-size: 20px;
  line-height: 1;
}
.icon-btn:hover { color: var(--text); background: var(--bg-card); }

/* --- Search --- */
.search-area {
  padding: 16px 24px;
}

#search-form {
  display: flex;
  gap: 8px;
  max-width: 600px;
}

#search-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text);
  font-size: 14px;
  outline: none;
}
#search-input:focus { border-color: var(--accent); }

#search-form button {
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}
#search-form button:hover { background: var(--accent-hover); }

/* --- Main --- */
main {
  padding: 0 24px 48px;
}

section { margin-top: 24px; }

section h2 {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 12px;
}

.topic-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.empty-msg {
  color: var(--text-dim);
  font-size: 14px;
  padding: 12px 0;
}

/* --- Topic Card --- */
.topic-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.topic-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  cursor: pointer;
  user-select: none;
}
.topic-header:hover { background: var(--bg-card-hover); }

.topic-title {
  font-size: 16px;
  font-weight: 600;
}

.topic-meta {
  font-size: 12px;
  color: var(--text-dim);
}

.topic-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.delete-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14px;
  padding: 4px 8px;
  border-radius: 4px;
}
.delete-btn:hover { color: var(--danger); background: rgba(224, 85, 85, 0.1); }

.chevron {
  color: var(--text-dim);
  transition: transform 0.2s;
  font-size: 12px;
}
.topic-card.expanded .chevron { transform: rotate(90deg); }

.topic-body {
  display: none;
  padding: 0 16px 16px;
  border-top: 1px solid var(--border);
}
.topic-card.expanded .topic-body { display: block; }

/* --- Progress Bar --- */
.progress-bar {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 8px;
}
.progress-bar .fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.3s;
  border-radius: 2px;
}
.progress-text {
  font-size: 12px;
  color: var(--accent);
  margin-bottom: 8px;
}

/* --- Story --- */
.story {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.story:last-child { border-bottom: none; }

.story h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
}

.story h3 a {
  color: var(--accent);
  text-decoration: none;
}
.story h3 a:hover { text-decoration: underline; }

.story-source {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.story-summary {
  font-size: 14px;
  margin-bottom: 8px;
}

.story-media {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.story-media img {
  max-width: 300px;
  max-height: 200px;
  border-radius: 4px;
  object-fit: cover;
}

.meta-questions {
  margin-top: 8px;
  padding: 10px 14px;
  background: rgba(74, 158, 255, 0.06);
  border-left: 3px solid var(--accent);
  border-radius: 0 4px 4px 0;
}

.meta-questions h4 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  margin-bottom: 6px;
}

.meta-questions ul {
  list-style: none;
  font-size: 13px;
  color: var(--text-dim);
}
.meta-questions li { padding: 2px 0; }
.meta-questions li::before { content: "? "; color: var(--accent); }

/* --- Overall Analysis --- */
.overall-analysis {
  padding: 14px;
  background: var(--bg);
  border-radius: var(--radius);
  margin-bottom: 12px;
  font-size: 14px;
  line-height: 1.6;
}

.key-questions {
  padding: 14px;
  background: rgba(74, 158, 255, 0.08);
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.key-questions h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 8px;
}

.key-questions ol {
  padding-left: 20px;
  font-size: 14px;
}

.key-questions li { padding: 3px 0; }

/* --- Sources --- */
.sources {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.sources h4 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.sources a {
  display: inline-block;
  font-size: 13px;
  color: var(--accent);
  text-decoration: none;
  margin-right: 16px;
  margin-bottom: 4px;
}
.sources a:hover { text-decoration: underline; }

/* --- Update timestamp --- */
.update-time {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 12px;
  padding-top: 8px;
}

/* --- Modal --- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal.hidden { display: none; }

.modal-content {
  background: var(--bg-modal);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 420px;
  max-width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 { font-size: 16px; }

.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-body label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-dim);
}

.modal-body select,
.modal-body input[type="datetime-local"] {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-card);
  color: var(--text);
  font-size: 14px;
}

.text-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: 12px;
  text-align: left;
  padding: 0;
}
.text-btn:hover { text-decoration: underline; }

.modal-actions {
  display: flex;
  gap: 8px;
  padding-top: 4px;
}

.primary-btn {
  padding: 8px 20px;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  cursor: pointer;
}
.primary-btn:hover { background: var(--accent-hover); }

.secondary-btn {
  padding: 8px 20px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: none;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
}
.secondary-btn:hover { background: var(--bg-card); }

.status-info {
  padding: 12px 20px;
  font-size: 12px;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
}

/* --- Responsive --- */
@media (max-width: 600px) {
  header { padding: 12px 16px; }
  .search-area { padding: 12px 16px; }
  main { padding: 0 16px 32px; }
  .story-media img { max-width: 100%; }
}
