:root {
  color-scheme: dark;
  --bg: #101114;
  --panel: #191b20;
  --panel-2: #20232a;
  --line: #30343d;
  --text: #f2f4f8;
  --muted: #9da6b5;
  --accent: #4fd1a5;
  --warn: #f3bf5f;
  --bad: #ff6b7a;
  --good: #4fd1a5;
  --blue: #76a7ff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  letter-spacing: 0;
}

a {
  color: inherit;
}

.shell {
  width: min(1580px, 100%);
  min-height: 100vh;
  margin-inline: auto;
  padding: 28px;
}

.topbar,
.stock-top,
.chat-header,
.status-strip {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.eyebrow,
.label,
.route,
dt {
  color: var(--muted);
  font-size: 12px;
}

.eyebrow {
  margin: 0 0 6px;
  text-transform: uppercase;
}

h1,
h2,
p,
dl {
  margin: 0;
}

h1 {
  font-size: 42px;
  line-height: 1;
}

.status-strip {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.pill {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 12px;
  background: var(--panel);
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.pill.ok {
  color: var(--good);
  border-color: color-mix(in srgb, var(--good), transparent 50%);
}

.pill.warn {
  color: var(--warn);
  border-color: color-mix(in srgb, var(--warn), transparent 50%);
}

.refresh-status {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  background: var(--panel);
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.refresh-icon {
  position: relative;
  width: 16px;
  height: 16px;
  display: inline-block;
  border: 2px solid color-mix(in srgb, var(--accent), transparent 45%);
  border-right-color: transparent;
  border-radius: 50%;
}

.refresh-status.is-refreshing .refresh-icon {
  animation: refresh-spin 700ms ease-in-out;
}

.refresh-icon::after {
  content: "";
  position: absolute;
  right: -3px;
  top: 0;
  width: 7px;
  height: 7px;
  background: var(--accent);
  clip-path: polygon(0 0, 100% 50%, 0 100%);
  transform: rotate(35deg);
}

.warnings {
  margin-bottom: 16px;
  border: 1px solid color-mix(in srgb, var(--warn), transparent 55%);
  border-radius: 8px;
  padding: 12px 14px;
  background: color-mix(in srgb, var(--warn), transparent 90%);
  color: var(--warn);
  font-size: 13px;
}

.markets {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 360px));
  justify-content: center;
  gap: 16px;
}

.positive strong {
  color: var(--bad);
}

.negative strong {
  color: var(--good);
}

.stock {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  background: var(--panel);
}

.stock.skeleton {
  background:
    linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.04), transparent),
    var(--panel);
  background-size: 180px 100%, auto;
  animation: shimmer 1.2s infinite linear;
}

.stock-top {
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 22px;
}

.stock-top h2 {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 5px;
  font-size: 24px;
}

.stock-top h2 small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
}

.stock-top a,
.chat-form button,
.icon-button {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-2);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}

.stock-top a {
  padding: 6px 9px;
  font-size: 12px;
}

.price-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.price-stack {
  min-width: 0;
}

.price {
  min-width: 0;
  min-height: 54px;
  font-size: 38px;
  font-weight: 800;
  line-height: 1.1;
}

.subprice {
  margin-top: 6px;
  color: var(--muted);
  text-align: left;
  white-space: nowrap;
}

.price-change {
  flex: 0 0 auto;
  padding-top: 4px;
  text-align: right;
}

.price-change strong,
.price-change span,
.price-change small {
  display: block;
}

.price-change strong {
  font-size: 20px;
  line-height: 1.1;
}

.price-change span {
  margin-top: 4px;
  font-size: 13px;
  font-weight: 700;
}

.price-change small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.price-change.positive strong,
.price-change.positive span {
  color: var(--bad);
}

.price-change.negative strong,
.price-change.negative span {
  color: var(--good);
}

.domestic-price {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding: 10px 0 0;
  border-top: 1px solid var(--line);
}

.domestic-price span {
  color: var(--muted);
  font-size: 13px;
}

.domestic-price strong {
  display: block;
  font-size: 18px;
  text-align: right;
}

.domestic-price em {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  text-align: right;
}

.domestic-price em.positive {
  color: var(--bad);
}

.domestic-price em.negative {
  color: var(--good);
}

.price.flash-up,
.domestic-price strong.flash-up {
  animation: price-flash-up 1400ms ease-out;
}

.price.flash-down,
.domestic-price strong.flash-down {
  animation: price-flash-down 1400ms ease-out;
}

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

.stats > div {
  min-width: 0;
}

dt {
  margin-bottom: 3px;
}

dd {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-panel {
  position: fixed;
  inset: 0 0 0 auto;
  width: 332px;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--line);
  background: #15171c;
}

.chat-panel[hidden] {
  display: none;
}

.chat-header {
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.chat-header strong {
  display: block;
  margin-top: 4px;
}

.icon-button {
  width: 38px;
  height: 38px;
}

.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
}

.chat-message {
  padding: 11px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.chat-message div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.chat-message strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.chat-message time {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.chat-message p {
  color: #d9dee8;
  font-size: 14px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr 64px;
  gap: 8px;
  padding: 14px;
  border-top: 1px solid var(--line);
}

.chat-form input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 11px 12px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
}

.chat-form button {
  font: inherit;
}

@keyframes shimmer {
  from {
    background-position: -180px 0, 0 0;
  }
  to {
    background-position: 420px 0, 0 0;
  }
}

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

@keyframes price-flash-up {
  0% {
    color: var(--bad);
    background: linear-gradient(90deg, rgba(255, 107, 122, 0.28), transparent);
  }
  100% {
    background: transparent;
  }
}

@keyframes price-flash-down {
  0% {
    color: var(--good);
    background: linear-gradient(90deg, rgba(79, 209, 165, 0.25), transparent);
  }
  100% {
    background: transparent;
  }
}

@media (max-width: 1040px) {
  .shell {
    width: 100%;
    min-height: auto;
    padding: 22px 18px;
  }

  .chat-panel {
    position: static;
    width: calc(100% - 36px);
    height: 320px;
    margin: 0 18px 18px;
    border-top: 1px solid var(--line);
    border: 1px solid var(--line);
    border-radius: 8px;
    border-left: 0;
  }

}

@media (max-width: 720px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .status-strip {
    justify-content: flex-start;
  }

  .refresh-status {
    width: 34px;
    justify-content: center;
    padding-inline: 0;
  }

  .refresh-status time {
    display: none;
  }

  h1 {
    font-size: 36px;
  }

  .price {
    font-size: 30px;
  }

  .price-row {
    gap: 8px;
  }

  .subprice {
    font-size: 12px;
  }

  .markets {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 430px) {
  .shell {
    padding: 18px 12px;
  }

  .status-strip {
    gap: 6px;
  }

  .pill {
    min-height: 31px;
    padding: 6px 10px;
    font-size: 12px;
  }

  .stock {
    min-height: 0;
    padding: 16px;
  }

  .stock-top h2 {
    font-size: 21px;
  }

  .price {
    font-size: 28px;
  }

  .stats {
    gap: 6px;
  }

  .chat-panel {
    width: calc(100% - 24px);
    margin-inline: 12px;
  }
}
