:root {
  --bg: #0b0e11;
  --bg2: #111418;
  --surface: #181c22;
  --surface-hover: #1e2329;
  --border: rgba(255,255,255,0.06);
  --border-light: rgba(255,255,255,0.1);
  --text: #eaecef;
  --text-secondary: #848e9c;
  --text-dim: #5e6673;
  --green: #0ecb81;
  --green-bg: rgba(14,203,129,0.12);
  --red: #f6465d;
  --red-bg: rgba(246,70,93,0.12);
  --accent: #f0b90b;
  --accent-dim: rgba(240,185,11,0.15);
  --radius: 12px;
  --radius-sm: 8px;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ─── STICKY SHELL (header + tabs pinned together) ─── */
.sticky-shell {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(11, 14, 17, 0.92);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
}

/* ─── HEADER ─── */
.header {
  padding: 14px 16px 0;
}

/* Row 1: Brand + right controls */
.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  object-fit: cover;
  box-shadow: 0 2px 12px rgba(240, 185, 11, 0.18);
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.brand-name {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1.15;
}

.brand-accent { color: var(--accent); }

.brand-sub {
  font-size: 0.68rem;
  color: var(--text-dim);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  line-height: 1.3;
}

.header-top-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.live-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  background: var(--green-bg);
  border: 1px solid rgba(14, 203, 129, 0.15);
  border-radius: 20px;
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--green);
  letter-spacing: 0.06em;
  flex-shrink: 0;
}

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse-dot 1.5s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(14,203,129,0.5); }
  50% { opacity: 0.6; box-shadow: 0 0 0 5px rgba(14,203,129,0); }
}

/* Row 2: Update ticker */
.update-ticker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 14px;
  margin-bottom: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--text-dim);
  transition: border-color 0.3s;
}

.update-ticker.fresh {
  border-color: rgba(14, 203, 129, 0.25);
}

.ticker-left {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ticker-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--green);
  opacity: 0.6;
  transition: opacity 0.3s, background 0.3s;
}

.ticker-dot.active {
  opacity: 1;
  animation: pulse-dot 1.5s ease-in-out infinite;
}

.ticker-label {
  font-size: 0.58rem;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.7;
}

.ticker-time {
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.3px;
}

.ticker-time .sec-tick {
  color: var(--green);
  font-weight: 700;
}

.update-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  opacity: 0;
  color: var(--green);
}

.update-indicator.spinning {
  animation: spin 1s linear infinite;
}

.update-indicator.active {
  opacity: 1;
}

.refresh-icon {
  width: 12px;
  height: 12px;
}

.ticker-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ticker-countdown {
  font-size: 0.6rem;
  color: var(--text-dim);
  font-weight: 500;
  letter-spacing: 0.1px;
  opacity: 0.65;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.ticker-coins {
  font-size: 0.6rem;
  color: var(--text-dim);
  font-weight: 600;
  letter-spacing: 0.05em;
  opacity: 0.7;
  white-space: nowrap;
}

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

/* ─── TOOLBAR ─── */
.toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.search-wrap {
  flex: 1;
  position: relative;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  pointer-events: none;
  transition: color 0.2s;
}

.search-wrap:focus-within .search-icon {
  color: var(--accent);
}

.search-wrap input {
  width: 100%;
  padding: 10px 36px 10px 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 0.85rem;
  font-family: inherit;
  font-weight: 500;
  transition: border-color 0.25s, box-shadow 0.25s, background 0.2s;
}

.search-wrap input::placeholder {
  color: var(--text-dim);
  font-weight: 400;
}

.search-wrap input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
  background: var(--bg);
}

.search-clear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--surface-hover);
  color: var(--text-dim);
  cursor: pointer;
  transition: background 0.2s, color 0.2s, opacity 0.2s, transform 0.2s;
  opacity: 1;
}

.search-clear:hover {
  background: var(--red-bg);
  color: var(--red);
}

.search-clear.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-50%) scale(0.7);
}

/* ─── SORT DROPDOWN ─── */
.sort-dropdown {
  position: relative;
  min-width: 140px;
}

.sort-trigger {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-width: 0;
  padding: 10px 10px 10px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.25s, background 0.2s, box-shadow 0.25s;
}

.sort-trigger:hover {
  background: var(--surface-hover);
  border-color: var(--border-light);
}

.sort-trigger:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.sort-dropdown.open .sort-trigger {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.sort-trigger-icon {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  opacity: 0.8;
}

.sort-trigger-text {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sort-arrow {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sort-dropdown.open .sort-arrow {
  transform: rotate(180deg);
}

.sort-arrow svg {
  display: block;
}

.sort-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: auto;
  right: 0;
  min-width: 200px;
  z-index: 200;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(0,0,0,0.4), 0 2px 8px rgba(0,0,0,0.2);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  max-height: 340px;
  overflow-y: auto;
  transform-origin: top right;
  animation: dropdownOpen 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes dropdownOpen {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(-4px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.sort-panel.hidden {
  display: none;
}

.sort-panel-header {
  padding: 8px 12px 6px;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  user-select: none;
}

.sort-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  position: relative;
}

.sort-opt-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--text-dim);
  transition: color 0.15s;
}

.sort-check {
  margin-left: auto;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s;
}

.sort-check::after {
  content: '';
  display: block;
  width: 16px;
  height: 16px;
  background: var(--accent);
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E") center/contain no-repeat;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E") center/contain no-repeat;
}

.sort-option:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.sort-option:hover .sort-opt-icon {
  color: var(--text-secondary);
}

.sort-option.active {
  background: var(--accent-dim);
  color: var(--accent);
}

.sort-option.active .sort-opt-icon {
  color: var(--accent);
}

.sort-option.active .sort-check {
  opacity: 1;
}

/* ─── THEME TOGGLE ─── */
.theme-toggle {
  flex-shrink: 0;
}

.theme-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.theme-btn:hover {
  background: var(--surface-hover);
  border-color: var(--border-light);
  color: var(--text);
}

.theme-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
}

.theme-icon.hidden {
  display: none;
}

.theme-icon svg {
  display: block;
}

/* ─── MAIN ─── */
.main {
  flex: 1;
  padding: 0 16px 20px;
}

.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 48px 16px;
  color: var(--text-dim);
  font-size: 0.85rem;
}

.loading-pulse {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

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

/* ─── SKELETON LOADERS ─── */
.skeleton-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.skeleton-container.hidden {
  display: none;
}

.skeleton-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 8px;
  border-radius: 8px;
  background: var(--surface);
}

.skeleton-icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(90deg, var(--surface-hover) 25%, var(--surface) 50%, var(--surface-hover) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
}

.skeleton-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.skeleton-line {
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--surface-hover) 25%, var(--surface) 50%, var(--surface-hover) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
}

.skeleton-line-sm {
  width: 60%;
}

.skeleton-line-md {
  width: 80%;
}

.skeleton-line-lg {
  width: 100%;
}

.skeleton-price {
  flex-shrink: 0;
  width: 70px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.skeleton-price .skeleton-line {
  width: 100%;
  height: 10px;
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ─── COIN LIST ─── */
.coin-list {
  list-style: none;
}

.coin-row {
  display: grid;
  grid-template-columns: 32px 44px 1fr 1fr;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
  cursor: default;
}

@media (min-width: 480px) {
  .coin-row {
    grid-template-columns: 32px 44px 1fr 140px;
  }
}

.coin-row:last-child { border-bottom: none; }

.coin-row {
  cursor: pointer;
}
.coin-row:hover {
  background: var(--surface);
  margin: 0 -16px;
  padding-left: 16px;
  padding-right: 16px;
}

/* Rank */
.cr-rank {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-dim);
  text-align: center;
}

/* Icon */
.cr-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* Name block */
.cr-info {
  min-width: 0;
}

.cr-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.cr-symbol {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  font-weight: 500;
  letter-spacing: 0.03em;
  line-height: 1.3;
}

.cr-detail-line {
  margin-top: 3px;
  font-size: 0.65rem;
  color: var(--text-dim);
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
}

.cr-detail-line .cr-change-abs { font-weight: 600; }
.cr-detail-line .cr-change-abs.positive { color: var(--green); }
.cr-detail-line .cr-change-abs.negative { color: var(--red); }

.cr-right {
  text-align: right;
}

.cr-price {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
  transition: color 0.3s;
}

.cr-price.flash-green { color: var(--green); }
.cr-price.flash-red { color: var(--red); }

.cr-pct {
  font-size: 0.75rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
  line-height: 1.2;
}

.cr-pct.positive { color: var(--green); }
.cr-pct.negative { color: var(--red); }
.cr-pct.neutral { color: var(--text-dim); }

/* Expand arrow */
.cr-expand-arrow {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  opacity: 0.5;
  transition: transform 0.25s ease, opacity 0.2s;
}
.cr-expand-arrow::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  margin: -4px 0 0 -4px;
  border: 2px solid currentColor;
  border-top: none;
  border-left: none;
  width: 6px;
  height: 6px;
  transform: rotate(45deg);
  box-sizing: border-box;
}
.coin-row.expanded .cr-expand-arrow {
  transform: translateY(-50%) rotate(180deg);
  opacity: 1;
}
.coin-row .cr-right {
  position: relative;
  padding-right: 24px;
}

/* ─── Раскрывающаяся панель графика ─── */
.coin-detail-panel {
  list-style: none;
  margin: 0 -16px;
  padding: 0 16px 16px;
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg2) 100%);
  border-bottom: 1px solid var(--border);
  animation: panelOpen 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes panelOpen {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
.chart-panel-inner {
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg2);
  border: 1px solid var(--border);
}
.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  gap: 8px;
  border-bottom: 1px solid var(--border);
}
.chart-legend {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.72rem;
  color: var(--text);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  min-height: 20px;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chart-legend-time {
  color: var(--text-dim);
  font-weight: 500;
  font-size: 0.68rem;
}
.chart-legend-price {
  color: var(--text);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: 0.78rem;
}
.chart-period-tabs {
  display: flex;
  gap: 2px;
  padding: 3px;
  background: var(--surface);
  border-radius: 8px;
  flex-shrink: 0;
}
.chart-period-btn {
  padding: 6px 10px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-dim);
  font-size: 0.68rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s ease;
  letter-spacing: 0.02em;
}
.chart-period-btn:hover {
  color: var(--text-secondary);
  background: var(--surface-hover);
}
.chart-period-btn.active {
  background: var(--accent-dim);
  color: var(--accent);
  box-shadow: none;
}
.chart-container {
  min-height: 220px;
  overflow: hidden;
  position: relative;
  background: var(--bg2);
}
.chart-placeholder {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.78rem;
  color: var(--text-dim);
  font-weight: 500;
  z-index: 1;
}
.coin-chart-svg {
  display: block;
  width: 100%;
  height: 100px;
}

/* Sparkline row (sub-row) */
.cr-sparkline-row {
  padding: 0 0 10px 88px;
  border-bottom: 1px solid var(--border);
}

@media (max-width: 360px) {
  .cr-sparkline-row { padding-left: 44px; }
}

.cr-sparkline-row svg {
  display: block;
  width: 100%;
  height: 28px;
}

.spark-positive { stroke: var(--green); }
.spark-negative { stroke: var(--red); }

/* ─── LOAD MORE ─── */
.load-more {
  text-align: center;
  padding: 20px 0;
}

.load-more button {
  padding: 12px 32px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.load-more button:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
}

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

/* ─── FOOTER ─── */
.footer {
  text-align: center;
  padding: 16px;
  border-top: 1px solid var(--border);
}

.footer-text {
  font-size: 0.72rem;
  color: var(--text-dim);
  font-weight: 500;
}

/* ─── ERROR ─── */
.error {
  padding: 20px;
  text-align: center;
  color: var(--red);
  font-size: 0.85rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.error-msg {
  display: block;
}

.error-retry {
  padding: 10px 20px;
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.error-retry:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
}

.hidden { display: none !important; }

/* ─── RESPONSIVE ─── */\n@media (max-width: 380px) {
  .coin-row {
    grid-template-columns: 24px 36px 1fr 95px;
    gap: 8px;
    padding: 12px 0;
  }
  .cr-icon { width: 30px; height: 30px; }
  .cr-name { font-size: 0.82rem; }
  .cr-price { font-size: 0.82rem; }
  .cr-pct { font-size: 0.7rem; }
  .cr-detail-line { font-size: 0.62rem; }
  .header { padding: 10px 12px 0; }
  .main { padding: 0 12px 16px; }
  .coin-detail-panel { margin: 0 -12px; padding: 0 12px 12px; }
  .chart-container { min-height: 200px; }
  .chart-header { padding: 8px 10px; flex-wrap: wrap; }
  .chart-period-btn { padding: 5px 8px; font-size: 0.64rem; }
  .sort-trigger-icon { display: none; }
  .sort-trigger { padding: 10px 8px; font-size: 0.75rem; }
  .sort-panel { min-width: 180px; }
  .sort-opt-icon { display: none; }
}

@media (min-width: 520px) {
  .coin-row {
    grid-template-columns: 32px 44px 1fr 150px;
  }
}

/* ─── СВЕТЛАЯ ТЕМА ─── */
body.theme-light {
  --bg: #f5f6f8;
  --bg2: #eef0f2;
  --surface: #ffffff;
  --surface-hover: #f0f2f5;
  --border: rgba(0,0,0,0.08);
  --border-light: rgba(0,0,0,0.12);
  --text: #1e2329;
  --text-secondary: #474d57;
  --text-dim: #707a8a;
  --green: #0ecb81;
  --green-bg: rgba(14,203,129,0.12);
  --red: #f6465d;
  --red-bg: rgba(246,70,93,0.12);
  --accent: #f0b90b;
  --accent-dim: rgba(240,185,11,0.2);
}

body.theme-light .sticky-shell {
  background: rgba(245, 246, 248, 0.92);
}

body.theme-light .update-ticker {
  background: var(--surface);
  border-color: var(--border);
}

body.theme-light .sort-panel {
  box-shadow: 0 12px 40px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.08);
  border-color: rgba(0,0,0,0.1);
}

/* ─── SCROLLBAR ─── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* TV Chart overrides */
.chart-container .tv-lightweight-charts { border-radius: 0 0 var(--radius) var(--radius); }
.chart-container table { font-family: 'Manrope', -apple-system, sans-serif !important; }

/* ═══════════════════════════════════════════
   TAB NAVIGATION
   ═══════════════════════════════════════════ */
.tab-nav {
  display: flex;
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
}

.tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 9px 0 8px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.tab-btn:active { opacity: 0.7; }

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-btn svg {
  width: 14px;
  height: 14px;
  opacity: 0.5;
  flex-shrink: 0;
  transition: opacity 0.2s;
}

.tab-btn.active svg {
  opacity: 1;
  stroke: var(--accent);
}

/* ─── NEWS CARDS ─── */
.news-list {
  padding: 8px 12px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.news-empty {
  text-align: center;
  color: var(--text-dim);
  padding: 40px 0;
  font-size: 0.95rem;
}

.news-card {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s;
}

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

.news-card-img {
  width: 100%;
  height: 180px;
  overflow: hidden;
  background: var(--bg2);
}

.news-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.news-card-body {
  padding: 12px 14px 14px;
}

.news-card-time {
  font-size: 0.72rem;
  color: var(--text-dim);
  font-weight: 500;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.news-card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.35;
  margin-bottom: 6px;
}

.news-card-desc {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ─── NEWS READER ─── */
.news-reader {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 200;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.news-reader-topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(11, 14, 17, 0.92);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  flex-shrink: 0;
}

.news-reader-topbar .brand {
  flex: 1;
  min-width: 0;
}

.news-reader-topbar .brand-logo {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  box-shadow: none;
}

.news-reader-topbar .brand-name {
  font-size: 1rem;
}

.news-reader-topbar .brand-sub {
  display: none;
}

.news-reader-topbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.news-reader-back {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  display: flex;
  align-items: center;
}

.news-reader-back:active { background: var(--accent-dim); }

.news-reader-title {
  flex: 1;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.news-reader-source {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  display: flex;
  align-items: center;
}

.news-reader-source:active { background: var(--accent-dim); }

.news-reader-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
}

.news-reader-img {
  width: 100%;
  border-radius: var(--radius);
  margin-bottom: 16px;
  display: block;
}

.news-reader-h1 {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.3;
  margin-bottom: 8px;
}

.news-reader-date {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-bottom: 16px;
  font-weight: 500;
}

.news-reader-text {
  font-size: 0.92rem;
  color: var(--text-secondary);
  line-height: 1.65;
}

.news-reader-text p {
  margin-bottom: 14px;
}

.news-reader-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-dim);
  font-size: 0.85rem;
  padding: 20px 0;
}

.news-reader-loading .loading-pulse {
  width: 20px;
  height: 20px;
}

.news-reader-link {
  display: inline-block;
  margin-top: 20px;
  padding: 10px 18px;
  background: var(--accent-dim);
  color: var(--accent);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s;
}

.news-reader-link:active {
  background: var(--accent);
  color: #000;
}

body.theme-light .news-card {
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

body.theme-light .news-reader {
  background: #fff;
}

body.theme-light .news-reader-topbar {
  background: rgba(245, 246, 248, 0.95);
}
