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

:root {
  --bg: #0F0E0D;
  --raised: #1A1918;
  --card: #222220;
  --border: rgba(255,255,255,0.15);
  --border-md: rgba(255,255,255,0.28);
  --text: #F0EDE8;
  --text2: #8A8882;
  --text3: #959590;
  --respond: #378ADD;
  --discover: #D85A30;
  --xprod: #7F77DD;
  --mod: #1D9E75;
  --tooltip-bg: #FFFFFF;
  --tooltip-text: #1A1918;
  --r: 10px;
  --r-sm: 6px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #FAFAF8;
    --raised: #F0EDE8;
    --card: #FFFFFF;
    --border: rgba(0,0,0,0.08);
    --border-md: rgba(0,0,0,0.15);
    --text: #1A1918;
    --text2: #6A6866;
    --text3: #4d4d4d;
    --tooltip-bg: #1A1918;
    --tooltip-text: #F0EDE8;
  }
}

/* ── Base ── */
body {
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Filters ── */
.filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.fbtn {
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 12px;
  font-weight: 500;
  padding: 4px 14px;
  border-radius: 100px;
  cursor: pointer;
  border: 1px solid;
  background: transparent;
  transition: background .15s, color .15s;
  letter-spacing: .01em;
  white-space: nowrap;
}

.toolbar-search {
  display: none;
  width: 100%;
}

.toolbar-search .search-field-wrap {
  margin-bottom: 0;
}

.fbtn-unprioritized {
  color: var(--text3) !important;
  border-color: var(--border) !important;
  opacity: 0.7;
  transition: opacity .15s, background .15s, color .15s;
}

.fbtn-unprioritized:hover {
  opacity: 1;
  background: var(--raised) !important;
  color: var(--text2) !important;
}

.fbtn-unprioritized.fbtn-active {
  opacity: 1;
  background: var(--text3) !important;
  color: var(--bg) !important;
  border-color: var(--text3) !important;
}

.fbtn-search {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text3) !important;
  border-color: var(--border) !important;
  transition: color .15s, border-color .15s, background .15s;
}

.fbtn-search:hover {
  color: var(--text2) !important;
  border-color: var(--border-md) !important;
  background: var(--raised) !important;
}

/* ── Main layout ── */
.main {
  max-width: 920px;
  margin: 0 auto;
  padding: 36px 28px 96px;
  transition: transform .35s cubic-bezier(.4, 0, .2, 1);
}

@media (min-width: 1024px) {
  body.panel-open .main {
    transform: translateX(-260px);
  }
}

/* ── Hero ── */
.hero { margin-bottom: 28px }

.hero-eyebrow {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  color: var(--text3);
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.hero-title {
  font-size: 32px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: -.02em;
  line-height: 1.15;
  margin-bottom: 10px;
}

.hero-title span { color: var(--discover) }

.hero-sub {
  font-size: 14px;
  color: var(--text2);
  line-height: 1.7;
}

/* ── Matrix ── */
.matrix-wrap {
  background: var(--raised);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px;
  margin-bottom: 28px;
}

.matrix-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 14px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.matrix-inner { display: flex }

.plot-wrap {
  flex: 1;
  min-width: 0;
}

.plot {
  position: relative;
  height: 360px;
  border-left: 1px solid var(--border-md);
  border-bottom: 1px solid var(--border-md);
}

.ql-v {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--border);
}

.ql-h {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--border);
}

.ql {
  position: absolute;
  font-size: 9px;
  color: var(--text3);
  letter-spacing: .05em;
  text-transform: uppercase;
}

/* ── Dots ── */
.dot {
  position: absolute;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 500;
  color: white;
  transform: translate(-50%, -50%);
  cursor: pointer;
  transition: opacity .2s, transform .12s;
  font-family: 'DM Mono', monospace;
}

.dot:hover,
.dot-active {
  transform: translate(-50%, -50%) scale(1.3);
  z-index: 100 !important;
}

.dot::after {
  content: attr(data-title);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  transform: translateX(-50%) scale(calc(1 / 1.3));
  transform-origin: bottom center;
  background: var(--tooltip-bg);
  color: var(--tooltip-text);
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: 0;
  padding: 6px 10px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity .12s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  z-index: 40;
}

.dot::before {
  content: '';
  position: absolute;
  left: 50%;
  bottom: calc(100% + 4px);
  transform: translateX(-50%) scale(calc(1 / 1.3));
  border: 4px solid transparent;
  border-top-color: var(--tooltip-bg);
  pointer-events: none;
  opacity: 0;
  transition: opacity .12s ease;
  z-index: 40;
}

.dot:hover::after,
.dot:hover::before {
  opacity: 1;
}

.dot-active {
  animation: dot-pulse 1.2s ease-in-out 2;
}

.dot-selected {
  transform: translate(-50%, -50%) scale(1.3);
  z-index: 30 !important;
}

@keyframes dot-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,255,255,0) }
  50% { box-shadow: 0 0 0 8px rgba(255,255,255,0.25) }
}

.item-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 500;
  color: white;
  flex-shrink: 0;
  font-family: 'DM Mono', monospace;
  margin-top: 1px;
  cursor: pointer;
  transition: transform .12s;
}

.item-num:hover { transform: scale(1.15) }


/* ── Section helpers (mod-footnotes) ── */
.section-brief {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.65;
  margin-bottom: 14px;
}

.section-rule {
  height: 1px;
  background: var(--border);
  margin-bottom: 14px;
}

/* ── Cards ── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px 18px;
  margin-bottom: 10px;
  scroll-margin-top: 16px;
  transition: border-color .15s;
}

.card:hover { border-color: var(--border-md) }

.card-top {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.item-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.4;
  margin-bottom: 7px;
}

.tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 100px;
  border: 1px solid var(--border-md);
  color: var(--text2);
}

.tag-urg {
  font-size: 11px;
  padding: 2px 10px;
  border-radius: 100px;
  background: rgba(215,90,48,.14);
  color: #d85a30;
  border: 1px solid rgba(215,90,48,.28);
}

.card-body {
  display: grid;
  grid-template-columns: minmax(0,1fr) minmax(0,1fr);
  gap: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

@media (max-width: 580px) {
  .card-body { grid-template-columns: 1fr }
}

.detail-label {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  color: var(--text3);
  letter-spacing: .05em;
  text-transform: uppercase;
  margin-bottom: 4px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.detail-text {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.65;
}

.signal-customer {
  font-size: 10px;
  font-weight: 500;
  color: var(--text);
  border: 1px solid var(--text);
  border-radius: 4px;
  padding: 1px 3px;
  white-space: nowrap;
}

/* ── Moderate section ── */
.mod-section { margin-bottom: 44px }

.mod-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.mod-title {
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
}

.mod-badge {
  font-size: 11px;
  padding: 2px 10px;
  border-radius: 100px;
  background: var(--mod);
  color: white;
  font-weight: 500;
}

/* ── Table ── */
.fn-table {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--border);
  border-radius: var(--r);
  overflow: hidden;
}

.fn-table th {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 8px 14px;
  background: var(--raised);
  border-bottom: 1px solid var(--border-md);
  text-align: left;
  font-weight: 400;
}

.fn-table td {
  font-size: 13px;
  color: var(--text2);
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  line-height: 1.55;
}

.fn-table tr:last-child td { border-bottom: none }
.fn-table td:first-child { font-weight: 500; color: var(--text); white-space: nowrap; width: 180px }
.fn-table td:nth-child(2) { font-family: 'DM Mono', monospace; font-size: 11px; color: var(--text3); white-space: nowrap; width: 100px }
.fn-table tr:hover td { background: var(--raised) }

/* ── Footer ── */
.footer {
  text-align: center;
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  color: var(--text3);
  padding: 40px 0 24px;
  border-top: 1px solid var(--border);
  margin-top: 40px;
  letter-spacing: .04em;
}

/* ── Alert banner ── */
.alert-banner {
  background: #FEF3EE;
  border: 1.5px solid #D85A30;
  border-radius: var(--r);
  padding: 16px 20px;
  margin-bottom: 28px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

@media (prefers-color-scheme: dark) {
  .alert-banner {
    background: rgba(215,90,48,0.12);
    border-color: rgba(215,90,48,0.5);
  }
}

.alert-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #D85A30;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
  box-shadow: rgba(215,90,48,0.2) 0px 0px 0px 5px;
  color: white;
  font-family: 'DM Mono', monospace;
  font-size: 12px;
}

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

.alert-body { flex: 1; min-width: 0 }

.alert-eyebrow {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  color: #D85A30;
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.alert-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.4;
  margin-bottom: 4px;
}

.alert-desc {
  font-size: 13px;
  color: var(--text2);
  line-height: 1.55;
}

.alert-chip {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 100px;
  background: #D85A30;
  color: white;
  white-space: nowrap;
  margin-top: 2px;
  display: inline-block;
}

.alert-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 8px;
  border-radius: 100px;
  border: 1.5px solid #D85A30;
  background: rgba(215,90,48,0.1);
  cursor: pointer;
  text-decoration: none;
  transition: background .15s;
}

.alert-inline:hover { background: rgba(215,90,48,0.18) }

@media (prefers-color-scheme: light) {
  .alert-inline { background: rgba(215,90,48,0.08) }
}

.alert-inline-icon {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #D85A30;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.alert-inline-icon svg { width: 9px; height: 9px }

.alert-inline-label {
  font-size: 12px;
  font-weight: 500;
  color: #D85A30;
  white-space: nowrap;
}

/* ── Side panel ── */
.panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease;
}

.panel-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

@media (min-width: 1024px) {
  .panel-overlay.open {
    opacity: 0;
    pointer-events: none;
  }
}

.side-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 520px;
  max-width: 92vw;
  background: var(--bg);
  border-left: 1px solid var(--border-md);
  z-index: 210;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform .35s cubic-bezier(.4, 0, .2, 1);
}

.side-panel.open {
  transform: translateX(0);
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.panel-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.3;
}

.panel-subtitle {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  color: var(--text3);
  margin-top: 4px;
}

.panel-close {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--raised);
  color: var(--text2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .15s, color .15s, border-color .15s;
}

.panel-close:hover {
  background: var(--card);
  color: var(--text);
  border-color: var(--border-md);
}

.panel-search {
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.panel-search .search-field-wrap {
  margin-bottom: 0;
}

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px 32px;
  -webkit-overflow-scrolling: touch;
}

.panel-body .card {
  scroll-margin-top: 0;
}

.panel-body .card-selected {
  border-color: var(--border-md);
  background: var(--raised);
}

.panel-body .card-selected .item-num {
  transform: scale(1.15);
}

.panel-body .card .card-body {
  grid-template-columns: 1fr;
}

.panel-divider-labeled {
  margin: 18px 0 14px;
}

.panel-divider-label {
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  color: var(--text3);
  letter-spacing: .04em;
  text-transform: uppercase;
  display: block;
  margin-bottom: 8px;
}

.panel-divider {
  height: 1px;
  background: var(--border-md);
}

/* ── Promote action ── */
.promote-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.promote-select {
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 12px;
  font-weight: 500;
  padding: 5px 28px 5px 14px;
  border-radius: 100px;
  border: 1px solid #e91d63;
  background-color: transparent;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23e91d63' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  color: #e91d63;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  transition: background-color .15s;
  white-space: nowrap;
}

.promote-select:hover {
  background-color: rgba(233,29,99,0.08);
}

.promote-select:focus {
  outline: none;
  background-color: rgba(233,29,99,0.08);
}

.promote-select option {
  color: var(--text);
  background: var(--card);
}

.promote-confirm {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  color: var(--mod);
  opacity: 0;
  transition: opacity .3s;
  white-space: nowrap;
}

.promote-confirm.visible {
  opacity: 1;
}

/* ── Manual items ── */
.card-manual {
  border-style: dashed;
}

.tag-manual {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 100px;
  background: var(--raised);
  border: 1px dashed var(--border-md);
  color: var(--text3);
  font-family: 'DM Mono', monospace;
  letter-spacing: .02em;
}

.remove-btn {
  font-family: 'DM Mono', monospace;
  font-size: 11px;
  color: var(--text3);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  white-space: nowrap;
  transition: color .15s;
  align-self: flex-start;
  margin-top: 2px;
}

.remove-btn:hover {
  color: #D85A30;
}

.dot-manual {
  background: transparent !important;
}

/* ── Search panel ── */
.search-field-wrap {
  position: relative;
  margin-bottom: 18px;
}

.search-field-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text3);
  pointer-events: none;
}

.search-field-input {
  width: 100%;
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border-md);
  border-radius: 8px;
  padding: 10px 12px 10px 34px;
  outline: none;
  transition: border-color .15s;
}

.search-field-input::placeholder {
  color: var(--text3);
}

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

.search-results {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.search-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 0 6px;
  font-family: 'DM Mono', monospace;
  font-size: 10px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text3);
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}

.search-group-header:first-child {
  padding-top: 4px;
}

.search-group-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.search-group-label {
  flex: 1;
  color: var(--text2);
  font-weight: 500;
}

.search-group-count {
  color: var(--text3);
}

.search-empty {
  padding: 32px 0;
  text-align: center;
  color: var(--text3);
  font-size: 13px;
}

/* ── Sync button ── */
.fbtn-sync {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text3) !important;
  border-color: var(--border) !important;
  transition: color .15s, border-color .15s, background .15s;
}

.fbtn-sync:hover {
  color: var(--text2) !important;
  border-color: var(--border-md) !important;
  background: var(--raised) !important;
}

.fbtn-sync.syncing {
  pointer-events: none;
  opacity: 0.7;
}

.fbtn-sync.syncing .sync-icon {
  animation: spin 1s linear infinite;
}

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

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--card);
  border: 1px solid var(--border-md);
  border-radius: var(--r);
  padding: 14px 20px;
  max-width: 480px;
  width: calc(100% - 48px);
  box-shadow: 0 8px 30px rgba(0,0,0,0.25);
  z-index: 300;
  opacity: 0;
  transition: opacity .3s, transform .3s;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 4px;
}

.toast-body {
  font-size: 12px;
  color: var(--text2);
  line-height: 1.55;
}

.toast-body .toast-stat {
  font-family: 'DM Mono', monospace;
  color: var(--text3);
}

.toast-error {
  border-color: rgba(215,90,48,0.5);
}

.toast-error .toast-title {
  color: #D85A30;
}

/* ── Mobile (≤640px) ── */
@media (max-width: 640px) {
  .matrix-toolbar {
    flex-wrap: wrap;
    align-items: stretch;
    gap: 12px;
  }

  .toolbar-search {
    display: block;
    order: -1;
  }

  .fbtn-search {
    display: none;
  }

  .fbtn-sync {
    margin-left: 0;
  }

  .fbtn-sync .sync-label {
    display: none;
  }

  .filters {
    gap: 8px;
  }

  .fbtn {
    font-size: 13px;
    padding: 6px 14px;
  }
}
