/* shadcn/ui — zinc theme (light + dark) + compact layout */

:root {
  --background: 0 0% 100%;
  --foreground: 240 10% 3.9%;
  --card: 0 0% 100%;
  --card-foreground: 240 10% 3.9%;
  --popover: 0 0% 100%;
  --popover-foreground: 240 10% 3.9%;
  --primary: 240 5.9% 10%;
  --primary-foreground: 0 0% 98%;
  --secondary: 240 4.8% 95.9%;
  --secondary-foreground: 240 5.9% 10%;
  --muted: 240 4.8% 95.9%;
  --muted-foreground: 240 3.8% 46.1%;
  --accent: 240 4.8% 95.9%;
  --accent-foreground: 240 5.9% 10%;
  --destructive: 0 84.2% 60.2%;
  --destructive-foreground: 0 0% 98%;
  --border: 240 5.9% 90%;
  --input: 240 5.9% 90%;
  --ring: 240 5.9% 10%;
  --radius: 0.5rem;
  --radius-sm: calc(var(--radius) - 2px);
  --success: 142 76% 36%;
  --success-fg: 0 0% 100%;
  --warn-text: 0 72% 42%;
  --warn-bg: 0 100% 97%;
  --warn-border: 0 84% 85%;
  --gap: 12px;
  --input-h: 36px;
  --signal-panel-w: 400px;
}

/* ── Dark theme — sleek gray / near-black ── */
html[data-theme="dark"] {
  --background: 240 8% 5%;
  --foreground: 0 0% 96%;
  --card: 240 6% 9%;
  --card-foreground: 0 0% 96%;
  --popover: 240 6% 10%;
  --popover-foreground: 0 0% 96%;
  --primary: 0 0% 98%;
  --primary-foreground: 240 6% 10%;
  --secondary: 240 5% 14%;
  --secondary-foreground: 0 0% 96%;
  --muted: 240 5% 14%;
  --muted-foreground: 240 5% 62%;
  --accent: 240 5% 17%;
  --accent-foreground: 0 0% 98%;
  --destructive: 0 72% 51%;
  --destructive-foreground: 0 0% 98%;
  --border: 240 5% 16%;
  --input: 240 5% 18%;
  --ring: 240 5% 70%;
  --success: 142 64% 48%;
  --success-fg: 0 0% 100%;
  --warn-text: 0 90% 76%;
  --warn-bg: 0 45% 12%;
  --warn-border: 0 45% 24%;
}

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

html {
  background: hsl(var(--background));
  color-scheme: light;
  transition: background 0.2s ease;
}
html[data-theme="dark"] { color-scheme: dark; }

body {
  font-family: "Inter var", Inter, ui-sans-serif, system-ui, sans-serif;
  font-feature-settings: "cv11", "ss01";
  font-size: 14px;
  line-height: 1.5;
  color: hsl(var(--foreground));
  background: hsl(var(--background));
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  min-height: 100dvh;
}

/* Hide native number spinners */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
}

::selection { background: hsl(var(--foreground) / 0.12); }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: hsl(var(--border)); border-radius: 99px; }

/* ── Header ── */
.header {
  height: 52px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid hsl(var(--border));
  background: hsl(var(--background));
  position: sticky; top: 0; z-index: 40;
}
.header-left { display: flex; align-items: center; gap: 10px; }
.logo {
  width: 28px; height: 28px; border-radius: 6px;
  background: hsl(var(--primary)); color: hsl(var(--primary-foreground));
  font-size: 13px; font-weight: 700;
  display: grid; place-items: center;
}
.header-title { font-size: 14px; font-weight: 600; letter-spacing: -0.02em; }
.header-right { display: flex; align-items: center; gap: 8px; }
.header-pip .select-trigger {
  height: 28px;
  font-size: 13px;
  padding: 0 10px;
}

/* ── Layout ── */
.main {
  max-width: 520px;
  margin: 0 auto;
  padding: 16px 16px 24px;
  display: flex; flex-direction: column; gap: 16px;
}

@media (min-width: 900px) {
  .main {
    max-width: 720px;
    padding: 24px 20px 32px;
  }
}

/* ── Card (shadcn) ── */
.card {
  background: hsl(var(--card));
  color: hsl(var(--card-foreground));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: 0 1px 2px hsl(0 0% 0% / 0.15);
  display: flex; flex-direction: column; gap: var(--gap);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 4px;
}
.card-flat { padding: 12px 16px; }

/* ── Grid ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); }

/* ── Form ── */
.field { min-width: 0; }
.lbl {
  display: block; font-size: 13px; font-weight: 500;
  margin-bottom: 6px; line-height: 1;
}
.lbl-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.lbl-row .lbl { margin: 0; }
.dim { color: hsl(var(--muted-foreground)); font-weight: 400; font-size: 12px; }
.hint { font-size: 12px; color: hsl(var(--muted-foreground)); margin-top: 6px; }
.hidden { display: none !important; }

/* ── Stat chip ── */
.stat-chip {
  height: var(--input-h);
  display: flex; align-items: center; justify-content: center;
  background: transparent;
  border-radius: var(--radius-sm);
  font-family: inherit; font-size: 13px;
  color: hsl(var(--foreground));
  font-weight: 500;
}

.chip {
  background: transparent; border: 1px solid hsl(var(--border));
  color: hsl(var(--muted-foreground)); font-family: inherit; font-size: 11px; font-weight: 500;
  padding: 2px 8px; border-radius: 4px; cursor: pointer;
}
.chip:hover { color: hsl(var(--foreground)); border-color: hsl(var(--ring)); }

/* ── Inputs ── */
.input {
  display: flex; width: 100%; height: var(--input-h);
  border-radius: var(--radius-sm);
  border: 1px solid hsl(var(--input));
  background: hsl(var(--background));
  padding: 0 12px;
  font-size: 14px; font-family: inherit; color: hsl(var(--foreground));
  outline: none;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.input::placeholder { color: hsl(var(--muted-foreground)); opacity: 0.45; }
.input:focus-visible {
  outline: none;
  border-color: hsl(var(--foreground) / 0.4);
  box-shadow: none;
}
.textarea { height: auto; min-height: 60px; padding: 10px 12px; resize: none; }

/* ── Toggle group (shadcn) ── */
.toggle-group {
  display: flex; gap: 2px;
  background: hsl(var(--muted));
  border-radius: var(--radius-sm);
  padding: 3px; width: 100%;
}
.toggle-xs .toggle-item { padding: 4px 10px; font-size: 12px; }
.toggle-item {
  flex: 1; border: none; border-radius: calc(var(--radius-sm) - 2px);
  background: transparent; color: hsl(var(--muted-foreground));
  font-family: inherit; font-size: 13px; font-weight: 500;
  padding: 6px 12px; cursor: pointer;
  transition: all 0.15s;
}
.toggle-item:hover { color: hsl(var(--foreground)); }
.toggle-item.active {
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  box-shadow: 0 1px 2px hsl(0 0% 0% / 0.2);
}
.toggle-item.buy.active { color: hsl(var(--success)); }
.toggle-item.sell.active { color: hsl(var(--destructive)); }

/* ── Buttons (shadcn) ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: var(--input-h); padding: 0 14px;
  border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500; font-family: inherit;
  cursor: pointer; white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  border: none;
}
.btn-sm { height: 32px; padding: 0 12px; font-size: 12px; }
.btn-icon {
  width: 36px; height: 36px; padding: 0;
  background: hsl(var(--background));
  border: 1px solid hsl(var(--input));
  color: hsl(var(--foreground));
}
.btn-icon:hover { background: hsl(var(--accent)); }
.btn-primary { background: hsl(var(--primary)); color: hsl(var(--primary-foreground)); }
.btn-primary:hover { opacity: 0.9; }
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}
.btn-ghost {
  background: transparent; color: hsl(var(--muted-foreground));
  border: 1px solid hsl(var(--border));
}
.btn-ghost:hover { background: hsl(var(--accent)); color: hsl(var(--foreground)); }
.btn-full { width: 100%; margin-top: 4px; }

/* ── Theme toggle ── */
.chart-label { display: flex; align-items: center; gap: 8px; }
.theme-toggle {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-sm);
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.theme-toggle:hover { background: hsl(var(--accent)); border-color: hsl(var(--ring)); }
.theme-toggle svg { width: 16px; height: 16px; }
.theme-toggle .icon-sun { display: none; }
html[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
html[data-theme="dark"] .theme-toggle .icon-sun { display: block; }

/* ── Select / Combobox (from ui.js) ── */
.select, .combobox { position: relative; }
.select-trigger {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; height: var(--input-h);
  padding: 0 12px;
  background: hsl(var(--background));
  border: 1px solid hsl(var(--input));
  border-radius: var(--radius-sm);
  color: hsl(var(--foreground)); font-size: 14px; font-family: inherit;
  cursor: pointer; text-align: left;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.select-trigger:hover { background: hsl(var(--accent)); }
.select-trigger:focus-visible {
  outline: none;
  border-color: hsl(var(--foreground) / 0.4);
  box-shadow: none;
}
.select-icon { opacity: 0.5; display: flex; }
.combobox-wrap { position: relative; display: flex; }
.combobox-input { padding-right: 36px; }
.combobox-trigger {
  position: absolute; right: 0; top: 0; bottom: 0; width: 36px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; cursor: pointer;
  color: hsl(var(--muted-foreground)); opacity: 0.5;
}
.combobox-trigger:hover { opacity: 1; }
.popover { display: none; position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 50; }
.popover.open { display: block; }
.popover-content {
  background: hsl(var(--popover));
  color: hsl(var(--popover-foreground));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-sm);
  padding: 4px;
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 10px 15px -3px rgb(0 0 0 / 0.15);
  max-height: 240px; overflow-y: auto;
}
.popover-empty { padding: 20px 12px; text-align: center; font-size: 13px; color: hsl(var(--muted-foreground)); }
.select-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 8px 10px; border: none; border-radius: calc(var(--radius-sm) - 2px);
  background: transparent; color: hsl(var(--foreground));
  font-size: 14px; font-family: inherit; text-align: left; cursor: pointer;
}
.select-item:hover, .select-item:focus-visible { background: hsl(var(--accent)); outline: none; }
.select-item-check { width: 16px; opacity: 0; flex-shrink: 0; }
.select-item.selected .select-item-check { opacity: 1; }
.select-item.selected { font-weight: 500; }

/* ── Stop loss (single row) ── */
.sl-row { display: flex; align-items: center; gap: 8px; }
.sl-row .lbl { margin: 0; flex-shrink: 0; }
.sl-toggle { width: auto; flex-shrink: 0; }
.sl-input-wrap { position: relative; display: flex; align-items: center; flex: 1; min-width: 0; }
.sl-input-wrap .input { width: 100%; }
#slPipsWrap .input { padding-right: 44px; }
.sl-suffix {
  position: absolute; right: 12px;
  font-size: 13px; color: hsl(var(--muted-foreground));
  pointer-events: none;
}
.sl-price-preview {
  position: absolute; right: 46px;
  font-size: 12px; color: hsl(var(--muted-foreground));
  opacity: 0.6; pointer-events: none; white-space: nowrap;
  display: none;
}

/* ── TP block (merged into Entry/SL card) ── */
.tp-block {
  display: flex; flex-direction: column; gap: 8px;
  border-top: 1px solid hsl(var(--border));
  padding-top: var(--gap);
}

/* ── TP list ── */
.tp-list { display: flex; flex-direction: column; gap: 8px; }
.tp-row {
  display: grid;
  grid-template-columns: 32px 1fr auto 28px;
  align-items: center; gap: 8px;
}
.tp-tag { font-size: 12px; font-weight: 600; color: hsl(var(--muted-foreground)); font-family: inherit; text-align: right; }
.tp-row .input { height: 32px; font-size: 13px; }
.tp-result { font-size: 12px; font-family: inherit; color: hsl(var(--success)); text-align: right; min-width: 90px; font-weight: 500; }
.tp-del {
  width: 28px; height: 28px; border: none; border-radius: var(--radius-sm);
  background: transparent; color: hsl(var(--muted-foreground)); font-size: 18px; cursor: pointer;
  display: grid; place-items: center;
}
.tp-del:hover { background: hsl(var(--accent)); color: hsl(var(--destructive)); }

/* ── Preview ── */
.preview {
  background: hsl(var(--muted) / 0.5);
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-sm);
  padding: 14px;
  font-family: inherit; font-size: 13px; line-height: 1.75;
  white-space: pre-wrap; word-break: break-word;
  color: hsl(var(--foreground));
  min-height: 140px;
}
html[data-theme="dark"] .preview {
  background: hsl(var(--background));
  border-color: hsl(var(--border));
  box-shadow: none;
}
.warn-item {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.45;
  font-weight: 500;
  color: hsl(var(--warn-text));
  background: hsl(var(--warn-bg));
  border: 1px solid hsl(var(--warn-border));
}

/* ── Presets ── */
.preset-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 2px;
  max-height: 160px;
  overflow-y: auto;
}
.preset-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-sm);
  background: hsl(var(--background));
  cursor: pointer;
}
.preset-item:hover {
  background: hsl(var(--accent));
}
.preset-item.active {
  border-color: hsl(var(--foreground) / 0.35);
}
.preset-name {
  font-size: 13px;
  font-weight: 500;
}
.preset-meta {
  font-size: 12px;
  color: hsl(var(--muted-foreground));
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: calc(76px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  background: hsl(var(--primary)); color: hsl(var(--primary-foreground));
  padding: 10px 16px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
  opacity: 0; pointer-events: none; transition: all .2s;
  box-shadow: 0 10px 25px rgb(0 0 0 / 0.2); z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.disclaimer {
  text-align: center;
  font-size: 11px;
  color: hsl(var(--muted-foreground));
  opacity: 0.6;
  padding: 24px 24px calc(84px + env(safe-area-inset-bottom));
  line-height: 1.6;
  max-width: 480px;
  margin: 0 auto;
}

/* ── Floating action dock ── */
.action-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 60;
  padding: 0 12px calc(12px + env(safe-area-inset-bottom));
  background: transparent;
  border: none;
  pointer-events: none;
}
.action-bar-inner {
  max-width: 520px;
  margin: 0 auto;
  pointer-events: auto;
  display: flex;
  gap: 8px;
  padding: 6px;
  background: hsl(var(--card) / 0.96);
  border: 1px solid hsl(var(--border));
  border-radius: 16px;
  box-shadow:
    0 4px 6px hsl(0 0% 0% / 0.06),
    0 16px 40px hsl(0 0% 0% / 0.22);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}
html[data-theme="dark"] .action-bar-inner {
  background: hsl(var(--card) / 0.88);
  box-shadow:
    0 4px 6px hsl(0 0% 0% / 0.2),
    0 16px 40px hsl(0 0% 0% / 0.45);
}
.btn-action {
  flex: 1;
  height: 46px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 11px;
  border: none;
}
.action-bar .btn-ghost {
  background: hsl(var(--muted));
  color: hsl(var(--foreground));
  border: none;
}
.action-bar .btn-ghost:hover { background: hsl(var(--accent)); }
.action-bar .btn-primary {
  background: hsl(var(--foreground));
  color: hsl(var(--background));
}
.action-bar .btn-primary:hover { opacity: 0.92; }
html[data-theme="dark"] .action-bar .btn-primary {
  background: hsl(0 0% 88%);
  color: hsl(240 8% 5%);
}

/* ── Preview sheet (bottom sheet) ── */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
}
.sheet.open { display: block; }
.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  animation: sheet-fade 0.18s ease;
}
.sheet-panel {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  background: hsl(var(--background));
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  border-top: 1px solid hsl(var(--border));
  box-shadow: 0 -10px 30px hsl(0 0% 0% / 0.4);
  padding: 8px 16px calc(16px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 12px;
  max-width: 520px;
  margin: 0 auto;
  max-height: 85vh;
  animation: sheet-up 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}
.sheet-handle {
  width: 36px; height: 4px;
  border-radius: 99px;
  background: hsl(var(--border));
  margin: 4px auto 2px;
}
.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
}
.sheet-close {
  width: 30px; height: 30px;
  border: none; border-radius: var(--radius-sm);
  background: transparent; color: hsl(var(--muted-foreground));
  font-size: 15px; cursor: pointer;
  display: grid; place-items: center;
}
.sheet-close:hover { background: hsl(var(--accent)); color: hsl(var(--foreground)); }
.sheet-panel .preview { flex: 1; overflow-y: auto; }

@keyframes sheet-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
@keyframes sheet-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (min-width: 900px) {
  .action-bar-inner { max-width: 720px; }
}

/* ── TradingView chart ── */
.tv-chart {
  position: relative;
  width: 100%;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: hsl(var(--card));
  transition: height 0.2s ease;
}
.tv-chart--compact { height: 220px; }
.tv-chart--large { height: 440px; }
.tv-chart--full {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  border: none;
  border-radius: 0;
  z-index: 1000;
}
.tv-fullscreen-header {
  display: none;
}
.tv-close {
  display: none;
}

@media (max-width: 899px) {
  .tv-chart--full .tv-fullscreen-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 46px;
    padding: 0 16px;
    background: hsl(var(--card));
    border-bottom: 1px solid hsl(var(--border));
  }
  .tv-chart--full .tv-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius-sm);
    background: hsl(var(--background));
    color: hsl(var(--foreground));
    font-size: 14px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
  }
  .tv-chart--full .tv-close:hover {
    background: hsl(var(--accent));
    border-color: hsl(var(--ring));
  }
  .tv-chart--full .tv-fullscreen-title {
    font-size: 14px;
    font-weight: 600;
    color: hsl(var(--foreground));
  }
  .tv-chart--full .tradingview-widget-container {
    height: calc(100% - 46px) !important;
  }
}

/* ── Signal side panel (desktop fullscreen) ── */
.signal-panel-head {
  display: none;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
  padding-bottom: 12px;
  border-bottom: 1px solid hsl(var(--border));
}

.desktop-preview-wrap {
  display: none;
}

@media (min-width: 900px) {
  #exampleBtn {
    display: none !important;
  }
  .desktop-preview-wrap {
    display: block;
    margin-top: 16px;
    border-top: 1px solid hsl(var(--border));
    padding-top: 16px;
  }
  .desktop-preview-wrap .lbl {
    margin-bottom: 8px;
  }
  body.desktop-chart-full .tv-chart--full {
    top: 0;
    left: 0;
    bottom: 0;
    right: var(--signal-panel-w);
    width: auto;
    height: 100dvh;
  }
  body.desktop-chart-full .signal-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: var(--signal-panel-w);
    height: 100dvh;
    z-index: 1001;
    overflow-y: auto;
    overflow-x: hidden;
    margin: 0;
    border: none;
    border-left: 1px solid hsl(var(--border));
    border-radius: 0;
    box-shadow: none;
    background: hsl(var(--card));
    padding: 16px;
    padding-bottom: calc(88px + env(safe-area-inset-bottom));
    -webkit-overflow-scrolling: touch;
  }
  body.desktop-chart-full .signal-panel-head {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 2;
    background: hsl(var(--card));
    padding-top: 4px;
    margin: -4px 0 0;
  }
  body.desktop-chart-full .main > .card:first-child .lbl-row {
    display: none;
  }
  body.desktop-chart-full .main > .card-flat,
  body.desktop-chart-full .disclaimer {
    visibility: hidden;
    pointer-events: none;
  }
  body.desktop-chart-full .action-bar {
    left: auto;
    right: 0;
    width: var(--signal-panel-w);
    padding: 0;
    border-top: 1px solid hsl(var(--border));
    background: hsl(var(--card));
    z-index: 1002;
  }
  body.desktop-chart-full .action-bar-inner {
    max-width: none;
    box-shadow: none;
    border: none;
    border-radius: 0;
    padding: 12px 16px;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  body.desktop-chart-full .toast {
    right: calc(var(--signal-panel-w) / 2);
    left: auto;
    transform: translateX(50%) translateY(8px);
  }
  body.desktop-chart-full .toast.show {
    transform: translateX(50%) translateY(0);
  }
}

.tv-chart .tradingview-widget-copyright {
  height: 28px;
  line-height: 28px;
  text-align: center;
  font-size: 11px;
  color: hsl(var(--muted-foreground));
}
.tv-chart .tradingview-widget-copyright a,
.tv-chart .tradingview-widget-copyright .blue-text {
  color: hsl(var(--muted-foreground));
  text-decoration: none;
}
.tv-chart .tradingview-widget-copyright a:hover .blue-text { color: hsl(var(--foreground)); }

/* ── Generic fold-out (Footer / Presets) ── */
.foldout { padding: 0; gap: 0; }
.foldout > .foldout-summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  user-select: none;
}
.foldout > .foldout-summary > .lbl { margin: 0; }
.foldout > .foldout-summary > .dim { margin-right: auto; }
.foldout > .foldout-summary::-webkit-details-marker { display: none; }
.foldout > .foldout-summary::marker { content: ""; }
.foldout > .foldout-summary::after {
  content: "";
  width: 7px; height: 7px;
  border-right: 1.5px solid hsl(var(--muted-foreground));
  border-bottom: 1.5px solid hsl(var(--muted-foreground));
  transform: rotate(-45deg);
  transition: transform 0.15s;
}
.foldout[open] > .foldout-summary::after { transform: rotate(45deg); }
.foldout[open] > .foldout-summary { border-bottom: 1px solid hsl(var(--border)); }
.foldout-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
}
.preset-select .select-trigger { height: 44px; font-size: 15px; }

/* ── Advanced fold-out ── */
.advanced { padding: 0; gap: 0; }
.advanced > .advanced-summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 16px;
  user-select: none;
}
.advanced > .advanced-summary::-webkit-details-marker { display: none; }
.advanced > .advanced-summary::marker { content: ""; }
.advanced[open] > .advanced-summary { border-bottom: 1px solid hsl(var(--border)); }
.advanced-body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
}

/* ── Mobile: flat sections, edge-to-edge width, full-bleed chart ── */
/* Placed last so it wins the cascade over the base .card rules above. */
@media (max-width: 640px) {
  .main {
    padding-top: 0;
    padding-left: 0;
    padding-right: 0;
    padding-bottom: 0;
    gap: 0;
  }
  /* Drop the card "chrome" so sections read as one continuous form. */
  .card {
    border: none;
    border-radius: 0;
    box-shadow: none;
  }
  .card + .card {
    border-top: 1px solid hsl(var(--border));
  }
  /* First section: chart flush to top + sides, only safe-area inset. */
  .main > .card:first-child {
    padding: max(10px, env(safe-area-inset-top)) 0 0;
  }
  .main > .card:first-child .lbl-row {
    margin-bottom: 8px;
    padding-left: 16px;
    padding-right: 16px;
  }
  /* Chart spans the full screen width. */
  .card .tv-chart--compact,
  .card .tv-chart--large {
    width: 100%;
    border-left: none;
    border-right: none;
    border-radius: 0;
  }
  .disclaimer {
    padding-left: 16px;
    padding-right: 16px;
    padding-top: 24px;
    padding-bottom: calc(96px + env(safe-area-inset-bottom));
  }
  .action-bar {
    padding-left: 10px;
    padding-right: 10px;
  }
  .toast {
    bottom: calc(82px + env(safe-area-inset-bottom));
  }
}
