/*
 * App shell: layout, topbar, sidebar, and shared UI components.
 * Loaded alongside application.css (tokens/reset) and landing.css.
 * Scoped under body.app-layout so landing page font-size is unaffected.
 */

body.app-layout {
  font-size: 14px;
}

/* ─── SHELL LAYOUT ──────────────────────────────────────────────────────────── */

.app {
  display: grid;
  grid-template-columns: 220px 1fr;
  grid-template-rows: 56px 1fr;
  min-height: 100vh;
}

/* ─── TOPBAR ─────────────────────────────────────────────────────────────────── */

.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
  z-index: 10;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.02em;
  color: var(--t1);
  text-decoration: none;
}

.logo:hover {
  text-decoration: none;
}

.logo-icon {
  width: 28px;
  height: 28px;
  background: var(--accent);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.logo-icon svg {
  width: 16px;
  height: 16px;
}

.logo-wordmark {
  display: inline-flex;
  align-items: baseline;
  white-space: nowrap;
}

.logo-suffix {
  color: var(--t2);
  font-weight: 400;
  margin-left: 2px;
  font-size: 13px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.plan-pill {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--accent-s);
  color: var(--accent);
  font-weight: 500;
}

/* Fixed "Feedback" tab pinned to the right edge of the viewport. */
.feedback-tab {
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 900;
  writing-mode: vertical-rl;
  rotate: 180deg;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: #fff;
  background: var(--accent);
  border: 0;
  padding: 14px 7px;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
}

.feedback-tab:hover {
  filter: brightness(1.08);
}

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}

/* ─── SIDEBAR ────────────────────────────────────────────────────────────────── */

.sidebar {
  grid-row: 2;
  border-right: 1px solid var(--border);
  background: var(--card);
  padding: 20px 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.nav-section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--t3);
  padding: 8px 28px 6px;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  margin: 0 8px;
  border-radius: 8px;
  font-size: 13px;
  color: var(--t2);
  transition: all 0.15s;
  position: relative;
  text-decoration: none;
}

.nav-item:hover {
  background: var(--surface);
  color: var(--t1);
  text-decoration: none;
}

.nav-item.active {
  background: var(--accent-s);
  color: var(--accent);
  font-weight: 500;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 18px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}

.nav-icon {
  width: 18px;
  height: 18px;
  opacity: 0.5;
  flex-shrink: 0;
}

.nav-item.active .nav-icon {
  opacity: 1;
}

.nav-badge {
  margin-left: auto;
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 10px;
  background: var(--surface);
  color: var(--t3);
  font-weight: 500;
  font-family: var(--mono);
}

.nav-badge.live {
  background: var(--red-s);
  color: var(--red);
}

.sidebar-footer {
  margin-top: auto;
  padding: 16px;
  border-top: 1px solid var(--border);
}

.sidebar-footer-text {
  font-size: 11px;
  color: var(--t3);
  line-height: 1.7;
}

.sidebar-footer-text strong {
  color: var(--t2);
}

/* ─── MAIN CONTENT ───────────────────────────────────────────────────────────── */

.main {
  grid-row: 2;
  padding: 24px 28px;
  overflow-y: auto;
  background: var(--bg);
}

.screen-header {
  margin-bottom: 24px;
}

.screen-header h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 4px;
}

.screen-header p {
  font-size: 13px;
  color: var(--t2);
}

/* ─── ANIMATION ──────────────────────────────────────────────────────────────── */

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.fade-up {
  animation: fadeUp 0.3s ease;
}

/* ─── CARD ───────────────────────────────────────────────────────────────────── */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--rl);
  padding: 20px;
  transition: border-color 0.2s;
}

.card-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--t2);
}

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

.card-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--t2);
  letter-spacing: -0.01em;
  margin: 0 0 var(--space-3);
}

.card-table {
  padding-bottom: 0;
}

.card-table .table-wrap {
  margin: var(--space-4) -20px 0;
  border-top: 1px solid var(--border);
}

/* ─── KPI ────────────────────────────────────────────────────────────────────── */

.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-label {
  font-size: 12px;
  color: var(--t2);
  font-weight: 500;
  margin-bottom: 10px;
}

.kpi-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.03em;
  font-family: var(--mono);
}

.kpi-delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  margin-top: 8px;
}

.kpi-delta.up   { background: var(--green-s); color: var(--green); }
.kpi-delta.down { background: var(--red-s);   color: var(--red);   }

/* ─── PROFILE BANNER ─────────────────────────────────────────────────────────── */

.profile-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: var(--input);
  border-radius: 10px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
}

.profile-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.profile-name {
  font-size: 12px;
  font-weight: 600;
}

.profile-note {
  font-size: 9px;
  color: var(--t3);
  font-weight: 400;
  margin-left: 6px;
}

.profile-stats {
  display: flex;
  gap: 16px;
  margin-top: 3px;
}

.profile-stats span  { font-size: 11px; color: var(--t2); }
.profile-stats strong { color: var(--t4); font-family: var(--mono); }

/* ─── GRIDS / LAYOUT HELPERS ─────────────────────────────────────────────────── */

.grid-2   { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.grid-4   { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
}

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

.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.mb-24 { margin-bottom: 24px; }

.chart-container {
  position: relative;
  height: 200px;
  margin-top: var(--space-2);
}

.chart-container canvas {
  width: 100% !important;
  height: 100% !important;
}

/* ─── DATA TABLE (in-card) ───────────────────────────────────────────────────── */

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

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

.data-table thead {
  background: var(--surface);
}

.data-table th {
  padding: 10px 16px;
  text-align: left;
  font-weight: 500;
  color: var(--t3);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

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

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover td {
  background: var(--card-hover);
}

.data-table .col-num,
.data-table th.col-num,
.data-table td.col-num {
  text-align: right;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--t4);
}

.data-table th.col-action,
.data-table td.col-action {
  text-align: right;
  width: 88px;
}

.kw-term {
  font-weight: 500;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.intent-tag {
  display: inline-flex;
  padding: 3px 9px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  background: var(--surface);
  color: var(--t2);
  border: 1px solid var(--border);
  text-transform: capitalize;
  white-space: nowrap;
}

.data-table td.col-num .diff-inline {
  justify-content: flex-end;
}

.data-table td.col-num .opp-score {
  display: block;
}

.opp-score {
  display: inline-block;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  min-width: 2ch;
  text-align: right;
}

/* ─── FILTER BAR ─────────────────────────────────────────────────────────────── */

.filter-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.fbtn {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--t2);
  font-size: 12px;
  cursor: pointer;
  font-family: var(--font);
  transition: all 0.15s;
  font-weight: 500;
}

.fbtn:hover           { border-color: var(--border-h); color: var(--t1); }
.fbtn.active          { background: var(--accent-s); border-color: var(--accent); color: var(--accent); }
.fbtn.yt.active       { background: var(--yt-s); border-color: var(--yt); color: var(--yt); }
.fbtn.tt.active       { background: var(--tt-s); border-color: var(--tt); color: var(--tt); }

/* ─── SEARCH / SERP INPUTS ───────────────────────────────────────────────────── */

.search-wrap {
  position: relative;
}

.search-wrap svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--t3);
  pointer-events: none;
}

.search-input {
  padding: 7px 14px 7px 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--input);
  color: var(--t1);
  font-size: 13px;
  font-family: var(--font);
  width: 220px;
  outline: none;
}

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

.serp-search-row {
  display: flex;
  align-items: stretch;
  gap: 12px;
}

.kw-seed-form .serp-search-row,
.serp-search-form .serp-search-row {
  flex-wrap: wrap;
}

@media (min-width: 640px) {
  .kw-seed-form .serp-search-row,
  .serp-search-form .serp-search-row {
    flex-wrap: nowrap;
  }
}

/* Shared text inputs + buttons (app screens) */
.text-input,
.serp-search-input,
.serp-input {
  flex: 1;
  min-width: 0;
  padding: 12px 18px;
  border-radius: var(--r);
  border: 1px solid var(--border);
  background: var(--input);
  color: var(--t1);
  font-size: 15px;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.15s;
}

.text-input::placeholder,
.serp-search-input::placeholder,
.serp-input::placeholder {
  color: var(--t3);
}

.text-input:focus,
.serp-search-input:focus,
.serp-input:focus {
  border-color: var(--accent);
}

.btn,
.serp-btn {
  padding: 12px 24px;
  border-radius: var(--r);
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  white-space: nowrap;
  transition: opacity 0.15s;
}

.btn:hover,
.serp-btn:hover {
  opacity: 0.88;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn:disabled,
.serp-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Inline action forms (e.g. table row Track buttons) */
td form {
  display: inline;
  margin: 0;
}

.platform-pills {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.platform-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--t2);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.platform-pill input[type="radio"] { display: none; }

.platform-pill:hover               { border-color: var(--border-h); color: var(--t1); }
.platform-pill.yt.active           { background: var(--yt-s); border-color: var(--yt); color: var(--yt); }
.platform-pill.tt.active           { background: var(--tt-s); border-color: var(--tt); color: var(--tt); }

.serp-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 64px 24px;
  text-align: center;
  color: var(--t3);
}

.serp-empty svg  { opacity: 0.3; }
.serp-empty p    { font-size: 15px; font-weight: 500; color: var(--t2); }
.serp-empty span { font-size: 13px; max-width: 400px; line-height: 1.6; }

/* Quota-paused: recoverable state, distinct from a hard error */
.serp-paused {
  border: 1px solid color-mix(in srgb, #e0a800 35%, transparent);
  border-radius: 12px;
  background: color-mix(in srgb, #e0a800 6%, transparent);
}
.serp-paused p { color: #e0a800; }

/* ─── TABLE ──────────────────────────────────────────────────────────────────── */

.tw {
  overflow-x: auto;
  border-radius: var(--rl);
  border: 1px solid var(--border);
  background: var(--card);
}

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

thead { background: var(--surface); }

th {
  padding: 10px 16px;
  text-align: left;
  font-weight: 500;
  color: var(--t3);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

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

tr:last-child td { border-bottom: none; }
tr:hover td      { background: var(--card-hover); }

/* ─── PLATFORM TAG ───────────────────────────────────────────────────────────── */

.ptag {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
}

.ptag.yt { background: var(--yt-s); color: var(--yt); }
.ptag.tt { background: var(--tt-s); color: var(--tt); }

/* ─── DIFFICULTY SCORE ───────────────────────────────────────────────────────── */

.diff-ring {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 2px 6px 2px 2px;
  border-radius: 8px;
}

.diff-ring:hover { background: rgba(99, 102, 241, 0.08); }

.diff-ring-num {
  position: absolute;
  top: 50%;
  left: 16px;
  transform: translate(-50%, -50%);
  font-size: 9px;
  font-weight: 700;
  font-family: var(--mono);
}

.diff-ring-label { font-size: 11px; font-weight: 600; line-height: 1.2; }
.diff-ring-sub   { font-size: 9px; color: var(--t3); }

/* ─── DIFFICULTY INLINE ──────────────────────────────────────────────────────── */

.diff-inline { display: flex; align-items: center; gap: 5px; }

.diff-bar,
.diff-bar-track {
  width: 28px;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  overflow: hidden;
  flex-shrink: 0;
}

.diff-bar-fill {
  height: 100%;
  border-radius: 2px;
}

.diff-num {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  min-width: 20px;
}

/* ─── POSITION / RANK ────────────────────────────────────────────────────────── */

.pos        { font-family: var(--mono); font-weight: 700; font-size: 14px; }
.pos-change { font-size: 11px; font-weight: 700; font-family: var(--mono); margin-left: 6px; }
.pos-change.up   { color: var(--green); }
.pos-change.down { color: var(--red); }
.pos-change.new  { color: var(--accent); }

/* ─── VOLUME BAR ─────────────────────────────────────────────────────────────── */

.vol-wrap { display: flex; align-items: center; gap: 8px; }
.vol-bar  { height: 4px; border-radius: 2px; background: var(--accent); opacity: 0.7; }
.vol-num  { font-family: var(--mono); font-size: 12px; color: var(--t2); }

/* ─── SPARKLINE ──────────────────────────────────────────────────────────────── */

.sparkline { display: block; }

/* ─── CONTENT THUMB ──────────────────────────────────────────────────────────── */

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

.thumb-box {
  width: 40px;
  height: 28px;
  border-radius: 4px;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.thumb-text {
  font-size: 12px;
  color: var(--t2);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── VELOCITY BADGE ─────────────────────────────────────────────────────────── */

.vel {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--mono);
  padding: 3px 9px;
  border-radius: 12px;
  white-space: nowrap;
}

.vel.hot     { background: var(--red-s);   color: var(--red);   }
.vel.rising  { background: var(--amber-s); color: var(--amber); }
.vel.steady  { background: var(--green-s); color: var(--green); }
.vel.new     { background: var(--accent-s); color: var(--accent); }

/* ─── TRACK BUTTON ───────────────────────────────────────────────────────────── */

.track-btn {
  padding: 5px 14px;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  font-size: 11px;
  cursor: pointer;
  font-family: var(--font);
  font-weight: 600;
  transition: all 0.15s;
}

.track-btn:hover        { background: var(--accent-s); }
.track-btn.tracked      { background: var(--accent-s); }

.serp-track-row {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 16px;
}
.serp-track-row .track-btn {
  padding: 7px 16px;
  font-size: 12px;
}

/* ─── TOGGLE ─────────────────────────────────────────────────────────────────── */

.toggle {
  width: 36px;
  height: 20px;
  border-radius: 10px;
  position: relative;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.toggle.on  { background: var(--green); border: 1px solid var(--green); }
.toggle.off { background: var(--surface); border: 1px solid var(--border); }

.toggle::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  top: 2px;
  transition: left 0.2s;
}

.toggle.on::after  { left: 18px; }
.toggle.off::after { left: 2px; }

/* ─── DIFF BREAKDOWN PANEL ───────────────────────────────────────────────────── */

.diff-panel {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--rl);
  background: var(--card);
  overflow: hidden;
  margin-bottom: 24px;
}

.diff-panel-left {
  width: 280px;
  border-right: 1px solid var(--border);
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.diff-panel-right { flex: 1; padding: 20px; }

.factor-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.serp-factor-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }

.factor-card {
  padding: 10px;
  background: var(--input);
  border-radius: 8px;
  border: 1px solid var(--border);
}

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

.factor-label  { font-size: 11px; font-weight: 600; display: flex; align-items: center; gap: 4px; }
.factor-score  { font-family: var(--mono); font-size: 11px; font-weight: 700; }

.factor-bar {
  height: 3px;
  border-radius: 2px;
  background: var(--border);
  margin-bottom: 6px;
  overflow: hidden;
}

.factor-bar-fill { height: 100%; border-radius: 2px; }
.factor-detail   { font-size: 10px; color: var(--t3); line-height: 1.4; }
.factor-verdict  { font-weight: 500; margin-top: 2px; }

/* ─── SERP RESULTS ───────────────────────────────────────────────────────────── */

.serp-result {
  display: flex;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}

.serp-result:hover        { background: var(--card-hover); }
.serp-result:last-child   { border-bottom: none; }

.serp-pos {
  min-width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 14px;
}

.serp-pos.top { background: var(--accent-s); color: var(--accent); }
.serp-pos.mid { background: var(--surface);  color: var(--t2);     }

.serp-body   { flex: 1; min-width: 0; }
.serp-title  { font-weight: 500; font-size: 14px; margin-bottom: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.serp-channel { font-size: 12px; color: var(--t2); margin-bottom: 5px; }
.serp-meta   { display: flex; gap: 16px; font-size: 12px; color: var(--t3); }
.serp-meta span { display: flex; align-items: center; gap: 4px; }

/* ─── KEYWORD CHIPS ──────────────────────────────────────────────────────────── */

.kw-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.kw-chip {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--card);
  font-size: 12px;
  color: var(--t2);
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font);
  display: inline-block;
}

.kw-chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-s); }

/* ─── TRENDING / MOVERS ──────────────────────────────────────────────────────── */

.trend-list { list-style: none; }

.trend-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  border-top: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}

.trend-item:hover { background: var(--card-hover); }

.trend-rank     { font-family: var(--mono); font-size: 12px; font-weight: 600; min-width: 22px; color: var(--t3); }
.trend-rank.top { color: var(--accent); }
.trend-kw       { flex: 1; font-size: 13px; font-weight: 500; }
.trend-vol      { font-family: var(--mono); font-size: 12px; color: var(--t2); }

.mover { display: flex; align-items: center; gap: 12px; padding: 10px 18px; border-top: 1px solid var(--border); }

.mover-badge {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 13px;
  line-height: 1;
}

.mover-badge.up   { background: var(--green-s); color: var(--green); }
.mover-badge.down { background: var(--red-s);   color: var(--red);   }

.mover-info   { flex: 1; }
.mover-kw     { font-weight: 500; font-size: 12px; }
.mover-detail { font-size: 11px; color: var(--t3); }

/* ─── SCROLLBAR ──────────────────────────────────────────────────────────────── */

::-webkit-scrollbar       { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ─── SCORE FEEDBACK ─────────────────────────────────────────────────────────── */

.score-feedback form { display: inline-flex; margin: 0; }

.feedback-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  font-size: 18px;
  line-height: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
}

.feedback-btn:hover  { background: var(--accent-s); border-color: var(--accent); }
.feedback-btn:active { transform: scale(0.92); }
.feedback-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ─── "SOON" NAV ITEMS (beta: not-yet-real screens) ──────────────────────────── */

.nav-item.soon {
  opacity: 0.45;
  cursor: default;
  pointer-events: none;
}

.nav-badge.soon {
  background: var(--surface);
  border: 1px solid var(--border);
  color: inherit;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ─── THEME TOGGLE (System / Light / Dark) ───────────────────────────────────── */

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin: 0;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--input);
}

.theme-opt {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--t3);
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.theme-opt svg {
  width: 15px;
  height: 15px;
}

.theme-opt:hover {
  color: var(--t1);
}

.theme-opt.active {
  background: var(--accent-s);
  color: var(--accent);
}

.theme-opt:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.review-rating-form { display: flex; gap: 10px; flex-wrap: wrap; }
.review-rating-form .track-btn { padding: 8px 18px; font-size: 13px; }
.review-verdict.agree    { color: var(--accent); }
.review-verdict.disagree { color: #c2410c; }

/* ─── MOBILE RESPONSIVENESS ──────────────────────────────────────────────────── */

.nav-hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--t1);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  margin-right: 4px;
  flex-shrink: 0;
}

.nav-hamburger:hover { background: var(--surface); }

.nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 40;
}

.nav-overlay.is-visible { display: block; }

@media (max-width: 768px) {
  /* Collapse grid to single column */
  .app {
    grid-template-columns: 1fr;
  }

  .nav-hamburger { display: flex; }

  /* Sidebar becomes a slide-in drawer */
  .sidebar {
    position: fixed;
    top: 56px;
    left: 0;
    width: 260px;
    height: calc(100vh - 56px);
    z-index: 50;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  /* Main takes full width */
  .main {
    padding: 16px;
    min-height: calc(100vh - 56px);
  }

  .screen-header {
    margin-bottom: 16px;
  }

  /* Stack the user-show dashboard cards */
  .serp-factor-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
  }

  /* Make sure tables don't overflow */
  .card table {
    min-width: 500px;
  }

  .card > table,
  .card > div > table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Search rows stack on small screens */
  .serp-search-row {
    flex-wrap: wrap;
  }

  .serp-search-row .serp-input {
    width: 100%;
  }

  /* Manage account form stacks */
  form[style*="display:flex"] {
    flex-direction: column;
    align-items: stretch !important;
  }

  /* Rank tracker KPI row: 4 equal columns overflow on narrow screens with
     no wrap — collapse to 2x2 so every card stays fully visible. */
  .kpi-row {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Rank tracker charts row (Position trend + Platform distribution):
     2fr/1fr ratio squeezes the second chart to an unusable sliver on
     mobile — stack instead, same pattern as .charts-grid at 900px. */
  .grid-3-1 {
    grid-template-columns: 1fr;
  }
}

/* ─── ANNOUNCEMENT BANNER (SOC-116) ──────────────────────────────────────── */
.announcement {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--accent-s);
  color: inherit;
  margin-bottom: 16px;
  font-size: 14px;
}
.announcement--warning { border-color: #d9a441; background: rgba(217, 164, 65, 0.12); }
.announcement--success { border-color: #3fae7a; background: rgba(63, 174, 122, 0.12); }
.announcement-body { line-height: 1.5; }
.announcement-dismiss {
  flex: none;
  background: transparent;
  border: 0;
  color: inherit;
  opacity: 0.6;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  padding: 2px 6px;
}
.announcement-dismiss:hover { opacity: 1; }
.flash--notice {
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: var(--accent-s);
  color: inherit;
}

/* ─── ACCOUNT ────────────────────────────────────────────────────────────────── */

.account-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
  align-items: start;
  max-width: 900px;
}

.account-identity {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.avatar-lg {
  width: 42px;
  height: 42px;
  font-size: 15px;
}

.account-meta {
  font-size: 12px;
  color: var(--t2);
  margin-top: 2px;
}

.account-facts {
  border-top: 1px solid var(--border);
  margin-bottom: 20px;
}

.account-facts > div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.account-facts dt { color: var(--t2); }
.account-facts dd { font-weight: 600; }

/* ─── FORM FIELDS (app screens) ──────────────────────────────────────────────── */

.form-field {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--t2);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--r);
  border: 1px solid var(--border);
  background: var(--input);
  color: var(--t1);
  font-size: 14px;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.15s;
}

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

.form-hint {
  font-size: 11px;
  color: var(--t3);
  margin-top: 4px;
}

.form-errors {
  border: 1px solid var(--red);
  background: var(--red-s);
  border-radius: var(--r);
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 13px;
}

.form-errors ul {
  list-style: none;
  margin: 0;
}

.btn-muted {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--t2);
}

/* Sign out is a button_to form; make it sit flush with the nav links. */
.nav-item-button {
  width: calc(100% - 16px);
  background: transparent;
  border: 0;
  font-family: var(--font);
  cursor: pointer;
  text-align: left;
}
