:root {
  --bg: #f0ece4;
  --surface: #faf8f4;
  --surface-2: #f0ece4;
  --ink: #1a1612;
  --ink-2: #5c5248;
  --ink-3: #a09486;
  --line: #ddd8ce;
  --line-2: #ccc6ba;
  --red: #c0392b;
  --red-dim: rgba(192, 57, 43, 0.08);
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, sans-serif;
  --display: 'Avenir Next Condensed', 'DIN Condensed', 'Arial Narrow', Impact,
    sans-serif;
  --mono: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;
}

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

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  min-height: 100vh;
}

/* TOPBAR */

.topbar {
  background: var(--ink);
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.topbar > div:first-child {
  display: flex;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
}

.topbar h1 {
  font-family: var(--display);
  font-size: 28px;
  font-weight: 800;
  text-transform: uppercase;
  line-height: 1;
  color: #faf8f4;
  letter-spacing: 0.01em;
}

.topbar h1 a {
  color: inherit;
  text-decoration: none;
}

.topbar h1 a:hover {
  color: #fff;
}

.topbar .eyebrow {
  font-size: 12px;
  color: #a09486;
  margin: 0;
}

.quick-links {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.quick-links a,
.quick-links button,
.sidebar-toggle {
  font-size: 12px;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: 3px;
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
  transition: all 0.12s;
  text-decoration: none;
  display: inline-block;
  letter-spacing: 0.01em;
}

.quick-links a:hover,
.quick-links button:hover,
.sidebar-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.quick-links button {
  background: #faf8f4;
  color: var(--ink);
  border-color: transparent;
  font-weight: 600;
}

.quick-links button:hover {
  background: #fff;
  color: var(--ink);
}

/* LAYOUT */

.layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  min-height: calc(100vh - 57px);
  transition: grid-template-columns 0.14s ease;
}

.layout.sidebar-collapsed {
  grid-template-columns: 96px 1fr;
}

/* SIDEBAR */

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line-2);
  padding: 20px 0;
}

.sidebar-head {
  display: grid;
  gap: 8px;
  padding: 0 18px 10px;
}

.sidebar-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-3);
}

.sidebar-count {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-3);
}

.sidebar-toggle {
  border-color: var(--line-2);
  background: var(--ink);
  color: #faf8f4;
  text-align: center;
}

.sidebar-toggle:hover {
  background: #2b251f;
}

.sidebar-collapsed .sidebar-head {
  padding: 0 12px 10px;
}

.sidebar-collapsed .sidebar-title,
.sidebar-collapsed .sidebar-count {
  display: none;
}

.model-tabs {
  display: grid;
  gap: 0;
}

#model-tabs[hidden] {
  display: none;
}

.model-tab {
  display: block;
  padding: 9px 18px;
  cursor: pointer;
  text-decoration: none;
  color: var(--ink-2);
  border-left: 2px solid transparent;
  transition: all 0.1s;
}

.model-tab:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.model-tab.active {
  color: var(--ink);
  border-left-color: var(--red);
  background: var(--surface-2);
}

.model-name {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
}

.model-meta {
  font-size: 11px;
  color: var(--ink-3);
  margin-top: 1px;
}

/* WORKSPACE */

.workspace {
  padding: 28px 32px;
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
}

.view {
  display: none;
}

.active-view {
  display: block;
}

.summary-band,
.control-row,
#index-view > .table-wrap,
.strategy-section,
.strategy-tabs,
.blocked-item {
  padding-bottom: 28px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--line-2);
}

.summary-band,
.product-header {
  display: grid;
  grid-template-columns: 1fr;
  gap: 28px;
  align-items: start;
  margin-bottom: 20px;
}

.summary-band .eyebrow,
.product-header .eyebrow,
.control-row::before,
#index-view > .table-wrap::before,
.note-block::before,
.strategy-section::before,
.blocked-item::before {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-3);
  margin-bottom: 14px;
  font-family: var(--sans);
}

.summary-band h2,
.product-header h2 {
  font-family: var(--display);
  font-size: 52px;
  font-weight: 800;
  text-transform: uppercase;
  line-height: 0.95;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.lead {
  margin-top: 10px;
  color: var(--ink-2);
  line-height: 1.7;
  font-size: 13.5px;
  max-width: 640px;
}

.back-link,
.table-link {
  color: var(--ink);
  font-weight: 600;
  text-decoration: none;
}

.back-link:hover,
.table-link:hover {
  color: var(--red);
}

/* FACTS / METRICS */

.metrics,
.facts {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 180px;
}

.metrics div,
.facts div {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
}

.metrics div:last-child,
.facts div:last-child {
  border-bottom: none;
}

.metrics strong,
.facts dd {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  font-family: var(--mono);
  margin: 0;
  order: 2;
}

.metrics span,
.facts dt {
  font-size: 11px;
  color: var(--ink-3);
  padding-top: 1px;
  margin: 0;
  order: 1;
}

/* TABS */

.strategy-tabs {
  display: flex;
  gap: 0;
  flex-wrap: wrap;
  padding-bottom: 0;
  margin-bottom: 2px;
  border-bottom: 1px solid var(--line-2);
}

.strategy-tab {
  font-size: 12px;
  font-weight: 500;
  padding: 8px 16px;
  cursor: pointer;
  background: none;
  border: none;
  color: var(--ink-3);
  border-bottom: 1.5px solid transparent;
  margin-bottom: -1px;
  letter-spacing: 0.01em;
  transition: color 0.12s;
}

.strategy-tab:hover {
  color: var(--ink-2);
}

.strategy-tab.active {
  color: var(--ink);
  border-bottom-color: var(--ink);
}

/* INDEX TABS */

.index-tabs {
  display: flex;
  gap: 0;
  max-width: 100%;
  border-bottom: 1px solid var(--line-2);
  margin-bottom: 22px;
}

.index-tab {
  appearance: none;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--ink-3);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  padding: 12px 16px 10px;
}

.index-tab:hover {
  color: var(--ink);
}

.index-tab.active {
  color: var(--ink);
  border-bottom-color: var(--ink);
}

/* FILTERS */

.control-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
  position: relative;
  padding-top: 22px;
}

.control-row::before {
  content: 'Filters';
  position: absolute;
  top: 0;
  left: 0;
}

.control-row label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-3);
}

select,
input,
textarea {
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: 3px;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 13px;
  padding: 7px 10px;
  min-height: 34px;
  outline: none;
}

select,
input {
  min-width: 190px;
}

.search-box input {
  min-width: 320px;
}

select:focus,
input:focus,
textarea:focus {
  border-color: var(--ink-2);
}

input::placeholder {
  color: var(--ink-3);
}

button:focus-visible,
a:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}

/* TABLE */

.table-wrap {
  border: 1px solid var(--line-2);
  border-radius: 4px;
  overflow: auto;
  background: var(--surface);
}

#index-view > .table-wrap {
  position: relative;
  padding-top: 28px;
}

#index-view > .table-wrap::before {
  content: attr(data-table-title);
  position: absolute;
  top: 10px;
  left: 16px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1080px;
}

th {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-3);
  padding: 9px 16px;
  text-align: left;
  border-bottom: 1px solid var(--line-2);
  background: var(--surface);
}

td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-2);
  vertical-align: middle;
  font-size: 13px;
}

th.row-index,
td.row-index {
  color: var(--ink-3);
  font-family: var(--mono);
  font-size: 11px;
  min-width: 34px;
  padding-left: 10px;
  padding-right: 8px;
  text-align: right;
  width: 34px;
}

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

#keyword-strategy-table tr:last-child td {
  border-bottom: 1px solid var(--line);
}

tbody tr:hover {
  background: var(--surface-2);
}

td span {
  font-size: 10px;
  color: var(--ink-3);
  display: block;
  margin-top: 2px;
}

.keyword-type {
  color: var(--ink);
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-top: 0;
  padding: 0;
}

.keyword-type-cell {
  background: rgba(240, 236, 228, 0.72);
  border-right: 1px solid var(--line);
  color: var(--ink);
  padding-top: 14px;
  vertical-align: top;
  width: 132px;
}

.keyword-ebike-cell {
  background: rgba(27, 22, 18, 0.06);
  border-right: 1px solid var(--line);
  color: var(--ink);
  padding-top: 14px;
  vertical-align: top;
  width: 92px;
}

.keyword-type-inline {
  background: var(--ink);
  border-radius: 3px;
  color: #fff;
  display: inline-block;
  font-size: 11px;
  line-height: 1.2;
  margin: 0;
  padding: 5px 8px;
  text-transform: none;
}

td .keyword-type-inline {
  color: #fff;
  display: inline-block;
  margin: 0;
}

mark {
  background: var(--red-dim);
  border-radius: 999px;
  color: var(--red);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
}

mark::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
}

mark.priority-p0 {
  background: rgba(192, 57, 43, 0.1);
  color: var(--red);
}

mark.priority-p1 {
  background: rgba(46, 125, 80, 0.1);
  color: #2e7d50;
}

mark.priority-p2 {
  background: rgba(169, 105, 34, 0.13);
  color: #9a5b16;
}

mark.priority-p3 {
  background: rgba(90, 82, 72, 0.1);
  color: var(--ink-2);
}

/* NOTES */

.note-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.product-notes {
  padding-bottom: 18px;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--line-2);
  max-width: 1120px;
}

.note-block {
  background: transparent;
  border-left: 2px solid var(--red);
  padding: 1px 0 1px 12px;
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.65;
  display: grid;
  gap: 2px;
}

.note-block::before {
  content: none;
}

.note-block span {
  color: var(--ink);
  font-weight: 600;
  font-size: 12px;
  line-height: 1.25;
}

.note-block p {
  max-width: 1040px;
  line-height: 1.55;
  white-space: pre-line;
}

.note-secondary {
  color: var(--ink-3);
  display: block;
  font-size: 12px;
  line-height: 1.55;
  margin-top: 3px;
  white-space: pre-line;
}
/* STRATEGY */

.strategy-list,
.blocked-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.strategy-section,
.blocked-item {
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}

.strategy-section::before {
  content: 'Strategy';
  display: block;
}

.strategy-section.keyword-section::before {
  content: none;
}

.blocked-item::before {
  content: 'Excluded';
  display: block;
}

.strategy-section:last-child,
.blocked-item:last-child {
  border-bottom: none;
}

.section-head {
  display: grid;
  grid-template-columns: 160px 1fr auto;
  gap: 20px;
  align-items: baseline;
}

.section-head .eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-3);
  margin: 0;
}

.section-head h3,
.blocked-item h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 4px;
}

.section-head > div {
  display: contents;
}

.section-head > span,
.blocked-item span {
  font-size: 11px;
  color: var(--ink-3);
  white-space: nowrap;
}

.strategy-section p,
.blocked-item p {
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.6;
  margin-top: 6px;
}

.tab-purpose {
  background: var(--red-dim);
  border-left: 2px solid var(--red);
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.7;
  padding: 10px 14px;
}

.table-wrap.compact {
  margin-top: 14px;
}

.keyword-groups {
  display: grid;
  gap: 14px;
  margin-top: 16px;
  border-top: 0;
}

.keyword-group {
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: 4px;
  overflow: hidden;
}

.keyword-group-head {
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.keyword-group-head h4 {
  background: var(--ink);
  border-radius: 3px;
  color: var(--surface);
  display: inline-block;
  font-size: 13px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 8px;
  padding: 6px 9px;
}

.keyword-group-head p {
  color: var(--ink-2);
  font-size: 12px;
  line-height: 1.6;
  max-width: 820px;
}

.keyword-stack {
  display: grid;
}

.keyword-disclosure {
  border-bottom: 1px solid var(--line);
}

.keyword-disclosure:last-child {
  border-bottom: none;
}

.keyword-disclosure summary {
  align-items: center;
  cursor: pointer;
  display: grid;
  grid-template-columns: minmax(180px, 0.45fr) minmax(240px, 1fr);
  gap: 16px;
  list-style: none;
  padding: 12px 16px;
  position: relative;
}

.keyword-disclosure summary::-webkit-details-marker {
  display: none;
}

.keyword-disclosure summary::before {
  color: var(--ink-3);
  content: '+';
  font-family: var(--mono);
  font-size: 14px;
  margin: 0 8px;
  position: absolute;
}

.keyword-disclosure[open] summary::before {
  content: '-';
}

.keyword-disclosure summary:hover {
  background: var(--surface-2);
}

.keyword-term {
  color: var(--ink);
  font-weight: 700;
  padding-left: 18px;
}

.keyword-meta {
  color: var(--ink-3);
  font-family: var(--mono);
  font-size: 11px;
}

.keyword-detail {
  background: var(--surface-2);
  border-top: 1px solid var(--line);
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr;
  padding: 14px 16px 16px;
}

.keyword-detail.has-facts {
  grid-template-columns: 360px 1fr;
}

.keyword-detail.no-facts {
  padding-top: 16px;
}

.keyword-facts {
  display: grid;
  gap: 0;
}

.keyword-facts div {
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 10px;
  padding: 6px 0;
}

.keyword-facts div:last-child {
  border-bottom: none;
}

.keyword-facts dt {
  color: var(--ink-3);
  font-size: 11px;
}

.keyword-facts dd {
  color: var(--ink);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
}

.planned-pages {
  background: #fafafa;
  border-left: 3px solid #79a778;
  margin-top: 24px;
  padding: 14px 14px 16px;
}

.planned-pages-table {
  border: 1px solid #d6e2d8;
  background: #f7faf7;
}

.planned-pages-table th {
  background: #eef5ee;
  color: #708070;
}

.planned-pages-table tbody tr:hover {
  background: #edf4ed;
}

.planned-pages-table mark {
  background: rgba(83, 128, 89, 0.1);
  color: #537f59;
}

.keyword-page-plan strong {
  color: var(--ink);
  font-size: 12px;
}

.page-type {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

/* Collection */
.type-collection {
  background: #fee1be;
  color: #c4662a;
}

/* Blog */
.type-blog {
  background: #eef4fb;
  color: #4f74a8;
}

/* Page */
.type-page {
  background: #f4eff9;
  color: #7a5ca8;
}

.keyword-pages {
  min-width: 0;
}

.keyword-pages > strong,
.planned-pages > strong {
  align-items: center;
  border-radius: 3px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  padding: 6px 9px;
}

.keyword-pages > strong {
  background: var(--ink);
  color: var(--surface);
}

.planned-pages > strong {
  background: #dfeee0;
  color: #3e7048;
}

.keyword-pages-table {
  margin-top: 10px;
}

.keyword-pages-table table {
  min-width: min(760px, 100%);
}

.keyword-pages-table th,
.keyword-pages-table td {
  font-size: 12px;
  padding: 9px 10px;
}

.keyword-pages-table mark {
  border-radius: 3px;
  font-size: 11px;
  padding: 2px 6px;
  white-space: nowrap;
}

.backlinks-table .empty-cell {
  color: var(--ink-3);
  font-family: var(--mono);
  padding: 18px 12px;
  text-align: center;
}

.empty-state {
  border: 1px dashed var(--line-2);
  color: var(--ink-3);
  font-family: var(--mono);
  font-size: 12px;
  padding: 18px;
  text-align: center;
}

.keyword-page-plan ul {
  color: var(--ink-2);
  display: grid;
  gap: 5px;
  font-size: 12px;
  line-height: 1.6;
  margin-top: 6px;
  padding-left: 16px;
}

.page-plan {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-3);
  margin-top: 10px;
}

.page-plan strong {
  color: var(--ink);
  font-family: var(--sans);
  font-size: 12px;
}

.page-plan ul {
  display: grid;
  gap: 3px;
  margin-top: 6px;
  padding-left: 16px;
}

/* RESPONSIVE */

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

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--line-2);
    padding: 12px 0;
  }

  .summary-band,
  .product-header {
    grid-template-columns: 1fr;
  }

  .section-head {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .keyword-disclosure summary,
  .keyword-detail {
    grid-template-columns: 1fr;
  }

  .section-head > div {
    display: block;
  }

  .search-box input {
    min-width: 220px;
  }
}

@media (max-width: 600px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .topbar > div:first-child {
    display: grid;
    gap: 6px;
  }

  .workspace {
    padding: 20px 18px;
  }

  .summary-band h2,
  .product-header h2 {
    font-size: 40px;
  }
}
