:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --panel-soft: #f7f8fa;
  --line: #e0e3eb;
  --text: #131722;
  --muted: rgba(19, 23, 34, 0.6);
  --accent: #2962ff;
  --shadow: 0 14px 30px rgba(19, 23, 34, 0.05);
  --chart-bg: #ffffff;
  --panel-elevated: rgba(255, 255, 255, 0.98);
  --floating-bg: rgba(255, 255, 255, 0.92);
  --floating-border: rgba(224, 227, 235, 0.92);
  --overlay-soft: rgba(255, 255, 255, 0.9);
  --modal-panel: linear-gradient(180deg, rgba(255, 255, 255, 0.985) 0%, rgba(247, 248, 250, 0.985) 100%);
  --note-text: #131722;
  --note-bg: rgba(255, 255, 255, 0.9);
  --note-border: rgba(224, 227, 235, 0.9);
  --note-shadow: 0 8px 18px rgba(19, 23, 34, 0.08);
}

body[data-theme="dark"] {
  --bg: #071117;
  --panel: #0e1720;
  --panel-soft: #121d29;
  --line: rgba(255, 255, 255, 0.08);
  --text: #f5f7fb;
  --muted: rgba(245, 247, 251, 0.64);
  --shadow: 0 18px 34px rgba(0, 0, 0, 0.26);
  --chart-bg: #081118;
  --panel-elevated: rgba(14, 23, 32, 0.98);
  --floating-bg: rgba(8, 17, 24, 0.9);
  --floating-border: rgba(255, 255, 255, 0.08);
  --overlay-soft: rgba(7, 17, 23, 0.88);
  --modal-panel: linear-gradient(180deg, rgba(10, 18, 27, 0.985) 0%, rgba(14, 23, 32, 0.985) 100%);
  --note-text: #f5f7fb;
  --note-bg: rgba(8, 17, 24, 0.78);
  --note-border: rgba(255, 255, 255, 0.08);
  --note-shadow: 0 10px 22px rgba(0, 0, 0, 0.24);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: "Space Grotesk", sans-serif;
  color: var(--text);
  background: var(--bg);
}

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

a {
  color: inherit;
}

button {
  cursor: pointer;
}

.news-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
  height: 100dvh;
  padding: 8px;
}

.news-topbar,
.news-chart-panel,
.sidebar-panel {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.news-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 58px;
  padding: 10px 14px;
}

.topbar-copy {
  display: inline-flex;
  align-items: center;
  min-width: 0;
}

.topbar-copy h1,
.sidebar-panel-head h3,
.chart-floating h2 {
  margin: 0;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.topbar-copy h1 {
  font-size: 18px;
  letter-spacing: -0.04em;
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

.news-search-control {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
}

.topbar-link,
.topbar-select,
.news-search-toggle,
.segmented button {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  text-decoration: none;
}

.topbar-link {
  padding: 8px 12px;
  font-size: 13px;
}

.news-search-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  padding: 8px 12px;
  font-size: 13px;
}

.news-search-toggle.active {
  background: rgba(41, 98, 255, 0.12);
  color: var(--accent);
}

.news-search-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 28;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
  width: min(420px, calc(100vw - 36px));
  max-height: min(66dvh, 520px);
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel-elevated);
  box-shadow: 0 20px 46px rgba(19, 23, 34, 0.14);
  backdrop-filter: blur(20px);
}

.news-search-panel.is-hidden {
  display: none;
}

.macro-window {
  position: fixed;
  top: 88px;
  right: 16px;
  z-index: 44;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(368px, calc(100vw - 24px));
  max-height: min(62dvh, 580px);
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel-elevated);
  box-shadow: 0 22px 52px rgba(19, 23, 34, 0.16);
  backdrop-filter: blur(18px);
  overflow: hidden;
}

.macro-window.is-hidden {
  display: none;
}

.macro-window-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--line);
  cursor: move;
  user-select: none;
}

.macro-window-head .eyebrow {
  margin-bottom: 4px;
}

.macro-window-head h3 {
  margin: 0;
  font-size: 16px;
  letter-spacing: -0.02em;
}

.macro-window-close {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  font-size: 12px;
}

.macro-window-body {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 8px;
  min-height: 0;
  padding: 10px;
}

.macro-window-stats {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.macro-search-results {
  min-height: 0;
  overflow: auto;
  display: grid;
  gap: 7px;
  padding-right: 2px;
}

.macro-search-result {
  display: grid;
  gap: 6px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-soft);
  text-align: left;
  transition:
    border-color 160ms ease,
    background-color 160ms ease,
    transform 160ms ease,
    box-shadow 160ms ease;
}

.macro-search-result:hover,
.macro-search-result:focus-visible {
  border-color: rgba(41, 98, 255, 0.34);
  background: rgba(41, 98, 255, 0.06);
  box-shadow: 0 10px 22px rgba(41, 98, 255, 0.08);
  outline: none;
}

.macro-search-result-head,
.macro-search-result-tags {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.macro-search-result-text {
  color: var(--text);
  font-size: 12px;
  line-height: 1.48;
}

.news-search-input {
  width: 100%;
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  font-size: 14px;
  outline: none;
}

.news-search-input:focus-visible {
  border-color: rgba(41, 98, 255, 0.44);
  box-shadow: 0 0 0 3px rgba(41, 98, 255, 0.12);
}

.news-search-results {
  min-height: 0;
  overflow: auto;
  display: grid;
  gap: 8px;
}

.news-search-empty {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 13px;
}

.news-search-result {
  display: grid;
  gap: 8px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-soft);
  text-align: left;
  transition:
    border-color 160ms ease,
    background-color 160ms ease,
    transform 160ms ease,
    box-shadow 160ms ease;
}

.news-search-result:hover,
.news-search-result:focus-visible {
  border-color: rgba(41, 98, 255, 0.34);
  background: rgba(41, 98, 255, 0.06);
  box-shadow: 0 10px 22px rgba(41, 98, 255, 0.08);
  outline: none;
}

.news-search-result:active {
  transform: scale(0.995);
}

.news-search-result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.news-search-result-time {
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
}

.news-search-result-text {
  color: var(--text);
  font-size: 13px;
  line-height: 1.48;
}

.topbar-select {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
}

.topbar-select span {
  color: var(--muted);
  font-size: 12px;
}

.topbar-select select {
  min-width: 76px;
  border: 0;
  background: transparent;
  color: var(--text);
  outline: none;
  font-size: 13px;
}

.topbar-select.compact {
  gap: 0;
}

.topbar-select.compact select {
  min-width: 88px;
}

.topbar-link.secondary {
  background: var(--panel-soft);
}

.segmented {
  display: inline-flex;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
}

.segmented button {
  min-width: 46px;
  border: 0;
  background: transparent;
  padding: 7px 10px;
  font-size: 13px;
}

.segmented button.active {
  background: rgba(41, 98, 255, 0.12);
  color: var(--accent);
}

.segmented.compact {
  padding: 3px;
}

.segmented.compact button {
  min-width: 46px;
  padding: 7px 10px;
}

.news-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 10px;
  min-height: 0;
}

.news-chart-panel {
  position: relative;
  min-height: 0;
  overflow: hidden;
}

#news-chart {
  width: 100%;
  height: 100%;
  background: var(--chart-bg);
}

.news-selected-bucket-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0;
  border-left: 1px solid rgba(41, 98, 255, 0.72);
  box-shadow: 0 0 0 1px rgba(41, 98, 255, 0.08);
  z-index: 3;
  pointer-events: none;
}

.news-selected-bucket-line.is-hidden {
  display: none;
}

.news-chart-selection-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0;
  border-left: 1px dashed rgba(123, 77, 255, 0.86);
  box-shadow: 0 0 0 1px rgba(123, 77, 255, 0.08);
  z-index: 3;
  pointer-events: none;
}

.news-chart-selection-line.is-hidden {
  display: none;
}

.chart-floating {
  position: absolute;
  top: 12px;
  z-index: 2;
  display: grid;
  gap: 6px;
  padding: 12px 14px;
  border: 1px solid var(--floating-border);
  border-radius: 18px;
  background: var(--floating-bg);
  backdrop-filter: blur(14px);
  box-shadow: 0 10px 24px rgba(19, 23, 34, 0.06);
  pointer-events: none;
}

.chart-floating-left {
  left: 12px;
}

.chart-floating-right {
  right: 12px;
  justify-items: end;
  text-align: right;
}

.chart-floating .eyebrow {
  margin-bottom: 2px;
}

.chart-floating h2 {
  font-size: 22px;
  letter-spacing: -0.03em;
}

#news-chart-range,
#news-chart-status,
.sidebar-muted,
.news-event-time,
.event-link,
.preview-status {
  color: var(--muted);
}

#news-chart-range,
#news-chart-status {
  font-size: 12px;
  line-height: 1.4;
}

.news-main-fit-button {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 4;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--floating-border);
  border-radius: 10px;
  background: var(--floating-bg);
  color: var(--text);
  backdrop-filter: blur(14px);
  box-shadow: 0 10px 24px rgba(19, 23, 34, 0.12);
}

.news-main-fit-button svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.news-main-fit-button:hover,
.news-main-fit-button:focus-visible {
  border-color: rgba(41, 98, 255, 0.34);
  color: var(--accent);
  outline: none;
}

.news-sidebar {
  display: grid;
  grid-template-rows: minmax(0, 1fr) 260px;
  gap: 10px;
  min-height: 0;
}

.sidebar-panel {
  display: grid;
  min-height: 0;
  overflow: hidden;
}

.sidebar-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--line);
}

.sidebar-panel-copy {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.sidebar-panel-head .eyebrow {
  margin-bottom: 4px;
}

.sidebar-panel-head h3 {
  font-size: 18px;
  letter-spacing: -0.02em;
}

.sidebar-mode-group {
  width: fit-content;
}

.sidebar-mode-group button {
  min-width: 58px;
}

.sidebar-events {
  grid-template-rows: auto minmax(0, 1fr);
}

.news-event-list {
  min-height: 0;
  overflow: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.news-event-list.is-macro {
  gap: 8px;
}

.news-event-list::-webkit-scrollbar {
  width: 10px;
}

.news-event-list::-webkit-scrollbar-thumb {
  background: #d7dce5;
  border-radius: 999px;
}

.news-event-card,
.empty-state {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel-soft);
}

.news-event-card {
  padding: 14px 16px;
  cursor: pointer;
  transition:
    border-color 160ms ease,
    background-color 160ms ease,
    transform 160ms ease,
    box-shadow 160ms ease;
}

.news-event-card.is-active {
  border-color: rgba(41, 98, 255, 0.34);
  background: rgba(41, 98, 255, 0.06);
  box-shadow: 0 10px 22px rgba(41, 98, 255, 0.08);
}

.news-event-card:active {
  transform: scale(0.995);
}

.news-event-card:focus-visible {
  outline: 2px solid rgba(41, 98, 255, 0.4);
  outline-offset: 2px;
}

.empty-state {
  padding: 18px;
}

.news-event-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.news-event-time {
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
}

.category-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.news-event-source {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.news-event-text {
  margin: 0 0 12px;
  line-height: 1.58;
  font-size: 14px;
}

.news-event-meta {
  display: flex;
  justify-content: flex-end;
}

.event-link {
  text-decoration: none;
  border-bottom: 1px solid currentColor;
  font-size: 12px;
}

.event-link:hover {
  color: var(--accent);
}

.news-preview-panel {
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}

.preview-panel-head {
  align-items: center;
}

.preview-panel-controls {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.preview-meta,
.news-list-status {
  padding: 10px 16px 0;
  color: var(--muted);
  font-size: 12px;
}

.preview-price-note {
  position: absolute;
  top: 10px;
  left: 12px;
  z-index: 3;
  max-width: min(calc(100% - 24px), 280px);
  padding: 6px 10px;
  border: 1px solid var(--note-border);
  border-radius: 999px;
  background: var(--note-bg);
  color: var(--note-text);
  backdrop-filter: blur(12px);
  box-shadow: var(--note-shadow);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
  pointer-events: none;
}

.preview-price-note:empty {
  display: none;
}

.preview-fit-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--text);
  font-size: 13px;
}

.preview-fit-button:hover,
.preview-fit-button:focus-visible {
  border-color: rgba(41, 98, 255, 0.34);
  color: var(--accent);
  outline: none;
}

.news-preview-wrap {
  position: relative;
  min-height: 0;
  min-block-size: 148px;
  margin: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  background: var(--chart-bg);
  cursor: pointer;
}

.news-preview-wrap:focus-visible {
  outline: 2px solid rgba(41, 98, 255, 0.45);
  outline-offset: 2px;
}

#news-preview-chart {
  width: 100%;
  height: 100%;
}

.preview-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  text-align: center;
  color: var(--muted);
  background: var(--overlay-soft);
}

.preview-empty[hidden] {
  display: none;
}

.preview-status {
  padding: 0 16px 14px;
  font-size: 12px;
}

.news-expanded-modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  place-items: center;
  padding: 28px;
}

.news-expanded-modal.is-open {
  display: grid;
}

.news-expanded-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(11, 17, 25, 0.58);
  backdrop-filter: blur(16px);
}

.news-expanded-dialog {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 14px;
  width: min(1160px, calc(100vw - 56px));
  height: min(860px, calc(100dvh - 56px));
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--modal-panel);
  box-shadow: 0 36px 120px rgba(0, 0, 0, 0.22);
}

.news-expanded-topbar,
.news-expanded-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.news-expanded-heading {
  display: grid;
  gap: 6px;
}

.news-expanded-heading h3 {
  margin: 0;
  font-size: 24px;
  letter-spacing: -0.03em;
}

.news-expanded-meta {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.news-expanded-actions {
  justify-content: flex-end;
}

#news-expanded-close {
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  color: var(--text);
}

.news-expanded-chart-wrap {
  position: relative;
  min-height: 0;
  overflow: hidden;
  border-radius: 24px;
  background: var(--chart-bg);
}

.expanded-message-note {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 3;
  display: -webkit-box;
  max-width: min(calc(100% - 28px), 540px);
  padding: 10px 12px;
  border: 1px solid var(--note-border);
  border-radius: 14px;
  background: var(--note-bg);
  color: var(--note-text);
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  backdrop-filter: blur(12px);
  box-shadow: var(--note-shadow);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.5;
  pointer-events: none;
}

.expanded-message-note:empty {
  display: none;
}

#news-expanded-chart {
  width: 100%;
  height: 100%;
}

@media (max-width: 1180px) {
  .news-workspace {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(420px, 62dvh) minmax(420px, auto);
  }

  .news-sidebar {
    grid-template-rows: minmax(0, 1fr) 240px;
  }
}

@media (max-width: 820px) {
  html,
  body {
    overflow: auto;
  }

  .news-shell {
    height: auto;
    min-height: 100dvh;
  }

  .news-topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    justify-content: flex-start;
  }

  .news-search-control {
    width: 100%;
  }

  .news-search-panel {
    left: 0;
    right: auto;
    width: min(100%, 420px);
  }

  .macro-window {
    top: 84px;
    left: 12px;
    right: 12px;
    width: auto;
    max-height: min(70dvh, 640px);
  }

  .topbar-select {
    justify-content: space-between;
    width: 100%;
  }

  .chart-floating {
    max-width: calc(100% - 24px);
  }

  .chart-floating-right {
    top: auto;
    right: 12px;
    bottom: 12px;
  }

  .preview-panel-head,
  .sidebar-panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .news-expanded-dialog {
    width: min(100vw - 24px, 1160px);
    height: min(100dvh - 24px, 860px);
    padding: 14px;
  }

  .news-expanded-topbar,
  .news-expanded-actions {
    align-items: flex-start;
    flex-direction: column;
  }
}
