:root {
  color-scheme: dark;
  --bg: #0b1220;
  --panel: #0b1220;
  --line: #1f2a3d;
  --grid: rgba(143, 155, 176, 0.08);
  --text: #d9e2f1;
  --muted: #8f9bb0;
  --green: #19c37d;
  --yellow: #f4b400;
  --red: #ef4444;
  --cyan: #22d3ee;
  --oi: #22d3ee;
}

@font-face {
  font-family: "ALSSchlangeslab-Bold";
  src: url("./assets/fonts/ALSSchlangeslab-Bold.ttf") format("truetype");
  font-style: normal;
  font-weight: 700;
  font-display: swap;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, sans-serif;
  overflow: hidden;
}

.app {
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}

.topbar {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: #0b1220;
}

.brand {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 156px;
}

.brand-mark {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  color: #f5f8fb;
  font-family: "ALSSchlangeslab-Bold", "ALS Schlange Slab Bold", "Arvo", "Roboto Slab", "Trebuchet MS", "Segoe UI", Arial, sans-serif;
  font-size: 32px;
  line-height: 0.78;
  letter-spacing: -0.025em;
  font-weight: 700;
  white-space: nowrap;
}

.brand-word {
  display: inline-block;
}

.brand-triangle {
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 10px solid var(--red);
  margin: 0 0 1px;
  transition: border-top-color 160ms ease, border-bottom-color 160ms ease, transform 160ms ease;
}

.brand-mark[data-trend="up"] .brand-triangle {
  border-top: 0;
  border-bottom: 10px solid var(--green);
  transform: translateY(-1px);
}

.brand-mark[data-trend="down"] .brand-triangle {
  border-bottom: 0;
  border-top: 10px solid var(--red);
  transform: translateY(1px);
}

.brand-mark[data-trend="neutral"] .brand-triangle {
  border-top: 0;
  border-bottom: 10px solid var(--green);
  transform: translateY(0);
}

.timeframe-picker {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  border-left: 1px solid rgba(143, 155, 176, 0.35);
  border-right: 1px solid rgba(143, 155, 176, 0.35);
  height: 38px;
  flex: 0 0 auto;
}

.tf-btn {
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: #c8d1df;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  padding: 2px 6px;
  cursor: pointer;
  transition: color 120ms ease, border-color 120ms ease, background-color 120ms ease;
}

.tf-btn:hover {
  color: #f3f7ff;
}

.tf-btn.active {
  color: #ffd768;
  background: rgba(244, 180, 0, 0.13);
  border-color: rgba(244, 180, 0, 0.4);
  box-shadow: inset 0 0 0 1px rgba(244, 180, 0, 0.08);
}

.news-brief-wrap {
  min-width: 0;
  width: 100%;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) 30px;
  align-items: stretch;
  gap: 6px;
}

.news-nav {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #0d1525;
  color: #8f9bb0;
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  transition: color 120ms ease, border-color 120ms ease, background-color 120ms ease;
}

.news-nav:hover:not(:disabled) {
  color: #dff5ff;
  border-color: rgba(34, 211, 238, 0.4);
  background: rgba(34, 211, 238, 0.08);
}

.news-nav:disabled {
  opacity: 0.45;
  cursor: default;
}

.news-brief {
  min-width: 0;
  width: 100%;
  border: 1px solid rgba(34, 211, 238, 0.16);
  background: linear-gradient(120deg, rgba(34, 211, 238, 0.08), rgba(11, 18, 32, 0.1));
  border-radius: 10px;
  padding: 8px 12px;
  text-decoration: none;
  overflow: hidden;
}

.news-headline {
  color: #dff5ff;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.news-summary {
  display: none;
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  white-space: nowrap;
}

.settings-btn {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #0d1525;
  color: var(--text);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.settings-btn:hover {
  border-color: rgba(34, 211, 238, 0.45);
  color: #dff5ff;
}

.settings-btn[data-state="guest"] {
  border-color: rgba(244, 180, 0, 0.35);
  color: #fde68a;
}

.settings-btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.meta-pill {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #0d1525;
  color: var(--muted);
  font-size: 11px;
}

#news-tone[data-tone="bullish"] {
  border-color: rgba(25, 195, 125, 0.42);
  color: #a7f3d0;
}

#news-tone[data-tone="bearish"] {
  border-color: rgba(239, 68, 68, 0.42);
  color: #fecaca;
}

#news-tone[data-tone="neutral"] {
  border-color: rgba(244, 180, 0, 0.42);
  color: #fde68a;
}

.dashboard {
  padding: 1px;
  background: var(--line);
  min-height: 0;
  overflow: hidden;
}

.grid {
  --grid-cols: 3;
  --grid-rows: 3;
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(var(--grid-cols), minmax(0, 1fr));
  grid-template-rows: repeat(var(--grid-rows), minmax(0, 1fr));
  gap: 1px;
}

.card {
  position: relative;
  min-height: 0;
  background: var(--panel);
  overflow: hidden;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px 0;
}

.symbol-block {
  min-width: 0;
}

.symbol-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.symbol {
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

.symbol-sub {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
}

.price-head {
  text-align: right;
}

.price-head-value {
  font-size: 14px;
  font-weight: 700;
  transition: color 120ms linear;
}

.price-head-value.price-up {
  color: var(--green);
}

.price-head-value.price-down {
  color: var(--red);
}

.price-head-sub {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.price-head > .price-head-sub:first-child {
  margin-top: 0;
}

.price-head-sub.price-change-up {
  color: #a7f3d0;
}

.price-head-sub.price-change-down {
  color: #fecaca;
}

.price-head-sub.price-change-neutral {
  color: var(--muted);
}

.chart-wrap {
  position: absolute;
  inset: 40px 6px 28px;
  background:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px),
    #0a1322;
  background-size: 100% 25%, 16.666% 100%;
  overflow: hidden;
}

.price-layer,
.volume-layer,
.oi-layer {
  position: absolute;
  inset: 0;
}

.price-layer svg,
.volume-layer svg,
.oi-layer svg {
  width: 100%;
  height: 100%;
  display: block;
}

.volume-layer {
  inset: auto 0 0 0;
  height: 24%;
  opacity: 0.38;
}

.oi-layer {
  inset: 4px 4px 24px 4px;
  opacity: 0.78;
}

.price-scale {
  position: absolute;
  top: 40px;
  right: 6px;
  bottom: 28px;
  width: 46px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-end;
  z-index: 2;
  pointer-events: none;
}

.price-tick,
.time-tick {
  font-size: 8px;
  line-height: 1;
  color: rgba(143, 155, 176, 0.9);
  background: rgba(11, 18, 32, 0.72);
  padding: 1px 2px;
  border-radius: 2px;
}

.price-tick-max,
.price-tick-min {
  font-size: 10px;
  line-height: 1.1;
  font-weight: 700;
  padding: 2px 4px;
}

.price-tick-max {
  color: #b6f8d6;
  background: rgba(15, 46, 34, 0.88);
  border: 1px solid rgba(25, 195, 125, 0.45);
}

.price-tick-min {
  color: #ffc8c8;
  background: rgba(56, 20, 25, 0.88);
  border: 1px solid rgba(239, 68, 68, 0.45);
}

.time-scale {
  position: absolute;
  left: 6px;
  right: 52px;
  bottom: 28px;
  height: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 2;
  pointer-events: none;
}

.signal-badge {
  display: inline-block;
  flex: 0 0 auto;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 9px;
  line-height: 1.2;
  font-weight: 700;
  border: 1px solid transparent;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.signal-up {
  background: rgba(22, 163, 74, 0.24);
  border-color: rgba(22, 163, 74, 0.5);
  color: #bbf7d0;
}

.signal-neutral {
  background: rgba(202, 138, 4, 0.26);
  border-color: rgba(202, 138, 4, 0.5);
  color: #fef3c7;
}

.signal-down {
  background: rgba(220, 38, 38, 0.26);
  border-color: rgba(220, 38, 38, 0.5);
  color: #fecaca;
}

.oi-label {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 15px;
  z-index: 3;
  font-size: 10px;
  line-height: 1;
  font-weight: 700;
  color: var(--oi);
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.oi-band {
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 6px;
  height: 6px;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(34, 211, 238, 0.12);
  background: rgba(34, 211, 238, 0.06);
  z-index: 3;
}

.oi-fill {
  height: 100%;
  background: linear-gradient(90deg, rgba(34, 211, 238, 0.28), rgba(34, 211, 238, 0.82));
}

.pending {
  position: absolute;
  inset: 40px 6px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px dashed rgba(143, 155, 176, 0.18);
  color: var(--muted);
  text-align: center;
  padding: 12px;
}

.pending-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.pending-note {
  font-size: 11px;
}

.error-box {
  position: absolute;
  inset: 40px 6px 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  text-align: center;
  color: #fca5a5;
  font-size: 11px;
}

.ribbon {
  display: flex;
  align-items: center;
  gap: 18px;
  height: 34px;
  padding: 0 10px;
  border-top: 1px solid var(--line);
  background: #0b1220;
  white-space: nowrap;
  overflow: hidden;
  font-size: 12px;
}

.ribbon-label {
  color: var(--cyan);
  font-weight: 700;
}

.ribbon-item {
  color: var(--text);
}

body.oi-hidden .oi-layer,
body.oi-hidden .oi-label,
body.oi-hidden .oi-band {
  display: none;
}

.hidden {
  display: none !important;
}

.settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(3, 8, 18, 0.74);
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 16px;
}

.settings-modal {
  width: min(980px, 100%);
  max-height: min(88vh, 940px);
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: #0b1220;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.settings-title {
  margin: 0;
  font-size: 16px;
}

.settings-subtitle {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.settings-close {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #0d1525;
  color: var(--text);
  cursor: pointer;
}

.settings-body {
  min-height: 0;
  overflow: auto;
  padding: 12px 14px;
}

.settings-layout {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.settings-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.settings-field input {
  width: 86px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d1525;
  color: var(--text);
  padding: 7px 9px;
  font-size: 14px;
}

.settings-field.settings-field-wide {
  margin-top: 12px;
}

.settings-field.settings-field-wide input {
  width: min(520px, 100%);
  font-size: 13px;
}

.settings-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text);
  margin-bottom: 2px;
}

.settings-hint {
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}

.settings-cells {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}

.settings-cell {
  display: grid;
  grid-template-columns: 34px 170px minmax(0, 1fr);
  gap: 8px;
}

.settings-index {
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d1525;
  color: var(--muted);
  font-size: 12px;
}

.settings-source,
.settings-symbol {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d1525;
  color: var(--text);
  padding: 8px 10px;
  font-size: 13px;
}

.settings-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
}

.settings-action {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d1525;
  color: var(--text);
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
}

.settings-save {
  border-color: rgba(34, 211, 238, 0.45);
  color: #dff5ff;
}

.account-auth-panel,
.account-settings-panel {
  display: grid;
  gap: 14px;
}

.account-copy,
.account-section-copy {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.account-auth-form {
  display: grid;
  gap: 12px;
}

.account-field {
  display: grid;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.account-field input {
  width: min(360px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d1525;
  color: var(--text);
  padding: 9px 10px;
  font-size: 14px;
}

.account-code-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.account-code-email {
  color: var(--muted);
  font-size: 12px;
}

.account-link-btn {
  border: 0;
  background: transparent;
  color: #dff5ff;
  cursor: pointer;
  padding: 0;
  font-size: 12px;
}

.account-debug,
.account-error {
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12px;
}

.account-debug {
  border: 1px solid rgba(25, 195, 125, 0.35);
  background: rgba(25, 195, 125, 0.08);
  color: #a7f3d0;
}

.account-error {
  border: 1px solid rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.08);
  color: #fecaca;
}

.account-section {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0d1525;
  padding: 12px;
}

.account-summary {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.account-user-name {
  font-size: 18px;
  font-weight: 700;
}

.account-user-email {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.account-user-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.account-badge {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #081224;
  color: var(--muted);
  font-size: 11px;
}

.account-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.account-section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.account-current-dashboard {
  border: 1px solid rgba(34, 211, 238, 0.2);
  border-radius: 999px;
  background: rgba(34, 211, 238, 0.08);
  color: var(--text);
  font-size: 11px;
  letter-spacing: 0.03em;
  padding: 8px 12px;
  white-space: nowrap;
}

.account-dashboard-create {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 10px;
}

.account-dashboard-create-field {
  margin-bottom: 0;
}

.account-dashboard-create-btn {
  min-width: 188px;
}

.account-dashboard-note {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.account-dashboard-manage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 12px;
}

.account-dashboard-manage-field {
  margin-bottom: 0;
}

.account-dashboard-rename-btn {
  min-width: 148px;
}

.account-dashboard-delete-btn {
  min-width: 120px;
  border-color: rgba(248, 113, 113, 0.38);
  color: #fecaca;
}

.account-dashboard-delete-btn:hover {
  border-color: rgba(248, 113, 113, 0.58);
  background: rgba(248, 113, 113, 0.12);
}

.account-dashboard-list {
  display: grid;
  gap: 8px;
}

.account-dashboard-btn {
  width: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #081224;
  color: var(--text);
  padding: 10px 12px;
  cursor: pointer;
  text-align: left;
}

.account-dashboard-btn:hover {
  border-color: rgba(34, 211, 238, 0.45);
}

.account-dashboard-btn.is-active {
  border-color: rgba(34, 211, 238, 0.45);
  background: rgba(34, 211, 238, 0.08);
}

.account-dashboard-copy {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.account-dashboard-path {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.account-empty {
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 1100px) {
  .brand {
    min-width: 0;
  }

  .brand-mark {
    font-size: 29px;
  }

  .brand-triangle {
    border-left-width: 5px;
    border-right-width: 5px;
  }

  .brand-mark[data-trend="up"] .brand-triangle,
  .brand-mark[data-trend="neutral"] .brand-triangle {
    border-bottom-width: 9px;
  }

  .brand-mark[data-trend="down"] .brand-triangle {
    border-top-width: 9px;
  }

  .timeframe-picker {
    padding: 0 8px;
    gap: 4px;
    height: 32px;
  }

  .tf-btn {
    font-size: 13px;
    padding: 2px 5px;
  }

  .settings-cell {
    grid-template-columns: 34px 1fr;
  }

  .settings-symbol {
    grid-column: 1 / -1;
  }
}

@media (max-width: 700px) {
  .brand-mark {
    font-size: 24px;
  }

  .brand-triangle {
    border-left-width: 4px;
    border-right-width: 4px;
  }

  .brand-mark[data-trend="up"] .brand-triangle,
  .brand-mark[data-trend="neutral"] .brand-triangle {
    border-bottom-width: 8px;
  }

  .brand-mark[data-trend="down"] .brand-triangle {
    border-top-width: 8px;
  }

  .timeframe-picker {
    width: 100%;
    justify-content: flex-start;
    gap: 4px;
    padding: 0;
    border-right: 0;
    border-left: 0;
    height: 28px;
  }

  .tf-btn {
    font-size: 12px;
    padding: 2px 5px;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-meta {
    width: 100%;
    flex-wrap: wrap;
    margin-left: 0;
  }

  .news-brief {
    width: 100%;
  }

  .news-brief-wrap {
    width: 100%;
    grid-template-columns: 26px minmax(0, 1fr) 26px;
    gap: 4px;
  }

  .news-nav {
    border-radius: 8px;
    font-size: 12px;
  }

  .settings-modal {
    max-height: 92vh;
  }

  .account-summary,
  .account-section-head,
  .account-dashboard-btn {
    flex-direction: column;
    align-items: flex-start;
  }

  .account-dashboard-create {
    grid-template-columns: 1fr;
  }

  .account-dashboard-manage {
    grid-template-columns: 1fr;
  }

  .account-dashboard-create-btn {
    width: 100%;
    min-width: 0;
  }

  .account-dashboard-rename-btn,
  .account-dashboard-delete-btn {
    width: 100%;
    min-width: 0;
  }

  .account-dashboard-path {
    white-space: normal;
  }
}
