/* ── Shared history charts (Din Daeng + Bangna) ─────────────────────────────
   Used by the Din Daeng dashboard and the Bangna Weather Twin overlay.
   Colours fall back to the host page's theme variables. */

.st-charts {
  scroll-margin-top: 92px;
  --st-line: var(--line, rgba(120, 190, 200, 0.16));
  --st-card-bg: rgba(3, 14, 20, 0.42);
  --st-text: var(--text, #e8f4f6);
  --st-muted: var(--muted, #8eacb6);
  position: relative;
  margin: 2rem 0 2.6rem;
  padding: 1.15rem 1.2rem 1.2rem;
  border: 1px solid var(--st-line);
  border-radius: 20px;
  background: var(--card, rgba(10, 28, 38, 0.78));
  backdrop-filter: blur(18px);
  color: var(--st-text);
}

.st-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.st-eyebrow {
  margin: 0;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--st-accent, #2ec4b6);
}

.st-head h2 {
  margin: 0.15rem 0 0;
  font-size: clamp(1.05rem, 1.6vw, 1.35rem);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.st-tools {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.st-tabs {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border: 1px solid var(--st-line);
  border-radius: 11px;
  background: rgba(4, 18, 26, 0.55);
}

.st-tabs button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--st-muted);
  font: inherit;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 0.34rem 0.62rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.st-tabs button:hover { color: var(--st-text); }

.st-tabs button.is-on {
  background: var(--st-accent, #2ec4b6);
  color: #03141a;
}

.st-export {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 0.7rem;
  border: 1px solid var(--st-line);
  border-radius: 10px;
  color: var(--st-text);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-decoration: none;
  background: rgba(4, 18, 26, 0.55);
  transition: border-color 0.2s ease, color 0.2s ease;
}

.st-export:hover {
  border-color: var(--st-accent, #2ec4b6);
  color: var(--st-accent, #2ec4b6);
}

.st-note {
  margin: 0.65rem 0 0;
  font-size: 0.7rem;
  line-height: 1.5;
  color: var(--st-muted);
}

.st-status {
  min-height: 1.05em;
  margin: 0.3rem 0 0.8rem;
  font-size: 0.68rem;
  color: var(--st-muted);
}

.st-status.is-error { color: #ff8a8a; }

.st-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
}

.st-card {
  min-width: 0;
  padding: 0.75rem 0.85rem 0.55rem;
  border: 1px solid var(--st-line);
  border-radius: 14px;
  background: var(--st-card-bg);
}

.st-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.35rem;
}

.st-card h3 {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.3;
}

.st-card-head span {
  flex: none;
  font-family: var(--mono, "JetBrains Mono", monospace);
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  color: var(--st-accent, #2ec4b6);
}

.st-canvas {
  position: relative;
  height: 208px;
}

.st-canvas canvas { display: block; }

/* ── Bangna history overlay ──────────────────────────────────────────────── */
.tw-history {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.1rem;
}

.tw-history[hidden] { display: none; }

.tw-history-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 8, 14, 0.8);
  backdrop-filter: blur(16px);
}

.tw-history-panel {
  position: relative;
  width: min(1160px, 100%);
  max-height: 92vh;
  overflow: auto;
  padding: 1.1rem 1.15rem 1.3rem;
  border: 1px solid var(--stroke-strong, rgba(120, 220, 255, 0.28));
  border-radius: 22px;
  background: rgba(5, 18, 28, 0.96);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
}

.tw-history-head {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 1rem;
  margin-bottom: 0.2rem;
}

.tw-history-head h2 {
  margin: 0.15rem 0 0;
  font-size: 1.1rem;
}

.tw-history-body .st-charts {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  backdrop-filter: none;
}

body.st-lock { overflow: hidden; }

@media (max-width: 760px) {
  .st-grid { grid-template-columns: 1fr; }
  .st-canvas { height: 190px; }
  .st-charts { padding: 0.95rem; border-radius: 16px; }
  .st-head { align-items: flex-start; }
  .st-tools { width: 100%; justify-content: space-between; }
  .tw-history { padding: 0; }
  .tw-history-panel {
    width: 100%;
    height: 100%;
    max-height: none;
    border-radius: 0;
    border: 0;
    padding: 0.9rem 0.8rem 1.4rem;
  }
  .tw-history-body .st-canvas { height: 180px; }
  .st-charts { scroll-margin-top: 190px; }
}
