:root {
  color-scheme: dark;
  --background: #09090b;
  --surface: #101014;
  --surface-2: #15151a;
  --surface-3: #1b1b22;
  --border: rgba(63, 63, 70, 0.42);
  --border-soft: rgba(63, 63, 70, 0.24);
  --text: #fafafa;
  --muted: #a1a1aa;
  --muted-soft: rgba(161, 161, 170, 0.52);
  --primary: #07b6d5;
  --positive: #34d399;
  --negative: #fb7185;
  --warning: #facc15;
  --focus: #f3b45b;
  --row-height: 61px;
  --content-width: 752px;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--background);
}

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

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 57px;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(9, 9, 11, 0.95);
  backdrop-filter: blur(14px);
}

.topbar-inner {
  width: min(var(--content-width), 100%);
  height: 100%;
  margin: 0 auto;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.exchange-tabs {
  min-width: 0;
  max-width: 100%;
  flex: 1 1 auto;
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border-radius: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  background: rgba(39, 39, 42, 0.45);
}

.exchange-tabs::-webkit-scrollbar {
  display: none;
}

.exchange-tab {
  min-width: 58px;
  min-height: 28px;
  padding: 4px 14px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.exchange-tab.is-active {
  background: var(--primary);
  color: #1a1a1a;
  box-shadow: 0 0 0 1px rgba(7, 182, 213, 0.32), 0 6px 18px rgba(7, 182, 213, 0.14);
}

.topbar-actions {
  min-width: 54px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  color: var(--muted);
}

.icon-button {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  display: inline-grid;
  place-items: center;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 160ms ease, background 160ms ease, transform 160ms ease;
}

.icon-button:hover {
  background: rgba(39, 39, 42, 0.55);
  color: var(--text);
}

.icon-button:active {
  transform: translateY(1px);
}

.icon {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

.timer {
  min-width: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.timer.is-fetching .icon {
  animation: spin 900ms linear infinite;
}

.rate-editor {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.rate-editor input {
  width: 96px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #0d0d11;
  color: var(--text);
  padding: 0 8px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  outline: none;
}

.manual-label {
  color: var(--warning);
  font-size: 10px;
}

.shell {
  width: min(var(--content-width), 100%);
  margin: 0 auto;
}

.market-section {
  padding: 12px 8px 6px;
}

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

.metric-card {
  min-height: 84px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(39, 39, 42, 0.16);
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 5px;
}


.metric-button {
  width: 100%;
  appearance: none;
  text-align: left;
  color: inherit;
  cursor: pointer;
}

.metric-button:hover,
.metric-button.is-active {
  border-color: rgba(7, 182, 213, 0.72);
  background: rgba(7, 182, 213, 0.08);
}

.metric-button.is-active {
  box-shadow: inset 0 0 0 1px rgba(7, 182, 213, 0.2);
}

.market-chart-panel {
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.market-chart-badge {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  background: rgba(7, 182, 213, 0.14);
  color: var(--primary);
  font-size: 10px;
  font-weight: 900;
}

.market-chart-mount {
  height: 360px;
}

.metric-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
}

.metric-value {
  min-height: 22px;
  color: var(--text);
  font-size: 19px;
  font-weight: 800;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.metric-change {
  min-height: 14px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.metric-unit {
  margin-left: 4px;
  color: var(--text);
  font-size: 10px;
  font-weight: 800;
}

.metal-unit-selector {
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.metal-unit-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}

.metal-unit-options {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(24, 24, 27, 0.72);
}

.metal-unit-button {
  min-width: 42px;
  height: 26px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}

.metal-unit-button:hover,
.metal-unit-button.is-active {
  background: var(--primary);
  color: #071014;
}

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

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

.neutral {
  color: var(--muted);
}

.table-section {
  padding: 0 0 2px;
  flex: 1;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
  scrollbar-color: rgba(113, 113, 122, 0.45) transparent;
}

.asset-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  table-layout: fixed;
}

.asset-table col.star-col {
  width: 34px;
}

.asset-table col.name-col {
  width: 38%;
}

.asset-table col.price-col {
  width: 24%;
}

.asset-table col.kimchi-col {
  width: 14%;
}

.asset-table col.change-col {
  width: 20%;
}

.asset-table th {
  height: 39px;
  padding: 8px 8px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-align: left;
  white-space: nowrap;
  user-select: none;
}

.asset-table th.align-right {
  text-align: right;
}

.sort-button {
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  font-size: inherit;
  font-weight: inherit;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.align-right .sort-button {
  justify-content: flex-end;
}

.sort-button:hover {
  color: var(--text);
}

.sort-icon {
  width: 12px;
  height: 12px;
  color: rgba(161, 161, 170, 0.48);
}

.sort-button.is-active .sort-icon {
  color: var(--primary);
}

.asset-row {
  height: var(--row-height);
  border-bottom: 1px solid rgba(39, 39, 42, 0.25);
  transition: background 160ms ease;
}

.asset-row:hover {
  background: rgba(39, 39, 42, 0.16);
}

.asset-row.is-expanded {
  border-bottom-color: transparent;
  background: rgba(39, 39, 42, 0.25);
}

.asset-table td {
  height: var(--row-height);
  padding: 10px 8px;
  vertical-align: middle;
}

.asset-table td.align-right {
  text-align: right;
}

.star-button {
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 6px;
  display: grid;
  place-items: center;
  background: transparent;
  color: rgba(161, 161, 170, 0.32);
  cursor: pointer;
}

.star-button:hover {
  color: var(--muted);
}

.star-button.is-starred {
  color: var(--warning);
}

.star-button.is-starred .icon {
  fill: currentColor;
}

.coin-button {
  width: 100%;
  border: 0;
  padding: 0;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  cursor: pointer;
}

.coin-icon {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  object-fit: contain;
  flex: 0 0 auto;
  background: #27272a;
}

.coin-fallback {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  display: none;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  color: #fff;
  font-size: 10px;
  font-weight: 900;
}

.stock-rank-icon {
  font-size: 11px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
}

.stock-rank-icon.small {
  font-size: 9px;
}

.coin-copy {
  min-width: 0;
}

.coin-name {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color 160ms ease;
}

.coin-button:hover .coin-name,
.asset-row.is-expanded .coin-name {
  color: var(--primary);
}

.coin-symbol {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.chevron {
  width: 14px;
  height: 14px;
  margin-left: auto;
  color: rgba(161, 161, 170, 0.5);
  transition: color 160ms ease, transform 200ms ease;
}

.asset-row.is-expanded .chevron {
  color: var(--primary);
  transform: rotate(180deg);
}

.primary-number {
  color: var(--text);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.secondary-number {
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.percent-number {
  font-size: 14px;
  font-weight: 800;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.chart-row {
  border-bottom: 1px solid rgba(63, 63, 70, 0.32);
}

.chart-cell {
  padding: 0 !important;
}

.chart-panel {
  overflow: hidden;
  background: #111218;
}

.chart-toolbar {
  height: 38px;
  padding: 8px 12px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #111218;
}

.chart-title {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.chart-title .coin-icon,
.chart-title .coin-fallback {
  width: 24px;
  height: 24px;
}

.chart-title strong {
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.chart-title span {
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-link {
  min-width: 24px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

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

.chart-mount {
  height: 380px;
  background: #111218;
}

.chart-placeholder {
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
}


.stock-chart {
  height: 100%;
  padding: 12px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stock-chart-meta,
.stock-chart-caption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.stock-chart-last {
  color: var(--text);
  font-size: 12px;
}

.stock-chart-svg {
  width: 100%;
  flex: 1;
  min-height: 250px;
  display: block;
}

.stock-chart-grid {
  stroke: rgba(63, 63, 70, 0.7);
  stroke-width: 1;
}

.stock-chart-line {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.stock-chart-line.positive,
.stock-chart-dot.positive {
  stroke: var(--positive);
  fill: var(--positive);
}

.stock-chart-line.negative,
.stock-chart-dot.negative {
  stroke: var(--negative);
  fill: var(--negative);
}

.stock-chart-area {
  opacity: 0.14;
}

.stock-chart-area.positive {
  fill: var(--positive);
}

.stock-chart-area.negative {
  fill: var(--negative);
}
.footer {
  width: min(var(--content-width), 100%);
  margin: 0 auto;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.updated-at {
  color: var(--muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.footer-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.text-button {
  min-height: 26px;
  border: 0;
  border-radius: 6px;
  padding: 4px 6px;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
}

.text-button:hover {
  background: rgba(39, 39, 42, 0.35);
  color: var(--text);
}

.text-button.underlined {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.skeleton {
  border-radius: 6px;
  background: linear-gradient(90deg, rgba(7, 182, 213, 0.06), rgba(7, 182, 213, 0.15), rgba(7, 182, 213, 0.06));
  background-size: 220% 100%;
  animation: shimmer 1200ms ease-in-out infinite;
}

.metric-card .skeleton {
  width: 116px;
  height: 24px;
  margin-top: 3px;
}

.row-skeleton .skeleton {
  height: 16px;
}

.row-skeleton .coin-icon {
  background: rgba(7, 182, 213, 0.1);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(320px, calc(100vw - 36px));
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(15, 15, 18, 0.96);
  color: var(--muted);
  font-size: 12px;
  box-shadow: 0 16px 38px rgba(0, 0, 0, 0.28);
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: transform 200ms ease, opacity 200ms ease;
}

.toast.is-visible {
  transform: translateY(0);
  opacity: 1;
}

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

@keyframes shimmer {
  0% {
    background-position: 120% 0;
  }
  100% {
    background-position: -120% 0;
  }
}

@media (max-width: 780px) {
  .topbar {
    height: calc(66px + env(safe-area-inset-top, 0px));
    padding-top: calc(env(safe-area-inset-top, 0px) + 8px);
  }

  .topbar-inner,
  .shell,
  .footer {
    width: 100%;
  }

  .topbar-inner {
    height: 58px;
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .metric-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
  }

  .metric-card {
    min-height: 64px;
    padding: 8px 6px;
    border-radius: 10px;
    gap: 4px;
  }

  .metric-label {
    overflow: hidden;
    font-size: 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .metric-value {
    min-height: 17px;
    font-size: 14px;
  }

  .metric-change {
    min-height: 11px;
    font-size: 10px;
  }

  .metric-unit {
    margin-left: 3px;
    font-size: 9px;
  }

  .metal-unit-selector {
    margin-top: 6px;
    padding: 0 2px;
  }

  .table-section {
    padding-left: 0;
    padding-right: 0;
  }

  .table-scroll {
    overflow-x: hidden;
  }

  .asset-table {
    min-width: 0;
  }

  .footer {
    align-items: flex-start;
  }
}

@media (max-width: 460px) {
  .topbar-inner {
    gap: 6px;
    padding-left: 8px;
    padding-right: 8px;
  }

  .topbar-actions {
    min-width: 42px;
    gap: 6px;
  }

  .exchange-tabs {
    gap: 3px;
    padding: 3px;
  }

  .exchange-tab {
    min-width: auto;
    padding: 4px 8px;
    font-size: 12px;
  }

  .market-section {
    padding-left: 8px;
    padding-right: 8px;
  }

  .metric-grid {
    gap: 5px;
  }

  .metric-card {
    min-height: 58px;
    padding: 7px 5px;
  }

  .metric-label,
  .metric-change {
    font-size: 9px;
  }

  .metal-unit-label {
    font-size: 10px;
  }

  .metal-unit-button {
    min-width: 38px;
    height: 24px;
    font-size: 10px;
  }

  .metric-value {
    font-size: 13px;
  }

  .table-scroll {
    padding-left: 0;
  }

  .asset-table {
    min-width: 0;
  }

  .asset-table col.star-col {
    width: 26px;
  }

  .asset-table col.name-col {
    width: 34%;
  }

  .asset-table col.price-col {
    width: 25%;
  }

  .asset-table col.kimchi-col {
    width: 19%;
  }

  .asset-table col.change-col {
    width: 22%;
  }

  .asset-table th {
    height: 34px;
    padding: 7px 2px;
    font-size: 10px;
  }

  .asset-table td {
    padding: 8px 2px;
  }

  .chart-mount {
    height: 320px;
  }

  .chart-toolbar {
    padding-left: 8px;
    padding-right: 8px;
  }

  .chart-link span {
    display: none;
  }

  .stock-chart {
    padding: 10px;
  }

  .stock-chart-svg {
    min-height: 220px;
  }

  .sort-button {
    gap: 2px;
  }

  .sort-icon {
    display: none;
  }

  .star-button {
    width: 20px;
    height: 20px;
  }

  .coin-button {
    gap: 6px;
  }

  .coin-icon,
  .coin-fallback {
    width: 28px;
    height: 28px;
  }

  .coin-name {
    font-size: 13px;
  }

  .coin-symbol {
    font-size: 10px;
  }

  .chevron {
    display: none;
  }

  .primary-number {
    font-size: 13px;
  }

  .secondary-number {
    margin-top: 4px;
    font-size: 9px;
  }

  .percent-number {
    font-size: 11px;
  }

  .asset-table td:nth-child(4) .secondary-number,
  .asset-table td:nth-child(5) .secondary-number {
    display: none;
  }

  .chart-link span {
    display: none;
  }

  .footer {
    padding-left: 12px;
    padding-right: 12px;
  }
}
