/* Berkeley Mono font - included for everyone */
@font-face {
  font-family: 'Berkeley Mono';
  font-style: normal;
  font-weight: 400;
  src: url('./BerkeleyMono-Regular.otf') format('opentype');
  font-display: swap;
}

@font-face {
  font-family: 'Berkeley Mono';
  font-style: normal;
  font-weight: 500;
  font-weight: 700;
  src: url('./BerkeleyMono-Bold.otf') format('opentype');
  font-display: swap;
}

@font-face {
  font-family: 'CommitMono';
  font-style: normal;
  font-weight: 400;
  src: url('./CommitMono-350-Regular.otf') format('opentype');
  font-display: swap;
}

@font-face {
  font-family: 'DepartureMono';
  font-style: normal;
  font-weight: 400;
  src: url('./DepartureMono-Regular.woff2') format('woff2'),
    url('./DepartureMono-Regular.woff') format('woff');
  font-display: swap;
}

:root {
  /* Font Variables */
  --font-main: 'Berkeley Mono', 'Courier New', monospace;

  /* Solarized Light - Zen palette */
  --bg: #fdf6e3;
  --bg-elev: #eee8d5;
  --text: #657b83;
  --text-bright: #000000;
  --muted: #93a1a1;
  --accent: #000000;
  --border: #d9d2c2;
  --card-bg: #fffdf7;
  --green: #00a25d;
  --red: #fe3a3a;
  --orange: #cb4b16;
  --yellow: #b58900;
  --cyan: #2aa198;
  --flash-start: color-mix(in srgb, var(--accent) 30%, transparent);
  --flash-mid: color-mix(in srgb, var(--accent) 15%, transparent);
}

html[data-theme="light"] {
  /* Light */
  --bg: #fdf6e3;
  --bg-elev: #eee8d5;
  --text: #596b72;
  --text-bright: #000000;
  --muted: #93a1a1;
  --accent: #000000;
  --border: #d9d2c265;
  --card-bg: #fffdf7;
  --green: #00a25d;
  --red: #fe3a3a;
  --orange: #cb4b16;
  --yellow: #b58900;
  --cyan: #2aa198;
  --flash-start: color-mix(in srgb, var(--accent) 30%, transparent);
  --flash-mid: color-mix(in srgb, var(--accent) 15%, transparent);
}

html[data-theme="astronomy"] {
  /* Astronomy Mode */
  --bg: #000000;
  --bg-elev: #1a0000;
  --text: #f00;
  --text-bright: #f00;
  --muted: #f00;
  --accent: #f00;
  --border: rgba(255, 68, 68, 0.2);
  --card-bg: #0d0000;
  --green: #f00;
  --red: #f00;
  --orange: #f00;
  --yellow: #f00;
  --cyan: #f00;
  --flash-start: color-mix(in srgb, var(--accent) 30%, transparent);
  --flash-mid: color-mix(in srgb, var(--accent) 15%, transparent);
}

html[data-theme="yellow-terminal"] {
  /* Yellow Terminal */
  --bg: #000;
  --bg-elev: #1a1000;
  --text: #ffbf00;
  --text-bright: #ffbf00;
  --muted: #cc9900;
  --accent: #ffbf00;
  --border: #211900;
  --card-bg: #0a0800;
  --green: #ffbf00;
  --red: #ffbf00;
  --orange: #ffbf00;
  --yellow: #ffbf00;
  --cyan: #ffbf00;
  --flash-start: color-mix(in srgb, var(--accent) 30%, transparent);
  --flash-mid: color-mix(in srgb, var(--accent) 15%, transparent);
}

html[data-theme="eva01"] {
  /* EVA01 - Evangelion Unit-01 */
  --bg: #000000;
  --bg-elev: #1a0f1a;
  --text: #a78bfa;
  --text-bright: #c4b5fd;
  --muted: #a78bfa;
  --accent: #a78bfa;
  --border: #2d1b3d8a;
  --card-bg: #0d0a0d;
  --green: #22c55e;
  --red: #FE8600;
  --orange: #FE8600;
  --yellow: #eab308;
  --cyan: #22c55e;
  --flash-start: color-mix(in srgb, var(--accent) 30%, transparent);
  --flash-mid: color-mix(in srgb, var(--accent) 15%, transparent);
}

html[data-theme="lcars"] {
  /* LCARS - Star Trek: The Next Generation */
  --bg: #000000;
  --bg-elev: #1a0d00;
  --text: #FF9900;
  --text-bright: #FFCC99;
  --muted: #CC9966;
  --accent: #FF9900;
  --border: rgba(255, 153, 0, 0.1);
  --card-bg: #0a0500;
  --green: #9999FF;
  --red: #CC6699;
  --orange: #FF9900;
  --yellow: #FFCC00;
  --cyan: #9999FF;
  --flash-start: color-mix(in srgb, var(--accent) 30%, transparent);
  --flash-mid: color-mix(in srgb, var(--accent) 15%, transparent);
}

* {
  box-sizing: border-box;
  font-family: var(--font-main) !important;
}

input,
select,
textarea,
button {
  font-family: var(--font-main) !important;
}

body.font-commit {
  --font-main: 'CommitMono', monospace;
}

body.font-departure {
  --font-main: 'DepartureMono', monospace;
}



a {
  color: var(--accent);
}

/* Greeting container with loader */
.greeting-container {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Mini loader in header */
.mini-loader {
  display: grid;
  grid-template-columns: repeat(4, 1.5px);
  grid-template-rows: repeat(4, 1.5px);
  gap: 2px;
  width: 12px;
  height: 12px;
  margin-left: 5px;
}

.mini-loader .dot {
  width: 1.5px;
  height: 1.5px;
}

/* Mobile adjustments for mini loader */
@media (max-width: 870px) {
  .greeting-container {
    gap: 8px;
  }
}

/* Flash animation for real-time updates */
@keyframes flash-update {
  0% {
    opacity: 0.3;
  }

  50% {
    opacity: 0.5;
  }

  100% {
    opacity: 1;
  }
}

@keyframes cell-flash {
  0% {
    background-color: var(--flash-start);
  }

  50% {
    background-color: var(--flash-mid);
  }

  100% {
    background-color: transparent;
  }
}

.cell-flash {
  animation: cell-flash 0.6s ease-out;
}

.flash-update {
  animation: flash-update 0.2s ease-out;
}

html {
  font-size: 15px;
  /* Default, overridden by JS */
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-main) !important;
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  position: relative;
  min-height: 100vh;
  /* Performance: Enable GPU acceleration and optimize font rendering */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeSpeed;
}

/* Disable scroll when modal or settings is open (mobile) */
@media (max-width: 870px) {
  body.modal-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
    touch-action: none;
  }
}

/* Wallpaper overlay to maintain readability */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--bg);
  opacity: 0.85;
  z-index: -1;
  pointer-events: none;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-size: inherit;
  font-weight: inherit;
  margin: 0;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 32px 0;
  gap: 16px;
}

.app-header .greeting {
  margin: 0;
  font-weight: 300;
  color: var(--text);
  line-height: 1.2;
}

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

.header-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.btn-text {
  background: transparent;
  border: none;
  font-family: var(--font-main) !important;
  font-size: inherit;
  font-weight: 400;
  cursor: pointer;
  color: var(--muted);
  padding: 0;
  text-transform: uppercase;
  opacity: .6
}

.btn-text:hover {
  color: var(--text);
}

.btn-text-accent {
  background: var(--accent);
  border: none;
  font-family: var(--font-main) !important;
  font-size: inherit;
  font-weight: 400;
  cursor: pointer;
  color: var(--bg);
  padding: 6px;
  text-transform: uppercase;
  opacity: 1;
}

.btn-text-accent:hover {
  opacity: 0.8;
}

.btn-text-accent.active {
  background: var(--accent);
  color: var(--bg);
  opacity: 1;
}

.btn-text.active {
  background: var(--accent);
  color: var(--bg);
  opacity: 1;
}

.btn-tab {
  background: transparent;
  border: none;
  font-family: var(--font-main) !important;
  font-size: inherit;
  font-weight: 400;
  cursor: pointer;
  color: var(--muted);
  padding: 6px 0;
  text-transform: uppercase;
  opacity: .6;
}

.btn-tab:hover {
  color: var(--text);
  opacity: 1;
}

.btn-tab.active {
  background: var(--accent);
  color: var(--bg);
  opacity: 1;
  padding: 6px;
}

.font-size-controls {
  display: flex;
  gap: 4px;
  align-items: center;
}

.font-size-controls #fontSizeDisplay {
  min-width: 32px;
  text-align: center;
}

.btn {
  background: var(--accent);
  color: #fdf6e3;
  border: 1px solid var(--accent);
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 400;
  font-size: inherit;
  font-family: var(--font-main) !important;
}

.btn:hover {
  opacity: 0.8;
}

.btn-small {
  padding: 6px 10px;
}

.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: none;
}

.btn-secondary:hover {
  background: var(--bg-elev);
  border-color: var(--accent);
}

.container {
  max-width: 870px;
  padding: 0 32px 60px;
}

/* Hero Section */
.hero {
  padding: 20px 0 0;
  text-align: left;
  transition: opacity 0.2s ease;
}

.hero:hover {
  opacity: 0.8;
}

.hero:active {
  opacity: 0.6;
}

.hero-summary {
  line-height: 1.7;
  margin: 0;
  max-width: 800px;
  font-weight: 300;
}

.hero-summary strong {
  color: var(--text);
  font-weight: 500;
}

/* Data Section */
.data-section {
  margin-top: 28px;
}

.section-title {
  font-weight: 400;
  color: var(--muted);
  text-transform: uppercase;
  margin: 0 0 12px;
}

.section-title[style*="cursor: pointer"]:hover {
  opacity: 0.7;
}

/* Data Table */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-main) !important;
}

.data-table thead {
  border-bottom: none;
}

.data-table th {
  text-align: left;
  font-weight: 400;
  color: var(--muted);
  padding: 8px 12px 8px 0;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  opacity: 0.6;
  white-space: nowrap;
}

.data-table td {
  padding: 14px 12px 14px 0;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.data-table tbody tr:last-child td {
  border-bottom: 1px solid var(--border);
}

.data-table .loading {
  text-align: center !important;
  color: var(--muted);
  padding: 40px;
}

.loading-terminal {
  color: var(--muted);
  animation: terminal-blink 1.5s ease-in-out infinite;
}

@keyframes terminal-blink {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.3;
  }
}

@keyframes pulse-fade {

  0%,
  100% {
    opacity: 0.3;
  }

  50% {
    opacity: 0.6;
  }
}

/* Hero pulsing animation (same as comics) */
#newSummary.fading {
  animation: pulse-fade 2s ease-in-out infinite !important;
}

/* Sparkline Charts */
.chart-cell {
  vertical-align: middle;
  padding: 0 8px !important;
}

.sparkline {
  display: inline-block;
  vertical-align: middle;
  width: 60px;
  height: 24px;
  shape-rendering: geometricPrecision;
}

.sparkline polyline {
  vector-effect: non-scaling-stroke;
}

.cell-loading,
.chart-loading {
  color: var(--muted);
  font-size: 0.9em;
  animation: pulse-fade 1s ease-in-out infinite;
}

/* Ensure chart header is never orphaned */
.th-chart {
  white-space: nowrap;
}

/* === VISIBILITY CONTROLS VIA BODY CLASSES === */

/* Hide chart columns when charts are disabled */
body.no-charts .chart {
  display: none !important;
}

/* Watchlist table 3-column layout when charts are hidden - align with positions */
body.no-charts #newWatchlistTable {
  table-layout: fixed;
}

/* Match positions Asset column width */
body.no-charts #newWatchlistTable th:nth-child(1),
body.no-charts #newWatchlistTable td:nth-child(1) {
  width: 90px;
}

/* Match positions Price column width */
body.no-charts #newWatchlistTable th:nth-child(2),
body.no-charts #newWatchlistTable td:nth-child(2) {
  width: 90px;
}

/* 24H% takes remaining space */
body.no-charts #newWatchlistTable th:last-child,
body.no-charts #newWatchlistTable td:last-child {
  width: auto;
}

/* Button visibility controls */
body.hide-snow-btn #newToggleSnowBtn,
body.hide-snow-btn #newToggleSnowBtnMobile {
  display: none !important;
}

body.hide-rain-btn #newToggleRainBtn,
body.hide-rain-btn #newToggleRainBtnMobile {
  display: none !important;
}

body.hide-font-size .font-size-controls {
  display: none !important;
}

body.hide-theme-btn .theme-select-wrapper {
  display: none !important;
}

body.hide-amounts-btn #newToggleAmountsBtn,
body.hide-amounts-btn #newToggleAmountsBtnMobile {
  display: none !important;
}



body.hide-donate-btn #newDonateBtn,
body.hide-donate-btn #newDonateBtnMobile {
  display: none !important;
}

body.hide-stickers-btn #newStickersBtn,
body.hide-stickers-btn #newStickersBtnMobile {
  display: none !important;
}

/* Section visibility controls */
body.hide-watchlist #watchlistSection,
body.hide-watchlist #newWatchlistSection {
  display: none !important;
}

body.hide-comic #comicSection,
body.hide-comic #newComicSection {
  display: none !important;
}

/* Performance: CSS containment for better rendering */
.data-table,
.position-card,
.watchlist-search-result,
.card {
  contain: layout style;
}

.hero,
.section {
  contain: layout style paint;
}

.asset-cell {
  font-weight: 500;
}

.exchange-cell {
  color: var(--muted);
}

.exchange-link {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
}

.exchange-link:hover {
  color: var(--accent);
  text-decoration-style: solid;
  opacity: 0.8;
}

.positive-pnl {
  color: var(--green) !important;
  font-weight: 500;
}

.negative-pnl {
  color: var(--red) !important;
  font-weight: 500;
}

.positive-neutral {
  color: var(--text-bright) !important;
  font-weight: 500;
}

.negative-neutral {
  color: var(--muted) !important;
  font-weight: 400;
  opacity: 0.6;
}

.neutral-value {
  color: var(--text) !important;
  font-weight: 400;
  opacity: 0.9;
}

.list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.list-inline {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 10px;
}

.row {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  max-width: 100%;
  overflow-x: hidden;
  box-sizing: border-box;
}

.settings-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  cursor: pointer;
}

.settings {
  border: 1px solid var(--border);
  padding: 0;
  color: var(--text);
  background: var(--bg);
  font-family: var(--font-main) !important;
  overflow-x: hidden;
  box-sizing: border-box;
  position: fixed;
  right: 0;
  top: 0;
  height: 100%;
  border-left: 1px solid var(--border);
  border-right: none;
  border-top: none;
  border-bottom: none;
  width: clamp(300px, 80vw, 500px);
  max-width: 500px;
  z-index: 1000;
}

.settings-form {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.settings-form section {
  flex: 1;
  overflow-y: auto;
  padding: 0 15px 15px 15px;
}

.settings-form header,
.settings-actions {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  box-sizing: border-box;
  overflow-x: hidden;
}

/* Settings Tabs */
.settings-tabs {
  display: flex;
  gap: 4px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  overflow-x: auto;
  flex-wrap: nowrap;
  -webkit-overflow-scrolling: touch;
}

.settings-tab {
  padding: 12px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  cursor: pointer;
  font-family: inherit;
  font-size: 1em;
  font-weight: 500;
  letter-spacing: 0.5px;
  transition: all 0.2s ease;
  white-space: nowrap;
  flex-shrink: 0;
}

.settings-tab:hover {
  color: var(--text);
  background: var(--border);
}

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

.settings-tab-content {
  display: none;
}

.settings-tab-content.active {
  display: block;
}

.settings-tab-content.show-all-mode {
  display: block !important;
}

.settings-form fieldset,
.settings-form label,
.settings-form .slider-controls {
  max-width: 100%;
  box-sizing: border-box;
}

.settings-form input:not([type="checkbox"]),
.settings-form select,
.settings-form textarea {
  max-width: 100%;
  box-sizing: border-box;
}

.settings-form textarea {
  resize: vertical;
  min-height: 3.5em;
}

.settings-actions {
  border-bottom: none;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  position: sticky;
  bottom: 0;
  background: var(--bg);
  max-width: 500px;
  box-sizing: border-box;
}

.settings-actions button {
  flex-shrink: 0;
}

.settings-export-area {
  height: 80px;
  font-family: monospace;
  font-size: 1em;
  background-color: var(--border);
  border: none;
  resize: none;
  width: 100%;
  outline: none;
  color: var(--text);
  padding: 8px;
  cursor: pointer;
  box-sizing: border-box;
}

.settings-export-area:focus {
  background-color: var(--bg-elev);
  cursor: text;
}

.settings-form section {
  padding: 16px;
  display: grid;
  gap: 12px;
  overflow-x: hidden;
  max-width: 100%;
  box-sizing: border-box;
}

fieldset {
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 0;
  padding-bottom: 16px;
  margin-bottom: 16px;
  background: transparent;
  max-width: 100%;
  box-sizing: border-box;
}

legend {
  padding: 0;
  margin-bottom: 10px;
  color: var(--accent);
  font-weight: 400;
  text-transform: uppercase;
  max-width: 100%;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

label {
  display: grid;
  gap: 6px;
  margin-top: 10px;
  color: var(--text);
  max-width: 100%;
  overflow-x: hidden;
  box-sizing: border-box;
}

label:first-of-type {
  margin-top: 0;
}

/* Checkbox labels should not be grid */
label[style*="display: flex"] {
  display: flex !important;
}

input[type="checkbox"] {
  width: 16px !important;
  height: 16px !important;
  min-width: 16px;
  min-height: 16px;
  max-width: 16px;
  max-height: 16px;
  margin: 0;
  padding: 0;
  cursor: pointer;
  flex-shrink: 0;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  border: 1px solid var(--text);
  background: var(--bg);
  position: relative;
}

input[type="checkbox"]:checked {
  background: var(--text);
}

h3 {
  text-transform: uppercase;
  color: var(--muted);
  max-width: 100%;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

input,
select,
textarea,
button {
  background: var(--card-bg);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 10px;
  font-family: var(--font-main) !important;
  font-size: inherit;
  max-width: 100%;
  box-sizing: border-box;
}

/* Text fields styling */
input:not([type="checkbox"]):not([type="range"]),
textarea {
  background-color: var(--border);
  color: var(--accent);
  border: none;
}

input:not([type="checkbox"]),
select,
textarea {
  width: 100%;
}

button,
input[type="checkbox"] {
  width: auto;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
}

/* Placeholder text styling */
input::placeholder,
textarea::placeholder {
  color: var(--muted);
  opacity: 1;
}

input::-webkit-input-placeholder,
textarea::-webkit-input-placeholder {
  color: var(--muted);
  opacity: 1;
}

input::-moz-placeholder,
textarea::-moz-placeholder {
  color: var(--muted);
  opacity: 1;
}

.help {
  color: var(--muted);
  max-width: 100%;
  overflow-wrap: break-word;
  word-wrap: break-word;
  padding: 10px;
  background-color: var(--border);
}

.info {
  color: var(--muted);
  max-width: 100%;
  overflow-wrap: break-word;
}

.status-info {
  color: var(--muted);
  max-width: 100%;
  overflow-wrap: break-word;
}

.item-row {
  display: grid;
  grid-template-columns: minmax(100px, 140px) 1fr minmax(80px, 120px) auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
  max-width: 100%;
  overflow-x: hidden;
  box-sizing: border-box;
}

.item-row-wide {
  grid-template-columns: minmax(80px, 100px) minmax(100px, 120px) minmax(80px, 100px) minmax(80px, 100px) auto;
}

.manual-positions-header {
  font-size: 1em;
  color: var(--muted);
  margin-bottom: 4px;
  font-weight: 400;
}

.manual-positions-header span {
  text-transform: uppercase;
}

.item-row .remove-btn {
  padding: 0;
}

.crypto-item {
  padding: 12px;
  background: transparent;
  margin-bottom: 8px;
  border: 1px solid var(--border);
}

.crypto-item:hover {
  background: transparent;
  opacity: 0.8;
}

.crypto-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.crypto-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
}

.change {
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: auto;
}

.change.positive {
  background: rgba(0, 208, 119, 0.1) !important;
  color: var(--green) !important;
}

.change.negative {
  background: rgba(254, 58, 58, 0.1) !important;
  color: var(--red) !important;
}

.crypto-details {
  color: var(--muted);
}

.pnl {
  margin-top: 4px;
  padding: 4px 8px;
  border-radius: 4px;
  display: inline-block;
}

.pnl.positive {
  background: rgba(0, 208, 119, 0.12) !important;
  color: var(--green) !important;
  font-weight: 500;
}

.pnl.negative {
  background: rgba(254, 58, 58, 0.12) !important;
  color: var(--red) !important;
  font-weight: 500;
}

.pnl-summary {
  margin-left: 8px;
  font-weight: 500;
}

.pnl-summary.positive {
  color: var(--green) !important;
}

.pnl-summary.negative {
  color: var(--red) !important;
}

.exchange-badge {
  background: rgba(38, 139, 210, 0.1);
  color: var(--accent);
  padding: 3px 10px;
  border-radius: 12px;
  font-weight: 600;
  margin-left: auto;
  border: 1px solid rgba(38, 139, 210, 0.2);
}

.calvin-container {
  display: flex;
}

.comic-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

#comicSection.collapsed .comic-header {
  justify-content: flex-start;
}

.comic-tabs {
  display: flex;
  gap: 16px;
  align-items: center;
}

.comic-tab {
  background: none;
  border: none;
  color: var(--text);
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  padding: 0;
  opacity: 0.4;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.comic-tab:hover {
  opacity: 0.7;
}

.comic-tab.active {
  opacity: 1;
}

.tab-mobile {
  display: none;
}

.comic-toggle {
  opacity: 0.6;
  white-space: nowrap;
}

.comic-toggle:hover {
  opacity: 1;
}

#comicSection.collapsed .comic-toggle {
  flex: 1;
  display: flex;
}

.toggle-collapsed {
  display: none;
}

#comicSection.collapsed .toggle-collapsed {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.comic-content {
  display: block;
}

#comicSection.collapsed .comic-content {
  display: none;
}

#comicSection.collapsed .toggle-expanded {
  display: none;
}

#comicSection.collapsed .toggle-collapsed {
  display: flex;
}

#comicSection.collapsed .comic-tabs {
  display: none;
}

.calvin-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 16px;
}

.button-row {
  display: flex;
  gap: 8px;
  margin: 6px 0;
}

.calvin-controls-mobile {
  display: none;
  gap: 8px;
  margin: 6px 0;
  flex-wrap: wrap;
}

.calvin-container img,
#newComic img {
  max-width: 100%;
  max-height: 500px;
  height: auto;
  border: 1px solid var(--border);
}

/* Far Side comics - full width on all screen sizes */
#newComic img[data-comic-type="farside"] {
  max-height: none;
  width: 100%;
}

.calvin-container.fading,
#newComic.fading {
  animation: pulse-fade 2s ease-in-out infinite !important;
}

#calvinImage {
  width: 100%;
  display: flex;
  justify-content: center;
}

/* Mobile Position Cards */
.mobile-positions-container {
  display: none;
}

.mobile-position-card {
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.card-asset {
  font-weight: 500;
  color: var(--text);
}

.card-exchange {
  color: var(--muted);
}

.card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 8px;
  max-width: 100%;
}

.card-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  overflow: hidden;
}

.card-field-wide {
  grid-column: 1 / -1;
}

.card-label {
  font-size: 1em;
  color: var(--muted);
  opacity: 0.6;
  text-transform: uppercase;
}

.card-value {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
}

.mobile-menu {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg);
  z-index: 1000;
  flex-direction: column;
}

.mobile-menu.active {
  display: flex;
}

/* Theme select wrapper and label */
.theme-select-wrapper {
  position: relative;
  display: inline-block;
  vertical-align: middle;
}

.theme-select-label {
  pointer-events: none;
  color: var(--muted);
  opacity: .6;
  font-family: var(--font-main) !important;
  font-size: inherit;
  font-weight: 400;
  line-height: 1.2;
  text-transform: uppercase;
  white-space: nowrap;
}

.theme-select-wrapper:hover .theme-select-label {
  color: var(--text);
  opacity: 1;
}

/* Theme select styled as btn-text */
.theme-select-btn {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background: transparent;
  border: none;
  color: transparent;
  cursor: pointer;
  margin: 0;
  padding: 0;
  font-family: var(--font-main) !important;
  font-size: inherit;
  font-weight: 400;
  line-height: 1.2;
  text-transform: uppercase;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* Remove dropdown arrow */
.theme-select-btn::-ms-expand {
  display: none;
}

.theme-select-btn:focus {
  outline: none;
}

.theme-select-btn:focus~.theme-select-label,
.theme-select-wrapper:focus-within .theme-select-label {
  color: var(--text);
  opacity: 1;
}

.theme-select-btn option {
  background: var(--bg);
  color: var(--text);
}


/* Prevent body scrolling when mobile menu is open */
body.mobile-menu-open {
  overflow: hidden;
  position: fixed;
  width: 100%;
  height: 100%;
}

.mobile-menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  gap: 16px;
}

.mobile-menu-header .greeting {
  margin: 0;
  font-weight: 300;
  color: var(--text);
  line-height: 1.2;
}

.mobile-menu-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
  align-items: flex-start;
  padding: 0 20px;
  flex: 1;
  overflow-y: auto;
}

.mobile-menu-footer {
  padding: 20px;
  margin-top: auto;
}

.mobile-menu-content .font-size-controls {
  display: flex;
  align-items: center;
}

/* Tablet breakpoint - switch to mobile menu to prevent nav wrapping */
@media (max-width: 1020px) {
  .header-actions {
    display: none;
  }

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

@media (max-width: 870px) {
  body {
    overflow-x: hidden;
  }

  /* Prevent auto-zoom on input focus */
  input,
  select,
  textarea {
    font-size: 16px !important;
  }

  .app-header {
    padding: 20px 20px 0;
  }

  .header-actions {
    display: none;
  }

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

  .container {
    padding: 0 20px 48px;
    max-width: 100%;
    overflow-x: hidden;
  }

  .hero {
    padding: 20px 0 0;
  }

  /* Hide desktop table, show mobile cards */
  .data-table {
    display: none;
  }

  /* Keep watchlist table visible on mobile */
  #watchlistTable {
    display: table;
  }

  /* Show positions table on mobile in compact mode */
  .data-table.compact-mode {
    display: table;
    width: 100%;
    min-width: 100%;
  }

  /* Make table wrapper scrollable on mobile */
  .table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Hide exchange column on mobile in compact mode for positions table only */
  /* Exchange is now the last column (8th) in compact mode */
  #positionsTable.data-table.compact-mode th:nth-child(8),
  #positionsTable.data-table.compact-mode td:nth-child(8) {
    display: none;
  }

  /* Prevent text wrapping in compact mode cells on mobile */
  .data-table.compact-mode th,
  .data-table.compact-mode td {
    white-space: nowrap;
  }

  /* Hide mobile cards when compact mode is active */
  body.compact-mode .mobile-positions-container {
    display: none;
  }

  .mobile-positions-container {
    display: block;
    max-width: 100%;
  }

  .mobile-position-card {
    display: block;
  }

  .card-row {
    display: flex;
    justify-content: space-between;
  }

  .calvin-container img,
  #newComic img {
    max-width: unset;
  }

  /* Comic controls on mobile */
  .calvin-controls {
    display: none !important;
  }

  .calvin-controls-mobile {
    display: flex !important;
  }

  .comic-header {
    margin-bottom: 12px;
  }

  .comic-tabs {
    gap: 8px;
  }

  .tab-desktop {
    display: none;
  }

  .tab-mobile {
    display: inline;
  }

  #newComic {
    margin-left: -20px;
    padding-left: 20px;
    margin-right: -20px;
    padding-right: 20px;
  }

  /* Calvin & Hobbes and Peanuts comics on mobile - exclude Far Side */
  #newComic img:not([data-comic-type="farside"]) {
    min-height: 250px !important;
    max-height: 250px !important;
  }

  /* Far Side comics on mobile - full width */
  #newComic img[data-comic-type="farside"] {
    width: 100%;
    height: auto;
  }

  /* Full bleed settings dialog on mobile */
  .settings {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    /* Use dynamic viewport height for mobile browsers */
    max-width: 100vw;
    max-height: 100vh;
    max-height: 100dvh;
    margin: 0;
    border: none;
    border-radius: 0;
    overflow-x: hidden;
  }

  /* Compact tabs on mobile */
  .settings-tabs {
    padding: 0 8px;
    gap: 2px;
  }

  .settings-tab {
    padding: 10px 8px;
    font-size: 1em;
    letter-spacing: 0.3px;
  }

  fieldset {
    border: none;
    border-bottom: 1px solid var(--border);
    margin-bottom: 10px;
  }

  legend {
    padding: 0;
  }

  /* Fullscreen watchlist search on mobile */
  #watchlistSearchWindow {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-width: 100vw;
    max-height: 100vh;
    max-height: 100dvh;
    margin: 0;
    border: none;
    border-radius: 0;
    top: 0;
    left: 0;
    transform: none;
  }

  .settings::backdrop {
    background: rgba(0, 0, 0, 0.8);
  }

  .settings-form {
    height: 100vh;
    height: 100dvh;
    /* Use dynamic viewport height for mobile browsers */
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    max-width: 100vw;
    box-sizing: border-box;
  }

  .settings-form header {
    padding: 16px;
    overflow-x: hidden;
  }

  .settings-form .settings-actions {
    padding: 16px;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    overflow-x: hidden;
  }

  .settings-form section {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 16px;
    box-sizing: border-box;
    width: 100%;
  }

  /* Improve spacing on mobile */
  fieldset {
    padding: 16px 0;
  }

  label {
    margin-top: 12px;
  }

  label:first-of-type {
    margin-top: 0;
  }

  legend {
    color: var(--accent);
    margin-bottom: 0;
  }

  .help {
    font-size: 0.9em;
    line-height: 1.4;
  }

  .info {
    font-size: 0.9em;
    line-height: 1.4;
  }

  .status-info {
    font-size: 0.9em;
    line-height: 1.4;
  }

  /* Scale inputs with user's font size on mobile */
  input:not([type="checkbox"]):not([type="range"]),
  select,
  textarea {
    font-size: 1em !important;
    padding: 10px !important;
    touch-action: manipulation;
    /* Prevents double-tap zoom */
  }

  /* Stack row elements vertically on mobile */
  .row {
    flex-direction: column;
    align-items: stretch;
  }

  /* Make item-row stack vertically on mobile */
  .item-row {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .item-row input:not([type="checkbox"]) {
    width: 100%;
  }

  .item-row label {
    margin-top: 0;
  }

  /* Ensure buttons fit */
  button:not([type="checkbox"]),
  .btn-text {
    max-width: 100%;
    white-space: normal;
    text-align: center;
  }

  /* Get location button on mobile */
  #getLocationBtn {
    width: 100%;
    margin-top: 8px;
  }

  /* Settings actions stack on mobile */
  .settings-actions {
    flex-wrap: wrap;
    justify-content: stretch;
    gap: 12px;
  }

  .settings-actions button {
    flex: 1;
    min-width: 120px;
  }

  /* Ensure help text wraps */
  .help {
    word-break: break-word;
  }

  .info {
    word-break: break-word;
  }

  .status-info {
    word-break: break-word;
  }
}


html[data-theme="matrix"] {
  /* Matrix green on black */
  --bg: #000000;
  --bg-elev: #001a00;
  --text: #00ff41;
  --text-bright: #00ff41;
  --muted: #00cf19;
  --accent: #00ff41;
  --border: rgba(0, 255, 65, 0.1);
  --card-bg: #000000;
  --green: #69ff90;
  --red: #00761e;
  --orange: #00ff41;
  --yellow: #00ff41;
  --cyan: #00ff41;
  --flash-start: color-mix(in srgb, var(--accent) 30%, transparent);
  --flash-mid: color-mix(in srgb, var(--accent) 15%, transparent);
}

html[data-theme="halloween"] {
  /* Spooky Halloween - orange on black with purple accents */
  --bg: #0a0a0a;
  --bg-elev: #1a0f00;
  --text: #ff8c00;
  --text-bright: #ffa500;
  --muted: #cc6600;
  --accent: #ff6600;
  --border: rgba(255, 140, 0, 0.1);
  --card-bg: #0a0a0a;
  --green: #9d4edd;
  --red: #ff4500;
  --orange: #ff8c00;
  --yellow: #ffa500;
  --cyan: #9d4edd;
  --flash-start: color-mix(in srgb, var(--accent) 30%, transparent);
  --flash-mid: color-mix(in srgb, var(--accent) 15%, transparent);
}

html[data-theme="christmas"] {
  /* Festive Christmas - red, green, and gold */
  --bg: #0d1f0d;
  --bg-elev: #1a0f0f;
  --text: #e8f5e8;
  --text-bright: #ffffff;
  --muted: #a8c5a8;
  --accent: #ff3333;
  --border: rgb(21, 46, 21);
  --card-bg: #0d1f0d;
  --green: #00c853;
  --red: #ff1744;
  --orange: #ffd700;
  --yellow: #ffd700;
  --cyan: #00c853;
  --flash-start: color-mix(in srgb, var(--accent) 30%, transparent);
  --flash-mid: color-mix(in srgb, var(--accent) 15%, transparent);
}

html[data-theme="cyberpunk"] {
  /* Cyberpunk - neon pink and cyan on dark */
  --bg: #000000;
  --bg-elev: #0a0e1a;
  --text: #00d9ff;
  --text-bright: #ff006e;
  --muted: #6b7199;
  --accent: #ff006e;
  --border: rgba(255, 0, 110, 0.1);
  --card-bg: #050811;
  --green: #00ff9f;
  --red: #ff006e;
  --orange: #ff8500;
  --yellow: #ffea00;
  --cyan: #00d9ff;
  --flash-start: color-mix(in srgb, var(--accent) 30%, transparent);
  --flash-mid: color-mix(in srgb, var(--accent) 15%, transparent);
}

html[data-theme="retro"] {
  /* Retro - warm browns and cream */
  --bg: #f5f1e8;
  --bg-elev: #e8dcc8;
  --text: #5a4a3a;
  --text-bright: #3d2e1f;
  --muted: #8b7a6a;
  --accent: #c85a54;
  --border: rgba(90, 74, 58, 0.1);
  --card-bg: #faf7f0;
  --green: #6b8e5f;
  --red: #c85a54;
  --orange: #d8894d;
  --yellow: #daa520;
  --cyan: #5a8a8a;
  --flash-start: color-mix(in srgb, var(--accent) 30%, transparent);
  --flash-mid: color-mix(in srgb, var(--accent) 15%, transparent);
}

html[data-theme="cozy-wooden"] {
  /* Wood - rich wood tones */
  --bg: #150f05;
  --bg-elev: #150f05;
  --text: #d4c5a0;
  --text-bright: #f0e6c8;
  --muted: #8b7a5a;
  --accent: #cd853f;
  --border: rgba(205, 133, 63, 0.1);
  --card-bg: #332a1a;
  --green: #90be6d;
  --red: #d35400;
  --orange: #cd853f;
  --yellow: #daa520;
  --cyan: #6b8e8e;
  --flash-start: color-mix(in srgb, var(--accent) 30%, transparent);
  --flash-mid: color-mix(in srgb, var(--accent) 15%, transparent);
}

html[data-theme="daily"] {
  /* The Daily - grayscale newspaper */
  --bg: #f5f5f5;
  --bg-elev: #ffffff;
  --text: #1a1a1a;
  --text-bright: #000000;
  --muted: #666666;
  --accent: #000000;
  --border: rgba(0, 0, 0, 0.15);
  --card-bg: #ffffff;
  --green: #2d2d2d;
  --red: #1a1a1a;
  --orange: #4d4d4d;
  --yellow: #666666;
  --cyan: #333333;
  --flash-start: color-mix(in srgb, var(--accent) 30%, transparent);
  --flash-mid: color-mix(in srgb, var(--accent) 15%, transparent);
}

html[data-theme="ft"] {
  /* FT - Financial Times salmon pink */
  --bg: #fff1e5;
  --bg-elev: #fef4ea;
  --text: #33302e;
  --text-bright: #000000;
  --muted: #6a5f56;
  --accent: #990f3d;
  --border: rgba(51, 48, 46, 0.1);
  --card-bg: #fef4ea;
  --green: #00994d;
  --red: #cc0000;
  --orange: #d97706;
  --yellow: #b8860b;
  --cyan: #0077b6;
  --flash-start: color-mix(in srgb, var(--accent) 30%, transparent);
  --flash-mid: color-mix(in srgb, var(--accent) 15%, transparent);
}


html[data-theme="dark"] {
  /* Black Midnight Vapor by sacred.computer */
  --bg: #000000;
  --bg-elev: #262626;
  --text: #ffffff;
  --text-bright: #ffffff;
  --muted: #8d8d8d;
  --accent: #ffffff;
  --border: rgba(82, 82, 82, 0.1);
  --card-bg: #161616;
  --green: #24a148;
  --red: #da1e28;
  --orange: #ff6c04;
  --yellow: #f1c21b;
  --cyan: #00ffff;
  --flash-start: color-mix(in srgb, var(--accent) 30%, transparent);
  --flash-mid: color-mix(in srgb, var(--accent) 15%, transparent);
}


html[data-theme="bioluminescence"] {
  /* Digital Bioluminescence by sacred.computer */
  --bg: #000000;
  --bg-elev: #005d79;
  --text: #3ddbda;
  --text-bright: #9ef0f0;
  --muted: #007d79;
  --accent: #00cfcf;
  --border: rgba(0, 125, 121, 0.1);
  --card-bg: #081a1c;
  --green: #cefaff;
  --red: #007785;
  --orange: #ff6c04;
  --yellow: #f1c21b;
  --cyan: #00ffff;
  --flash-start: color-mix(in srgb, var(--accent) 30%, transparent);
  --flash-mid: color-mix(in srgb, var(--accent) 15%, transparent);
}

html[data-theme="safe-blue"] {
  /* Operation Safe Blue by sacred.computer */
  --bg: #002d9c;
  --bg-elev: #0043ce;
  --text: #edf5ff;
  --text-bright: #ffffff;
  --muted: #a6c8ff;
  --accent: #4589ff;
  --border: rgba(15, 98, 254, 0.1);
  --card-bg: #001141;
  --green: #79ffa1;
  --red: #ff9096;
  --orange: #ff6c04;
  --yellow: #f1c21b;
  --cyan: #4589ff;
  --flash-start: color-mix(in srgb, var(--accent) 30%, transparent);
  --flash-mid: color-mix(in srgb, var(--accent) 15%, transparent);
}


html[data-theme="as400"] {
  /* Kirkland Signature AS/400 by sacred.computer */
  --bg: #000000;
  --bg-elev: #262626;
  --text: #24a148;
  --text-bright: #24a148;
  --muted: #047017;
  --accent: #24a148;
  --border: rgba(25, 128, 56, 0.2);
  --card-bg: #161616;
  --green: #42ff78;
  --red: #da1e28;
  --orange: #ff6c04;
  --yellow: #f1c21b;
  --cyan: #00ffff;
  --flash-start: color-mix(in srgb, var(--accent) 30%, transparent);
  --flash-mid: color-mix(in srgb, var(--accent) 15%, transparent);
}


html[data-theme="ntsc-bw"] {
  /* BW NTSC TV (CGA) w/overscan, blurry */
  --bg: #0a0a0f;
  --bg-elev: #151520;
  --text: #c0c0d0;
  --text-bright: #e8e8f0;
  --muted: #7070a0;
  --accent: #b0b0d0;
  --border: rgba(192, 192, 208, 0.1);
  --card-bg: #0a0a0f;
  --green: #aeaeff;
  --red: #d0d0e0;
  --orange: #c0c0d0;
  --yellow: #d0d0e0;
  --cyan: #b0b0d0;
  --flash-start: color-mix(in srgb, var(--accent) 30%, transparent);
  --flash-mid: color-mix(in srgb, var(--accent) 15%, transparent);
}


html[data-theme="amber-low"] {
  /* Low-res amber TTL (CGA, custom palette w/overscan) */
  --bg: #1a0800;
  --bg-elev: #2a1200;
  --text: #ffaa00;
  --text-bright: #ffc040;
  --muted: #cc8800;
  --accent: #ffaa00;
  --border: rgba(255, 170, 0, 0.2);
  --card-bg: #1a0800;
  --green: #ffd072;
  --red: #ff8800;
  --orange: #ffaa00;
  --yellow: #ffc040;
  --cyan: #ffaa00;
  --flash-start: color-mix(in srgb, var(--accent) 30%, transparent);
  --flash-mid: color-mix(in srgb, var(--accent) 15%, transparent);
}

html[data-theme="vga-white"] {
  /* White mono VGA (custom resolution), sharp */
  --bg: #000000;
  --bg-elev: #0a0a0a;
  --text: #e0e0e0;
  --text-bright: #ffffff;
  --muted: #909090;
  --accent: #e0e0e0;
  --border: rgba(224, 224, 224, 0.1);
  --card-bg: #000000;
  --green: #e0e0e0;
  --red: #e0e0e0;
  --orange: #e0e0e0;
  --yellow: #ffffff;
  --cyan: #e0e0e0;
  --flash-start: color-mix(in srgb, var(--accent) 30%, transparent);
  --flash-mid: color-mix(in srgb, var(--accent) 15%, transparent);
}

html[data-theme="paper-white"] {
  /* "Paper White" VGA (640x480 monochrome mode) */
  --bg: #d8d0c0;
  --bg-elev: #c8c0b0;
  --text: #202020;
  --text-bright: #000000;
  --muted: #606060;
  --accent: #404040;
  --border: rgba(32, 32, 32, 0.1);
  --card-bg: #d8d0c0;
  --green: #005e00;
  --red: #7f0000;
  --orange: #604000;
  --yellow: #606000;
  --cyan: #004040;
  --flash-start: color-mix(in srgb, var(--accent) 30%, transparent);
  --flash-mid: color-mix(in srgb, var(--accent) 15%, transparent);
}

html[data-theme="vga-amber"] {
  /* Amber VGA (320x200 double-scanned), very sharp */
  --bg: #0f0500;
  --bg-elev: #1a0a00;
  --text: #ff9944;
  --text-bright: #ffbb66;
  --muted: #cc6622;
  --accent: #ff9944;
  --border: rgba(255, 153, 68, 0.1);
  --card-bg: #0f0500;
  --green: #ffc18d;
  --red: #ff6622;
  --orange: #ff9944;
  --yellow: #ffbb66;
  --cyan: #ff9944;
  --flash-start: color-mix(in srgb, var(--accent) 30%, transparent);
  --flash-mid: color-mix(in srgb, var(--accent) 15%, transparent);
}

html[data-theme="p7-phosphor"] {
  /* P7 phosphor, latency and persistence visible */
  --bg: #0a0a10;
  --bg-elev: #151520;
  --text: #9090c0;
  --text-bright: #b8b8e0;
  --muted: #6060a0;
  --accent: #9090c0;
  --border: rgba(144, 144, 192, 0.1);
  --card-bg: #0a0a10;
  --green: #e3e3ff;
  --red: #c09090;
  --orange: #c0a090;
  --yellow: #b8b8e0;
  --cyan: #90a0c0;
  --flash-start: color-mix(in srgb, var(--accent) 30%, transparent);
  --flash-mid: color-mix(in srgb, var(--accent) 15%, transparent);
}

html[data-theme="bloomberg"] {
  /* Bloomberg Terminal */
  --bg: #000000;
  --bg-elev: #000000;
  --text: #F09000;
  --text-bright: #F09000;
  --muted: #F09000;
  --accent: #F09000;
  --border: rgba(255, 136, 0, 0.1);
  --card-bg: #000000;
  --green: #01C605;
  --red: #DB3333;
  --orange: #F09000;
  --yellow: #F09000;
  --cyan: #0053A6;
  --flash-start: color-mix(in srgb, var(--accent) 30%, transparent);
  --flash-mid: color-mix(in srgb, var(--accent) 15%, transparent);
}

/* Sticker grid container */
#stickerGrid {
  display: grid !important;
  visibility: visible !important;
  overflow-y: auto !important;
}

/* Sticker grid items */
.sticker-item {
  display: flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3px;
  cursor: pointer;
  border: 2px solid transparent;
  background: var(--bg);
  visibility: visible !important;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

.sticker-item * {
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.sticker-item:hover {
  background: var(--border);
}

.sticker-item.selected {
  border-color: var(--accent);
  background: var(--bg-elev);
}

.sticker-icon {
  width: 48px;
  height: 48px;
  display: flex !important;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  line-height: 1;
  margin-bottom: 2px;
  visibility: visible !important;
}

.sticker-icon img {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  width: auto !important;
  height: auto !important;
  max-width: 48px !important;
  max-height: 48px !important;
  object-fit: contain;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: -moz-crisp-edges;
  image-rendering: -o-crisp-edges;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  -ms-interpolation-mode: nearest-neighbor;
}

.sticker-label {
  font-size: 8px;
  text-align: center;
  color: var(--dd);
  line-height: 1.1;
  word-break: break-all;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sticker-item.selected .sticker-label {
  color: var(--text);
}

/* Sticky stickers */
#stickyStickers {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1000;
}

.sticky-sticker {
  position: absolute;
  cursor: move;
  pointer-events: all;
  user-select: none;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
}

.sticky-sticker:hover {
  filter: brightness(1.1);
  z-index: 1001;
}

.sticky-sticker.dragging {
  opacity: 0.8;
  cursor: grabbing;
}

.sticky-sticker img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  -webkit-image-rendering: pixelated;
  -ms-interpolation-mode: nearest-neighbor;
}

.sticky-sticker .resize-handle {
  position: absolute;
  bottom: 2px;
  right: 2px;
  padding: 2px 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  cursor: nwse-resize;
  opacity: 0;
  z-index: 2;
  font-size: 0.75em;
  line-height: 1;
  font-family: inherit;
  pointer-events: auto;
}

.sticky-sticker .rotate-handle {
  position: absolute;
  bottom: 2px;
  left: 2px;
  padding: 2px 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  cursor: grab;
  opacity: 0;
  z-index: 2;
  font-size: 0.75em;
  line-height: 1;
  font-family: inherit;
  pointer-events: auto;
}

.sticky-sticker .rotate-handle:active {
  cursor: grabbing;
}

.sticky-sticker:hover .resize-handle,
.sticky-sticker:hover .rotate-handle {
  opacity: 1;
}

.sticky-sticker .remove-btn {
  position: absolute;
  top: 2px;
  right: 2px;
  padding: 2px 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  font-size: 0.75em;
  line-height: 1;
  opacity: 0;
  font-family: inherit;
  pointer-events: auto;
}

.sticky-sticker:hover .remove-btn {
  opacity: 1;
}

/* Pixel art rain overlay */
#rainCanvas,
#newRainCanvas,
.rain-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 9999;
  display: none;
  margin: 0;
  padding: 0;
  border: none;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  backface-visibility: hidden;
  transform: translateZ(0);
  will-change: auto;
}

#rainCanvas.active,
#newRainCanvas.active,
.rain-canvas.active {
  display: block;
}

/* Slider label row - label on left, value on right */
.slider-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.slider-label-row span:last-child {
  color: var(--text);
  font-family: inherit;
}

/* Slider controls styling */
.slider-controls {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 100%;
  box-sizing: border-box;
}

.slider-controls input[type="range"] {
  width: 100%;
  min-width: 0;
}

.slider-controls span {
  min-width: 50px;
  max-width: 60px;
  text-align: right;
  color: var(--text);
  font-family: inherit;
  flex-shrink: 0;
}

/* Range slider styling - clean terminal look */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  cursor: pointer;
  width: 100%;
  padding: 0;
  margin: 0;
  height: 16px;
}

/* Track - hidden */
input[type="range"]::-webkit-slider-track {
  background: transparent;
  height: 16px;
  border-radius: 0;
  border: none;
}

input[type="range"]::-moz-range-track {
  background: transparent;
  height: 16px;
  border-radius: 0;
  border: none;
}

/* Thumb - vertical line same height as checkbox */
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 2px;
  height: 16px;
  background: var(--text);
  border: none;
  border-radius: 0;
  margin: 0;
  padding: 0;
}

input[type="range"]::-moz-range-thumb {
  width: 2px;
  height: 16px;
  background: var(--text);
  border: none;
  border-radius: 0;
  margin: 0;
  padding: 0;
}

/* Focus */
input[type="range"]:focus::-webkit-slider-thumb {
  background: var(--accent);
}

input[type="range"]:focus::-moz-range-thumb {
  background: var(--accent);
}

/* Sticker Window */
.sticker-window {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 480px;
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 100px);
  background: var(--bg);
  border: 1px solid var(--border);
  z-index: 10000;
  display: flex;
  flex-direction: column;
}

.sticker-window-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sticker-window-content {
  padding: 12px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

/* Primary button style */
.btn-primary {
  width: 100%;
  color: var(--accent);
}

.btn-primary:hover {
  opacity: 0.9;
}

/* Sticker help messages - show desktop by default, swap on mobile */
.sticker-help-mobile {
  display: none;
}

.sticker-help-desktop {
  display: block;
}

@media (max-width: 870px) {

  /* Full-screen modals on mobile (except sticker window) */
  .sticker-window:not(#stickerWindow) {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-width: 100vw;
    max-height: 100vh;
    max-height: 100dvh;
    transform: none;
    border: none;
    border-radius: 0;
    display: flex;
    flex-direction: column;
  }

  /* Ensure modal content scrolls properly */
  .sticker-window:not(#stickerWindow) .sticker-window-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  /* Sticker window stays as bottom sheet */
  #stickerWindow {
    bottom: 0;
    right: 0;
    left: 0;
    top: auto;
    transform: none;
    width: auto;
    max-width: none;
    max-height: 60vh;
    border: none;
    border-top: 1px solid var(--border);
  }

  .sticker-help-desktop {
    display: none;
  }

  .sticker-help-mobile {
    display: block;
  }
}

/* Last update timestamp - bottom left on desktop, last card on mobile */
.last-update-timestamp {
  position: fixed;
  bottom: 24px;
  left: 32px;
  font-size: 11px;
  color: var(--muted);
  opacity: 0.6;
  cursor: pointer;
  z-index: 5;
}

.last-update-timestamp:hover {
  opacity: 1;
}

@media (max-width: 870px) {
  .last-update-timestamp {
    position: static;
    margin: 24px auto;
    text-align: center;
    opacity: 0.6;
    cursor: pointer;
  }

  .last-update-timestamp:active {
    opacity: 1;
  }
}

/* Edit list mode */
.position-row-hidden {
  opacity: 0.6;
}

/* Edit mode asset cell wrapper - keeps [X] and asset name on same line */
.edit-asset-cell {
  display: inline-flex;
  align-items: center;
  gap: 0;
  white-space: nowrap;
}

.position-edit-btn,
.position-delete-btn,
.position-restore-btn,
.watchlist-edit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  /* Compact padding that doesn't affect line height */
  padding: 0 4px 0 0;
  margin: 0;
  border: none;
  font-size: inherit;
  line-height: 1;
  cursor: pointer;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  opacity: 0.5;
  /* Touch target handled at cell level, not button */
  vertical-align: middle;
  flex-shrink: 0;
}

.position-edit-btn:hover,
.position-delete-btn:hover,
.position-restore-btn:hover,
.watchlist-edit-btn:hover {
  color: var(--text);
  opacity: 1;
}

/* External link styling */
.external-link {
  color: var(--accent);
  background-color: var(--border);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
  padding: 2px 6px;
}

/* Watchlist Section */
.watchlist-content {
  display: block;
  transition: all 0.3s ease;
}

#watchlistSection.collapsed .watchlist-content {
  display: none;
}

#watchlistSection.collapsed .toggle-expanded {
  display: none;
}

#watchlistSection.collapsed .toggle-collapsed {
  display: flex;
}

#watchlistSection:not(.collapsed) .toggle-collapsed {
  display: none;
}

#watchlistSection:not(.collapsed) .toggle-expanded {
  display: inline;
}

#newWatchlistSearchResults:not(:empty),
#newAddPositionPythResults:not(:empty) {
  border: 1px solid var(--border);
  max-height: 500px;
  overflow-y: auto;
}

@media (max-width: 870px) {
  #newWatchlistSearchResults:not(:empty) {
    max-height: calc(100vh - 150px);
  }
}

.watchlist-search-result {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: background 0.2s ease;
}

.watchlist-search-result:hover {
  background: var(--bg);
}

.watchlist-search-result:last-child {
  border-bottom: none;
}

.watchlist-search-result.added {
  background: var(--card-bg);
}

.watchlist-search-result .asset-name {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.watchlist-search-result .asset-full-name {
  font-size: 1em;
  color: var(--text);
}

.watchlist-search-result .asset-symbol {
  font-size: 1em;
  color: var(--muted);
}

.watchlist-search-result button.added {
  color: var(--accent);
}

.watchlist-remove-btn {
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  font-family: inherit;
  transition: color 0.2s ease;
}

.watchlist-remove-btn:hover {
  color: var(--text);
}

.watchlist-edit-btn {
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: color 0.2s ease;
}

.watchlist-edit-btn:hover {
  color: var(--text);
}

/* === ALIGNED TABLE COLUMNS (Positions + Watchlist) === */
/* Set matching widths for Asset, Price, Chart columns */

/* Positions table column widths */
#newPositionsTable {
  width: 100%;
  min-width: 800px;
  /* Ensure horizontal scroll on mobile */
  table-layout: fixed;
}

#newPositionsTable th:nth-child(1),
#newPositionsTable td:nth-child(1) {
  width: 90px;
  text-align: left;
}

#newPositionsTable th:nth-child(2),
#newPositionsTable td:nth-child(2) {
  width: 90px;
  text-align: left;
}

#newPositionsTable th:nth-child(3),
#newPositionsTable td:nth-child(3) {
  width: 70px;
  text-align: center;
}

/* Watchlist table column widths - align Chart with positions Value column */
#newWatchlistTable {
  width: 100%;
  table-layout: fixed;
}

#newWatchlistTable th:nth-child(1),
#newWatchlistTable td:nth-child(1) {
  width: 90px;
  text-align: left;
  white-space: nowrap;
  padding-left: 0;
}

/* Price column wider to push Chart to align with positions Value column */
#newWatchlistTable th:nth-child(2),
#newWatchlistTable td:nth-child(2) {
  width: 160px;
  text-align: left;
}

#newWatchlistTable th.chart,
#newWatchlistTable td.chart {
  width: 70px;
  text-align: center;
  padding: 0 8px;
}

#newWatchlistTable th:last-child,
#newWatchlistTable td:last-child {
  text-align: right;
  padding-right: 0;
  white-space: nowrap;
}

/* Ensure sparkline SVGs have explicit sizing for cross-browser compatibility */
#newWatchlistTable .sparkline,
.data-table .sparkline {
  display: inline-block;
  vertical-align: middle;
  width: 60px;
  height: 24px;
  max-width: 100%;
}

/* Mobile styles for watchlist table */
@media (max-width: 870px) {

  /* Keep watchlist table visible on mobile */
  #newWatchlistTable {
    display: table !important;
    width: 100%;
    table-layout: fixed;
  }

  /* Mobile column widths - more room before chart */
  #newWatchlistTable th:nth-child(1),
  #newWatchlistTable td:nth-child(1) {
    width: 70px;
  }

  /* Wider price column for spacing before chart */
  #newWatchlistTable th:nth-child(2),
  #newWatchlistTable td:nth-child(2) {
    width: 110px;
  }

  #newWatchlistTable th.chart,
  #newWatchlistTable td.chart {
    width: 70px;
    min-width: 70px;
    max-width: 70px;
    padding: 0 8px !important;
  }

  /* Fixed sparkline size on mobile - match positions table */
  #newWatchlistTable .sparkline {
    display: inline-block;
    width: 55px;
    height: 20px;
    max-width: 100%;
  }
}

/* Compact list mode - inspired by sacred.computer terminal tables */
.data-table.compact-mode {
  border-collapse: collapse;
}

.data-table.compact-mode th,
.data-table.compact-mode td {
  padding: 4px 8px;
  line-height: 1.2;
}

/* Remove padding from edge cells in compact mode */
.data-table.compact-mode th:first-child,
.data-table.compact-mode td:first-child {
  padding-left: 0;
}

.data-table.compact-mode th:last-child,
.data-table.compact-mode td:last-child {
  padding-right: 0;
}

.data-table.compact-mode thead th {
  padding-top: 6px;
  padding-bottom: 6px;
}

.data-table.compact-mode tbody tr {
  border-bottom: 1px solid var(--border);
}

.data-table.compact-mode tbody tr:last-child {
  border-bottom: none;
}

.badge {
  display: inline-block;
  padding: 2px 6px;
  background: var(--border);
  color: var(--muted);
  font-size: 1em;
  border-radius: 3px;
}

.external-link:hover,
.external-link:focus {
  text-decoration-style: solid;
  opacity: 0.8;
}

/* Donate window styling - minimal */

.donate-address-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

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

.donate-label {
  font-weight: 500;
  color: var(--text);
  text-transform: uppercase;
  opacity: 0.6;
}

.donate-address {
  font-family: 'Berkeley Mono', monospace;
  color: var(--muted);
  word-break: break-all;
  line-height: 1.5;
  margin: 4px 0;
}

.copy-address-btn {
  align-self: flex-start;
  padding: 0;
  margin: 0;
  background: transparent;
  border: none;
}

.copy-address-btn:active {
  opacity: 0.6;
}

/* Wallet breakdown tooltip */
.wallet-breakdown-tooltip {
  position: fixed;
  z-index: 10000;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 12px;
  min-width: 280px;
  max-width: 400px;
  font-size: inherit;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  pointer-events: none;
}

@media (max-width: 870px) {
  .wallet-breakdown-tooltip {
    min-width: 240px;
    max-width: calc(100vw - 32px);
  }
}

.wallet-breakdown-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.wallet-breakdown-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.wallet-breakdown-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.wallet-address {
  font-family: 'Berkeley Mono', monospace;
  color: var(--muted);
  font-size: inherit;
}

.wallet-amount {
  font-family: 'Berkeley Mono', monospace;
  color: var(--text);
  font-size: inherit;
  font-weight: 500;
  white-space: nowrap;
}

.wallet-breakdown-bar {
  display: flex;
  width: 100%;
  height: 8px;
  border-radius: 2px;
  overflow: hidden;
  gap: 1px;
}

.wallet-bar-segment {
  height: 100%;
}

.has-wallet-breakdown {
  cursor: help;
}

.wallet-breakdown-indicator {
  color: var(--muted);
  font-size: 0.9em;
}



.loading {
  opacity: 0.6;
  pointer-events: none;
}

/* Loading indicator for sections */
.section-loading {
  position: relative;
}

.section-loading::after {
  content: '⏳';
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  font-size: 0.9rem;
  /* No animation - instant feel */
}

/* === PULL TO REFRESH (Mobile Only) === */
.pull-to-refresh {
  display: none;
}

@media (max-width: 870px) {
  .pull-to-refresh {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    height: 100vh;
    height: 100dvh;
    background: var(--text);
    color: var(--bg);
    z-index: 997;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    padding-top: max(env(safe-area-inset-top, 20px), 20px);
  }

  .pull-to-refresh.visible {
    opacity: 1;
    visibility: visible;
  }

  .pull-to-refresh-text {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: 500;
    padding: 16px 0;
  }

  /* Main content wrapper slides down when pulling */
  .main-content {
    background: var(--bg);
    min-height: 100vh;
    min-height: 100dvh;
    position: relative;
    z-index: 998;
  }

  /* Only apply transform-related properties when actively pulling */
  .main-content.pulling-active {
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
  }

  /* Snap-back transition - Apple-like spring physics, faster */
  .main-content.snapping-back {
    transition: transform 0.3s cubic-bezier(0.25, 0.1, 0.25, 1);
  }
}

/* iOS Status Bar Cover - completely independent element */
/* This is OUTSIDE mainContent so it never transforms */
.status-bar-cover {
  display: none;
}

@media (max-width: 870px) {
  .status-bar-cover {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: env(safe-area-inset-top, 0px);
    background: var(--bg);
    z-index: 10000;
    /* Above everything */
    pointer-events: none;
  }
}

/* === FUNDING COLUMN STYLES === */

/* Funding cell - hoverable but no special cursor */
.funding-cell {
  position: relative;
  cursor: help;
}

/* Custom mouse-tracking tooltip (created via JS) */
.funding-rate-tooltip {
  position: fixed;
  z-index: 10001;
  background: var(--bg);
  border: 1px solid var(--text);
  color: var(--text);
  padding: 6px 10px;
  font-size: inherit;
  pointer-events: none;
  white-space: pre-line;
  line-height: 1.4;
  opacity: 0;
  transition: opacity 0s;
}

.funding-rate-tooltip.visible {
  opacity: 1;
}

/* Funding rate inline display for mobile cards */
.funding-rate-inline {
  color: var(--muted);
  font-size: 0.85em;
  opacity: 0.8;
}

/* Funding column header */
.th-funding {
  white-space: nowrap;
}