/* iOS-inspiriertes Design-System – Clean Glass */
:root {
  --bg: #f2f2f7;
  --bg-elevated: rgba(255, 255, 255, 0.78);
  --bg-grouped: rgba(255, 255, 255, 0.72);
  --text: #1c1c1e;
  --text-secondary: #8e8e93;
  --text-tertiary: #aeaeb2;
  --accent: #007aff;
  --accent-pressed: #005ecb;
  --danger: #ff3b30;
  --success: #34c759;
  --warning: #ff9500;
  --separator: rgba(60, 60, 67, 0.08);
  --glass-blur: 28px;
  --glass-blur-strong: 36px;
  --glass-saturate: 120%;
  --glass-bg: rgba(255, 255, 255, 0.72);
  --glass-bg-elevated: rgba(255, 255, 255, 0.84);
  --glass-bg-solid: rgba(255, 255, 255, 0.92);
  --glass-border: rgba(255, 255, 255, 0.65);
  --glass-border-subtle: rgba(0, 0, 0, 0.04);
  --glass-highlight: rgba(255, 255, 255, 0.7);
  --card-shadow: 0 1px 2px rgba(0, 0, 0, 0.03), 0 6px 20px rgba(0, 0, 0, 0.04);
  --card-shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.02), 0 4px 14px rgba(0, 0, 0, 0.03);
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-xl: 22px;
  --sidebar-width: 240px;
  --top-bar-height: 52px;
  --breakpoint-desktop: 768px;
  --breakpoint-wide: 1200px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", system-ui, sans-serif;
}

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

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

body.layout-mobile { overflow: hidden; }
body.layout-desktop { overflow: hidden; }

.app {
  display: flex;
  height: 100dvh;
  width: 100%;
  background: transparent;
  position: relative;
  isolation: isolate;
}

/* Dezenter Hintergrund – weniger Farbrauschen */
.app::before,
.login-body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 70% 45% at 12% 0%, rgba(0, 122, 255, 0.07), transparent 55%),
    radial-gradient(ellipse 55% 40% at 100% 100%, rgba(88, 86, 214, 0.05), transparent 50%),
    #f2f2f7;
  pointer-events: none;
}

/* Frosted-Glass-Panels */
.stat-card,
.chart-card,
.list-card,
.group-card,
.activity-feed,
.ai-feed-list,
.trading-price-bar,
.position-card,
.signal-card,
.tf-card,
.constants-list,
.settings-toolbar,
.memory-detail,
.memory-chip,
.journal-row,
.journal-data-table,
.thinking-box,
.feed-item,
.login-card,
.freeze-overlay__card,
.sidebar,
.top-bar,
.stats-grid--unified,
.ki-panel,
.status-banner {
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
}

/* ── Sidebar (Desktop) ─────────────────────────────────────────────── */
.sidebar {
  display: none;
  flex-direction: column;
  width: var(--sidebar-width);
  background: rgba(255, 255, 255, 0.78);
  border-right: 0.5px solid var(--separator);
  flex-shrink: 0;
  z-index: 50;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 20px 20px;
  border-bottom: 0.5px solid var(--separator);
}

.sidebar__logo {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #007aff, #5856d6);
  color: #fff;
  border-radius: 10px;
  font-size: 16px;
}

.sidebar__title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.sidebar__tagline {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 1px;
}

.sidebar__nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: none;
  background: transparent;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  font-family: var(--font);
  color: var(--text-secondary);
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: rgba(0, 122, 255, 0.06); }
.nav-item--active {
  background: rgba(0, 122, 255, 0.12);
  color: var(--accent);
  font-weight: 600;
}
.nav-item__icon { font-size: 18px; width: 22px; text-align: center; }

.sidebar__status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-top: 0.5px solid var(--separator);
}

.sidebar__footer {
  padding: 10px 20px 16px;
  font-size: 11px;
  color: var(--text-tertiary);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar__hub-link {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}

.sidebar__hub-link:hover {
  text-decoration: underline;
}

/* ── Main Panel ────────────────────────────────────────────────────── */
.main-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100dvh;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.72);
  border-bottom: 0.5px solid var(--separator);
  min-height: var(--top-bar-height);
  gap: 12px;
}

.top-bar__menu {
  display: none;
  border: 1px solid var(--glass-border-subtle);
  background: rgba(255, 255, 255, 0.42);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
}

.top-bar__left { display: flex; align-items: center; gap: 8px; }
.top-bar__title {
  flex: 1;
  text-align: center;
  font-size: 17px;
  font-weight: 600;
  display: none;
}
.top-bar__right {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.top-bar__hub-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 7px 12px;
  border-radius: 10px;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.top-bar__hub-btn:hover {
  background: color-mix(in srgb, var(--accent) 10%, white);
  border-color: color-mix(in srgb, var(--accent) 30%, var(--glass-border));
}

.nav-item--hub {
  text-decoration: none;
  color: inherit;
  margin-bottom: 4px;
  border: 1px dashed color-mix(in srgb, var(--accent) 35%, var(--glass-border));
  background: color-mix(in srgb, var(--accent) 6%, transparent);
}

.module-shell-body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
}

.module-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.module-shell__bar {
  position: sticky;
  top: 0;
  z-index: 20;
}

.module-shell__title {
  flex: 1;
  text-align: center;
  font-size: 17px;
  font-weight: 600;
}

.module-shell__spacer {
  width: 88px;
  flex-shrink: 0;
}

.module-shell__content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px 32px;
}

.placeholder-card-inner {
  width: 100%;
  max-width: 420px;
  background: var(--glass-bg-elevated);
  border-radius: 22px;
  border: 1px solid var(--glass-border);
  box-shadow: var(--card-shadow);
  padding: 28px 24px;
  text-align: center;
}

.layout-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-tertiary);
  padding: 2px 8px;
  background: rgba(118, 118, 128, 0.1);
  border-radius: 6px;
  display: none;
}

.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-tertiary);
}
.dot--off { background: var(--text-tertiary); }
.dot--ok { background: var(--success); }
.dot--run { background: var(--accent); animation: pulse 1.5s infinite; }
.dot--err { background: var(--danger); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
  background: rgba(142, 142, 147, 0.15);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.badge--running { background: rgba(0, 122, 255, 0.15); color: var(--accent); }
.badge--stopping { background: rgba(255, 149, 0, 0.16); color: var(--warning); }
.badge--completed { background: rgba(52, 199, 89, 0.15); color: var(--success); }
.badge--error { background: rgba(255, 59, 48, 0.15); color: var(--danger); }

/* Screens */
.screens {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.screen {
  display: none;
  height: 100%;
  overflow-y: auto;
  padding: 0 16px 16px;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}
.screen--active { display: block; }

.screen-header { margin-bottom: 4px; }

.large-title {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.5px;
  padding-top: 4px;
  line-height: 1.1;
}

.subtitle {
  font-size: 15px;
  color: var(--text-secondary);
  margin: 2px 0 24px;
}

.section-header {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  text-transform: none;
  letter-spacing: -0.2px;
  margin: 20px 0 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.dashboard-aside .section-header:first-child {
  margin-top: 0;
}

/* Hero Card – ein klares Akzent-Widget */
.hero-card {
  background: linear-gradient(145deg, #007aff 0%, #0056c8 100%);
  border-radius: var(--radius-xl);
  padding: 22px 24px;
  color: #fff;
  border: none;
  box-shadow: 0 4px 20px rgba(0, 122, 255, 0.18);
  margin-bottom: 12px;
}

.hero-card--compact {
  background: linear-gradient(145deg, #30b0ff 0%, #007aff 100%);
  box-shadow: 0 4px 20px rgba(0, 122, 255, 0.15);
}

.hero-card__label {
  font-size: 13px;
  font-weight: 500;
  opacity: 0.85;
  margin-bottom: 4px;
}

.hero-card__value {
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -1px;
  margin-bottom: 16px;
  font-variant-numeric: tabular-nums;
}

.hero-card__value--sm { font-size: 32px; }

.hero-card__row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  border-top: 1px solid rgba(255,255,255,0.2);
  padding-top: 14px;
}

.meta-label {
  display: block;
  font-size: 11px;
  opacity: 0.75;
  margin-bottom: 2px;
}

.meta-value {
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 4px;
}

.stats-grid--3 { grid-template-columns: repeat(3, 1fr); }

/* Dashboard: eine gemeinsame Metrik-Leiste statt 4 Einzelkarten */
.stats-grid--unified {
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  background: var(--glass-bg-elevated);
  border-radius: var(--radius-md);
  box-shadow: var(--card-shadow-soft);
  margin-bottom: 20px;
  overflow: hidden;
}

.stats-grid--unified .stat-card {
  background: transparent;
  box-shadow: none;
  border: none;
  border-radius: 0;
  padding: 14px 12px;
  border-right: 0.5px solid var(--separator);
}

.stats-grid--unified .stat-card:last-child {
  border-right: none;
}

.stats-grid--unified .stat-card__label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.stats-grid--unified .stat-card__value {
  font-size: 17px;
}

.stat-card {
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  padding: 14px;
  box-shadow: var(--card-shadow-soft);
}

.stat-card__icon { display: none; }

.stat-card__label {
  font-size: 11px;
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: 4px;
}

.stat-card__value {
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.stat-card__value--green { color: var(--success); }
.stat-card__value--red { color: var(--danger); }

.chart-card--tall canvas { min-height: 120px; }

.chart-card--mini {
  margin-bottom: 12px;
}

.chart-card--market canvas {
  min-height: 168px;
}

.chart-interval-row {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin-bottom: 10px;
  padding: 3px;
  background: rgba(118, 118, 128, 0.08);
  border-radius: 8px;
}

.chart-interval-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font);
  padding: 5px 9px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

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

.chart-interval-btn--active {
  background: var(--glass-bg-solid);
  color: var(--accent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.mini-chart-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.mini-chart-price {
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.mini-chart-change {
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.mini-chart-change--up { color: var(--success); }
.mini-chart-change--down { color: var(--danger); }

.mini-chart-footer {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-tertiary);
}

#bybit-chart-dash,
#bybit-chart-market {
  display: block;
  width: 100%;
}

#bybit-chart-dash {
  height: 200px;
  min-height: 200px;
}

.chart-card--dash-primary {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.chart-card--dash-primary canvas {
  flex: 1;
  min-height: 200px;
}

.dashboard-bybit-header {
  margin-top: 8px;
}

.layout-col--primary {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#bybit-chart-market {
  height: 168px;
  min-height: 168px;
}

.activity-feed--tall { max-height: 160px; }
.ai-feed-list--tall { max-height: 280px; }

.constants-list--tall { max-height: 240px; }

/* Layout Grids (responsive) */
.layout-dashboard,
.layout-trading,
.layout-market,
.layout-settings {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Chart */
.chart-card {
  background: var(--glass-bg-elevated);
  border-radius: var(--radius-md);
  padding: 14px;
  box-shadow: var(--card-shadow-soft);
  overflow: hidden;
}

.chart-card--clean {
  padding: 12px 14px 14px;
}
.chart-card canvas,
#equity-chart {
  display: block;
  width: 100%;
}

/* Buttons */
.btn {
  border: none;
  border-radius: var(--radius-md);
  padding: 12px 18px;
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: transform 0.1s, opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.97); opacity: 0.85; }
.btn--full { width: 100%; }

.btn--primary {
  background: var(--accent);
  color: #fff;
}
.btn--secondary {
  background: rgba(0, 122, 255, 0.12);
  color: var(--accent);
}
.btn--danger {
  background: rgba(255, 59, 48, 0.12);
  color: var(--danger);
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}
.btn--run {
  min-height: 48px;
  font-size: 16px;
  font-weight: 600;
}

.action-row {
  display: flex;
  gap: 8px;
}
.action-row .btn { flex: 1; }

/* Progress */
.progress-block { margin-top: 12px; }
.progress-block__label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.progress-bar {
  height: 6px;
  background: rgba(255, 255, 255, 0.35);
  border: 1px solid var(--glass-border-subtle);
  border-radius: 3px;
  overflow: hidden;
}
.progress-bar__fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  width: 0%;
  transition: width 0.3s ease;
}

/* Activity Feed */
.activity-feed {
  background: var(--glass-bg-elevated);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--card-shadow-soft);
  max-height: 200px;
  overflow-y: auto;
}

.activity-item {
  padding: 10px 14px;
  font-size: 13px;
  border-bottom: 1px solid var(--separator);
  display: flex;
  gap: 8px;
}
.activity-item:last-child { border-bottom: none; }
.activity-item__time {
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  width: 52px;
}
.activity-item--warn .activity-item__msg { color: var(--warning); }
.activity-item--error .activity-item__msg { color: var(--danger); }

/* KI-Feed (Echtzeit-Denkprotokoll) */
.section-header--row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(0, 122, 255, 0.12);
  color: var(--accent);
}

.chip--muted {
  background: rgba(118, 118, 128, 0.12);
  color: var(--text-secondary);
}

.thinking-box {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 14px 16px;
  margin-bottom: 0;
  box-shadow: none;
}

.thinking-box__label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: none;
  letter-spacing: normal;
  margin-bottom: 6px;
}

.thinking-box__text {
  font-size: 14px;
  font-weight: 500;
  line-height: 1.45;
  color: var(--text);
}

.thinking-box__meta {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

.ai-feed-list {
  background: transparent;
  border-radius: 0;
  box-shadow: none;
  overflow-y: auto;
  max-height: 220px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.ai-feed-list--tall { max-height: 240px; }

.ki-panel {
  background: var(--glass-bg-elevated);
  border-radius: var(--radius-md);
  box-shadow: var(--card-shadow-soft);
  overflow: hidden;
  margin-bottom: 8px;
}

.ki-panel .ai-feed-list {
  border-top: 0.5px solid var(--separator);
  max-height: 200px;
}

.ki-panel .ai-feed-list--tall {
  max-height: 220px;
}

.ki-panel .empty-state {
  padding: 20px 16px;
  font-size: 13px;
}

/* Status-Banner (Dashboard) */
.status-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 4px 0 16px;
}

.status-banner {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--glass-bg);
  color: var(--text-secondary);
  box-shadow: var(--card-shadow-soft);
}

.status-banner--warn {
  background: rgba(255, 149, 0, 0.08);
  color: #8a4b12;
}

.status-banner--danger {
  background: rgba(255, 59, 48, 0.08);
  color: #b3261e;
}

.feed-item {
  border: none;
  border-radius: 0;
  padding: 10px 16px;
  background: transparent;
  border-bottom: 0.5px solid var(--separator);
}

.feed-item:last-child {
  border-bottom: none;
}

.feed-item--warn { background: rgba(255, 149, 0, 0.05); }
.feed-item--error { background: rgba(255, 59, 48, 0.05); }

.feed-item__line {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 13px;
  line-height: 1.4;
}

.feed-item__time {
  flex-shrink: 0;
  width: 52px;
  font-size: 11px;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}

.feed-item__cat {
  flex-shrink: 0;
  min-width: 44px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--accent);
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(0, 122, 255, 0.1);
}

.feed-item--warn .feed-item__cat {
  color: var(--warning);
  background: rgba(255, 149, 0, 0.12);
}

.feed-item--error .feed-item__cat {
  color: var(--danger);
  background: rgba(255, 59, 48, 0.1);
}

.feed-item__text {
  flex: 1;
  min-width: 0;
  color: var(--text);
}

.feed-item--warn .feed-item__text { color: #8a4b12; }
.feed-item--error .feed-item__text { color: #b3261e; }

.ki-panel--trading {
  margin-bottom: 16px;
}

.ki-status-line {
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 0.5px solid var(--separator);
  line-height: 1.4;
}

.ai-feed-list--trading {
  max-height: 280px;
}

.ki-panel .ai-feed-list--tall {
  max-height: 320px;
}

.feed-item__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.feed-item__title {
  font-size: 13px;
  font-weight: 700;
}

.feed-item__time {
  font-size: 11px;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.feed-item__msg {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.35;
}

.feed-cat {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 2px 6px;
  border-radius: 6px;
  margin-bottom: 6px;
}

.feed-cat--llm { background: rgba(88, 86, 214, 0.15); color: #5856d6; }
.feed-cat--signal { background: rgba(0, 122, 255, 0.15); color: var(--accent); }
.feed-cat--risk { background: rgba(255, 149, 0, 0.15); color: #ff9500; }
.feed-cat--market { background: rgba(52, 199, 89, 0.15); color: var(--success); }
.feed-cat--rules { background: rgba(255, 59, 48, 0.12); color: var(--danger); }
.feed-cat--trade { background: rgba(52, 199, 89, 0.18); color: #248a3d; }
.feed-cat--system { background: rgba(118, 118, 128, 0.15); color: var(--text-secondary); }

/* Group Card */
.group-card {
  background: var(--glass-bg-elevated);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--card-shadow-soft);
  margin-bottom: 12px;
}
.group-card__title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
}
.group-card__actions { margin-top: 14px; }

/* Segmented Control */
.segmented {
  display: flex;
  background: rgba(118, 118, 128, 0.1);
  border-radius: 9px;
  padding: 2px;
}
.segmented__btn {
  flex: 1;
  border: none;
  background: transparent;
  padding: 7px 0;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font);
  color: var(--text);
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
}
.segmented__btn--active {
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  font-weight: 600;
}

.segmented--compact {
  flex: 0 0 auto;
  min-width: 148px;
}

.section-header--row .chart-category-switch {
  margin-left: auto;
}

.form-hint {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
  margin: 6px 0 0;
}

/* Details (Advanced) – ruhiger, einheitlicher Look */
.settings-details > summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  list-style: none;
}
.settings-details > summary::-webkit-details-marker { display: none; }
.settings-details > summary::after {
  content: "›";
  margin-left: 8px;
  display: inline-block;
  transform: rotate(90deg);
  opacity: 0.7;
}
.settings-details[open] > summary::after { transform: rotate(-90deg); }

/* Dashboard: Intervalle reduzieren (häufigste) */
[data-chart-scope="dash"] .chart-interval-btn[data-chart-interval="1s"],
[data-chart-scope="dash"] .chart-interval-btn[data-chart-interval="2s"],
[data-chart-scope="dash"] .chart-interval-btn[data-chart-interval="5s"],
[data-chart-scope="dash"] .chart-interval-btn[data-chart-interval="10s"],
[data-chart-scope="dash"] .chart-interval-btn[data-chart-interval="30s"],
[data-chart-scope="dash"] .chart-interval-btn[data-chart-interval="3"],
[data-chart-scope="dash"] .chart-interval-btn[data-chart-interval="10"],
[data-chart-scope="dash"] .chart-interval-btn[data-chart-interval="30"],
[data-chart-scope="dash"] .chart-interval-btn[data-chart-interval="120"] {
  display: none;
}

.form-hint--warn {
  color: var(--accent-orange, #c93400);
  font-weight: 500;
}

.memory-preview {
  margin: 8px 16px 12px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-secondary);
  background: rgba(118, 118, 128, 0.08);
  border-radius: var(--radius-sm);
  max-height: 140px;
  overflow-y: auto;
}

.memory-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px 8px;
  min-height: 48px;
}
.memory-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  border: none;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-family: var(--font);
  font-weight: 500;
  color: var(--text);
  background: var(--bg-elevated);
  box-shadow: var(--card-shadow);
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
}
.memory-chip:hover {
  background: rgba(0, 122, 255, 0.08);
}
.memory-chip--active {
  background: rgba(0, 122, 255, 0.14);
  box-shadow: 0 0 0 2px rgba(0, 122, 255, 0.35);
}
.memory-chip--superseded {
  opacity: 0.45;
  text-decoration: line-through;
}
.memory-chip__kind {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.memory-chip__text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.memory-detail {
  margin: 8px 16px 16px;
  padding: 14px 16px;
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  box-shadow: var(--card-shadow);
}
.memory-detail__label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.memory-detail__body {
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
}
.memory-footer-hint {
  padding: 0 16px 24px;
}
.memory-back-link {
  display: inline-block;
  margin-top: 8px;
  font-size: 14px;
}

.thinking-box__memory {
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-tertiary);
}

/* List Card */
.list-card {
  background: var(--glass-bg-elevated);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--card-shadow-soft);
}

.list-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  font-size: 15px;
  border-bottom: 1px solid var(--separator);
}
.list-row:last-child { border-bottom: none; }
.list-row span:last-child {
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.pill {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
}
.pill--ok { background: rgba(52,199,89,0.15); color: var(--success); }
.pill--bad { background: rgba(255,59,48,0.15); color: var(--danger); }

/* Positions */
.positions-list { display: flex; flex-direction: column; gap: 8px; }

.trading-price-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  background: var(--glass-bg-elevated);
  border: 1px solid var(--glass-border);
  box-shadow: var(--card-shadow);
}

.trading-price-bar__main {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 10px;
  min-width: 0;
}

.trading-price-bar__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

.trading-price-bar__value {
  font-size: 28px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  line-height: 1.1;
}

.trading-price-bar__change {
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.trading-price-bar__change--up { color: var(--success); }
.trading-price-bar__change--down { color: var(--danger); }

.trading-price-bar__meta {
  font-size: 11px;
  color: var(--text-tertiary);
  white-space: nowrap;
}

#dash-chart-title { flex: 1; min-width: 0; }

.position-card {
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: var(--card-shadow);
}

.position-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.position-card__symbol {
  font-size: 17px;
  font-weight: 700;
}

.side-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  text-transform: uppercase;
}
.side-badge--long { background: rgba(52,199,89,0.15); color: var(--success); }
.side-badge--short { background: rgba(255,59,48,0.15); color: var(--danger); }

.position-card__grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}
.position-card__grid strong {
  color: var(--text);
  font-weight: 600;
}

.position-card__actions {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
}

.btn--compact {
  min-height: 32px;
  padding: 6px 12px;
  font-size: 13px;
}

.paper-reset-block {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--separator, rgba(60, 60, 67, 0.12));
}

.paper-reset-block .form-hint {
  margin-top: 8px;
  margin-bottom: 0;
}

/* Signal Card */
.signal-card {
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--card-shadow);
}

.signal-card__score {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
}

/* Timeframe Grid */
.tf-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.tf-card {
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  padding: 12px;
  box-shadow: var(--card-shadow);
}
.tf-card__label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  margin-bottom: 4px;
}
.tf-card__price {
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.tf-card__meta {
  font-size: 11px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

/* Constants */
.constants-list {
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  max-height: 240px;
  overflow-y: auto;
  box-shadow: var(--card-shadow);
  font-size: 12px;
  font-family: "SF Mono", "Menlo", monospace;
}
.const-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 14px;
  border-bottom: 1px solid var(--separator);
}
.const-row span:first-child { color: var(--text-secondary); }
.const-row span:last-child { font-weight: 600; }

/* Journal Table */
.journal-table { display: flex; flex-direction: column; gap: 8px; }

.journal-row {
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  box-shadow: var(--card-shadow);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px;
  font-size: 13px;
}
.journal-row__pnl {
  font-size: 16px;
  font-weight: 700;
  text-align: right;
  align-self: center;
}
.journal-row__pnl--win { color: var(--success); }
.journal-row__pnl--loss { color: var(--danger); }

.journal-row--detailed .journal-row__main { flex: 1; min-width: 0; }
.journal-row__meta {
  color: var(--text-secondary);
  margin-top: 2px;
  font-size: 12px;
}
.journal-row__reason,
.journal-row__exit {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-secondary);
  white-space: pre-wrap;
}
.journal-row__exit { color: var(--text-tertiary); }
.journal-row__foot {
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-tertiary);
}
.journal-cell-explain {
  max-width: 360px;
  white-space: pre-wrap;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-secondary);
}

/* Desktop Journal Table */
.journal-data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--card-shadow);
  font-size: 13px;
  display: none;
}
.journal-data-table th,
.journal-data-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--separator);
}
.journal-data-table th {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  background: rgba(118, 118, 128, 0.06);
}
.journal-data-table tr:last-child td { border-bottom: none; }
.journal-data-table .pnl-win { color: var(--success); font-weight: 700; }
.journal-data-table .pnl-loss { color: var(--danger); font-weight: 700; }

.positions-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Settings */
/* Interaktiver Chat (Autonom) */
#autonomous-chat-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 420px;
}

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-height: 320px;
  max-height: min(52vh, 520px);
  overflow-y: auto;
  padding: 14px;
  margin-bottom: 4px;
  border-radius: var(--radius-md);
  background: var(--glass-bg);
  border: 0.5px solid var(--separator);
}

.chat-messages.empty-state {
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  font-size: 13px;
  text-align: center;
}

.chat-bubble {
  max-width: 92%;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.45;
}

.chat-bubble--user {
  align-self: flex-end;
  background: rgba(0, 122, 255, 0.14);
  color: var(--text);
  border-bottom-right-radius: 4px;
}

.chat-bubble--assistant {
  align-self: flex-start;
  background: var(--glass-bg-elevated);
  border: 0.5px solid var(--separator);
  border-bottom-left-radius: 4px;
}

.chat-bubble--loading {
  align-self: flex-start;
  background: rgba(118, 118, 128, 0.08);
  border: 0.5px dashed var(--separator);
  border-bottom-left-radius: 4px;
}

.chat-bubble__text--loading {
  color: var(--text-secondary);
  font-style: italic;
}

.chat-bubble__time {
  display: block;
  margin-top: 4px;
  font-size: 10px;
  color: var(--text-tertiary);
}

.chat-compose {
  display: flex;
  gap: 8px;
  align-items: center;
}

.chat-compose__input {
  flex: 1;
  min-width: 0;
  padding: 11px 14px;
  font-size: 15px;
  font-family: var(--font);
  border: 0.5px solid var(--separator);
  border-radius: 12px;
  background: var(--glass-bg-elevated);
}

.chat-compose__input:focus {
  outline: none;
  border-color: rgba(0, 122, 255, 0.4);
}

.chat-compose__send {
  flex-shrink: 0;
  padding: 11px 16px;
  min-height: 44px;
}

/* Legacy chat-log (Settings) */
.chat-log {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(118, 118, 128, 0.08);
  font-size: 12px;
  line-height: 1.45;
  max-height: 140px;
  overflow-y: auto;
}
.chat-log__item { margin-bottom: 8px; }
.chat-log__item:last-child { margin-bottom: 0; }
.chat-log__time { color: var(--text-secondary); margin-right: 6px; }

.settings-group { margin-bottom: 20px; }
.settings-toolbar {
  margin-bottom: 20px;
  padding: 14px 16px;
  background: var(--glass-bg-elevated);
  border-radius: 12px;
  box-shadow: var(--card-shadow-soft);
}
.settings-toolbar__row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.settings-toolbar__row:last-of-type { margin-bottom: 0; }
.settings-toolbar__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 88px;
  flex-shrink: 0;
}
.settings-toolbar__row .segmented { flex: 1; min-width: 200px; }
.settings-toolbar__hint {
  margin: 4px 0 12px;
  font-size: 12px;
}
.settings-group__title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 8px;
  padding-left: 4px;
}

.form-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 16px;
  border-bottom: 1px solid var(--separator);
  font-size: 15px;
  gap: 12px;
}
.form-row:last-child { border-bottom: none; }
.form-row span:first-child { flex-shrink: 0; }

.form-row--stacked {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

.form-row--stacked span:first-child { flex-shrink: 1; }

.form-textarea {
  width: 100%;
  min-height: 72px;
  resize: vertical;
  background: rgba(255, 255, 255, 0.38);
  border: 1px solid var(--glass-border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  line-height: 1.4;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.form-input {
  border: none;
  background: transparent;
  font-size: 15px;
  font-family: var(--font);
  color: var(--text-secondary);
  text-align: right;
  flex: 1;
  min-width: 0;
  outline: none;
}
.form-input:focus { color: var(--accent); }
select.form-input { cursor: pointer; }

.form-row--toggle { cursor: default; }

/* iOS Toggle */
.toggle {
  appearance: none;
  width: 51px;
  height: 31px;
  background: rgba(120, 120, 128, 0.16);
  border-radius: 16px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}
.toggle::after {
  content: "";
  position: absolute;
  width: 27px;
  height: 27px;
  background: #fff;
  border-radius: 50%;
  top: 2px;
  left: 2px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  transition: transform 0.2s;
}
.toggle:checked { background: var(--success); }
.toggle:checked::after { transform: translateX(20px); }

.settings-actions { margin: 24px 0 8px; }

.alert {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.4;
}
.alert--danger {
  background: rgba(255, 59, 48, 0.1);
  color: var(--danger);
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font);
}

.empty-state {
  text-align: center;
  color: var(--text-tertiary);
  font-size: 14px;
  padding: 24px;
}

.footer-note {
  text-align: center;
  font-size: 12px;
  color: var(--text-tertiary);
  padding: 16px 0 8px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: calc(var(--safe-bottom) + 16px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(28, 28, 30, 0.72);
  color: #fff;
  padding: 12px 20px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
  z-index: 200;
  max-width: 90%;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  transition: opacity 0.3s, transform 0.3s;
}
.toast.hidden {
  opacity: 0;
  transform: translateX(-50%) translateY(10px);
  pointer-events: none;
}

.hidden { display: none !important; }

/* Login-Seite – Frosted Glass */
.login-body {
  min-height: 100vh;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
  position: relative;
  isolation: isolate;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--glass-bg-elevated);
  border-radius: 22px;
  border: 1px solid var(--glass-border);
  box-shadow: var(--card-shadow);
  padding: 28px 24px;
}
.login-brand {
  text-align: center;
  margin-bottom: 22px;
}
.login-logo {
  font-size: 34px;
  color: var(--accent);
  display: block;
  margin-bottom: 8px;
}
.login-title {
  font-size: 22px;
  font-weight: 700;
}
.login-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}
.login-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.login-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}
.login-input {
  width: 100%;
  box-sizing: border-box;
  padding: 12px 14px;
  font-size: 15px;
  font-family: var(--font);
  border: 1px solid var(--glass-border-subtle);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: border-color 0.15s, background 0.15s;
}
.login-input:focus {
  outline: none;
  border-color: rgba(0, 122, 255, 0.45);
  background: rgba(255, 255, 255, 0.62);
}
.login-account {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  background: rgba(0, 122, 255, 0.08);
  border-radius: 8px;
  padding: 8px 12px;
  text-align: center;
}
.login-hint {
  font-size: 12px;
  color: var(--text-secondary);
  margin: 0;
}
.login-error {
  margin-top: 14px;
  min-height: 18px;
  font-size: 13px;
  color: var(--danger);
  text-align: center;
}

/* Hub – Modul-Auswahl nach Login */
.hub-body.login-body {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  padding-top: max(56px, calc(20px + env(safe-area-inset-top)));
}

.hub-topbar {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  z-index: 30;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: max(12px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 0
    max(14px, env(safe-area-inset-left));
  pointer-events: none;
}

.hub-topbar__actions {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.hub-settings-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  min-height: 38px;
  border-radius: 10px;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}

.hub-settings-btn:hover {
  background: color-mix(in srgb, var(--accent) 12%, white);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--glass-border));
  transform: translateY(-1px);
}

.hub-settings-btn[hidden] {
  display: none !important;
}

.hub-logout-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  min-height: 38px;
  border-radius: 10px;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.hub-logout-btn:hover {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 35%, var(--glass-border));
  background: color-mix(in srgb, var(--danger) 8%, white);
}

.hub-card {
  max-width: 420px;
  width: min(420px, 100%);
}

.hub-topbar__actions--spread {
  width: 100%;
  justify-content: flex-start;
}

.pc-stage {
  width: min(520px, 100%);
  display: flex;
  justify-content: center;
}

.hub-chat--module {
  max-width: 520px;
  width: 100%;
  min-height: min(70vh, 640px);
}

.hub-chat__list--tall {
  max-height: none;
  flex: 1;
  min-height: 360px;
}

.hub-stage {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  justify-content: center;
  gap: 18px;
  width: min(920px, 100%);
}

.hub-chat {
  max-width: 360px;
  width: min(360px, 100%);
  display: flex;
  flex-direction: column;
  min-height: 420px;
  padding-bottom: 16px;
}

.hub-chat__header {
  margin-bottom: 10px;
}

.hub-chat__title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}

.hub-chat__sub {
  margin: 4px 0 0;
  font-size: 0.85rem;
  color: var(--ios-secondary-label, #8e8e93);
}

.hub-chat__list {
  list-style: none;
  margin: 0;
  padding: 8px;
  flex: 1;
  overflow-y: auto;
  max-height: 320px;
  min-height: 220px;
  border-radius: 14px;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.45);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hub-chat-empty {
  margin: auto;
  padding: 12px;
  text-align: center;
  color: var(--ios-secondary-label, #8e8e93);
  font-size: 0.9rem;
}

.hub-chat-msg {
  align-self: flex-start;
  max-width: 92%;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.04);
}

.hub-chat-msg--mine {
  align-self: flex-end;
  background: rgba(0, 122, 255, 0.12);
}

.hub-chat-msg__meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 2px;
  font-size: 0.72rem;
  color: var(--ios-secondary-label, #8e8e93);
}

.hub-chat-msg__name {
  font-weight: 700;
  color: var(--ios-label, #1c1c1e);
}

.hub-chat-msg__text {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.35;
  white-space: pre-wrap;
  word-break: break-word;
}

.hub-chat__status {
  min-height: 16px;
  margin: 6px 0 0;
  font-size: 0.78rem;
  color: var(--ios-secondary-label, #8e8e93);
}

.hub-chat__form {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.hub-chat__input {
  flex: 1;
  min-width: 0;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  padding: 10px 12px;
  font: inherit;
  background: rgba(255, 255, 255, 0.7);
}

.hub-chat__send {
  border: none;
  border-radius: 12px;
  padding: 10px 14px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  background: #007aff;
  color: #fff;
}

.hub-chat__send:hover {
  filter: brightness(1.05);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 760px) {
  .hub-stage {
    flex-direction: column;
    align-items: center;
  }

  .hub-chat {
    max-width: 420px;
    width: min(420px, 100%);
    min-height: 360px;
  }
}

.hub-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.hub-tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 18px 20px;
  border-radius: 16px;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.hub-tile:hover {
  transform: translateY(-1px);
  box-shadow: var(--card-shadow);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--glass-border));
}

.hub-tile--primary {
  background: color-mix(in srgb, var(--accent) 8%, var(--glass-bg-elevated));
}

.hub-tile--secondary {
  background: var(--glass-bg-elevated);
}

.hub-tile--accent {
  background: color-mix(in srgb, #ff9500 10%, var(--glass-bg-elevated));
  border-color: color-mix(in srgb, #ff9500 25%, var(--glass-border));
}

.hub-tile__icon {
  font-size: 22px;
  line-height: 1;
  color: var(--accent);
}

.hub-tile__title {
  font-size: 17px;
  font-weight: 700;
}

.hub-tile__desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.35;
}


.hub-settings-body {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  padding-top: 8px;
}

.hub-settings-sheet {
  max-height: min(92vh, 920px);
}

.hub-tile--hidden {
  display: none !important;
}

.hub-empty {
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
  margin: 8px 0 16px;
  padding: 12px;
}

.hub-empty.hidden {
  display: none;
}

.placeholder-card {
  text-align: center;
}

.placeholder-empty {
  margin: 8px 0 20px;
  padding: 28px 16px;
  border-radius: 14px;
  background: var(--glass-bg);
  border: 1px dashed var(--glass-border);
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.45;
}

.form-row--toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.form-row--toggle input[type="checkbox"] {
  width: 48px;
  height: 28px;
  accent-color: var(--danger);
  cursor: pointer;
}

.freeze-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
}

.freeze-overlay.hidden {
  display: none;
}

.freeze-overlay__card {
  width: min(420px, 100%);
  background: var(--glass-bg-solid);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--card-shadow);
  text-align: center;
}

.freeze-overlay__title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 10px;
}

.freeze-overlay__text {
  color: var(--text-secondary);
  margin-bottom: 18px;
  line-height: 1.45;
}

.body--frozen .main-panel,
.body--frozen .sidebar {
  pointer-events: none;
  user-select: none;
}

/* Sidebar overlay (mobile drawer) */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 40;
}
.sidebar-backdrop--visible { display: block; }

/* ══════════════════════════════════════════════════════════════════════
   MOBILE  (< 768px) – Hamburger-Menü, einspaltig
   ══════════════════════════════════════════════════════════════════════ */
@media (max-width: 767px) {
  .sidebar { display: none; }
  .sidebar.sidebar--open {
    display: flex;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(var(--glass-blur-strong)) saturate(var(--glass-saturate));
    -webkit-backdrop-filter: blur(var(--glass-blur-strong)) saturate(var(--glass-saturate));
    border-right: 0.5px solid var(--separator);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.08);
  }

  .top-bar__menu { display: block; }
  .top-bar__title { display: block; }
  .top-bar__left { display: flex; }
  .top-bar__left .dot,
  .top-bar__left .badge {
    display: inline-flex;
  }
  .top-bar__left .badge {
    max-width: 42vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .screens {
    flex: 1;
    overflow: hidden;
  }

  .screen {
    padding: 0 12px 16px;
    padding-bottom: calc(var(--safe-bottom) + 16px);
    overflow-x: hidden;
  }

  .screen-header .large-title { font-size: 28px; }
  .screen-header .subtitle { display: block; font-size: 14px; }

  .hero-card {
    padding: 18px;
    margin-bottom: 12px;
  }
  .hero-card__value { font-size: 34px; }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .stats-grid--unified {
    grid-template-columns: repeat(2, 1fr);
    gap: 0;
  }

  .stats-grid--unified .stat-card:nth-child(2) { border-right: none; }
  .stats-grid--unified .stat-card:nth-child(1),
  .stats-grid--unified .stat-card:nth-child(2) { border-bottom: 0.5px solid var(--separator); }
  .stats-grid--unified .stat-card:nth-child(4) { border-right: none; }

  .chart-interval-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin-right: -4px;
    padding-bottom: 6px;
  }
  .chart-interval-row::-webkit-scrollbar { display: none; }
  .chart-interval-btn {
    flex: 0 0 auto;
    min-height: 32px;
    padding: 6px 10px;
  }

  .segmented,
  .chart-category-switch {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .layout-label { display: none; }

  #server-run-hint {
    font-size: 12px;
    line-height: 1.4;
    margin: 0 0 12px;
  }

  .journal-data-table,
  .activity-feed,
  .thinking-box,
  .positions-list {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .form-input,
  .form-select,
  .btn {
    min-height: 44px;
    font-size: 16px;
  }
}

/* ══════════════════════════════════════════════════════════════════════
   DESKTOP (≥ 768px) – Sidebar, Mehrspalten-Layouts
   ══════════════════════════════════════════════════════════════════════ */
@media (min-width: 768px) {
  .sidebar { display: flex; }

  .top-bar__menu { display: none; }
  .top-bar__title { display: none; }
  .top-bar__left { display: none; }

  .screens {
    flex: 1;
    overflow: hidden;
    min-width: 0;
    padding: 0 8px;
  }

  .screen {
    padding: 8px 24px 32px;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    box-sizing: border-box;
  }

  .screen-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-top: 8px;
  }

  .screen-header .large-title {
    font-size: 28px;
    padding-top: 0;
  }

  .screen-header .subtitle {
    margin: 0;
    font-size: 14px;
  }

  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .stats-grid--journal {
    grid-template-columns: repeat(3, 1fr);
    max-width: 600px;
  }

  /* Dashboard: 2 Spalten */
  .layout-dashboard {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 28px;
    align-items: start;
    min-width: 0;
  }

  .layout-dashboard > *,
  .layout-trading > *,
  .layout-market > *,
  .layout-settings > * {
    min-width: 0;
  }

  .hero-card__value { font-size: 48px; }

  .chart-card--tall canvas { min-height: 220px; }
  .activity-feed--tall { max-height: 320px; }

  #bybit-chart-dash {
    height: 280px;
    min-height: 280px;
  }

  .chart-card--dash-primary canvas {
    min-height: 280px;
  }

  /* Trading: Steuerung links, Positionen rechts */
  .layout-trading {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 24px;
    align-items: start;
  }

  .layout-col--positions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    align-content: start;
  }

  .layout-col--positions .section-header:first-child { grid-column: 1; }
  .layout-col--positions #open-positions { grid-column: 1; }
  .layout-col--positions .section-header:nth-of-type(2) { grid-column: 2; grid-row: 1; }
  .layout-col--positions #closed-positions { grid-column: 2; grid-row: 2; }
  .layout-col--positions .section-header:nth-of-type(3) { grid-column: 1 / -1; }
  .layout-col--positions #last-signal { grid-column: 1 / -1; }

  .positions-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 400px;
    overflow-y: auto;
  }

  /* Markt: 2 Spalten */
  .layout-market {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 24px;
    align-items: start;
  }

  .tf-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .constants-list--tall {
    max-height: calc(100vh - 200px);
  }

  /* Einstellungen: 2-Spalten-Grid */
  .layout-settings {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px 24px;
  }

  .settings-actions {
    grid-column: 1 / -1;
    max-width: 400px;
  }

  .footer-note { grid-column: 1 / -1; }

  /* Journal: Tabelle statt Karten */
  .journal-table--cards { display: none; }
  .journal-data-table { display: table; }

  .toast {
    bottom: 32px;
    left: calc(var(--sidebar-width) + 50%);
    transform: translateX(-50%);
  }
  .toast.hidden {
    transform: translateX(-50%) translateY(10px);
  }
}

/* ══════════════════════════════════════════════════════════════════════
   TABLET DESKTOP (768px – 1199px) – einspaltig, kein Overflow
   ══════════════════════════════════════════════════════════════════════ */
@media (min-width: 768px) and (max-width: 1199px) {
  .layout-dashboard,
  .layout-trading,
  .layout-market,
  .layout-settings {
    grid-template-columns: 1fr;
    min-width: 0;
  }

  .layout-trading {
    gap: 16px;
  }

  .layout-col--positions {
    grid-template-columns: 1fr;
  }

  .layout-col--positions .section-header:first-child,
  .layout-col--positions #open-positions,
  .layout-col--positions .section-header:nth-of-type(2),
  .layout-col--positions #closed-positions,
  .layout-col--positions .section-header:nth-of-type(3),
  .layout-col--positions #last-signal {
    grid-column: 1;
    grid-row: auto;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tf-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hero-card__value { font-size: 40px; }

  .screen {
    padding: 8px 16px 28px;
  }
}

/* ══════════════════════════════════════════════════════════════════════
   WIDE DESKTOP (≥ 1200px)
   ══════════════════════════════════════════════════════════════════════ */
@media (min-width: 1200px) {
  :root { --sidebar-width: 260px; }

  .layout-dashboard {
    grid-template-columns: 1.1fr 1fr;
  }

  .layout-trading {
    grid-template-columns: 400px 1fr;
  }

  .screen { padding: 8px 40px 40px; }
}

/* Rulebook-Editor (Modal / Bottom-Sheet) */
.rulebook-modal {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

.rulebook-modal.hidden {
  display: none;
}

.rulebook-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
}

.rulebook-modal__sheet {
  position: relative;
  z-index: 1;
  width: min(920px, 100%);
  max-height: min(92vh, 900px);
  display: flex;
  flex-direction: column;
  text-align: left;
  background: var(--glass-bg-solid);
  border: 1px solid var(--glass-border);
  border-radius: 20px 20px 0 0;
  box-shadow: var(--card-shadow);
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
  animation: rulebook-slide-up 0.28s ease-out;
}

@keyframes rulebook-slide-up {
  from { transform: translateY(24px); opacity: 0.6; }
  to { transform: translateY(0); opacity: 1; }
}

.rulebook-modal__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.rulebook-modal__title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
}

.rulebook-modal__meta {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--text-secondary);
}

.rulebook-modal__close {
  border: none;
  background: var(--surface-2, rgba(120, 120, 128, 0.16));
  color: var(--text-primary);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
}

.rulebook-modal__hint {
  margin: 0 0 12px;
}

.rulebook-modal__editor {
  flex: 1;
  min-height: 280px;
  max-height: calc(92vh - 220px);
  resize: vertical;
  font-family: ui-monospace, "Cascadia Code", "Segoe UI Mono", monospace;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  text-align: left;
  direction: ltr;
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.38);
  border: 1px solid var(--glass-border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.rulebook-modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

@media (min-width: 768px) {
  .rulebook-modal {
    align-items: center;
    padding: 24px;
  }

  .rulebook-modal__sheet {
    border-radius: 20px;
    max-height: min(88vh, 860px);
  }
}

body.rulebook-modal-open {
  overflow: hidden;
}

/* ── Modul 2: Styles in module2.css ─────────────────────────────────── */
/* max-width entfernt – Desktop-Grid braucht volle Breite */

.module3-main {
  padding: 12px 16px 32px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.paper-banner {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(52, 199, 89, 0.12);
  color: var(--label-primary);
  font-size: 14px;
  line-height: 1.35;
}

.paper-banner.hidden {
  display: none;
}

#bybit-chart-m3 {
  width: 100%;
  height: 200px;
  display: block;
}

.module2-controls__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.module2-controls__row--actions {
  margin-top: 12px;
  flex-direction: column;
}

.chart-card--module2 {
  padding: 14px;
}

/* bybit-chart-m2: siehe module2.css */

.module2-chat .chat-messages {
  max-height: 280px;
  overflow-y: auto;
  margin: 10px 0;
}

.module2-settings summary {
  list-style: none;
}

.module2-settings summary::-webkit-details-marker {
  display: none;
}

