/* PaperBull web — same palette as the iPhone app (Theme.swift). */

:root {
  --bg: #060609;
  --card: #121118;
  --card-2: #1a1823;
  --line: rgba(184, 173, 204, 0.14);
  --cream: #f5e8d6;
  --purple: #9e47f2;
  --light-purple: #c78cff;
  --text-gray: #b8adcc;
  --up: #34c759;
  --down: #ff9f0a;
  --danger: #ff6b5e;
  --radius: 16px;
  --radius-sm: 12px;
  --sidebar: 232px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--cream);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

a { color: var(--light-purple); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--light-purple); outline-offset: 2px; border-radius: 6px; }

.muted { color: var(--text-gray); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.strong { font-weight: 600; }
.accent { color: var(--purple); }
.up { color: var(--up); }
.down { color: var(--down); }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Boot screen */
.boot { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 14px; }
.boot img { border-radius: 22px; filter: drop-shadow(0 0 28px rgba(158, 71, 242, 0.45)); }
.wordmark { font-size: 34px; font-weight: 800; letter-spacing: -0.02em; }

.spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2.5px solid rgba(158, 71, 242, 0.25); border-top-color: var(--purple);
  display: inline-block; animation: spin 0.8s linear infinite;
}
.spinner.large { width: 44px; height: 44px; border-width: 3.5px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Shell */
.shell { min-height: 100vh; }

.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar);
  padding: 22px 14px; display: flex; flex-direction: column; gap: 26px;
  border-right: 1px solid var(--line); background: var(--bg); z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 21px; color: var(--cream); padding: 0 8px; }
.brand:hover { text-decoration: none; }
.brand img { border-radius: 10px; }
.nav-links { display: flex; flex-direction: column; gap: 4px; }
.nav-link {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px;
  color: var(--text-gray); font-weight: 600;
}
.nav-link svg, .tab svg { width: 20px; height: 20px; flex: none; }
.nav-link:hover { background: var(--card); color: var(--cream); text-decoration: none; }
.nav-link.active { background: rgba(158, 71, 242, 0.14); color: var(--cream); }
.nav-link.active svg { color: var(--purple); }
.sidebar-foot { margin-top: auto; }
.sidebar-foot .market-status { flex-wrap: wrap; }

.view { margin-left: var(--sidebar); min-height: 100vh; outline: none; }

.tabbar { display: none; }

.demo-badge {
  position: fixed; top: 10px; right: 12px; z-index: 20; padding: 4px 10px; border-radius: 999px;
  background: var(--purple); color: #fff; font-size: 12px; font-weight: 700;
}

/* Pages */
.page { max-width: 1180px; margin: 0 auto; padding: 28px 32px 60px; display: flex; flex-direction: column; gap: 20px; }
.page.narrow { max-width: 720px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.page-head > div > p { margin-bottom: 2px; font-weight: 600; }

.grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 32px; align-items: start; }
.main-col, .side-col { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.side-col { gap: 26px; }

.section-title { font-size: 19px; font-weight: 650; margin-bottom: 10px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
}
.card-inset { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }

.market-status {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 14px;
  background: var(--card); font-size: 13px; font-weight: 600;
}
.market-status .muted { font-weight: 400; }
.market-status .status-note::before { content: "· "; }
.sidebar-foot .market-status { display: grid; grid-template-columns: auto 1fr; row-gap: 2px; }
.sidebar-foot .status-note { grid-column: 1 / -1; }
.sidebar-foot .status-note::before { content: none; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; }
.status-dot.open { background: var(--up); }
.status-dot.closed { background: var(--down); }

/* Value + change */
.value-block { display: flex; flex-direction: column; gap: 4px; }
.big-value { font-size: 40px; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.value-sub { min-height: 20px; display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; }
.change { font-size: 14px; font-weight: 700; display: inline-flex; gap: 6px; align-items: baseline; font-variant-numeric: tabular-nums; }
.change.up { color: var(--up); }
.change.down { color: var(--down); }
.change .arrow { font-size: 9px; }
.change-label { color: var(--text-gray); font-weight: 500; }

/* Charts */
.chart-wrap { position: relative; }
.chart { width: 100%; }
.chart-svg { display: block; width: 100%; touch-action: pan-y; cursor: crosshair; user-select: none; }
.chart-line { fill: none; stroke: var(--purple); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.chart-shade { fill: rgba(184, 173, 204, 0.05); }
.chart-rule { stroke: rgba(184, 173, 204, 0.28); stroke-dasharray: 3 4; }
.chart-baseline { stroke: rgba(245, 232, 214, 0.25); stroke-dasharray: 2 5; }
.chart-marker { fill: var(--purple); stroke: var(--bg); stroke-width: 2; }
.chart-cursor { stroke: rgba(245, 232, 214, 0.4); stroke-width: 1; }
.chart-selected { fill: var(--cream); }
.chart-dot { fill: var(--purple); }
.chart-pulse { fill: var(--purple); opacity: 0.35; transform-origin: center; animation: pulse 1.6s ease-out infinite; }
@keyframes pulse { from { transform: scale(1); opacity: 0.45; } to { transform: scale(3.4); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .chart-pulse { animation: none; } }
.chart-loading { position: absolute; inset: 0; display: grid; place-items: center; }
.chart-loading[hidden] { display: none; }

.range-picker { display: flex; justify-content: space-between; gap: 4px; border-bottom: 1px solid var(--line); padding-bottom: 12px; }
.range {
  border: 0; background: none; color: var(--purple); font-weight: 700; font-size: 13px;
  padding: 6px 12px; border-radius: 999px; cursor: pointer;
}
.range:hover { background: rgba(158, 71, 242, 0.12); }
.range.active { background: var(--purple); color: #0a0610; }

/* Asset cards & stats */
.asset-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat span { font-size: 13px; font-weight: 600; }
.stat strong { font-size: 19px; font-variant-numeric: tabular-nums; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.stat-grid.two { grid-template-columns: repeat(2, 1fr); }
.stat-item { display: flex; flex-direction: column; gap: 2px; }
.stat-item strong { font-variant-numeric: tabular-nums; font-size: 15px; }

/* Lists */
.list { display: flex; flex-direction: column; gap: 10px; }
.grid-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.stock-row {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 14px 16px; border-radius: var(--radius); background: var(--card);
  border: 1px solid rgba(158, 71, 242, 0.2); color: var(--cream);
  transition: border-color 0.15s, transform 0.15s;
}
a.stock-row:hover { text-decoration: none; border-color: rgba(158, 71, 242, 0.55); transform: translateY(-1px); }
.stock-row-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.stock-row-side { text-align: right; display: flex; flex-direction: column; gap: 2px; flex: none; }
.symbol { font-weight: 750; font-size: 17px; }
.price { font-weight: 700; font-variant-numeric: tabular-nums; }

/* Search */
.search {
  display: flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 0 16px;
}
.search svg { width: 18px; height: 18px; color: var(--text-gray); flex: none; }
.search input { flex: 1; background: none; border: 0; color: var(--cream); font-size: 16px; padding: 15px 0; outline: none; }
.search:focus-within { border-color: rgba(158, 71, 242, 0.6); }

/* Buttons */
.btn {
  border: 0; border-radius: 14px; padding: 12px 18px; font-weight: 700; cursor: pointer;
  transition: filter 0.15s, transform 0.1s, opacity 0.15s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn.primary { background: linear-gradient(135deg, var(--light-purple), var(--purple)); color: #fff; box-shadow: 0 6px 24px rgba(158, 71, 242, 0.35); }
.btn.primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn.ghost { background: var(--card-2); color: var(--cream); border: 1px solid var(--line); }
.btn.ghost:hover:not(:disabled) { border-color: rgba(158, 71, 242, 0.5); }
.btn.danger { background: var(--danger); color: #1a0705; }
.btn.danger-text { color: var(--down); }
.btn.small { padding: 7px 12px; font-size: 13px; border-radius: 999px; }
.btn.block { width: 100%; padding: 15px; font-size: 16px; }
.link { background: none; border: 0; color: var(--light-purple); font-weight: 600; cursor: pointer; padding: 0; }

/* Stock page */
.stock-title { display: flex; align-items: center; gap: 12px; }
.back { font-size: 34px; line-height: 1; color: var(--cream); padding: 0 6px 4px 0; }
.back:hover { text-decoration: none; color: var(--light-purple); }
.star { background: var(--card); border: 1px solid var(--line); border-radius: 50%; width: 44px; height: 44px; font-size: 22px; cursor: pointer; color: var(--text-gray); }
.star.on { color: var(--purple); border-color: rgba(158, 71, 242, 0.5); }
.trade-card { display: flex; flex-direction: column; gap: 14px; }
.trade-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.trade-buttons .btn { padding: 14px; font-size: 16px; }

/* Notices */
.notice { padding: 12px 14px; border-radius: var(--radius-sm); font-size: 14px; }
.notice.error { background: rgba(255, 107, 94, 0.12); border: 1px solid rgba(255, 107, 94, 0.35); color: #ffc9c3; }

/* Modal */
#modal-root { position: relative; z-index: 50; }
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(6px);
  display: grid; place-items: center; padding: 16px; opacity: 0; transition: opacity 0.2s;
}
.modal-backdrop.show { opacity: 1; }
.modal {
  width: min(460px, 100%); max-height: calc(100vh - 32px); overflow: auto;
  background: var(--bg); border: 1px solid var(--line); border-radius: 22px; padding: 22px;
  display: flex; flex-direction: column; gap: 14px;
  transform: translateY(12px); transition: transform 0.2s;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(158, 71, 242, 0.08);
}
.modal-backdrop.show .modal { transform: none; }
.modal-title { font-size: 26px; font-weight: 750; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 4px; }
.modal-actions .btn { flex: 1; }

.order { display: flex; flex-direction: column; gap: 14px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg-btn { border: 0; border-radius: 12px; padding: 12px; font-weight: 700; background: var(--card); color: var(--purple); cursor: pointer; }
.seg-btn.active { background: var(--purple); color: #0a0610; }
.chips { display: flex; gap: 8px; }
.chip { border: 0; border-radius: 11px; padding: 7px 15px; font-size: 13px; font-weight: 700; background: var(--card); color: var(--text-gray); cursor: pointer; }
.chip.active { background: var(--purple); color: #0a0610; }
.amount {
  display: flex; align-items: center; gap: 4px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px 16px;
}
.amount:focus-within { border-color: rgba(158, 71, 242, 0.6); }
.amount-prefix { font-size: 34px; font-weight: 700; }
.amount input { flex: 1; min-width: 0; background: none; border: 0; outline: none; color: var(--cream); font-size: 38px; font-weight: 700; font-variant-numeric: tabular-nums; }
.info { display: flex; flex-direction: column; gap: 10px; }
.info-row { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.info-row strong { font-variant-numeric: tabular-nums; text-align: right; }
.working { display: grid; justify-items: center; gap: 16px; padding: 48px 0; }
.result { display: grid; justify-items: center; text-align: center; gap: 8px; padding: 18px 0 8px; }
.result-icon {
  width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center;
  font-size: 40px; font-weight: 800; color: #fff; background: var(--purple);
  box-shadow: 0 0 40px rgba(158, 71, 242, 0.55); margin-bottom: 6px;
}
.result.bad .result-icon { background: var(--down); box-shadow: 0 0 40px rgba(255, 159, 10, 0.35); }

/* Forms (auth) */
.form { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text-gray); }
.field input {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 13px 14px; color: var(--cream); font-size: 16px; outline: none;
}
.field input:focus { border-color: rgba(158, 71, 242, 0.6); }
.form-error { color: var(--danger); font-size: 14px; min-height: 0; }
.form-error:empty, .form-info:empty { display: none; }
.form-info { color: var(--up); font-size: 14px; }

.auth {
  min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; align-items: center;
  max-width: 1080px; margin: 0 auto; padding: 40px 32px; gap: 56px;
}
.auth-hero { display: flex; flex-direction: column; gap: 14px; }
.home-link { color: var(--text-gray); font-weight: 600; font-size: 14px; align-self: flex-start; }
.home-link:hover { color: var(--cream); text-decoration: none; }
.auth-logo { border-radius: 26px; filter: drop-shadow(0 0 36px rgba(158, 71, 242, 0.5)); }
.auth-hero .wordmark { font-size: 52px; }
.hero-line { font-size: 30px; font-weight: 700; line-height: 1.15; }
.auth-card { padding: 28px; display: flex; flex-direction: column; gap: 14px; background: linear-gradient(180deg, var(--card), #0d0c12); }
.auth-card h2 { font-size: 30px; font-weight: 750; }
.auth-switch { display: flex; flex-wrap: wrap; gap: 6px 10px; justify-content: center; font-size: 14px; }
.auth-switch > .link:first-child:not(:last-child) { flex-basis: 100%; text-align: center; margin-bottom: 4px; }

/* Learn */
.lessons { display: flex; flex-direction: column; gap: 10px; }
.lesson summary { cursor: pointer; font-weight: 650; font-size: 16px; display: flex; align-items: center; gap: 12px; list-style: none; }
.lesson summary::-webkit-details-marker { display: none; }
.lesson summary::after { content: "+"; margin-left: auto; color: var(--purple); font-size: 20px; }
.lesson[open] summary::after { content: "−"; }
.lesson p { margin-top: 12px; color: var(--text-gray); line-height: 1.6; }
.lesson-num {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: rgba(158, 71, 242, 0.16); color: var(--light-purple); font-size: 13px; font-weight: 800;
}

/* Profile */
.profile { align-items: center; text-align: center; }
.profile .list { width: 100%; text-align: left; }
.avatar {
  width: 96px; height: 96px; border-radius: 50%; display: grid; place-items: center;
  font-size: 34px; font-weight: 800; color: #fff; margin-top: 12px;
  background: linear-gradient(135deg, var(--light-purple), var(--purple));
  box-shadow: 0 0 40px rgba(158, 71, 242, 0.5);
}
.profile .btn.block { margin-top: 10px; }

/* Toasts */
#toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; pointer-events: none; width: min(440px, calc(100% - 32px)); }
.toast {
  background: var(--card-2); border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px;
  font-size: 14px; opacity: 0; transform: translateY(8px); transition: opacity 0.25s, transform 0.25s;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
.toast.show { opacity: 1; transform: none; }
.toast.success { border-color: rgba(52, 199, 89, 0.4); }
.toast.error { border-color: rgba(255, 159, 10, 0.5); }

/* Tablet / phone */
@media (max-width: 1080px) {
  .grid { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .sidebar { display: none; }
  .view { margin-left: 0; padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
  .page { padding: 18px 16px 40px; gap: 16px; }
  .head-status { width: 100%; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; inset: auto 0 0 0; z-index: 10;
    background: rgba(6, 6, 9, 0.92); backdrop-filter: blur(12px); border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .tab { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; font-size: 11px; font-weight: 600; color: var(--text-gray); }
  .tab:hover { text-decoration: none; }
  .tab.active { color: var(--purple); }
  .big-value { font-size: 34px; }
  .asset-cards { grid-template-columns: 1fr 1fr; }
  .asset-cards .stat:last-child { grid-column: span 2; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .range { padding: 6px 8px; }
  .auth { grid-template-columns: 1fr; gap: 28px; padding: 32px 16px; align-content: start; }
  .auth-hero { align-items: center; text-align: center; }
  .auth-hero .wordmark { font-size: 40px; }
  .hero-line { font-size: 24px; }
  .auth-logo { width: 88px; height: 88px; }
  .modal-backdrop { place-items: end center; padding: 0; }
  .modal { width: 100%; border-radius: 22px 22px 0 0; max-height: 92vh; padding-bottom: calc(22px + env(safe-area-inset-bottom)); }
  #toasts { bottom: calc(84px + env(safe-area-inset-bottom)); }
}
