/* === Neo-BW Theme Tokens (Tools category) === */
:root {
  --bg: #0A0A0A;
  --surface: #111111;
  --surface-2: #161616;
  --text: #F5F5F5;
  --muted: #B3B3B3;
  --border: rgba(245,245,245,0.12);
  --primary: #FFFFFF;
  --primary-contrast: #0A0A0A;
  --accent: #A3FF12;
  --danger: #FF3B30;
  --success: #34C759;
  --warning: #FFCC00;

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;

  --shadow-1: 0 10px 30px rgba(0,0,0,0.45);
  --shadow-2: 0 24px 80px rgba(0,0,0,0.60);
  --ring: rgba(163,255,18,0.45);

  --font-sans: ui-sans-serif, system-ui, -apple-system, "SF Pro Text", "Apple SD Gothic Neo", "Noto Sans KR", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

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

html {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

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

/* === AppBar === */
.appbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  min-height: 72px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.appbar-title {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.3;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
}

.appbar-title .accent { color: var(--accent); }

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

.appbar-btn {
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--muted);
  cursor: pointer;
  font-size: 18px;
  transition: color 0.16s, border-color 0.16s;
}
.appbar-btn:hover { color: var(--text); border-color: var(--accent); }
.appbar-btn:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

/* === Main Content === */
.main {
  flex: 1;
  padding: 16px;
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
}

/* === Hero / CTA Area === */
.hero {
  text-align: center;
  padding: 32px 0 24px;
}

.hero-tagline {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 24px;
  line-height: 1.5;
}

.action-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: transform 0.16s, box-shadow 0.16s, opacity 0.16s;
  touch-action: manipulation;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }
.btn:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

.btn-primary {
  background: var(--accent);
  color: var(--primary-contrast);
}
.btn-primary:hover { box-shadow: 0 0 20px rgba(163,255,18,0.3); }

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--accent); }

.btn-ghost {
  background: transparent;
  color: var(--muted);
}
.btn-ghost:hover { color: var(--text); }

/* Loading spinner inside button */
.btn .spinner {
  width: 18px;
  height: 18px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* === Audio Player === */
.audio-section {
  margin: 24px 0;
  display: none;
}
.audio-section.visible { display: block; }

.audio-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.audio-card audio {
  width: 100%;
  height: 48px;
  border-radius: var(--radius-sm);
}

.audio-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* === News Items === */
.news-section {
  margin: 24px 0 48px;
  display: none;
}
.news-section.visible { display: block; }

.news-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.news-header h2 {
  font-size: 20px;
  font-weight: 700;
}

.news-date {
  font-size: 12px;
  color: var(--muted);
  font-family: var(--font-mono);
}

.news-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 12px;
  transition: border-color 0.16s;
}
.news-item:hover { border-color: var(--accent); }

.news-item-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.news-item-rank {
  min-width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: var(--primary-contrast);
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.news-item-title {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
  flex: 1;
}
.news-item-title a {
  color: var(--text);
}
.news-item-title a:hover { color: var(--accent); }

.news-item-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.news-tag {
  font-size: 11px;
  font-family: var(--font-mono);
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--muted);
  text-transform: uppercase;
}

.news-score {
  font-size: 11px;
  color: var(--accent);
  font-family: var(--font-mono);
}

.news-item-summary {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  margin-bottom: 8px;
}

.news-item-why {
  font-size: 13px;
  color: var(--warning);
  font-style: italic;
  padding: 8px 12px;
  background: rgba(255,204,0,0.06);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--warning);
}

.news-item-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.btn-copy {
  font-size: 12px;
  padding: 4px 12px;
  min-height: 32px;
  border-radius: 6px;
}

/* === Settings panel === */
.settings-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin: 16px 0;
  display: none;
}
.settings-panel.visible { display: block; }

.settings-group {
  margin-bottom: 16px;
}
.settings-group:last-child { margin-bottom: 0; }

.settings-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.source-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.source-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  transition: border-color 0.16s, background 0.16s;
  min-height: 44px;
}
.source-toggle:has(input:checked) {
  border-color: var(--accent);
  background: rgba(163,255,18,0.08);
}
.source-toggle input { accent-color: var(--accent); }

.count-input {
  width: 60px;
  min-height: 44px;
  padding: 8px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 16px;
  font-family: var(--font-mono);
  text-align: center;
}
.count-input:focus { outline: 2px solid var(--ring); outline-offset: 2px; border-color: var(--accent); }

/* === Toast === */
.toast-container {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  pointer-events: none;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 24px;
  color: var(--text);
  font-size: 14px;
  box-shadow: var(--shadow-2);
  pointer-events: auto;
  animation: toastIn 0.2s ease-out;
  max-width: 90vw;
}
.toast.error { border-color: var(--danger); color: var(--danger); }
.toast.success { border-color: var(--success); color: var(--success); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* === Voice indicator === */
.voice-indicator {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 0;
  color: var(--accent);
  font-size: 14px;
}
.voice-indicator.active { display: flex; }

.voice-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }

/* === Loading state === */
.loading-overlay {
  display: none;
  text-align: center;
  padding: 48px 16px;
}
.loading-overlay.visible { display: block; }

.loading-bar {
  width: 120px;
  height: 4px;
  background: var(--surface-2);
  border-radius: 2px;
  margin: 16px auto;
  overflow: hidden;
}
.loading-bar-inner {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  animation: loadingSlide 1.5s ease-in-out infinite;
}
@keyframes loadingSlide {
  0% { width: 0%; margin-left: 0; }
  50% { width: 60%; margin-left: 20%; }
  100% { width: 0%; margin-left: 100%; }
}

.loading-text {
  font-size: 14px;
  color: var(--muted);
  margin-top: 8px;
}

/* === Empty state === */
.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--muted);
}
.empty-state-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state-text { font-size: 14px; line-height: 1.6; }

/* === Responsive === */
@media (max-width: 480px) {
  .appbar { padding: 12px; }
  .appbar-title { font-size: 18px; }
  .main { padding: 12px; }
  .action-row { flex-direction: column; }
  .action-row .btn { width: 100%; }
}

@supports (padding: max(0px)) {
  .appbar {
    padding-top: max(12px, env(safe-area-inset-top));
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }
}

/* === Scrollbar === */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
