﻿/* ===== 基础 ===== */
:root {
  --bg: #0a1c24;
  --surface: #112e38;
  --surface-hover: #183b48;
  --border: #1e4958;
  --text: #cce8f0;
  --text-muted: #528a99;
  --accent: #06b6d4;
  --green: #3fb950;
  --red: #f85149;
  --orange: #f0883e;
  --warm: #f59e42;
  --cool: #38bdf8;
  --radius: 16px;
  --radius-sm: 10px;
  --top-space: 28vh;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { background: var(--bg); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); min-height: 100vh;
  display: flex; flex-direction: column; align-items: center; line-height: 1.5;
}

header {
  width: 100%; height: 42px; background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: flex-end; padding: 0 1.5rem;
}
.clock { font-size: 0.78rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.top-gap { margin-top: var(--top-space); }

.panels {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem;
  width: 100%; max-width: 860px; padding: 0 1.5rem 3rem;
}

.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.5rem;
  transition: border-color 0.25s, box-shadow 0.25s;
}
.panel:hover { border-color: var(--accent); box-shadow: 0 0 0 1px rgba(6,182,212,0.15); }
.panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; flex-wrap: wrap; gap: 0.4rem; }
.panel-header h2 { font-size: 0.95rem; font-weight: 600; }

.icon-btn {
  background: none; border: 1px solid var(--border); border-radius: 50%;
  color: var(--text-muted); cursor: pointer;
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem; transition: all 0.2s;
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); border-color: var(--accent); }
.icon-btn:active { transform: scale(0.9); }
.icon-btn.spinning .btn-icon { animation: spin 0.8s linear infinite; }
.btn-icon { display: inline-block; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

.weather-panel.loading .weather-temp,.weather-panel.loading .weather-desc,.weather-panel.loading .weather-range { opacity: 0.25; filter: blur(3px); transition: opacity .5s, filter .5s; }
.weather-panel .weather-temp,.weather-panel .weather-desc,.weather-panel .weather-range { opacity: 1; filter: blur(0); transition: opacity .6s, filter .6s; }
.weather-main { display: flex; align-items: center; gap: 1rem; margin-bottom: .3rem; }
.weather-temp { font-size: 3.2rem; font-weight: 700; line-height: 1; }
.weather-icon { font-size: 2.5rem; }
.weather-desc { font-size: .95rem; color: var(--text-muted); margin-bottom: .75rem; }
.weather-range { margin-bottom: .5rem; }
.range-labels { display: flex; justify-content: space-between; align-items: center; font-size: .82rem; margin-bottom: .4rem; position: relative; }
.range-lo { color: var(--cool); font-weight: 600; }
.range-hi { color: var(--warm); font-weight: 600; }
.range-cur { font-size: .7rem; color: var(--text-muted); position: absolute; transform: translateX(-50%); white-space: nowrap; top: -1.1rem; }
.range-bar-wrap { position: relative; height: 6px; background: var(--bg); border-radius: 3px; overflow: visible; margin-top: .6rem; }
.range-bar-track { position: absolute; top: 0; height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--cool), var(--green), var(--orange), var(--red)); }
.range-bar-dot { position: absolute; top: -4px; width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 2px solid var(--accent); box-shadow: 0 0 8px rgba(6,182,212,.5); transform: translateX(-50%); }
.range-lo.pop,.range-hi.pop { animation: popNum .5s cubic-bezier(.16,1,.3,1); }
@keyframes popNum { 0%{transform:scale(.6);opacity:0;} 100%{transform:scale(1);opacity:1;} }

/* 股市 */
.stock-status { font-size: .78rem; color: var(--green); font-weight: 600; }
.stock-panel.error .stock-status { color: var(--red); }
.stock-list { display: flex; flex-direction: column; gap: .75rem; margin-bottom: .5rem; }
.stock-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: .75rem 1rem; background: var(--bg); border-radius: var(--radius-sm);
  border: 1px solid transparent; transition: all .2s;
  cursor: pointer; position: relative;
}
.stock-item:hover { border-color: var(--border); background: var(--surface-hover); }
.stock-name { font-weight: 600; font-size: .9rem; flex: 1; }
.stock-price { font-size: 1.05rem; font-weight: 700; font-variant-numeric: tabular-nums; margin-right: .75rem; }
.stock-change { font-size: .85rem; font-weight: 600; font-variant-numeric: tabular-nums; min-width: 100px; text-align: right; }
.stock-change.up { color: var(--red); }
.stock-change.down { color: var(--green); }
.stock-updated { font-size: .7rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* K线卡片 */
.kline-tip {
  position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%);
  background: #0a1820; border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: .6rem .7rem .4rem; z-index: 20;
  visibility: hidden; opacity: 0;
  transition: opacity .2s, visibility 0s .2s;
  box-shadow: 0 8px 24px rgba(0,0,0,.55); min-width: 270px; pointer-events: auto;
}
.stock-item:hover .kline-tip { visibility: visible; opacity: 1; transition: opacity .25s .35s, visibility 0s .35s; }
.kline-tip-title { font-size: .7rem; color: var(--text-muted); margin-bottom: .35rem; }
.kline-tip svg { display: block; cursor: crosshair; }
.kline-tip-detail {
  margin-top: .4rem; padding-top: .35rem; border-top: 1px solid var(--border);
  font-size: .68rem; color: var(--text-muted);
  min-height: 2.8rem; display: flex; align-items: center; justify-content: center;
}
.kline-tip-detail.active { color: var(--text); }
.cg { transition: transform .18s cubic-bezier(.16,1,.3,1); }

/* ===== 弹窗 ===== */
.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0); z-index: 100;
  display: flex; align-items: center; justify-content: center;
  visibility: hidden; transition: background .3s, visibility 0s .3s;
}
.overlay.open { background: rgba(0,0,0,.72); visibility: visible; transition: background .3s, visibility 0s 0s; }

.detail-modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  width: 90vw; max-width: 680px; max-height: 90vh; overflow-y: auto;
  transform: translateY(30px) scale(.93); opacity: 0;
  transition: transform .35s cubic-bezier(.16,1,.3,1), opacity .25s;
  padding: 1.5rem; display: flex; flex-direction: column; gap: .75rem; position: relative; min-height: 0;
}
.overlay.open .detail-modal { transform: translateY(0) scale(1); opacity: 1; }

.detail-close {
  position: absolute; top: .75rem; right: 1rem; background: none; border: none;
  color: var(--text-muted); font-size: 1.2rem; cursor: pointer; z-index: 2;
  transition: color .15s, transform .2s;
}
.detail-close:hover { color: var(--text); transform: rotate(90deg); }

.detail-header { display: flex; align-items: baseline; gap: 1rem; }
.detail-name { font-size: 1.3rem; font-weight: 700; }
.detail-code { font-size: .8rem; color: var(--text-muted); }
.detail-price-row { display: flex; align-items: baseline; gap: 1rem; }
.detail-price { font-size: 2.2rem; font-weight: 700; }
.detail-change { font-size: 1rem; font-weight: 600; }
.detail-change.up { color: var(--red); }
.detail-change.down { color: var(--green); }

.detail-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: .6rem; }
.detail-stat {
  display: flex; flex-direction: column; gap: .1rem; background: var(--bg);
  padding: .5rem .6rem; border-radius: var(--radius-sm);
  transition: transform .2s cubic-bezier(.16,1,.3,1), border-color .2s, box-shadow .2s;
  border: 1px solid transparent; cursor: default;
}
.detail-stat:hover { transform: translateY(-2px) scale(1.08); border-color: var(--accent); box-shadow: 0 4px 14px rgba(6,182,212,.25); }
.detail-stat .ds-label { font-size: .68rem; color: var(--text-muted); }
.detail-stat .ds-value { font-size: .85rem; font-weight: 600; }

.chart-tabs { display: flex; gap: 2px; background: var(--bg); border-radius: 6px; padding: 2px; width: fit-content; }
.chart-tab { padding: .25rem .7rem; border-radius: 4px; cursor: pointer; font-size: .75rem; color: var(--text-muted); transition: all .2s; border: none; background: none; }
.chart-tab:hover { color: var(--text); }
.chart-tab.active { background: var(--accent); color: #000; font-weight: 600; }

.detail-chart { background: var(--bg); border-radius: var(--radius-sm); padding: .75rem; position: relative; flex-shrink: 0; min-height: 150px; }
.detail-chart svg { display: block; cursor: crosshair; width: 100%; height: auto; }
.detail-chart-info {
  position: absolute; bottom: .75rem; left: .75rem; right: .75rem;
  text-align: center; font-size: .72rem; color: var(--text-muted);
  pointer-events: none; transition: color .15s;
}
.detail-chart-info.active { color: var(--text); }

.jump-btn {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .35rem .75rem; border-radius: 6px;
  font-size: .75rem; font-weight: 600; cursor: pointer; border: 1px solid var(--accent);
  background: none; color: var(--accent); transition: all .2s;
  animation: jumpPulse 2s ease-in-out infinite; text-decoration: none;
}
.jump-btn:hover { background: var(--accent); color: #000; animation: none; }
@keyframes jumpPulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(6,182,212,.4); }
  50% { box-shadow: 0 0 0 6px rgba(6,182,212,0); }
}

.btn-sm {
  display: inline-block; padding: .3rem .8rem; border-radius: 6px;
  font-size: .78rem; font-weight: 600; cursor: pointer; border: none; transition: all .2s;
  background: var(--accent); color: #000;
}
.btn-sm:hover { filter: brightness(1.15); }
.btn-sm.outline { background: none; border: 1px solid var(--accent); color: var(--accent); }
.btn-sm.outline:hover { background: var(--accent); color: #000; }

.cross-v,.cross-h { pointer-events: none; }

@keyframes shimmer { 0%{background-position:-200px 0;} 100%{background-position:200px 0;} }
.skeleton-text {
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-hover) 50%, var(--surface) 75%);
  background-size: 400px 100%; animation: shimmer 1.5s ease-in-out infinite;
  border-radius: 4px; color: transparent !important;
}

/* ===== 平板 ===== */
@media (max-width: 900px) {
  .detail-modal { width: 94vw; max-width: 94vw; padding: 1.2rem; }
  .detail-stats { grid-template-columns: repeat(4, 1fr); gap: .4rem; }
  .detail-stat { padding: .4rem .45rem; }
  .detail-price { font-size: 1.8rem; }
  .detail-chart svg { max-height: 180px; }
}

/* ===== 手机 ===== */
@media (max-width: 700px) {
  :root { --top-space: 6vh; }
  .panels { grid-template-columns: 1fr; padding: 0 1rem 2rem; }
  .panel { padding: 1.2rem; }
  .weather-temp { font-size: 2.5rem; }
  .weather-icon { font-size: 2rem; }
  .detail-modal { width: 100vw; max-width: 100vw; border-radius: var(--radius) var(--radius) 0 0; max-height: 85vh; padding: 1rem; gap: .5rem; margin: 0; min-height: 0; }
  .overlay { align-items: flex-end; }
  /* duplicate removed - merged into base rule */
  .overlay.open .detail-modal { transform: translateY(0) scale(1); opacity: 1; }
  .detail-name { font-size: 1.1rem; }
  .detail-price { font-size: 1.6rem; }
  .detail-change { font-size: .85rem; }
  .detail-stats { grid-template-columns: repeat(2, 1fr); gap: .4rem; }
  .detail-stat { padding: .4rem .5rem; }
  .detail-stat .ds-label { font-size: .62rem; }
  .detail-stat .ds-value { font-size: .8rem; }
  .detail-chart { padding: .5rem; }
  .chart-tab { font-size: .7rem; padding: .2rem .5rem; }
  .jump-btn { font-size: .7rem; padding: .25rem .5rem; }
  .stock-change { min-width: 80px; font-size: .78rem; }
  .stock-price { font-size: .95rem; }
  .stock-item { padding: .6rem .75rem; }
  .clock { font-size: .7rem; }
  header { padding: 0 1rem; height: 38px; }
  .detail-chart svg { max-height: 160px; }
  .detail-modal { -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
}

@media (max-width: 400px) {
  .weather-temp { font-size: 2rem; }
  .weather-icon { font-size: 1.8rem; }
  .detail-price { font-size: 1.3rem; }
  .detail-stats { gap: .3rem; }
  .detail-stat .ds-value { font-size: .72rem; }
  .kline-tip { min-width: 230px; left: auto; right: 0; transform: none; }
  .stock-item:hover .kline-tip { transform: translateY(-4px); }
  .detail-chart svg { max-height: 130px; }
}
