/* ── Reset & Variables ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #0f1117;
  --bg2:         #181c27;
  --bg3:         #1f2537;
  --border:      #2a3050;
  --accent:      #4f8ef7;
  --accent-dark: #3a6ed4;
  --warn:        #e85858;
  --green:       #3ecf8e;
  --text:        #e2e6f0;
  --text2:       #8892aa;
  --radius:      12px;
  --shadow:      0 4px 24px rgba(0,0,0,.45);
  --font:        'Segoe UI', system-ui, -apple-system, sans-serif;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.65;
  min-height: 100vh;
}

/* ── Layout ───────────────────────────────────────────────────── */
.app { display: flex; flex-direction: column; min-height: 100vh; }

.container {
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  padding: 24px 16px 48px;
  flex: 1;
}

/* ── Header ───────────────────────────────────────────────────── */
.site-header {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent);
}
.logo svg { width: 28px; height: 28px; }

/* ── Footer ───────────────────────────────────────────────────── */
.site-footer {
  text-align: center;
  padding: 16px;
  color: var(--text2);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
}

/* ── Cards ────────────────────────────────────────────────────── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

/* ── Input Form ───────────────────────────────────────────────── */
.input-card h2 { font-size: 1.4rem; margin-bottom: 6px; }
.subtitle { color: var(--text2); font-size: 0.9rem; margin-bottom: 22px; }

.field-group { margin-bottom: 18px; }
.field-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 7px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.hint { font-weight: 400; text-transform: none; letter-spacing: 0; }

input[type="url"],
input[type="date"] {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color .15s;
}
input[type="url"]:focus,
input[type="date"]:focus { border-color: var(--accent); }
input[type="date"] { color-scheme: dark; }

/* ── URL combobox ─────────────────────────────────────────────── */
.combobox-wrap {
  position: relative;
  display: flex;
  align-items: stretch;
}
.combobox-wrap input[type="url"] {
  border-radius: 8px 0 0 8px;
  flex: 1;
  min-width: 0;
}
.combobox-wrap input[type="url"]:focus { border-color: var(--accent); }
.combobox-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-left: none;
  border-radius: 0 8px 8px 0;
  color: var(--text2);
  cursor: pointer;
  transition: background .15s, color .15s;
  flex-shrink: 0;
}
.combobox-arrow:hover { background: var(--border); color: var(--text); }
.combobox-arrow svg { width: 10px; height: 6px; pointer-events: none; }

.combobox-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg2);
  border: 1px solid var(--accent);
  border-radius: 8px;
  list-style: none;
  margin: 0;
  padding: 4px 0;
  z-index: 100;
  box-shadow: var(--shadow);
  max-height: 260px;
  overflow-y: auto;
}
.combobox-list[hidden] { display: none; }

.combobox-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0;
}
.combobox-list li button.pick {
  flex: 1;
  text-align: left;
  background: none;
  border: none;
  color: var(--text);
  font-size: 0.88rem;
  padding: 9px 14px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background .1s;
}
.combobox-list li button.pick:hover,
.combobox-list li button.pick:focus { background: var(--bg3); outline: none; }
.combobox-list li button.pick.active { color: var(--accent); }

.combobox-list li button.del {
  background: none;
  border: none;
  color: var(--text2);
  font-size: 1rem;
  padding: 9px 12px;
  cursor: pointer;
  line-height: 1;
  transition: color .1s;
  flex-shrink: 0;
}
.combobox-list li button.del:hover { color: var(--warn); }

.btn-primary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 28px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .1s;
}
.btn-primary:hover { background: var(--accent-dark); }
.btn-primary:active { transform: scale(.97); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }

/* ── Spinner ──────────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 1s linear infinite; width: 20px; height: 20px; }

/* ── Progress ─────────────────────────────────────────────────── */
.progress-card h3 { margin-bottom: 14px; font-size: 1rem; color: var(--text2); }

.progress-track {
  width: 100%;
  height: 6px;
  background: var(--bg3);
  border-radius: 99px;
  margin-bottom: 16px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width .4s ease;
}

.progress-log {
  list-style: none;
  max-height: 240px;
  overflow-y: auto;
  font-size: 0.82rem;
  color: var(--text2);
  padding-right: 4px;
}
.progress-log li { padding: 3px 0; border-bottom: 1px solid transparent; }
.progress-log li.log-step  { color: var(--text); font-weight: 500; }
.progress-log li.log-crawl { color: var(--accent); }
.progress-log li.log-skip  { color: var(--text2); opacity: .7; }
.progress-log li.log-sum   { color: var(--green); }
.progress-log li.log-done  { color: var(--green); font-weight: 500; }
.progress-log li.log-error { color: var(--warn); }

/* ── Report ───────────────────────────────────────────────────── */
.report-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.report-header h2 { font-size: 1.4rem; }

/* ── Audio Button ─────────────────────────────────────────────── */
.btn-audio {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--bg3);
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.btn-audio:hover { background: var(--accent); color: #fff; }
.btn-audio svg { width: 18px; height: 18px; }
.btn-audio.playing { background: var(--accent); color: #fff; }

.audio-status {
  font-size: 0.82rem;
  color: var(--text2);
  margin: 6px 0 12px;
  min-height: 20px;
}

/* ── Tabs ─────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
}
.tab {
  padding: 8px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text2);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: -2px;
  transition: color .15s, border-color .15s;
  border-radius: 6px 6px 0 0;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Report Body ──────────────────────────────────────────────── */
.report-body {
  color: var(--text);
  line-height: 1.75;
  font-size: 0.95rem;
  white-space: pre-wrap;
}
.report-body p { margin-bottom: 12px; }

/* ── Articles List ────────────────────────────────────────────── */
.articles-list { display: flex; flex-direction: column; gap: 16px; }

.article-item {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
}
.article-item h4 {
  font-size: 0.95rem;
  margin-bottom: 6px;
  color: var(--text);
}
.article-item a {
  font-size: 0.78rem;
  color: var(--accent);
  text-decoration: none;
  word-break: break-all;
  display: block;
  margin-bottom: 10px;
}
.article-item a:hover { text-decoration: underline; }
.article-item p {
  font-size: 0.88rem;
  color: var(--text2);
  line-height: 1.65;
}

/* ── Error banner ─────────────────────────────────────────────── */
.error-banner {
  background: rgba(232,88,88,.12);
  border: 1px solid var(--warn);
  color: var(--warn);
  border-radius: 8px;
  padding: 14px 18px;
  font-size: 0.9rem;
  margin-bottom: 16px;
}

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 600px) {
  .card { padding: 18px; }
  .report-header { flex-direction: column; }
  .btn-audio { width: 100%; justify-content: center; }
}
