/* =========================================================
   Keyword Radar — dark editorial / research terminal
   ========================================================= */

:root {
  --bg: #0b0d10;
  --bg-elev: #12161b;
  --bg-elev-2: #181d24;
  --line: #232a33;
  --line-soft: #1a2027;

  --ink: #ece8df;
  --ink-mute: #8d9099;
  --ink-faint: #5a5f68;

  --accent: #b8ff5e;          /* phosphor green */
  --accent-soft: rgba(184, 255, 94, 0.12);
  --gold: #f0c060;
  --coral: #ff7a6b;
  --blue: #6db8ff;

  --serif: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  --sans: 'Geist', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: 'Geist Mono', 'JetBrains Mono', ui-monospace, monospace;

  --radius: 4px;
  --shadow-sm: 0 1px 0 rgba(255, 255, 255, 0.02) inset;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Subtle grain texture overlay for atmosphere */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  background-image:
    radial-gradient(circle at 20% 10%, rgba(184, 255, 94, 0.03), transparent 50%),
    radial-gradient(circle at 80% 90%, rgba(109, 184, 255, 0.025), transparent 50%);
}

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px dotted rgba(184, 255, 94, 0.4);
  transition: opacity 0.2s ease;
}
a:hover { opacity: 0.7; }

/* ======== Top bar ======== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 32px;
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 2;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.02em;
}

.brand__mark {
  color: var(--accent);
  font-size: 14px;
  animation: pulse 2.5s ease-in-out infinite;
}

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

.brand__name {
  font-family: var(--serif);
  font-style: italic;
  font-size: 18px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.brand__sub {
  color: var(--ink-faint);
  font-size: 12px;
}

.topbar__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-mute);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink-faint);
  display: inline-block;
}
.status-dot[data-state="ok"] { background: var(--accent); box-shadow: 0 0 8px var(--accent-soft); }
.status-dot[data-state="error"] { background: var(--coral); }

/* ======== Layout ======== */
.layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  min-height: calc(100vh - 116px);
  position: relative;
  z-index: 2;
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
}

/* ======== Controls (left) ======== */
.controls {
  border-right: 1px solid var(--line);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.005));
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  background: var(--bg-elev);
  box-shadow: var(--shadow-sm);
}

.card__title {
  margin: 0 0 6px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--accent);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.card__desc {
  margin: 0 0 14px;
  color: var(--ink-mute);
  font-size: 12.5px;
  line-height: 1.55;
}

.field {
  display: block;
  margin-bottom: 0;
}
.field__label {
  display: block;
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-faint);
  margin-bottom: 6px;
}

.field input[type="text"],
.field input[type="password"],
.field input[type="number"] {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s ease;
}

.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 12.5px;
  color: var(--ink-mute);
  cursor: pointer;
  user-select: none;
}
.checkbox input { accent-color: var(--accent); }

.radio-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.radio {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s ease;
  background: var(--bg);
}
.radio:hover { border-color: var(--line); background: var(--bg-elev-2); }
.radio:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.radio input { accent-color: var(--accent); }
.radio__title {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
}
.radio__hint {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-faint);
  text-align: right;
  letter-spacing: 0.02em;
}

.slider-row {
  display: grid;
  grid-template-columns: 1fr 40px;
  align-items: center;
  gap: 12px;
}
.slider-row input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--line);
  border-radius: 2px;
  outline: none;
}
.slider-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
}
.slider-row input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: var(--accent);
  border: none;
  border-radius: 50%;
  cursor: pointer;
}

.slider-value {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--accent);
  text-align: right;
}

/* ======== Workspace (right) ======== */
.workspace {
  padding: 40px 48px 48px;
  min-width: 0; /* allow table overflow handling */
}

@media (max-width: 600px) {
  .workspace { padding: 28px 20px; }
}

.search-block {
  margin-bottom: 36px;
}

.hero {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(36px, 5vw, 56px);
  line-height: 1.0;
  letter-spacing: -0.025em;
  margin: 0 0 28px;
  color: var(--ink);
}

.hero__line {
  display: block;
}
.hero em {
  font-style: italic;
  color: var(--accent);
  font-weight: 300;
}
.hero__line--mono {
  font-family: var(--mono);
  font-size: 0.45em;
  font-weight: 400;
  color: var(--ink-mute);
  text-transform: lowercase;
  letter-spacing: 0.02em;
  margin-top: 14px;
}

.search {
  display: grid;
  grid-template-columns: 1fr auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-elev);
  overflow: hidden;
  transition: border-color 0.15s ease;
}
.search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search__input {
  border: none;
  background: transparent;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  padding: 16px 20px;
  outline: none;
}
.search__input::placeholder {
  color: var(--ink-faint);
  font-style: italic;
}

.search__btn {
  display: flex;
  align-items: center;
  gap: 10px;
  border: none;
  border-left: 1px solid var(--line);
  background: var(--bg-elev-2);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 0 24px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.search__btn:hover { background: var(--accent); color: var(--bg); }
.search__btn:disabled { opacity: 0.5; cursor: not-allowed; }
.search__btn:disabled:hover { background: var(--bg-elev-2); color: var(--accent); }

.search__btnArrow {
  transition: transform 0.15s ease;
  font-size: 16px;
}
.search__btn:hover .search__btnArrow { transform: translateX(3px); }

.search__hint {
  margin-top: 12px;
  font-size: 12px;
  color: var(--ink-faint);
  font-style: italic;
}

/* ======== Loading ======== */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 48px 0;
}

.loading__spinner {
  width: 28px;
  height: 28px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading__text {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-mute);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.loading__progress {
  width: 240px;
  height: 2px;
  background: var(--line);
  border-radius: 1px;
  overflow: hidden;
}
.loading__bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.3s ease;
}

/* ======== Alert ======== */
.alert {
  display: flex;
  gap: 12px;
  padding: 14px 18px;
  border: 1px solid var(--coral);
  border-radius: var(--radius);
  background: rgba(255, 122, 107, 0.08);
  margin-bottom: 24px;
}
.alert__label {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--coral);
  flex-shrink: 0;
}
.alert__msg {
  color: var(--ink);
  font-size: 13.5px;
}

/* ======== Results ======== */
.results__header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.results__stats {
  display: flex;
  gap: 32px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stat__num {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.02em;
}
.stat__label {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-faint);
}

.btn-ghost {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 12px;
  padding: 8px 14px;
  cursor: pointer;
  border-radius: var(--radius);
  transition: all 0.15s ease;
}
.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Table */
.table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: auto;
  background: var(--bg-elev);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table thead {
  background: var(--bg-elev-2);
  border-bottom: 1px solid var(--line);
}

.table th {
  text-align: left;
  padding: 12px 16px;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-faint);
}

.table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}

.table tbody tr {
  transition: background 0.1s ease;
}
.table tbody tr:hover { background: var(--bg-elev-2); }
.table tbody tr:last-child td { border-bottom: none; }

.col-rank {
  width: 50px;
  font-family: var(--mono);
  color: var(--ink-faint);
  font-size: 11px;
}
.col-kw { min-width: 200px; }
.col-num {
  width: 90px;
  text-align: right;
  font-family: var(--mono);
}
.col-score {
  width: 200px;
  text-align: right;
}

.kw-text {
  color: var(--ink);
  font-size: 14px;
}

.trend-up { color: var(--accent); }
.trend-flat { color: var(--ink-mute); }
.trend-down { color: var(--coral); }

/* Score bar */
.score {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: flex-end;
}
.score__bar {
  flex: 1;
  height: 6px;
  background: var(--line);
  border-radius: 3px;
  overflow: hidden;
  max-width: 100px;
}
.score__fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}
.score__num {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 500;
  width: 28px;
  text-align: right;
}
.score__label {
  font-family: var(--mono);
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  width: 76px;
  text-align: right;
}

.label-EXCELLENT { color: var(--accent); }
.label-GOOD { color: var(--accent); opacity: 0.85; }
.label-MODERATE { color: var(--gold); }
.label-WEAK { color: var(--ink-mute); }
.label-POOR { color: var(--ink-faint); }

.fill-EXCELLENT { background: var(--accent); }
.fill-GOOD { background: var(--accent); opacity: 0.7; }
.fill-MODERATE { background: var(--gold); }
.fill-WEAK { background: var(--ink-mute); }
.fill-POOR { background: var(--ink-faint); }

.results__empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--ink-mute);
  font-size: 13.5px;
  font-style: italic;
}

/* ======== Footer ======== */
.footer {
  padding: 20px 32px;
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
  text-align: center;
  position: relative;
  z-index: 2;
}

/* Selection */
::selection {
  background: var(--accent);
  color: var(--bg);
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-faint); }
