:root {
  color-scheme: light;
  --canvas: oklch(96.5% 0.009 84);
  --surface: oklch(99% 0.004 84);
  --surface-soft: oklch(94.5% 0.01 84);
  --surface-tint: oklch(91.5% 0.018 150);
  --ink: oklch(20% 0.022 92);
  --muted: oklch(48% 0.017 92);
  --quiet: oklch(62% 0.014 92);
  --line: oklch(87% 0.012 84);
  --accent: oklch(40% 0.055 155);
  --up: oklch(50% 0.15 32);
  --down: oklch(46% 0.13 150);
  --warning: oklch(56% 0.13 70);
  --shadow: 0 14px 34px rgba(51, 44, 30, 0.08), 0 1px 2px rgba(51, 44, 30, 0.08);
  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-pill: 999px;
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, oklch(98.2% 0.007 84) 0%, var(--canvas) 38%),
    var(--canvas);
  touch-action: manipulation;
}

button {
  font: inherit;
  color: inherit;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.eyebrow,
.summary-label,
.quiet,
.summary-meta,
.fund-code,
.detail-label,
.toolbar-label,
.toolbar-count {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.eyebrow {
  margin: 0 0 2px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 21px;
  line-height: 1.16;
  letter-spacing: -0.012em;
}

h2 {
  font-size: 21px;
  line-height: 1.18;
  letter-spacing: -0.012em;
  text-wrap: balance;
}

.icon-button,
.primary-button,
.ghost-button,
.source-strip select,
.sync-action,
.tab-button,
.sort-button,
.fund-row {
  border: 0;
  cursor: pointer;
  transition-property: transform, opacity, background-color, color, box-shadow;
  transition-duration: 160ms;
  transition-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
}

.icon-button:active,
.primary-button:active,
.ghost-button:active,
.sync-action:active,
.tab-button:active,
.sort-button:active,
.fund-row:active {
  transform: scale(0.96);
}

.icon-button:focus-visible,
.primary-button:focus-visible,
.ghost-button:focus-visible,
.sync-action:focus-visible,
.tab-button:focus-visible,
.sort-button:focus-visible,
.fund-row:focus-visible {
  outline: 2px solid color-mix(in oklch, var(--accent) 62%, white);
  outline-offset: 3px;
}

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: var(--radius-pill);
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(51, 44, 30, 0.12);
  font-size: 19px;
}

.icon-button.is-loading span {
  animation: spin 800ms linear infinite;
}

.notice {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: oklch(93% 0.035 80);
  color: oklch(38% 0.075 70);
  font-size: 13px;
  line-height: 1.45;
}

.binding-card,
.summary-panel {
  background: var(--surface);
  border-radius: var(--radius-lg);
  outline: 1px solid color-mix(in oklch, var(--line) 68%, transparent);
  outline-offset: -1px;
  box-shadow: var(--shadow);
}

.binding-card {
  position: relative;
  overflow: hidden;
  padding: 20px;
}

.binding-card::before {
  position: absolute;
  inset: 0 0 auto;
  height: 7px;
  background: linear-gradient(90deg, var(--accent), color-mix(in oklch, var(--warning) 64%, var(--surface-tint)));
  content: "";
}

.binding-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.binding-copy {
  margin-top: 10px;
  max-width: 34ch;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
  text-wrap: pretty;
}

.binding-status {
  display: inline-flex;
  min-height: 30px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  padding: 0 11px;
  border-radius: var(--radius-pill);
  background: color-mix(in oklch, var(--surface-soft) 78%, white);
  color: var(--muted);
  font-size: 12px;
  font-weight: 780;
  line-height: 1;
  white-space: nowrap;
}

.binding-status.is-working {
  background: color-mix(in oklch, var(--warning) 15%, white);
  color: oklch(43% 0.095 70);
}

.binding-status.is-ready {
  background: color-mix(in oklch, var(--accent) 13%, white);
  color: color-mix(in oklch, var(--accent) 78%, var(--ink));
}

.binding-status.is-success {
  background: color-mix(in oklch, var(--down) 13%, white);
  color: color-mix(in oklch, var(--down) 78%, var(--ink));
}

.binding-status.is-error {
  background: color-mix(in oklch, var(--up) 12%, white);
  color: color-mix(in oklch, var(--up) 78%, var(--ink));
}

.qr-stage {
  margin: 24px 0 16px;
  padding: 10px;
  border-radius: 18px;
  background:
    radial-gradient(circle at 18px 18px, color-mix(in oklch, var(--accent) 18%, transparent) 0 2px, transparent 3px) 0 0 / 26px 26px,
    color-mix(in oklch, var(--surface-tint) 46%, white);
  box-shadow:
    inset 0 0 0 1px color-mix(in oklch, var(--line) 58%, transparent),
    0 10px 24px rgba(51, 44, 30, 0.07);
}

.qr-frame {
  position: relative;
  display: grid;
  min-height: 254px;
  place-items: center;
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--quiet);
  text-align: center;
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, 0.07),
    0 1px 2px rgba(51, 44, 30, 0.08);
}

.qr-frame::before,
.qr-frame::after {
  position: absolute;
  width: 32px;
  height: 32px;
  border-color: color-mix(in oklch, var(--accent) 62%, var(--ink));
  content: "";
  opacity: 0.72;
}

.qr-frame::before {
  top: 18px;
  left: 18px;
  border-top: 2px solid;
  border-left: 2px solid;
  border-radius: 8px 0 0;
}

.qr-frame::after {
  right: 18px;
  bottom: 18px;
  border-right: 2px solid;
  border-bottom: 2px solid;
  border-radius: 0 0 8px;
}

.qr-placeholder {
  display: grid;
  gap: 12px;
  place-items: center;
}

.qr-placeholder span {
  position: relative;
  width: 74px;
  height: 74px;
  overflow: hidden;
  border-radius: 16px;
  background:
    linear-gradient(90deg, color-mix(in oklch, var(--line) 58%, white) 2px, transparent 2px) 0 0 / 18px 18px,
    linear-gradient(0deg, color-mix(in oklch, var(--line) 58%, white) 2px, transparent 2px) 0 0 / 18px 18px,
    color-mix(in oklch, var(--surface-soft) 72%, white);
  box-shadow: inset 0 0 0 1px color-mix(in oklch, var(--line) 78%, transparent);
}

.qr-placeholder span::after {
  position: absolute;
  right: 10px;
  left: 10px;
  height: 2px;
  border-radius: var(--radius-pill);
  background: color-mix(in oklch, var(--accent) 72%, white);
  box-shadow: 0 0 18px color-mix(in oklch, var(--accent) 38%, transparent);
  content: "";
  transform: translateY(14px);
}

.qr-placeholder p {
  max-width: 16ch;
  color: var(--quiet);
  font-size: 13px;
  line-height: 1.45;
  text-wrap: balance;
}

.qr-frame.is-loading .qr-placeholder span::after {
  animation: scanLine 1200ms cubic-bezier(0.16, 1, 0.3, 1) infinite;
}

.qr-frame.is-error .qr-placeholder span {
  background:
    linear-gradient(90deg, color-mix(in oklch, var(--up) 16%, white) 2px, transparent 2px) 0 0 / 18px 18px,
    linear-gradient(0deg, color-mix(in oklch, var(--up) 16%, white) 2px, transparent 2px) 0 0 / 18px 18px,
    color-mix(in oklch, var(--up) 8%, white);
}

.qr-frame.is-error .qr-placeholder span::after {
  background: color-mix(in oklch, var(--up) 72%, white);
}

.qr-frame img {
  width: min(216px, 68vw);
  height: auto;
  aspect-ratio: 1;
  padding: 10px;
  border-radius: 12px;
  background: white;
  box-shadow:
    0 18px 32px rgba(51, 44, 30, 0.12),
    0 1px 2px rgba(51, 44, 30, 0.1);
  animation: qrAppear 260ms cubic-bezier(0.16, 1, 0.3, 1);
}

.binding-actions {
  display: grid;
  justify-items: center;
}

.binding-actions .primary-button {
  min-width: 132px;
  background: color-mix(in oklch, var(--accent) 12%, white);
  color: color-mix(in oklch, var(--accent) 76%, var(--ink));
  box-shadow: inset 0 0 0 1px color-mix(in oklch, var(--accent) 22%, transparent);
}

.binding-footnote {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 14px;
  color: var(--quiet);
  font-size: 12px;
  line-height: 1.45;
}

.binding-footnote span {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  margin-top: 5px;
  border-radius: var(--radius-pill);
  background: color-mix(in oklch, var(--accent) 62%, var(--surface-tint));
}

.primary-button,
.ghost-button {
  min-height: 44px;
  border-radius: var(--radius-pill);
  font-weight: 700;
}

.primary-button {
  background: var(--ink);
  color: var(--surface);
  box-shadow: 0 4px 14px rgba(45, 38, 27, 0.16);
}

.ghost-button {
  background: var(--surface-soft);
  color: var(--ink);
}

.ghost-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.summary-panel {
  position: relative;
  overflow: hidden;
  padding: 17px 18px 18px;
}

.summary-panel::before {
  position: absolute;
  top: 0;
  right: 18px;
  left: 18px;
  height: 3px;
  border-radius: 0 0 var(--radius-pill) var(--radius-pill);
  background: color-mix(in oklch, var(--accent) 58%, var(--surface-tint));
  content: "";
}

.summary-meta,
.summary-subline,
.source-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.source-strip {
  margin-top: 12px;
  padding: 7px 9px;
  border-radius: var(--radius-sm);
  background: color-mix(in oklch, var(--surface-tint) 44%, white);
  color: var(--muted);
  font-size: 12px;
  font-weight: 720;
}

.source-select {
  display: flex;
  flex: 1;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.source-strip select {
  width: 118px;
  min-height: 30px;
  padding: 0 24px 0 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 760;
}

.sync-action {
  min-height: 30px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-pill);
  background: color-mix(in oklch, var(--surface) 78%, var(--surface-tint));
  color: color-mix(in oklch, var(--accent) 74%, var(--ink));
  font-size: 12px;
  font-weight: 780;
  white-space: nowrap;
}

.sync-action:disabled {
  cursor: not-allowed;
}

.summary-meta span:first-child {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 0 9px;
  border-radius: var(--radius-pill);
  background: color-mix(in oklch, var(--surface-tint) 52%, white);
  color: color-mix(in oklch, var(--accent) 82%, var(--ink));
  font-weight: 760;
}

.source-strip select:focus {
  border-color: color-mix(in oklch, var(--accent) 62%, white);
  outline: 0;
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--accent) 16%, transparent);
}

.summary-label {
  margin-top: 13px;
}

.summary-value {
  margin-top: 4px;
  font-size: clamp(43px, 12vw, 60px);
  font-weight: 780;
  line-height: 1;
  letter-spacing: -0.022em;
  font-variant-numeric: tabular-nums;
}

.summary-subline {
  margin-top: 12px;
  color: var(--muted);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.summary-subline strong {
  color: var(--ink);
  font-weight: 750;
}

.account-tabs {
  display: flex;
  gap: 8px;
  margin: 15px 0 9px;
  overflow-x: auto;
  scrollbar-width: none;
}

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

.tab-button {
  min-height: 38px;
  padding: 0 15px;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--muted);
  white-space: nowrap;
}

.tab-button.is-active {
  background: var(--ink);
  color: var(--surface);
  box-shadow: 0 4px 12px rgba(51, 44, 30, 0.12);
}

.holding-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 4px 0 10px;
  padding: 8px 0 9px;
  border-bottom: 1px solid color-mix(in oklch, var(--line) 70%, transparent);
}

.toolbar-label {
  margin: 0;
  color: var(--ink);
  font-weight: 780;
}

.toolbar-count {
  margin: 1px 0 0;
  color: var(--quiet);
  font-variant-numeric: tabular-nums;
}

.sort-controls {
  display: flex;
  justify-content: flex-end;
  min-width: 0;
}

.sort-button {
  display: inline-flex;
  min-width: 70px;
  min-height: 34px;
  align-items: center;
  justify-content: space-between;
  gap: 7px;
  padding: 0 9px 0 12px;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 720;
  white-space: nowrap;
}

.sort-button.is-active {
  background: color-mix(in oklch, var(--accent) 11%, white);
  color: color-mix(in oklch, var(--accent) 70%, var(--ink));
  box-shadow: inset 0 0 0 1px color-mix(in oklch, var(--accent) 24%, transparent);
}

.sort-title {
  color: inherit;
}

.sort-direction {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  padding: 0;
  border-radius: var(--radius-pill);
  background: color-mix(in oklch, var(--surface-soft) 76%, white);
  color: var(--quiet);
  font-size: 13px;
  font-weight: 760;
  text-align: center;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.sort-button.is-active .sort-direction {
  background: color-mix(in oklch, var(--accent) 18%, white);
  color: color-mix(in oklch, var(--accent) 82%, var(--ink));
}

.holding-list {
  display: grid;
  gap: 7px;
}

.fund-row {
  width: 100%;
  padding: 0;
  border-radius: var(--radius-md);
  background: color-mix(in oklch, var(--surface) 84%, var(--canvas));
  box-shadow: inset 0 0 0 1px color-mix(in oklch, var(--line) 78%, transparent);
  text-align: left;
}

.fund-row-inner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  padding: 12px;
}

.fund-name {
  overflow: hidden;
  font-size: 15px;
  font-weight: 720;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fund-code {
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

.fund-numbers {
  min-width: 118px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.estimate-rate {
  font-size: 17px;
  font-weight: 780;
  line-height: 1.25;
}

.estimate-nav {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.fund-meta {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding-top: 2px;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.fund-detail {
  grid-column: 1 / -1;
  display: none;
  grid-template-columns: 1fr 1fr;
  gap: 10px 16px;
  margin-top: 2px;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: color-mix(in oklch, var(--surface-soft) 78%, white);
  box-shadow: inset 0 0 0 1px color-mix(in oklch, var(--line) 72%, transparent);
}

.fund-row.is-open .fund-detail {
  display: grid;
}

.detail-value {
  display: block;
  margin-top: 2px;
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

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

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

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

.empty-state {
  margin-top: 28px;
  padding: 24px 18px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(61, 48, 28, 0.1);
}

.empty-state p {
  margin: 8px 0 16px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

@media (hover: hover) {
  .icon-button:hover,
  .ghost-button:hover,
.sync-action:hover,
  .tab-button:hover,
  .sort-button:hover,
  .fund-row:hover {
    background: color-mix(in oklch, var(--surface-soft) 76%, white);
  }

  .sort-button.is-active:hover {
    background: color-mix(in oklch, var(--accent) 15%, white);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }
}

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

@keyframes scanLine {
  0% {
    opacity: 0;
    transform: translateY(12px);
  }

  18%,
  82% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translateY(60px);
  }
}

@keyframes qrAppear {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
