/* Telegram Theme Integration */
:root {
  --bg-color: var(--tg-theme-bg-color, #1a1a2e);
  --text-color: var(--tg-theme-text-color, #e0e0e0);
  --hint-color: var(--tg-theme-hint-color, #8a8a9a);
  --link-color: var(--tg-theme-link-color, #6c9bd2);
  --button-color: var(--tg-theme-button-color, #5b8cde);
  --button-text: var(--tg-theme-button-text-color, #ffffff);
  --secondary-bg: var(--tg-theme-secondary-bg-color, #232340);
  --section-bg: var(--tg-theme-section-bg-color, var(--secondary-bg));

  --card-radius: 14px;
  --spacing: 16px;
  --spacing-sm: 10px;
  --spacing-xs: 6px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-color);
  line-height: 1.5;
  padding: var(--spacing);
  padding-bottom: calc(var(--spacing) + env(safe-area-inset-bottom, 0px));
  min-height: 100vh;
  overflow-x: hidden;
}

.hidden {
  display: none !important;
}

/* State Screens */
.state-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  gap: 16px;
  color: var(--hint-color);
  font-size: 15px;
}

.state-screen .error-icon,
.state-screen .empty-icon {
  font-size: 48px;
}

.loader {
  width: 32px;
  height: 32px;
  border: 3px solid var(--secondary-bg);
  border-top-color: var(--button-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.btn {
  background: var(--button-color);
  color: var(--button-text);
  border: none;
  border-radius: 10px;
  padding: 10px 24px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn:active {
  opacity: 0.7;
}

/* Header */
#briefing-header {
  margin-bottom: var(--spacing);
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--spacing-xs);
}

.header-row h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.date-badge {
  font-size: 13px;
  color: var(--hint-color);
  background: var(--secondary-bg);
  padding: 4px 10px;
  border-radius: 8px;
  font-weight: 500;
}

/* Banners */
.banner {
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: var(--spacing-sm);
  background: rgba(255, 170, 50, 0.12);
  color: #f0a040;
}

.banner-info {
  background: rgba(100, 160, 255, 0.1);
  color: var(--link-color);
}

/* Cards */
.card {
  background: var(--section-bg);
  border-radius: var(--card-radius);
  padding: var(--spacing);
  margin-bottom: var(--spacing);
}

.section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.section-header h2 {
  font-size: 16px;
  font-weight: 650;
  flex: 1;
}

.section-icon {
  font-size: 18px;
}

.section-meta {
  font-size: 13px;
  color: var(--hint-color);
}

/* Weather */
.weather-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.weather-temps {
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.temp-high {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -1px;
}

.temp-divider {
  font-size: 24px;
  color: var(--hint-color);
  margin: 0 2px;
}

.temp-low {
  font-size: 24px;
  font-weight: 500;
  color: var(--hint-color);
}

.weather-detail {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.weather-summary {
  font-size: 14px;
  color: var(--hint-color);
}

.rain-badge {
  font-size: 13px;
  font-weight: 600;
  color: #5ba3f5;
  background: rgba(91, 163, 245, 0.12);
  padding: 3px 8px;
  border-radius: 6px;
  white-space: nowrap;
}

/* Headlines */
.headlines-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: var(--spacing);
}

.headline-card {
  background: var(--section-bg);
  border-radius: var(--card-radius);
  padding: 14px var(--spacing);
  text-decoration: none;
  color: inherit;
  display: block;
  transition: transform 0.15s, opacity 0.15s;
}

.headline-card:active {
  transform: scale(0.98);
  opacity: 0.8;
}

.headline-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.category-badge {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 7px;
  border-radius: 4px;
  flex-shrink: 0;
}

.category-badge.geopolitics { background: rgba(239, 83, 80, 0.15); color: #ef5350; }
.category-badge.ai-tech { background: rgba(126, 87, 194, 0.15); color: #9575cd; }
.category-badge.crypto { background: rgba(255, 183, 77, 0.15); color: #ffb74d; }
.category-badge.uk { background: rgba(66, 165, 245, 0.15); color: #42a5f5; }

.headline-source {
  font-size: 12px;
  color: var(--hint-color);
}

.headline-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
  margin-bottom: 4px;
}

.headline-content {
  font-size: 13px;
  color: var(--hint-color);
  line-height: 1.4;
}

.headline-time {
  font-size: 12px;
  color: var(--hint-color);
  margin-top: 6px;
  opacity: 0.7;
}

/* Crypto */
.crypto-body {
  display: flex;
  gap: 12px;
}

.crypto-coin {
  flex: 1;
  background: var(--bg-color);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
}

.crypto-symbol {
  font-size: 13px;
  font-weight: 600;
  color: var(--hint-color);
  margin-bottom: 4px;
}

.crypto-price {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 4px;
}

.crypto-change {
  font-size: 13px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  display: inline-block;
}

.crypto-change.up {
  color: #66bb6a;
  background: rgba(102, 187, 106, 0.12);
}

.crypto-change.down {
  color: #ef5350;
  background: rgba(239, 83, 80, 0.12);
}

/* Breaking News */
#breaking-section .headline-card {
  border-left: 3px solid #ef5350;
}

/* Footer */
#briefing-footer {
  text-align: center;
  padding: 20px 0 8px;
  font-size: 12px;
  color: var(--hint-color);
  opacity: 0.6;
}

/* Smooth entry animation */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

#briefing .card,
#briefing .headline-card,
#briefing section {
  animation: fadeUp 0.35s ease-out both;
}

#briefing .card:nth-child(1) { animation-delay: 0.05s; }
#briefing .card:nth-child(2) { animation-delay: 0.1s; }
#briefing section:nth-of-type(1) { animation-delay: 0.05s; }
#briefing section:nth-of-type(2) { animation-delay: 0.15s; }
#briefing section:nth-of-type(3) { animation-delay: 0.25s; }
#briefing section:nth-of-type(4) { animation-delay: 0.35s; }
