:root {
  color-scheme: dark;
  --bg: #07111f;
  --surface: #0e1b2d;
  --surface-2: #13243a;
  --line: rgba(255, 255, 255, 0.08);
  --text: #f4f7fb;
  --muted: #8fa3ba;
  --green: #25d695;
  --green-soft: rgba(37, 214, 149, 0.13);
  --blue: #4b8dff;
  --purple: #9a6bff;
  --red: #ff607a;
  --warning: #f7c75c;
  --radius: 20px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 75% -10%, rgba(75, 141, 255, 0.18), transparent 32%),
    radial-gradient(circle at -10% 25%, rgba(37, 214, 149, 0.08), transparent 28%),
    var(--bg);
  color: var(--text);
}

button, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

#app {
  max-width: 760px;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 14px calc(28px + env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 2px 12px;
  background: linear-gradient(180deg, rgba(7, 17, 31, 0.98) 70%, rgba(7, 17, 31, 0));
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
}
.brand-logo, .footer-logo {
  position: relative;
  flex: none;
  overflow: hidden;
  border: 1px solid rgba(75, 141, 255, 0.55);
  background: #07111f;
  box-shadow:
    0 0 0 3px rgba(75, 141, 255, 0.1),
    0 8px 28px rgba(17, 103, 255, 0.28);
}
.brand-logo {
  width: 48px;
  height: 48px;
  border-radius: 16px;
}
.brand-logo::after, .footer-logo::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(145deg, rgba(255,255,255,.16), transparent 45%);
  pointer-events: none;
}
.brand-logo img, .footer-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 22%;
}
.brand-name {
  color: var(--green);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .2em;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 25px; letter-spacing: -0.04em; }
h2 { margin-bottom: 8px; font-size: 20px; letter-spacing: -0.025em; }
p { color: var(--muted); line-height: 1.55; }

.eyebrow {
  color: var(--green);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.profile-button, .icon-button {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 14px;
}
.profile-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 44px;
  height: 44px;
}
.profile-button span {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--muted);
}
.icon-button { width: 46px; min-width: 46px; font-size: 24px; }

.state-card {
  min-height: 70vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 28px;
}
.state-card p { max-width: 380px; }
.state-icon { font-size: 46px; margin-bottom: 16px; }

.market-loader {
  position: relative;
  width: 170px;
  height: 170px;
  margin-bottom: 24px;
}
.loader-glow {
  position: absolute;
  inset: 26px;
  border-radius: 50%;
  background: rgba(75, 141, 255, .24);
  filter: blur(28px);
  animation: loaderPulse 1.8s ease-in-out infinite;
}
.loader-orbit {
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgba(75, 141, 255, .28);
}
.orbit-one {
  inset: 10px;
  border-top-color: var(--green);
  border-right-color: var(--blue);
  animation: orbitSpin 2.4s linear infinite;
}
.orbit-two {
  inset: 25px;
  border-bottom-color: var(--purple);
  border-left-color: rgba(154, 107, 255, .55);
  animation: orbitSpin 1.7s linear infinite reverse;
}
.loader-logo {
  position: absolute;
  inset: 42px;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, .16);
  border-radius: 25px;
  background: var(--surface);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .35);
  animation: logoFloat 1.8s ease-in-out infinite;
}
.loader-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 22%;
}
.loader-chart {
  position: absolute;
  left: 50%;
  bottom: 2px;
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 27px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(7, 17, 31, .92);
  transform: translateX(-50%);
}
.loader-chart i {
  display: block;
  width: 4px;
  border-radius: 4px;
  background: linear-gradient(180deg, var(--green), var(--blue));
  animation: chartBounce .9s ease-in-out infinite alternate;
}
.loader-chart i:nth-child(1) { height: 7px; animation-delay: -.4s; }
.loader-chart i:nth-child(2) { height: 13px; animation-delay: -.2s; }
.loader-chart i:nth-child(3) { height: 9px; animation-delay: -.6s; }
.loader-chart i:nth-child(4) { height: 17px; animation-delay: -.1s; }
.loader-chart i:nth-child(5) { height: 21px; animation-delay: -.5s; }
.loading-dots {
  display: flex;
  gap: 6px;
  margin-top: 2px;
}
.loading-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  animation: dotWave 1s ease-in-out infinite;
}
.loading-dots span:nth-child(2) { animation-delay: .15s; }
.loading-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes orbitSpin { to { transform: rotate(360deg); } }
@keyframes loaderPulse { 50% { opacity: .55; transform: scale(1.18); } }
@keyframes logoFloat { 50% { transform: translateY(-6px) scale(1.03); } }
@keyframes chartBounce { to { height: 5px; opacity: .5; } }
@keyframes dotWave { 50% { opacity: .35; transform: translateY(-5px); } }

.loader {
  width: 42px;
  height: 42px;
  border: 3px solid rgba(255,255,255,0.1);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 18px;
}
.loader.small { width: 24px; height: 24px; margin: 0; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }

.welcome-card, .control-card, .chart-card, .analysis-card, .favorites-card, .guide-card {
  border: 1px solid var(--line);
  background: linear-gradient(145deg, rgba(19, 36, 58, 0.94), rgba(12, 26, 43, 0.96));
  border-radius: var(--radius);
  box-shadow: 0 18px 55px rgba(0, 0, 0, 0.2);
}

.welcome-card {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 18px;
  margin-bottom: 14px;
}
.welcome-card h2 { margin: 8px 0 4px; }
.welcome-card p { margin: 0; font-size: 13px; }
.plan-badge {
  display: inline-flex;
  padding: 5px 9px;
  border: 1px solid rgba(37, 214, 149, 0.28);
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 10px;
  font-weight: 800;
}
.ai-counter {
  min-width: 88px;
  align-self: center;
  text-align: center;
  padding: 12px 10px;
  background: rgba(7, 17, 31, 0.55);
  border-radius: 16px;
}
.ai-counter span { display: block; color: var(--muted); font-size: 10px; }
.ai-counter strong { display: block; margin-top: 4px; font-size: 20px; }

.market-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  margin: 14px 0;
}
.market-tab {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  padding: 11px 5px;
  border-radius: 13px;
  font-size: 12px;
  font-weight: 700;
}
.market-tab.active {
  color: #03120d;
  border-color: var(--green);
  background: var(--green);
}

.control-card { padding: 17px; margin-bottom: 14px; }
.field-row + .field-row { margin-top: 15px; }
label, .field-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}
.symbol-control { display: flex; gap: 8px; }
select {
  width: 100%;
  border: 1px solid var(--line);
  outline: none;
  padding: 13px 14px;
  background: #091728;
  color: var(--text);
  border-radius: 14px;
}
.interval-buttons { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; }
.interval-button {
  border: 1px solid var(--line);
  padding: 10px 4px;
  border-radius: 11px;
  background: #091728;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}
.interval-button.active { color: var(--text); border-color: var(--blue); background: rgba(75, 141, 255, 0.18); }

.chart-card { padding: 16px 10px 10px; overflow: hidden; }
.chart-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 0 7px 12px;
}
.chart-heading > div:last-child { text-align: right; }
.chart-symbol { font-weight: 800; }
.chart-interval {
  margin-left: 6px;
  color: var(--muted);
  font-size: 11px;
}
#currentPrice { display: block; }
.price-change { font-size: 11px; color: var(--muted); }
.price-change.positive { color: var(--green); }
.price-change.negative { color: var(--red); }
#chart { width: 100%; height: 330px; }
.inline-error {
  margin: 10px;
  padding: 13px;
  border-radius: 12px;
  background: rgba(255, 96, 122, 0.12);
  color: #ff9aac;
  font-size: 13px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 25px 3px 10px;
}
.section-heading h2 { margin: 3px 0 0; }
.section-heading.compact { margin-top: 0; }
.ghost-button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 12px;
}
.indicator-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 9px;
}
.indicator-card {
  min-height: 94px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}
.indicator-card span { color: var(--muted); font-size: 11px; }
.indicator-card strong { display: block; margin: 6px 0 2px; font-size: 17px; }
.indicator-card small { color: var(--muted); font-size: 10px; }
.indicator-card.good strong { color: var(--green); }
.indicator-card.bad strong { color: var(--red); }
.indicator-card.warning strong { color: var(--warning); }

.analysis-card { padding: 18px; margin-top: 25px; }
.analysis-card.primary-analysis {
  position: relative;
  overflow: hidden;
  margin: 0 0 16px;
  padding: 20px;
  border-color: rgba(75, 141, 255, 0.32);
  background:
    radial-gradient(circle at 100% 0, rgba(154, 107, 255, 0.2), transparent 42%),
    linear-gradient(145deg, rgba(20, 42, 69, 0.98), rgba(11, 25, 43, 0.98));
}
.analysis-card.primary-analysis::before {
  content: "";
  position: absolute;
  top: -70px;
  right: -55px;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  border: 1px solid rgba(75, 141, 255, 0.16);
  box-shadow: 0 0 60px rgba(75, 141, 255, 0.12);
  pointer-events: none;
}
.analysis-heading { display: flex; gap: 12px; align-items: center; margin-bottom: 15px; }
.analysis-heading h2, .analysis-heading p { margin-bottom: 2px; }
.analysis-heading p { font-size: 12px; }
.analysis-icon {
  display: grid;
  place-items: center;
  min-width: 48px;
  height: 48px;
  border-radius: 15px;
  color: white;
  font-weight: 900;
  background: linear-gradient(135deg, var(--blue), var(--purple));
  box-shadow: 0 10px 30px rgba(107, 102, 255, 0.3);
}
.primary-button, .upgrade-button {
  border: 0;
  border-radius: 14px;
  padding: 13px 18px;
  background: var(--green);
  color: #03140e;
  font-weight: 800;
}
.primary-button.wide { width: 100%; }
.ai-main-button {
  position: relative;
  width: 100%;
  min-height: 60px;
  padding: 17px 22px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 18px;
  color: white;
  background: linear-gradient(115deg, #427fff, #7f5cff 52%, #a45cff);
  box-shadow:
    0 14px 32px rgba(75, 94, 255, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  font-size: 16px;
  letter-spacing: .01em;
}
.ai-main-button:active { transform: translateY(1px); }
.ai-button-icon {
  display: inline-block;
  margin-right: 7px;
  font-size: 20px;
  vertical-align: -1px;
}
.primary-button:disabled { opacity: 0.55; cursor: wait; }
.analysis-loading {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-top: 15px;
  color: var(--muted);
  font-size: 13px;
}
.analysis-result {
  margin-top: 16px;
  padding: 16px;
  border-left: 3px solid var(--purple);
  border-radius: 4px 14px 14px 4px;
  background: rgba(7, 17, 31, 0.55);
  white-space: pre-wrap;
  line-height: 1.62;
  font-size: 14px;
}
.upgrade-box {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid rgba(154, 107, 255, 0.34);
  border-radius: 16px;
  background: rgba(154, 107, 255, 0.1);
}
.upgrade-box p { margin: 7px 0 13px; font-size: 13px; }
.upgrade-button { background: linear-gradient(135deg, var(--purple), var(--blue)); color: white; }

.favorites-card, .guide-card { padding: 18px; margin-top: 15px; }
.favorites-list { display: flex; gap: 8px; flex-wrap: wrap; }
.favorite-chip {
  border: 1px solid var(--line);
  background: #091728;
  color: var(--text);
  padding: 9px 11px;
  border-radius: 999px;
  font-size: 12px;
}

.guide-card { margin-top: 25px; }
.guide-card > h2 { margin: 4px 0 18px; }
.guide-step {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 11px;
  padding: 13px 0;
  border-top: 1px solid var(--line);
}
.guide-step > span {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 10px;
  background: var(--green-soft);
  color: var(--green);
  font-weight: 800;
  font-size: 12px;
}
.guide-step strong { font-size: 14px; }
.guide-step p { margin: 4px 0 0; font-size: 12px; }

footer {
  padding: 34px 14px 5px;
}
.footer-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
}
.footer-logo {
  width: 42px;
  height: 42px;
  border-radius: 14px;
}
.footer-brand > div:last-child {
  text-align: left;
}
.footer-brand strong {
  display: block;
  color: var(--text);
  font-size: 14px;
  letter-spacing: .01em;
}
.footer-brand span {
  display: block;
  margin-top: 2px;
  color: var(--green);
  font-size: 9px;
  letter-spacing: .07em;
  text-transform: uppercase;
}
footer p {
  max-width: 360px;
  margin: 14px auto 0;
  color: #647990;
  text-align: center;
  font-size: 10px;
  line-height: 1.5;
}

@media (min-width: 620px) {
  #app { padding-left: 22px; padding-right: 22px; }
  .indicator-grid { grid-template-columns: repeat(3, 1fr); }
  #chart { height: 410px; }
}
