:root {
  /* Warm, editorial palette — paper tones + terracotta, instead of a
     generic blue SaaS scheme. */
  --bg: #f7f4ee;
  --bg-elevated: #fffdf8;
  --bg-widget-header: #efe9dc;
  --text: #211d17;
  --text-muted: #6f6656;
  --border: #e2dac6;
  --accent: #b8552e;
  --accent-contrast: #fffdf8;
  --up: #3f7d4a;
  --down: #b83b2c;
  --shadow: 0 1px 3px rgba(40, 30, 15, 0.08), 0 1px 2px rgba(40, 30, 15, 0.06);
  --radius: 10px;
  --font-sans: "Science Gothic", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-serif: "IBM Plex Serif", Georgia, "Times New Roman", serif;
}

/* "Dusk" — the original warm dark theme (terracotta on near-black brown). */
html[data-theme="dark"] {
  --bg: #171310;
  --bg-elevated: #201c16;
  --bg-widget-header: #29241c;
  --text: #f3ece0;
  --text-muted: #a89a83;
  --border: #372f23;
  --accent: #e2894f;
  --accent-contrast: #171310;
  --up: #63b072;
  --down: #e2624a;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* "Midnight" — a cooler, soothing deep-blue dark theme. */
html[data-theme="midnight"] {
  --bg: #0a1120;
  --bg-elevated: #101a2e;
  --bg-widget-header: #16233d;
  --text: #dce6f5;
  --text-muted: #8593b3;
  --border: #223252;
  --accent: #5b9bf0;
  --accent-contrast: #0a1120;
  --up: #4fd08a;
  --down: #ee6f6f;
  --shadow: 0 1px 3px rgba(0, 0, 10, 0.5), 0 1px 2px rgba(0, 0, 10, 0.35);
}

* { box-sizing: border-box; }

/* Themed scrollbars — slimmer than default, matching the paper/terracotta
   palette instead of the OS default track/thumb. */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }
*::-webkit-scrollbar-thumb:hover { background: var(--accent); }

body {
  margin: 0;
  font-family: var(--font-serif);
  background: var(--bg);
  color: var(--text);
  transition: background 0.15s ease, color 0.15s ease;
}

h1, h2, h3, h4,
.brand-name, .version-chip,
.btn, .icon-btn, .sidebar-btn,
.field span, .field input, .field select,
input, select, button,
table th, .feed-source-group h4, .mo-name,
.ticker-track .tag, .status-table td:first-child {
  font-family: var(--font-sans);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 0.5rem; }
.brand-mark { color: var(--accent); font-size: 1.2rem; }
.brand-name { font-weight: 700; font-size: 1.15rem; letter-spacing: -0.02em; }

.version-chip {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--bg-widget-header);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
}
.version-chip:hover { color: var(--accent); border-color: var(--accent); }
.loadtime-wrap { position: relative; display: inline-flex; }
.loadtime-chip { font-family: inherit; }
.loadtime-chip.stale { color: #d9822b; border-color: #d9822b; }
.loadtime-tooltip {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 0.4rem;
  min-width: 220px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 0.5rem 0.65rem;
  z-index: 40;
}
.loadtime-tooltip.hidden { display: none; }
.loadtime-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 0.2rem 0;
}
.loadtime-row:not(:last-child) { border-bottom: 1px solid var(--border); }
.loadtime-row b { color: var(--text); font-weight: 600; }

.mobile-menu-btn { display: none; }

.header-controls {
  display: flex;
  align-items: center;
  flex: 1;
  justify-content: space-between;
}

.search-wrap { flex: 1; max-width: 420px; margin: 0 1rem; }
.search-input {
  width: 100%;
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-widget-header);
  color: var(--text);
  font-size: 0.85rem;
}
.search-input:focus { outline: none; border-color: var(--accent); }

.header-actions { display: flex; align-items: center; gap: 0.5rem; }

.btn {
  border: 1px solid var(--border);
  background: var(--bg-widget-header);
  color: var(--text);
  border-radius: 8px;
  padding: 0.45rem 0.8rem;
  font-size: 0.85rem;
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); font-weight: 600; }
.auto-refresh-select { font-family: var(--font-sans); }

.icon-btn {
  border: 1px solid var(--border);
  background: var(--bg-widget-header);
  border-radius: 8px;
  width: 2.1rem;
  height: 2.1rem;
  cursor: pointer;
  font-size: 1rem;
  color: var(--text);
}

.ticker-bar {
  display: flex;
  align-items: center;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  padding: 0.4rem 0;
}
.ticker-bar-secondary { background: var(--bg-widget-header); font-size: 0.8rem; }
.ticker-scroll-area {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}
.ticker-speed-controls {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0 0.6rem;
  border-left: 1px solid var(--border);
  margin-left: 0.4rem;
}
.ticker-speed-btn {
  border: 1px solid var(--border);
  background: var(--bg-widget-header);
  color: var(--text-muted);
  border-radius: 6px;
  width: 1.7rem;
  height: 1.7rem;
  line-height: 1;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
}
.ticker-speed-btn:hover { color: var(--accent); border-color: var(--accent); }
.ticker-speed-btn:active { background: var(--accent); color: var(--accent-contrast); }
.ticker-track {
  display: inline-block;
  animation: ticker-scroll 105s linear infinite;
  font-size: 0.85rem;
}
.ticker-track a { color: var(--text); text-decoration: none; margin-right: 2.5rem; }
.ticker-track a:hover { color: var(--accent); }
.ticker-track .tag {
  color: var(--accent);
  font-weight: 700;
  margin-right: 0.4rem;
}
/* The track's JS-rendered content is duplicated back-to-back (see
   setTickerContent in app.js), so scrolling exactly half its width loops
   seamlessly — the moment the first copy scrolls off, the second is
   already sitting where the first started, instead of going blank while
   waiting for a full padding-buffered cycle to complete. */
@keyframes ticker-scroll {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}
.ticker-scroll-area:hover .ticker-track { animation-play-state: paused; }

.trending-topics-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 1rem;
  background: var(--bg-widget-header);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.trending-label {
  flex: 0 0 auto;
  font-weight: 700;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.trending-chips { display: flex; gap: 0.4rem; flex-wrap: nowrap; }
.trend-chip {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  border-radius: 999px;
  padding: 0.2rem 0.65rem;
  font-size: 0.78rem;
  cursor: pointer;
  white-space: nowrap;
}
.trend-chip:hover { border-color: var(--accent); color: var(--accent); }
.trend-count {
  font-size: 0.68rem;
  color: var(--text-muted);
  background: var(--bg-widget-header);
  border-radius: 999px;
  padding: 0.05rem 0.35rem;
}

.app-body {
  display: flex;
  align-items: flex-start;
}

.sidebar {
  flex: 0 0 190px;
  padding: 1rem 0.75rem;
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.sidebar-toggle-btn {
  align-self: flex-end;
  border: 1px solid var(--border);
  background: var(--bg-widget-header);
  color: var(--text-muted);
  border-radius: 8px;
  width: 1.9rem;
  height: 1.9rem;
  cursor: pointer;
  font-size: 0.95rem;
  margin-bottom: 0.3rem;
}
.sidebar-toggle-btn:hover { color: var(--accent); border-color: var(--accent); }
body.sidebar-collapsed .sidebar-toggle-btn { align-self: center; }

.sidebar-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.7rem;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  text-align: left;
}
.sidebar-btn:hover { background: var(--bg-widget-header); color: var(--text); }
.sidebar-btn.active { background: var(--bg-widget-header); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.sidebar-btn .count {
  font-size: 0.72rem;
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
}

.sidebar-feeds-section {
  margin-top: 0.6rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.sidebar-section-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  padding: 0 0.7rem 0.2rem;
}
.sidebar-feed-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  padding: 0.4rem 0.7rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-align: left;
  cursor: pointer;
  border-radius: 8px;
  font-family: var(--font-sans);
}
.sidebar-feed-header:hover { background: var(--bg-widget-header); color: var(--text); }
.sidebar-feed-header .chevron { font-size: 0.7rem; width: 0.8rem; display: inline-block; color: var(--text-muted); }
.sidebar-feed-list {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.2rem 0.5rem 0.4rem 1.6rem;
}
.sidebar-feed-list.hidden { display: none; }
.sidebar-feed-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.76rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.1rem 0;
}
.sidebar-feed-row:hover { color: var(--text); }
.sidebar-feed-row input { accent-color: var(--accent); cursor: pointer; }

.widget-grid {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
  padding: 1rem;
  align-items: start;
}
.widget.category-hidden { display: none; }

.widget {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 520px;
}
.widget.dragging { opacity: 0.4; }
.widget.wide { grid-column: span 2; }

/* Two adjacent "half" widgets render inside this wrapper (one grid cell,
   split top/bottom) instead of each getting its own — see renderGrid() in
   app.js. The wrapper matches a normal widget's max-height so each half is
   roughly half of a full widget's height. */
.widget-half-pair {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-height: 520px;
  min-height: 260px;
  min-width: 0;
  /* The grid's align-items:start doesn't stretch items to the row height by
     default, so without this, the wrapper has no definite height of its
     own for its flex:1 children to divide — they'd collapse to ~0 (flex
     basis 0, min-height 0, nothing else establishing a size). Stretching
     just this item to the row's height (set by its taller siblings) gives
     it something real to split 50/50. min-height above is the floor for
     the rare case where a pair is the tallest/only thing in its row. */
  align-self: stretch;
}
.widget-half-pair .widget {
  flex: 1 1 0;
  min-height: 0;
  max-height: none;
}
.widget-header .controls .half-btn.active { color: var(--accent); }

/* CrypTrack's content is a fixed-height iframe by default, which makes it
   look short next to taller feed/table widgets even though there's no
   reason it couldn't fill the row like everything else does. */
.widget[data-type="cryptrack"] { align-self: stretch; }

.widget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.75rem;
  background: var(--bg-widget-header);
  border-bottom: 1px solid var(--border);
  cursor: grab;
}
.widget-header h3 { margin: 0; font-size: 0.9rem; font-weight: 700; }
.widget-header .controls { display: flex; gap: 0.25rem; }
.widget-header .controls button {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0.2rem 0.35rem;
  border-radius: 6px;
}
.widget-header .controls button:hover { color: var(--accent); background: var(--bg); }
.widget-header .controls .wide-btn.active { color: var(--accent); }

.widget-body {
  padding: 0.5rem 0.75rem;
  overflow-y: auto;
  flex: 1;
}

.feed-item { padding: 0.45rem 0; border-bottom: 1px solid var(--border); }
.feed-item:last-child { border-bottom: none; }
.feed-item a { color: var(--text); text-decoration: none; font-size: 0.85rem; font-weight: 500; }
.feed-item a:hover { color: var(--accent); }
.feed-item .meta { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.15rem; }
.feed-source-group { margin-bottom: 0.75rem; }
.feed-source-group h4 {
  margin: 0 0 0.25rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.market-item { padding: 0.5rem 0; border-bottom: 1px solid var(--border); }
.market-item:last-child { border-bottom: none; }
.market-item .q { font-size: 0.85rem; font-weight: 600; display: block; color: var(--text); text-decoration: none; }
.market-item .q:hover { color: var(--accent); }
.market-item .odds { display: flex; gap: 0.5rem; margin-top: 0.3rem; flex-wrap: wrap; }
.odds-chip {
  font-size: 0.72rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: var(--bg-widget-header);
  border: 1px solid var(--border);
}
.market-item .stats { font-size: 0.7rem; color: var(--text-muted); margin-top: 0.25rem; }

.widget-map {
  /* Leaflet's own children (zoom controls, popups, tile/marker panes) use
     z-index values up to 1000. Without a positioned, z-indexed container of
     its own here, those escape this stacking context on scroll and render
     above the sticky header, modals, and the floating scroll/lock buttons. */
  position: relative;
  z-index: 0;
  width: 100%;
  height: 180px;
  border-radius: 8px;
  margin-bottom: 0.6rem;
  border: 1px solid var(--border);
  background: var(--bg-widget-header);
}
.search-hidden { display: none !important; }

.widget-map-large { height: 260px; }

.widget-iframe {
  width: 100%;
  height: 100%;
  min-height: 280px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-widget-header);
}
.widget-iframe-large { height: 480px; }

.mover-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.6rem;
  padding: 0.3rem 0;
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
}
.mover-row:first-of-type { border-top: none; }
.mover-symbol { font-family: var(--font-sans); font-weight: 600; }

.scroll-top-btn {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 1.2rem;
  cursor: pointer;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(0.5rem);
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 30;
}
.scroll-top-btn.visible { opacity: 1; pointer-events: auto; transform: translateY(0); }
.scroll-top-btn:hover { filter: brightness(1.1); }

.scroll-lock-btn {
  position: fixed;
  right: 1.25rem;
  bottom: 4.35rem;
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 1.1rem;
  cursor: pointer;
  box-shadow: var(--shadow);
  z-index: 30;
}
.scroll-lock-btn:hover { filter: brightness(1.1); }
.scroll-lock-btn.active { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); }

/* Scroll lock: freeze every widget's internal scroll so a touch drag always
   moves the page instead of a widget list stealing it. */
/* touch-action: none (previous value) disables ALL default touch handling
   for a touch that starts here — it does NOT hand the gesture off to a
   scrollable ancestor, so a swipe starting inside a locked widget just did
   nothing instead of scrolling the page. pan-y still blocks the widget's
   own scroll (it has no scrollable content while overflow is hidden) but
   lets the browser carry a vertical swipe up to the page, which is the
   whole point of locking. */
body.widgets-locked .widget-body { overflow: hidden; touch-action: pan-y; }

/* Sidebar collapse (desktop) — collapses to a slim rail holding just the
   toggle button, rather than disappearing entirely (which would strand it). */
body.sidebar-collapsed .sidebar { flex: 0 0 auto; width: auto; padding: 1rem 0.5rem; }
body.sidebar-collapsed .sidebar-btn { display: none; }
body.sidebar-collapsed .sidebar-feeds-section { display: none; }

.outbound-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}
.outbound-btn { white-space: nowrap; }

.outbound-card { text-align: center; padding: 1.5rem 1rem; }
.outbound-card-icon { font-size: 2rem; margin-bottom: 0.5rem; }
.outbound-card p { margin: 0.3rem 0; }
.outbound-card .btn { margin-top: 0.8rem; }

.potd-image { display: block; width: 100%; height: auto; border-radius: 6px; }
.screenshot-image { display: block; width: 100%; height: auto; border-radius: 6px; border: 1px solid var(--border); }
.potd-caption { padding-top: 0.6rem; }
.potd-title { font-weight: 600; }
.potd-caption p { margin: 0.3rem 0 0; font-size: 0.85rem; color: var(--text-muted); }
.potd-nav { display: flex; justify-content: flex-end; gap: 0.3rem; margin-top: 0.5rem; }
.potd-nav-btn {
  min-width: 1.8rem;
  padding: 0.15rem 0.5rem;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--bg-widget-header);
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1.2;
}
.potd-nav-btn:hover:not(:disabled) { color: var(--accent); border-color: var(--accent); }
.potd-nav-btn:disabled { opacity: 0.35; cursor: default; }

/* Finviz-style heatmap block. Fixed aspect-ratio box with tiles positioned
   by percentage (from layoutTreemap in app.js) — width scales with the
   widget (1-col or double-width via the ⬌ toggle), height follows from
   the aspect-ratio, no JS resize-observer needed. */
.sectors-treemap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border-radius: 6px;
}
.sector-tile {
  position: absolute;
  box-sizing: border-box;
  border: 1px solid var(--bg-widget-header);
  padding: 0.3rem 0.4rem;
  overflow: hidden;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.sector-tile-name { font-size: 0.78rem; font-weight: 600; line-height: 1.15; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sector-tile-pct { font-size: 0.85rem; font-weight: 700; margin-top: 0.15rem; }

/* WoW item names vary a lot in length ("Bismuth" vs. "Finishing Reagent -
   Concentration Extract") so unlike the sectors treemap this stays
   single-column with full-width wrapping names, not tiled. */
.wow-item-row { padding: 0.5rem 0; border-top: 1px solid var(--border); }
.wow-item-row:first-child { border-top: none; }
.wow-item-name { font-weight: 500; margin-bottom: 0.15rem; }
.wow-item-price { display: flex; align-items: center; gap: 0.4rem; font-size: 0.9rem; }
/* CSS-drawn instead of an emoji glyph so it's guaranteed gold on every
   platform/font, rather than however that emoji happens to render. */
.gold-coin {
  display: inline-block;
  width: 0.8em;
  height: 0.8em;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff3b8, #e8b923 55%, #a8760c 100%);
  box-shadow: inset 0 0 1px rgba(0, 0, 0, 0.45);
  flex-shrink: 0;
}

.forecast-strip {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  margin-top: 0.6rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border);
}
.forecast-cell {
  flex: 0 0 96px;
  width: 96px;
  text-align: center;
  padding: 0.5rem 0.4rem;
  border-radius: 6px;
  background: var(--bg-widget-header);
}
.forecast-day { font-size: 0.7rem; font-weight: 600; color: var(--text-muted); }
.forecast-temp { font-size: 1.05rem; font-weight: 700; margin: 0.2rem 0; }
.forecast-desc { font-size: 0.7rem; color: var(--text-muted); line-height: 1.2; word-wrap: break-word; }

table.status-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; table-layout: fixed; }
table.status-table td { padding: 0.4rem 0; border-top: 1px solid var(--border); vertical-align: top; }
table.status-table tr:first-child td { border-top: none; }
table.status-table td:first-child { width: 42%; white-space: nowrap; }
.status-dot { display: inline-block; width: 0.55rem; height: 0.55rem; border-radius: 999px; margin-right: 0.5rem; }
.status-dot.ok { background: var(--up); }
.status-dot.minor { background: #e0a622; }
.status-dot.major { background: var(--down); }
.status-dot.unknown { background: var(--text-muted); }
.status-desc { color: var(--text-muted); text-align: left; line-height: 1.35; }

.markets-overview { display: flex; flex-direction: column; gap: 0.9rem; }
table.markets-table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
table.markets-table thead th {
  text-align: left;
  color: var(--accent);
  font-weight: 700;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border);
}
table.markets-table td { padding: 0.3rem 0.2rem; border-top: 1px solid var(--border); }
table.markets-table .mo-name { color: var(--text-muted); }
table.markets-table .mo-price { font-weight: 600; }
.sparkline { display: block; }
.sparkline.pos { color: var(--up); }
.sparkline.neg { color: var(--down); }

.portfolio-controls { display: flex; gap: 0.4rem; margin-bottom: 0.6rem; }
.portfolio-controls input {
  flex: 1;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.8rem;
}
table.portfolio-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
table.portfolio-table th { text-align: left; color: var(--text-muted); font-weight: 600; font-size: 0.72rem; text-transform: uppercase; padding-bottom: 0.3rem; }
table.portfolio-table th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
table.portfolio-table th.sortable:hover { color: var(--accent); }
table.portfolio-table td { padding: 0.35rem 0; border-top: 1px solid var(--border); }
.pos { color: var(--up); font-weight: 600; }
.neg { color: var(--down); font-weight: 600; }
.remove-symbol { background: none; border: none; color: var(--text-muted); cursor: pointer; }
.remove-symbol:hover { color: var(--down); }

.empty-state, .error-state, .loading-state {
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 1rem 0.25rem;
  text-align: center;
}
.error-state { color: var(--down); }

.app-footer {
  text-align: center;
  padding: 1.25rem;
  color: var(--text-muted);
  font-size: 0.75rem;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}
.modal-backdrop.hidden { display: none; }
.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 460px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}
.modal.modal-large { max-width: 720px; }
.modal.modal-large .widget-map,
.modal.modal-large .widget-map-large { height: 320px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { margin: 0; font-size: 1.05rem; }
.modal-body { padding: 1rem; overflow-y: auto; }
.modal-footer { padding: 0.85rem 1rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; }

.field { display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 0.8rem; font-size: 0.82rem; }
.field span { color: var(--text-muted); font-weight: 600; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.03em; }
.field input, .field select {
  padding: 0.5rem 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.88rem;
}
.field-group.hidden { display: none; }

.patch-entry { margin-bottom: 1rem; }
.patch-entry .ver { font-weight: 700; color: var(--accent); }
.patch-entry .date { color: var(--text-muted); font-size: 0.75rem; margin-left: 0.4rem; }
.patch-entry ul { margin: 0.35rem 0 0; padding-left: 1.1rem; font-size: 0.85rem; }

.feeds-modal-actions { display: flex; gap: 0.5rem; margin-bottom: 1rem; flex-wrap: wrap; }
.feeds-modal-actions input.hidden { display: none; }
.feeds-bundle-group {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 0.9rem;
  margin-bottom: 0.8rem;
  background: var(--bg-widget-header);
}
.feeds-bundle-group h4 { margin: 0 0 0.5rem; font-size: 0.9rem; }
.feeds-list { display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 0.6rem; }
.feed-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  cursor: pointer;
}
.feed-row input { accent-color: var(--accent); cursor: pointer; }
.feed-row-name { flex: 1; }
.feed-remove-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 0.1rem 0.3rem;
}
.feed-remove-btn:hover { color: var(--down); }
.add-feed-form { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.add-feed-form input {
  flex: 1;
  min-width: 140px;
  padding: 0.4rem 0.55rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.82rem;
}

/* Mobile responsiveness */
@media (max-width: 640px) {
  .app-header { padding: 0.5rem 0.75rem; flex-wrap: nowrap; }
  .brand-name { font-size: 0.95rem; }
  .version-chip { font-size: 0.62rem; padding: 0.1rem 0.4rem; }

  .mobile-menu-btn { display: flex; align-items: center; justify-content: center; }

  .header-controls {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
    padding: 0.75rem;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
  }
  .header-controls.open { display: flex; }
  .search-wrap { max-width: none; margin: 0; }
  .header-actions { justify-content: space-between; }

  .app-body { flex-direction: column; }
  .sidebar {
    flex: 0 0 auto;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    width: 100%;
    position: static;
    padding: 0.5rem 0.6rem;
    gap: 0.35rem;
    border-bottom: 1px solid var(--border);
  }
  .sidebar-btn { flex: 0 0 auto; white-space: nowrap; padding: 0.4rem 0.6rem; }

  /* Flatter, lighter "list" feel instead of heavy shadowed desktop cards. */
  .widget-grid { grid-template-columns: 1fr; padding: 0; gap: 0; }
  .widget.wide { grid-column: span 1; }
  /* Sidebar collapse is a desktop-only affordance; mobile's horizontal
     strip stays as-is regardless of the toggle state. */
  body.sidebar-collapsed .sidebar { flex: 0 0 auto; width: auto; padding: 0.5rem 0.6rem; overflow-x: auto; }
  body.sidebar-collapsed .sidebar-btn { display: flex; }
  .sidebar-toggle-btn { display: none; }
  /* The expandable per-feed toggle list doesn't fit the mobile sidebar's
     horizontal category strip — use the "🗞 Feeds" header button (also in
     the mobile menu) to manage feeds on small screens instead. */
  .sidebar-feeds-section { display: none; }
  .scroll-lock-btn { bottom: 4rem; }
  .widget {
    border-radius: 0;
    border-left: none;
    border-right: none;
    box-shadow: none;
    border-bottom: 6px solid var(--bg);
    max-height: 340px;
  }
  .widget-header { padding: 0.55rem 0.85rem; }
  .widget-body { padding: 0.4rem 0.85rem; }

  .header-actions .btn span.label { display: none; }
}
