:root,
[data-theme="paper"] {
  --bg: #efe6d2;
  --ink: #1c1710;
  --muted: #6a5e4e;
  --line: #d9ccb4;
  --up: #176b4b;
  --down: #b43332;
  --panel: #f7f1e4;
  --shadow: 0 18px 40px rgb(48 36 18 / 0.16);
}

[data-theme="stone"] {
  --bg: #e6e2d8;
  --ink: #1f2420;
  --muted: #5c635c;
  --line: #cfc8bb;
  --up: #3e6e52;
  --down: #9a5648;
  --panel: #f3efe6;
  --shadow: 0 18px 40px rgb(40 40 32 / 0.14);
}

[data-theme="phosphor"] {
  --bg: #07140c;
  --ink: #c6f5c0;
  --muted: #7fb887;
  --line: #163822;
  --up: #3dff7a;
  --down: #ffb020;
  --panel: #0c1f12;
  --shadow: 0 18px 40px rgb(0 0 0 / 0.5);
}

[data-theme="dusk"] {
  --bg: #161325;
  --ink: #efe7ff;
  --muted: #b7adc8;
  --line: #2c2640;
  --up: #3ee0c8;
  --down: #ff7a8a;
  --panel: #1f1a33;
  --shadow: 0 18px 40px rgb(10 8 20 / 0.5);
}

[data-theme="night"] {
  --bg: #10131a;
  --ink: #f2ead8;
  --muted: #c4b8a0;
  --line: #2a3140;
  --up: #3ee08a;
  --down: #ff5d55;
  --panel: #1a1f2a;
  --shadow: 0 18px 40px rgb(8 10 16 / 0.45);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Bricolage Grotesque", "Segoe UI", sans-serif;
  min-height: 100dvh;
  height: 100dvh;
}

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

.top {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px 20px;
  padding: 12px 18px 10px;
}

.brand {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.index {
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
  font-variant-numeric: tabular-nums;
}

.idx-name {
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.idx-val {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 1.15rem;
  font-weight: 500;
}

.idx-chg {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.92rem;
}

.idx-chg.up,
.tip .up {
  color: var(--up);
}

.idx-chg.down,
.tip .down {
  color: var(--down);
}

.meta {
  display: flex;
  justify-self: end;
  align-items: center;
  gap: 12px;
}

#asof {
  color: var(--muted);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.72rem;
}

.theme-wrap {
  position: relative;
}

.theme-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}

.theme-btn svg {
  width: 18px;
  height: 18px;
  color: var(--ink);
}

.theme-btn svg .ring {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
}

.theme-btn svg .half {
  fill: currentColor;
}

.theme-btn:hover,
.theme-btn[aria-expanded="true"] {
  background: var(--panel);
}

.theme-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 4;
  display: grid;
  gap: 4px;
  min-width: 148px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.theme-menu[hidden] {
  display: none;
}

.theme-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.88rem;
  text-align: left;
  cursor: pointer;
}

.theme-menu button:hover,
.theme-menu button[aria-selected="true"] {
  background: color-mix(in srgb, var(--ink) 8%, transparent);
}

.swatch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 18px;
  height: 18px;
  overflow: hidden;
  border-radius: 999px;
}

.swatch i:last-child {
  grid-column: 2;
}

.board {
  position: relative;
  flex: 1 1 0;
  min-height: 0;
  overflow: hidden;
  margin: 0 10px 10px;
}

.tile {
  position: absolute;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  overflow: hidden;
  padding: 8px 10px;
  border: 1px solid color-mix(in srgb, var(--ink) 14%, transparent);
  border-radius: 8px;
  cursor: default;
}

.sym,
.chg {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.sym {
  font-size: clamp(0.62rem, 1.1vw, 0.92rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.chg {
  margin-top: 2px;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: clamp(0.58rem, 0.9vw, 0.78rem);
}

.tile .chg {
  color: inherit;
  opacity: 0.92;
}

.empty {
  margin: 24px;
  color: var(--muted);
}

.tip {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 6;
  min-width: 180px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
  pointer-events: none;
}

.tip-name {
  font-size: 0.92rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.tip-sym,
.tip-cap {
  color: var(--muted);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.7rem;
}

.tip-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0 6px;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.86rem;
}

@media (max-width: 760px) {
  .top {
    grid-template-columns: 1fr auto;
  }

  .index {
    grid-column: 1 / -1;
    flex-wrap: wrap;
  }

  .idx-val {
    font-size: 1.3rem;
  }
}

@media (prefers-reduced-motion: no-preference) {
  body,
  .theme-btn,
  .theme-menu button {
    transition: background-color 160ms ease, color 160ms ease, border-color 160ms ease;
  }
}
