:root {
  color-scheme: light;
  --bg: #eef4f4;
  --panel: #ffffff;
  --ink: #061719;
  --chart-ink: #f8fcfd;
  --text: #102326;
  --muted: #63787c;
  --line: #d7e4e5;
  --accent: #00a9b7;
  --accent-strong: #006d78;
  --coral: #ff6a3d;
  --gold: #e4af3f;
  --mint: #34d399;
  --shadow: 0 18px 46px rgba(6, 23, 25, 0.14);
  --tight-shadow: 0 10px 26px rgba(6, 23, 25, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: #e7f0f1;
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
  display: flex;
  justify-content: center;
  background:
    linear-gradient(115deg, rgba(0, 169, 183, 0.1), transparent 34%),
    linear-gradient(245deg, rgba(228, 175, 63, 0.12), transparent 38%),
    repeating-linear-gradient(90deg, rgba(0, 109, 120, 0.035) 0 1px, transparent 1px 56px),
    #e5eff0;
}

button,
input {
  font: inherit;
}

.app-shell {
  width: min(100vw, 430px);
  min-height: 100dvh;
  margin: 0 auto;
  background:
    radial-gradient(circle at 18% 0%, rgba(0, 169, 183, 0.22), transparent 34%),
    radial-gradient(circle at 90% 28px, rgba(255, 106, 61, 0.12), transparent 28%),
    linear-gradient(180deg, #f9ffff 0, #edf8f9 178px, var(--bg) 179px),
    var(--bg);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.78), 0 24px 80px rgba(5, 22, 26, 0.16);
  padding: max(18px, env(safe-area-inset-top)) 16px max(22px, env(safe-area-inset-bottom));
  overflow-x: hidden;
  position: relative;
}

.app-shell::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 190px;
  background:
    linear-gradient(135deg, transparent 0 36%, rgba(0, 169, 183, 0.18) 36% 37%, transparent 37% 100%),
    linear-gradient(35deg, transparent 0 58%, rgba(255, 106, 61, 0.12) 58% 59%, transparent 59% 100%),
    repeating-linear-gradient(0deg, rgba(0, 109, 120, 0.04) 0 1px, transparent 1px 18px);
  pointer-events: none;
  animation: energy-scan 9s ease-in-out infinite alternate;
}

.top-bar {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 2px 20px;
}

.top-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  color: #062b30;
  font-size: 34px;
  line-height: 1.08;
  text-shadow: 0 8px 24px rgba(0, 169, 183, 0.12);
}

h2 {
  font-size: 18px;
  line-height: 1.2;
}

.status-pill {
  min-width: 78px;
  padding: 8px 10px;
  border: 1px solid rgba(0, 169, 183, 0.2);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  backdrop-filter: blur(14px);
}

.orientation-button {
  min-width: 74px;
  min-height: 34px;
  border: 1px solid rgba(0, 169, 183, 0.24);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--accent-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 800;
  backdrop-filter: blur(14px);
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.orientation-button:active {
  transform: translateY(1px);
}

.orientation-button[aria-pressed="true"] {
  border-color: rgba(0, 169, 183, 0.32);
  background: linear-gradient(135deg, var(--accent), var(--coral));
  color: #ffffff;
}

.control-panel,
.chart-panel {
  position: relative;
  z-index: 1;
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.control-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 12px;
  margin-top: 2px;
  animation: float-in 520ms ease both;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.field input {
  width: 100%;
  min-height: 42px;
  border: 1px solid rgba(16, 35, 38, 0.1);
  border-radius: 8px;
  background: #f8fbfb;
  color: var(--text);
  padding: 0 10px;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.82);
}

.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(12, 124, 134, 0.12);
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  align-self: end;
  min-height: 42px;
  padding: 4px;
  border: 1px solid rgba(16, 35, 38, 0.1);
  border-radius: 8px;
  background: #eaf2f3;
}

.segment {
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.segment.active {
  background: linear-gradient(180deg, #ffffff, #f4fbfb);
  color: var(--accent-strong);
  box-shadow: 0 5px 15px rgba(15, 46, 52, 0.12);
}

.primary-button {
  grid-column: 1 / -1;
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #007d8a 58%, var(--gold));
  color: #ffffff;
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 12px 26px rgba(0, 125, 138, 0.28);
  transition: transform 160ms ease, box-shadow 160ms ease;
  overflow: hidden;
  position: relative;
}

.primary-button::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 -46%;
  width: 42%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.42), transparent);
  transform: skewX(-18deg);
  animation: button-shine 3.8s ease-in-out infinite;
}

.primary-button:active {
  transform: translateY(1px);
  box-shadow: 0 7px 18px rgba(0, 125, 138, 0.22);
}

.primary-button:disabled {
  opacity: 0.65;
}

.button-icon {
  font-size: 18px;
  line-height: 1;
  transition: transform 220ms ease;
}

.primary-button:not(:disabled):active .button-icon {
  transform: rotate(80deg);
}

.metric-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 12px 0;
}

.metric {
  min-height: 82px;
  padding: 12px 10px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(247, 252, 252, 0.9)),
    #ffffff;
  box-shadow: var(--tight-shadow);
  position: relative;
  overflow: hidden;
  animation: float-in 560ms ease both;
}

.metric:nth-child(2) {
  animation-delay: 80ms;
}

.metric:nth-child(3) {
  animation-delay: 160ms;
}

.metric::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--coral), var(--gold));
}

.metric:nth-child(2)::before {
  background: linear-gradient(90deg, var(--coral), #ffb86b);
}

.metric:nth-child(3)::before {
  background: linear-gradient(90deg, var(--gold), var(--mint));
}

.metric:nth-child(1) strong {
  color: #007d8a;
}

.metric:nth-child(2) strong {
  color: #dc4f2e;
}

.metric:nth-child(3) strong {
  color: #94670a;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 10px;
  color: #061719;
  font-size: clamp(18px, 7vw, 26px);
  line-height: 1;
  white-space: nowrap;
}

.chart-panel {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(246, 252, 253, 0.94)),
    var(--chart-ink);
  border-color: rgba(255, 255, 255, 0.82);
  color: var(--text);
  position: relative;
  padding: 14px 12px 8px;
  overflow: hidden;
  animation: float-in 640ms ease both;
  animation-delay: 180ms;
}

.chart-panel h2 {
  color: #09272c;
}

.chart-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(120deg, transparent 0 54%, rgba(0, 169, 183, 0.08) 54% 55%, transparent 55%),
    repeating-linear-gradient(90deg, rgba(0, 109, 120, 0.035) 0 1px, transparent 1px 42px),
    repeating-linear-gradient(0deg, rgba(0, 109, 120, 0.026) 0 1px, transparent 1px 34px);
  pointer-events: none;
  animation: chart-grid-drift 8s linear infinite;
}

.chart-head {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 10px;
}

.chart-head p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.legend {
  display: grid;
  gap: 6px;
  align-content: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.legend span,
.legend-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-toggle {
  min-height: 28px;
  border: 1px solid rgba(0, 109, 120, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.8);
  color: var(--muted);
  padding: 0 9px;
  font-size: 12px;
  font-weight: 800;
}

.legend-toggle.active {
  border-color: rgba(0, 169, 183, 0.28);
  color: var(--text);
  box-shadow: 0 6px 16px rgba(0, 169, 183, 0.12);
}

.legend-toggle:not(.active) {
  opacity: 0.48;
}

.legend-mark {
  width: 12px;
  height: 4px;
  border-radius: 999px;
}

.day-ahead {
  background: var(--accent);
}

.intraday {
  background: var(--coral);
}

.chart-wrap {
  position: relative;
  z-index: 1;
  width: 100%;
  aspect-ratio: 1.16;
  min-height: 320px;
}

#priceChart {
  display: block;
  width: 100%;
  height: 100%;
}

.axis {
  stroke: rgba(91, 119, 124, 0.4);
  stroke-width: 1;
}

.grid-line {
  stroke: rgba(0, 109, 120, 0.08);
  stroke-width: 1;
}

.chart-label {
  fill: #6c8589;
  font-size: 11px;
  font-weight: 700;
}

.line-day-ahead,
.line-intraday {
  fill: none;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 10px rgba(0, 169, 183, 0.22));
  animation: draw-line 900ms ease both;
}

.line-day-ahead {
  stroke: #22d3ee;
}

.line-intraday {
  stroke: #ff7a45;
}

.dot-day-ahead,
.dot-intraday {
  stroke: #ffffff;
  stroke-width: 2;
}

.dot-day-ahead {
  fill: #7defff;
}

.dot-intraday {
  fill: #ff9a73;
}

.area-day-ahead,
.area-intraday {
  opacity: 0.12;
}

.area-day-ahead {
  fill: #22d3ee;
}

.area-intraday {
  fill: #ff7a45;
}

.hit-dot {
  fill: transparent;
  cursor: pointer;
}

.focus-guide {
  stroke: rgba(9, 39, 44, 0.34);
  stroke-width: 1;
  stroke-dasharray: 4 4;
}

.chart-tooltip {
  position: absolute;
  min-width: 128px;
  max-width: 190px;
  padding: 8px 10px;
  border: 1px solid rgba(0, 109, 120, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 12px 34px rgba(6, 23, 25, 0.18);
  color: var(--text);
  font-size: 12px;
  font-weight: 800;
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 12px));
  z-index: 3;
}

.chart-tooltip span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-weight: 700;
}

.empty-state {
  display: none;
  position: absolute;
  inset: 72px 12px 8px;
  place-items: center;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.74);
  color: var(--muted);
  font-weight: 800;
}

.empty-state.visible {
  display: grid;
}

@keyframes draw-line {
  from {
    stroke-dasharray: 900;
    stroke-dashoffset: 900;
  }

  to {
    stroke-dasharray: 900;
    stroke-dashoffset: 0;
  }
}

@keyframes pulse-status {
  0%,
  100% {
    box-shadow: 0 0 0 rgba(134, 244, 255, 0);
  }

  50% {
    box-shadow: 0 0 18px rgba(134, 244, 255, 0.18);
  }
}

@keyframes float-in {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.985);
  }

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

@keyframes energy-scan {
  from {
    transform: translateX(-10px);
    opacity: 0.72;
  }

  to {
    transform: translateX(10px);
    opacity: 1;
  }
}

@keyframes chart-grid-drift {
  from {
    background-position: 0 0, 0 0, 0 0;
  }

  to {
    background-position: 0 0, 42px 0, 0 34px;
  }
}

@keyframes button-shine {
  0%,
  56% {
    left: -46%;
  }

  100% {
    left: 110%;
  }
}

.status-pill {
  animation: pulse-status 2.8s ease-in-out infinite;
}

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

@supports not (backdrop-filter: blur(1px)) {
  .control-panel {
    background: #ffffff;
  }

  .chart-panel {
    background: #ffffff;
  }
}

body.landscape-preview {
  overflow: hidden;
  align-items: center;
  min-height: 100dvh;
}

body.landscape-preview .app-shell {
  width: min(100vw, 860px);
  height: min(var(--visible-height, 100dvh), 430px);
  min-height: 0;
  display: block;
  background: #edf6f7;
  overflow: auto;
  padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  animation: landscape-pop 260ms ease both;
}

@keyframes landscape-pop {
  from {
    opacity: 0.72;
    transform: scale(0.985);
  }

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

body.landscape-preview .top-bar {
  position: fixed;
  top: max(10px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  z-index: 5;
  padding: 0;
}

body.landscape-preview .top-bar > div:first-child,
body.landscape-preview .status-pill,
body.landscape-preview .control-panel,
body.landscape-preview .metric-grid {
  display: none;
}

body.landscape-preview .top-actions {
  gap: 6px;
}

body.landscape-preview .orientation-button {
  min-height: 30px;
  min-width: 68px;
  padding-top: 6px;
  padding-bottom: 6px;
  font-size: 11px;
}

body.landscape-preview .chart-panel {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  box-shadow: none;
  padding: 10px 10px 8px;
  overflow: hidden;
  border-color: rgba(134, 244, 255, 0.22);
}

body.landscape-preview .chart-head {
  margin-bottom: 8px;
  padding-right: 78px;
}

body.landscape-preview .chart-head h2 {
  font-size: 16px;
}

body.landscape-preview .chart-head p,
body.landscape-preview .legend,
body.landscape-preview .legend-toggle {
  font-size: 10px;
}

body.landscape-preview .chart-wrap {
  flex: 1;
  min-height: 0;
  aspect-ratio: auto;
}

@media (orientation: portrait) {
  body.landscape-preview .app-shell {
    position: fixed;
    inset: 0 auto auto 0;
    width: var(--visible-height, 100vh);
    height: var(--visible-width, 100vw);
    max-width: none;
    transform: rotate(90deg) translateY(-100%);
    transform-origin: top left;
    overflow: auto;
  }
}

@media (max-width: 380px) {
  .control-panel {
    grid-template-columns: 1fr;
  }

  .primary-button {
    grid-column: auto;
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }
}

@media (min-width: 520px) {
  .app-shell {
    min-height: min(100dvh, 920px);
  }
}
