:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --text: #17181c;
  --muted: #747985;
  --line: #e6e8ee;
  --primary: #2368ff;
  --primary-soft: #e9f0ff;
  --positive: #e63b47;
  --negative: #1f78ff;
  --neutral: #747985;
  --shadow: 0 10px 30px rgba(24, 29, 40, 0.08);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans KR", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101114;
    --surface: #181a20;
    --surface-raised: #20232b;
    --text: #f2f3f5;
    --muted: #a2a7b2;
    --line: #2c3038;
    --primary: #6e9cff;
    --primary-soft: #1d2a46;
    --positive: #ff6972;
    --negative: #67a3ff;
    --neutral: #a2a7b2;
    --shadow: none;
  }
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(100%, 760px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 18px calc(94px + env(safe-area-inset-bottom));
}

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

.view {
  display: none;
}

.view.active {
  display: block;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 4px 0 18px;
}

.eyebrow,
.section-label,
.asset-code {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

h1 {
  margin: 5px 0 0;
  font-size: 28px;
  line-height: 1.18;
  letter-spacing: 0;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.icon-button span {
  display: block;
  font-size: 22px;
  line-height: 1;
}

.icon-button.loading span {
  animation: spin 0.9s linear infinite;
}

.summary-panel {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.quick-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.quick-strip div {
  min-width: 0;
  padding: 14px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.quick-strip span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.quick-strip strong {
  display: block;
  margin-top: 5px;
  font-size: 16px;
  line-height: 1.2;
}

.summary-main {
  display: grid;
  gap: 8px;
}

.summary-main strong {
  display: block;
  font-size: 34px;
  line-height: 1.12;
  letter-spacing: 0;
}

.status-pill {
  width: fit-content;
  max-width: 100%;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
}

.status-pill.error {
  background: rgba(230, 59, 71, 0.12);
  color: var(--positive);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 22px;
}

.summary-grid div,
.metric-grid div {
  min-width: 0;
}

.summary-grid span,
.metric-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.summary-grid strong,
.metric-grid strong {
  display: block;
  margin-top: 5px;
  overflow-wrap: anywhere;
  font-size: 16px;
  line-height: 1.25;
}

.toolbar {
  position: sticky;
  top: 0;
  z-index: 5;
  margin: 18px -18px 0;
  padding: 10px 18px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px);
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.segment {
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.segment.active {
  background: var(--primary-soft);
  color: var(--primary);
}

.asset-list {
  display: grid;
  gap: 12px;
  padding-top: 8px;
}

.asset-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-raised);
  overflow: hidden;
}

.asset-card-button {
  width: 100%;
  border: 0;
  padding: 18px;
  background: transparent;
  color: inherit;
  text-align: left;
}

.asset-card-button:active {
  background: color-mix(in srgb, var(--primary-soft) 42%, transparent);
}

.asset-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
}

.asset-head h2 {
  margin: 5px 0 0;
  font-size: 18px;
  line-height: 1.28;
  letter-spacing: 0;
}

.price-block {
  min-width: 96px;
  text-align: right;
}

.current-price {
  display: block;
  font-size: 18px;
  line-height: 1.25;
}

.gap-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin-top: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 12px;
  margin-top: 18px;
}

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

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

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

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.section-head h2,
.detail-hero h2 {
  margin: 4px 0 0;
  font-size: 22px;
  line-height: 1.22;
  letter-spacing: 0;
}

.text-button,
.primary-button {
  border: 0;
  border-radius: 8px;
  font-weight: 900;
}

.text-button {
  min-height: 36px;
  padding: 0 12px;
  background: var(--primary-soft);
  color: var(--primary);
  white-space: nowrap;
}

.primary-button {
  width: 100%;
  min-height: 50px;
  padding: 0 18px;
  background: var(--primary);
  color: #ffffff;
}

.bulk-form {
  display: grid;
  gap: 10px;
}

.bulk-row {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(74px, 0.8fr) minmax(86px, 1fr);
  gap: 10px;
  align-items: end;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.bulk-row h3 {
  margin: 4px 0 0;
  font-size: 15px;
  line-height: 1.28;
  letter-spacing: 0;
}

.bulk-row label,
.detail-selector {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.bulk-row input,
.detail-selector select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 11px;
  background: var(--surface);
  color: var(--text);
}

.sticky-action {
  position: sticky;
  bottom: calc(74px + env(safe-area-inset-bottom));
  z-index: 4;
  margin: 14px -18px 0;
  padding: 10px 18px 0;
  background: linear-gradient(to top, var(--bg) 72%, transparent);
}

.detail-selector {
  margin-bottom: 12px;
}

.detail-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

.detail-hero {
  padding: 20px;
  border-bottom: 1px solid var(--line);
}

.detail-hero strong {
  display: block;
  margin-top: 14px;
  font-size: 32px;
  line-height: 1.12;
}

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

.detail-grid div {
  min-width: 0;
  padding: 15px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.detail-grid div:nth-child(2n) {
  border-right: 0;
}

.detail-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.detail-grid strong {
  display: block;
  margin-top: 6px;
  overflow-wrap: anywhere;
  font-size: 15px;
  line-height: 1.25;
}

.empty-state {
  padding: 28px 20px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.bottom-nav {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  width: min(100%, 760px);
  transform: translateX(-50%);
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(16px);
  padding: 8px 14px max(8px, env(safe-area-inset-bottom));
}

.nav-item {
  display: grid;
  place-items: center;
  gap: 3px;
  min-height: 52px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
}

.nav-item span {
  font-size: 20px;
  line-height: 1;
}

.nav-item strong {
  font-size: 12px;
  line-height: 1;
}

.nav-item.active {
  background: var(--primary-soft);
  color: var(--primary);
}

@media (min-width: 700px) {
  .app-shell {
    padding-inline: 26px;
  }

  .toolbar {
    margin-inline: -26px;
    padding-inline: 26px;
  }

  .sticky-action {
    margin-inline: -26px;
    padding-inline: 26px;
  }

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

  .bulk-row {
    grid-template-columns: minmax(0, 1.8fr) minmax(120px, 0.8fr) minmax(140px, 0.9fr);
  }
}

@media (max-width: 430px) {
  .summary-grid {
    grid-template-columns: 1fr 1fr;
  }

  .summary-grid div:first-child {
    grid-column: 1 / -1;
  }

  .asset-head {
    grid-template-columns: 1fr;
  }

  .price-block {
    text-align: left;
  }

  .quick-strip {
    grid-template-columns: 1fr 1fr;
  }

  .quick-strip div:first-child {
    grid-column: 1 / -1;
  }

  .bulk-row {
    grid-template-columns: 1fr 1fr;
  }

  .bulk-row > div {
    grid-column: 1 / -1;
  }
}

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