:root {
  color-scheme: dark;
  --bg: #07111f;
  --panel: rgba(13, 27, 45, 0.88);
  --panel-strong: #10243a;
  --line: rgba(152, 183, 210, 0.16);
  --text: #f4f8fb;
  --muted: #8fa6ba;
  --cyan: #54d6d0;
  --blue: #6da6ff;
  --up: #ef4444;
  --down: #18a76d;
  --amber: #f5b95f;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(circle at 8% -5%, rgba(61, 125, 184, 0.23), transparent 34rem),
    linear-gradient(180deg, #07111f 0%, #091522 45%, #060d16 100%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.ambient {
  position: fixed;
  border-radius: 999px;
  filter: blur(80px);
  opacity: 0.2;
  pointer-events: none;
}

.ambient-one { width: 16rem; height: 16rem; background: #2f8fca; top: 12%; right: -8rem; }
.ambient-two { width: 14rem; height: 14rem; background: #2eaa9d; bottom: 8%; left: -8rem; }

.app-shell {
  width: min(100%, 48rem);
  margin: 0 auto;
  padding: max(1rem, env(safe-area-inset-top)) 1rem max(1.5rem, env(safe-area-inset-bottom));
  position: relative;
  z-index: 1;
}

.hidden { display: none !important; }
.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; }

.access-gate {
  min-height: calc(100dvh - 2rem);
  display: grid;
  align-content: center;
  padding: 2.25rem 1.35rem;
}

.gate-mark {
  width: 3.2rem;
  height: 3.2rem;
  display: grid;
  place-items: center;
  margin-bottom: 2rem;
  border: 1px solid rgba(84, 214, 208, 0.5);
  border-radius: 1rem;
  background: linear-gradient(145deg, rgba(84, 214, 208, 0.22), rgba(109, 166, 255, 0.08));
  color: var(--cyan);
  font: 700 1.25rem/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  box-shadow: inset 0 0 24px rgba(84, 214, 208, 0.08);
}

.eyebrow {
  margin: 0 0 0.42rem;
  color: var(--cyan);
  font: 650 0.68rem/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.17em;
}

h1, h2, p { margin-top: 0; }
.access-gate h1 { margin-bottom: 0.65rem; font-size: clamp(2.35rem, 11vw, 4rem); letter-spacing: -0.055em; }
.gate-copy { max-width: 24rem; margin-bottom: 2.2rem; color: var(--muted); line-height: 1.7; }

.unlock-form label {
  display: block;
  margin-bottom: 0.65rem;
  color: #c7d3dd;
  font-size: 0.8rem;
}

.passcode-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.65rem;
}

input, select {
  min-height: 2.9rem;
  border: 1px solid var(--line);
  border-radius: 0.85rem;
  outline: none;
  background: rgba(8, 19, 32, 0.88);
  color: var(--text);
}

input { width: 100%; padding: 0 0.95rem; }
select { padding: 0 2rem 0 0.8rem; }
input:focus, select:focus { border-color: rgba(84, 214, 208, 0.75); box-shadow: 0 0 0 3px rgba(84, 214, 208, 0.1); }

.passcode-row button, .refresh-button {
  min-height: 2.9rem;
  padding: 0 1.1rem;
  border: 0;
  border-radius: 0.85rem;
  background: var(--cyan);
  color: #06171c;
  font-weight: 750;
}

.form-error, .page-error { min-height: 1.4rem; margin: 0.55rem 0 0; color: #ff8f8f; font-size: 0.82rem; }
.gate-footnote { margin: 3rem 0 0; color: #61798e; font-size: 0.75rem; }

.dashboard { display: grid; gap: 0.85rem; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 0.15rem 0.7rem;
}

.topbar h1 { margin: 0; font-size: 1.55rem; letter-spacing: -0.035em; }
.icon-button {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.55rem 0.8rem;
  background: rgba(10, 24, 39, 0.7);
  color: var(--muted);
  font-size: 0.78rem;
}

.search-card, .quote-card, .chart-card, .indicator-card {
  border: 1px solid var(--line);
  border-radius: 1.25rem;
  background: linear-gradient(145deg, rgba(16, 36, 58, 0.93), rgba(10, 23, 38, 0.9));
  box-shadow: var(--shadow);
}

.search-card { padding: 0.85rem; }
.symbol-row { display: grid; grid-template-columns: minmax(0, 1fr) 5.4rem auto; gap: 0.55rem; align-items: end; }
.symbol-row label > span { display: block; margin: 0 0 0.35rem 0.15rem; color: var(--muted); font-size: 0.66rem; }
.symbol-row input, .symbol-row select { min-height: 2.65rem; font-size: 0.88rem; }
.refresh-button { min-height: 2.65rem; padding: 0 0.9rem; font-size: 0.82rem; }

.quick-symbols { display: flex; gap: 0.45rem; overflow-x: auto; margin-top: 0.65rem; padding-bottom: 0.1rem; scrollbar-width: none; }
.quick-symbols::-webkit-scrollbar { display: none; }
.quick-symbols button, .range-strip button {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(5, 15, 26, 0.55);
  color: var(--muted);
}
.quick-symbols button { padding: 0.45rem 0.68rem; font-size: 0.72rem; }

.quote-card { padding: 1.05rem; }
.quote-title-row { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; }
.quote-symbol { margin-bottom: 0.15rem; color: var(--muted); font: 0.68rem/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.1em; }
.quote-title-row h2 { margin: 0; font-size: 1rem; font-weight: 620; }
.source-badge { max-width: 48%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0.3rem 0.5rem; border-radius: 999px; background: rgba(84, 214, 208, 0.1); color: var(--cyan); font-size: 0.62rem; }
.source-badge.stale { background: rgba(245, 185, 95, 0.12); color: var(--amber); }
.quote-value-row { display: flex; gap: 0.7rem; align-items: baseline; margin: 1.1rem 0 0.95rem; }
.quote-value-row strong { font-size: clamp(2.25rem, 11vw, 3.8rem); line-height: 0.9; letter-spacing: -0.055em; }
.quote-value-row span { font: 700 0.92rem/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.positive { color: var(--up) !important; }
.negative { color: var(--down) !important; }

.quote-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.5rem; margin: 0; }
.quote-grid div { padding: 0.58rem; border-radius: 0.7rem; background: rgba(5, 14, 24, 0.45); }
.quote-grid dt { color: #688197; font-size: 0.62rem; }
.quote-grid dd { margin: 0.2rem 0 0; font: 650 0.74rem/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; }
.freshness { margin: 0.72rem 0 0; color: #637c91; font-size: 0.68rem; }

.range-strip { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.35rem; }
.range-strip button { min-height: 2.25rem; padding: 0; font-size: 0.7rem; }
.range-strip button.active { border-color: rgba(84, 214, 208, 0.58); background: rgba(84, 214, 208, 0.14); color: var(--cyan); }

.chart-card, .indicator-card { overflow: hidden; }
.section-heading { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1rem 0; }
.section-heading h2 { margin: 0; font-size: 0.98rem; font-weight: 620; }
.chart { width: 100%; }
.chart-price { height: 25rem; }
.chart-indicator { height: 16rem; }
.indicator-select select { min-height: 2.25rem; border-radius: 999px; font-size: 0.72rem; color: var(--cyan); }
.method-note { margin: -0.2rem 1rem 1rem; color: #6d8498; font-size: 0.67rem; line-height: 1.5; }

.loading-layer {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 0.85rem;
  background: rgba(4, 11, 19, 0.72);
  backdrop-filter: blur(8px);
  color: #b7c8d5;
  font-size: 0.8rem;
}
.loader { width: 1.8rem; height: 1.8rem; border: 2px solid rgba(84, 214, 208, 0.18); border-top-color: var(--cyan); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.page-error { min-height: 0; padding: 0.8rem 1rem; border: 1px solid rgba(239, 68, 68, 0.25); border-radius: 0.9rem; background: rgba(97, 23, 31, 0.32); }
footer { display: flex; justify-content: space-between; gap: 1rem; padding: 1rem 0.25rem; color: #50687c; font: 0.6rem/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; }

@media (max-width: 390px) {
  .app-shell { padding-left: 0.75rem; padding-right: 0.75rem; }
  .symbol-row { grid-template-columns: minmax(0, 1fr) 4.8rem; }
  .refresh-button { grid-column: 1 / -1; }
  .chart-price { height: 22rem; }
}

@media (min-width: 720px) {
  .app-shell { padding-top: 1.5rem; }
  .dashboard { grid-template-columns: 1fr 1fr; }
  .topbar, .search-card, .range-strip, .chart-card, .indicator-card, footer, .page-error { grid-column: 1 / -1; }
  .quote-card { grid-column: 1 / -1; }
  .chart-price { height: 31rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
  .loader { animation-duration: 1.8s; }
}
