:root {
  color-scheme: dark;
  --bg: #08090a;
  --panel: rgba(255, 255, 255, 0.04);
  --panel-strong: rgba(255, 255, 255, 0.07);
  --border: rgba(255, 255, 255, 0.09);
  --text: #f7f8f8;
  --muted: #8a8f98;
  --soft: #d0d6e0;
  --accent: #7170ff;
  --green: #10b981;
  --red: #f05252;
  --yellow: #fbbf24;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at 20% 0%, rgba(113, 112, 255, 0.18), transparent 32rem),
    linear-gradient(180deg, #101116 0%, var(--bg) 45%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-feature-settings: "cv01", "ss03";
}

button {
  border: 0;
  color: inherit;
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}

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

.hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 0 8px;
}

.hero-actions {
  display: flex;
  gap: 6px;
  flex: 0 0 auto;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(28px, 8.5vw, 38px);
  line-height: 0.98;
  letter-spacing: -0.055em;
}

h2 {
  font-size: 18px;
  letter-spacing: -0.02em;
}

.subtitle {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.ghost-btn,
.primary-btn {
  min-height: 34px;
  border-radius: 999px;
  padding: 0 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  font-weight: 650;
}

.primary-btn {
  width: 100%;
  min-height: 42px;
  background: var(--accent);
  border-color: transparent;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1.25fr 1fr 1fr;
  gap: 8px;
}

.stat-card,
.chart-card,
.log-card,
.strategy-card,
.message,
.modal-card {
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 16px 60px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(18px);
}

.stat-card {
  min-width: 0;
  border-radius: 14px;
  padding: 9px 10px;
}

.stat-card span,
.stat-card small,
.price-box span,
.ohlc-row,
.lots-control span,
#winRate {
  color: var(--muted);
  font-size: 12px;
}

.stat-card small {
  display: block;
  margin-top: 2px;
  line-height: 1.22;
  overflow-wrap: anywhere;
}

.stat-card strong {
  display: block;
  overflow: hidden;
  margin-top: 3px;
  font-size: 17px;
  letter-spacing: -0.04em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-card {
  margin-top: 12px;
  border-radius: 24px;
  padding: 15px;
}

.chart-head,
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 10px;
  color: var(--soft);
  background: rgba(255, 255, 255, 0.03);
  font-size: 12px;
  font-weight: 650;
}

#dateLabel {
  margin-top: 8px;
}

.price-box {
  text-align: right;
}

.price-box strong {
  display: block;
  margin-top: 3px;
  font-size: 26px;
  letter-spacing: -0.06em;
}

#klineCanvas {
  display: block;
  width: 100%;
  height: 320px;
  margin-top: 12px;
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.22);
}

.ohlc-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-top: 10px;
  text-align: center;
}

.message {
  margin-top: 10px;
  border-radius: 16px;
  padding: 12px 14px;
  color: var(--soft);
  font-size: 14px;
  line-height: 1.4;
}

.message.good {
  border-color: rgba(16, 185, 129, 0.35);
  color: #a7f3d0;
}

.message.bad {
  border-color: rgba(240, 82, 82, 0.4);
  color: #fecaca;
}

.strategy-card {
  display: grid;
  gap: 10px;
  margin-top: 10px;
  border-radius: 18px;
  padding: 13px 14px;
}

.strategy-card .section-title span,
.strategy-metrics span,
#strategyLots {
  color: var(--muted);
  font-size: 12px;
}

.strategy-main {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

#strategyAction {
  font-size: 22px;
  letter-spacing: -0.04em;
}

#strategyReason {
  color: var(--soft);
  font-size: 13px;
  line-height: 1.45;
}

.strategy-metrics {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.strategy-card.buy {
  border-color: rgba(16, 185, 129, 0.36);
}

.strategy-card.buy #strategyAction {
  color: #86efac;
}

.strategy-card.sell {
  border-color: rgba(239, 68, 68, 0.36);
}

.strategy-card.sell #strategyAction {
  color: #fca5a5;
}

.strategy-card.hold {
  border-color: rgba(113, 112, 255, 0.32);
}

.strategy-card.hold #strategyAction {
  color: #c4b5fd;
}

.trade-panel {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  width: min(100%, 520px);
  margin: 0 auto;
  padding: 6px 16px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: rgba(8, 9, 10, 0.88);
  backdrop-filter: blur(20px);
}

.lots-control {
  display: grid;
  grid-template-columns: 34px minmax(68px, 1fr) 34px;
  align-items: center;
  gap: 6px;
  width: min(190px, 54%);
  margin: 0 auto 4px;
}

.lots-control button,
.action-grid button {
  border-radius: 16px;
  background: var(--panel-strong);
  font-weight: 750;
}

.lots-control button {
  min-height: 30px;
  border-radius: 10px;
  font-size: 16px;
}

.action-grid button {
  min-height: 42px;
  font-size: 18px;
}

.lots-control div {
  text-align: center;
}

.lots-control strong {
  display: block;
  font-size: 16px;
  line-height: 1.05;
}

.action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

.action-grid .buy {
  background: linear-gradient(180deg, #22c55e, #15803d);
}

.action-grid .hold {
  background: linear-gradient(180deg, #6366f1, #4338ca);
}

.action-grid .sell {
  background: linear-gradient(180deg, #ef4444, #b91c1c);
}

.log-card {
  margin-top: 12px;
  border-radius: 22px;
  padding: 15px;
}

.trade-log {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.trade-log li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  border-radius: 14px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--soft);
  font-size: 13px;
}

.trade-log b {
  color: var(--text);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: end center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.62);
}

.modal[hidden] {
  display: none;
}

.modal-card {
  width: min(100%, 488px);
  max-height: min(82vh, 680px);
  overflow: auto;
  border-radius: 28px;
  padding: 22px;
}

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

.summary-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 18px 0;
}

.stock-reveal {
  margin-top: 12px;
}

.stock-reveal span,
.save-status {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.stock-reveal strong {
  display: block;
  margin-top: 4px;
  font-size: 22px;
  letter-spacing: -0.03em;
}

.summary-mini-chart {
  display: block;
  width: 100%;
  height: 150px;
  margin-top: 14px;
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.26);
}

.summary-body div {
  border-radius: 16px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.05);
}

.summary-body span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.summary-body strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
}

.save-status {
  min-height: 17px;
  margin: -6px 0 14px;
}

.save-status.good {
  color: #a7f3d0;
}

.save-status.bad {
  color: #fecaca;
}

.history-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.history-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  border: 0;
  border-radius: 16px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.05);
  color: inherit;
  text-align: left;
}

.history-item strong,
.history-item span,
.history-item small,
.history-metrics b {
  display: block;
}

.history-item strong {
  font-size: 15px;
}

.history-item span,
.history-item small,
.empty-history {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.history-item small {
  margin-top: 3px;
  color: var(--soft);
}

.history-metrics {
  min-width: 96px;
  text-align: right;
}

.empty-history {
  border-radius: 16px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.05);
}

.history-detail-card {
  max-height: min(88vh, 760px);
}

.history-detail-chart {
  display: block;
  width: 100%;
  height: 260px;
  margin-top: 16px;
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.26);
}

.history-detail-trades {
  max-height: 170px;
}

.up {
  color: var(--green) !important;
}

.down {
  color: var(--red) !important;
}

@media (max-width: 370px) {
  .app {
    padding-right: 12px;
    padding-left: 12px;
  }

  .stat-card {
    padding: 11px 9px;
  }

  .stat-card strong {
    font-size: 16px;
  }
}
