*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #E8500A;
  --primary-dark: #c44208;
  --primary-light: #fff3ee;
  --text: #1a1a1a;
  --text-secondary: #666;
  --text-muted: #999;
  --bg: #f5f5f5;
  --bg-white: #ffffff;
  --border: #e0e0e0;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 12px rgba(0,0,0,0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --header-height: 56px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.6;
  padding-top: var(--header-height);
  padding-bottom: calc(60px + var(--safe-bottom));
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--primary);
  text-decoration: none;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Header */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  padding: 0 16px;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.app-header .back-btn {
  display: none;
  background: none;
  border: none;
  color: white;
  font-size: 24px;
  cursor: pointer;
  padding: 8px;
  margin-left: -8px;
  margin-right: 4px;
  line-height: 1;
}

.app-header .back-btn.visible {
  display: block;
}

.app-header .logo {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
  flex: 1;
}

.app-header .logo span {
  font-weight: 400;
  opacity: 0.8;
  font-size: 14px;
}

.app-header .header-actions {
  display: flex;
  gap: 8px;
}

.app-header .header-btn {
  background: none;
  border: none;
  color: white;
  font-size: 22px;
  cursor: pointer;
  padding: 8px;
  line-height: 1;
  opacity: 0.9;
}

.app-header .header-btn:hover {
  opacity: 1;
}

/* Pull to refresh */
.ptr {
  text-align: center;
  padding: 16px;
  color: var(--text-muted);
  font-size: 13px;
  display: none;
  transition: transform 0.2s;
}

.ptr.visible {
  display: block;
}

.ptr .spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-right: 8px;
  vertical-align: middle;
}

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

/* Ticker / Running Text */
.ticker-bar {
  display: flex;
  align-items: center;
  background: var(--text);
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
}

.ticker-label {
  background: var(--primary);
  color: #fff;
  font-family: 'Space Mono', monospace;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  padding: 4px 12px;
  white-space: nowrap;
  flex-shrink: 0;
  text-transform: uppercase;
  z-index: 2;
}

.ticker-track {
  overflow: hidden;
  flex: 1;
}

.ticker-inner {
  display: flex;
  gap: 48px;
  animation: scroll-ticker 80s linear infinite;
  width: max-content;
}

.ticker-inner span {
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
}

.ticker-inner span::before {
  content: '◆ ';
  font-size: 8px;
}

@keyframes scroll-ticker {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

/* News Slider */
.slider {
  width: 100%;
  overflow: hidden;
  position: relative;
  background: #000;
  margin-bottom: 4px;
}

.slider-track {
  position: relative;
  width: 100%;
}

.slide {
  display: none;
  position: relative;
  width: 100%;
  cursor: pointer;
}

.slide.active {
  display: block;
}

.slide-image {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  display: block;
}

.slide-placeholder {
  width: 100%;
  aspect-ratio: 16/9;
  background: var(--border);
}

.slide-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 32px 16px 28px;
  background: linear-gradient(transparent, rgba(0,0,0,0.85));
  color: white;
}

.slide-title {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.slide-meta {
  font-size: 11px;
  opacity: 0.8;
  display: flex;
  gap: 10px;
}

.slider-dots {
  position: absolute;
  bottom: 10px;
  right: 16px;
  display: flex;
  gap: 4px;
  z-index: 5;
}

.slider-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255,255,255,0.4);
  cursor: pointer;
  transition: all 0.3s;
  border: none;
  padding: 0;
}

.slider-dot.active {
  background: white;
}

/* Article Card */
.article-card {
  background: var(--bg-white);
  border-radius: var(--radius);
  overflow: hidden;
  margin: 12px 16px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s;
  cursor: pointer;
}

.article-card:active {
  box-shadow: var(--shadow-lg);
}

.article-card .card-image {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  background: var(--border);
}

.article-card .card-image-placeholder {
  width: 100%;
  aspect-ratio: 16/9;
  background: linear-gradient(135deg, var(--primary-light), #ffe0cc);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  font-size: 48px;
  font-weight: bold;
}

.article-card .card-body {
  padding: 16px;
}

.article-card .card-category {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.article-card .card-title {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.article-card .card-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 12px;
}

.article-card .card-meta .author {
  color: var(--text-secondary);
}

/* Featured Card */
.article-card.featured {
  margin: 0 -16px;
  border-radius: 0;
}

.article-card.featured .card-image {
  aspect-ratio: 16/10;
}

.article-card.featured .card-title {
  font-size: 20px;
}

/* Section */
.section {
  padding: 16px 0;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  margin-bottom: 12px;
}

.section-title {
  font-size: 18px;
  font-weight: 700;
}

.section-title .accent {
  color: var(--primary);
}

/* Category Pills */
.category-pills {
  display: flex;
  gap: 8px;
  padding: 0 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  margin-bottom: 16px;
}

.category-pills::-webkit-scrollbar {
  display: none;
}

.category-pill {
  flex-shrink: 0;
  padding: 6px 16px;
  border-radius: 20px;
  background: var(--bg-white);
  border: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.category-pill.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.category-pill:active {
  transform: scale(0.96);
}

/* Loading Skeleton */
.skeleton {
  background: var(--bg-white);
  border-radius: var(--radius);
  margin: 12px 16px;
  padding: 0;
  overflow: hidden;
}

.skeleton .sk-image {
  width: 100%;
  aspect-ratio: 16/9;
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

.skeleton .sk-body {
  padding: 16px;
}

.skeleton .sk-line {
  height: 14px;
  border-radius: 4px;
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  margin-bottom: 8px;
}

.skeleton .sk-line.short {
  width: 30%;
}

.skeleton .sk-line.medium {
  width: 60%;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Article Detail */
.article-detail {
  padding-bottom: 32px;
}

.article-detail .hero-image {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  background: var(--border);
}

.article-detail .hero-placeholder {
  width: 100%;
  aspect-ratio: 16/9;
  background: linear-gradient(135deg, var(--primary-light), #ffe0cc);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  font-size: 64px;
  font-weight: bold;
}

.article-detail .article-content {
  padding: 20px 16px;
}

.article-detail .article-category {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.article-detail h1 {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.35;
  margin-bottom: 12px;
}

.article-detail .article-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
  color: var(--text-muted);
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.article-detail .article-meta .author {
  color: var(--text-secondary);
}

.article-detail .article-body {
  font-size: 17px;
  line-height: 1.8;
  color: #2c2c2c;
}

.article-detail .article-body h2 {
  font-size: 20px;
  font-weight: 700;
  margin: 24px 0 12px;
}

.article-detail .article-body h3,
.article-detail .article-body h4 {
  font-size: 18px;
  font-weight: 600;
  margin: 20px 0 10px;
}

.article-detail .article-body p {
  margin-bottom: 16px;
}

.article-detail .article-body img {
  width: 100%;
  border-radius: var(--radius-sm);
  margin: 16px 0;
}

.article-detail .article-body a {
  color: var(--primary);
  text-decoration: underline;
  word-break: break-all;
}

.article-detail .article-body blockquote {
  border-left: 4px solid var(--primary);
  padding: 12px 16px;
  margin: 16px 0;
  background: var(--primary-light);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-style: italic;
  color: #444;
}

.article-detail .article-body ul,
.article-detail .article-body ol {
  margin: 12px 0;
  padding-left: 24px;
}

.article-detail .article-body li {
  margin-bottom: 8px;
}

.article-detail .article-body iframe {
  width: 100%;
  aspect-ratio: 16/9;
  border: none;
  border-radius: var(--radius-sm);
  margin: 16px 0;
}

.related-section {
  padding: 24px 16px;
}

.related-section h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 16px;
}

/* Search */
.search-bar {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
}

.search-bar input {
  flex: 1;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  outline: none;
  background: var(--bg);
  transition: border-color 0.2s;
}

.search-bar input:focus {
  border-color: var(--primary);
  background: white;
}

.search-bar button {
  padding: 10px 20px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.search-bar button:active {
  background: var(--primary-dark);
}

/* Categories Page */
/* Categories List */
.category-search-wrap {
  padding: 12px 16px 0;
}

.category-search {
  width: 100%;
  padding: 10px 14px 10px 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--bg-white);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
}

.category-search:focus {
  border-color: var(--primary);
}

.category-search-wrap {
  position: relative;
}

.category-search-icon {
  position: absolute;
  left: 28px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  color: var(--text-muted);
  pointer-events: none;
}

.categories-list {
  padding: 8px 16px 16px;
}

.category-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-white);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: all 0.2s;
}

.category-item:active {
  transform: scale(0.98);
  background: var(--primary-light);
}

.category-item .cat-name {
  font-size: 15px;
  font-weight: 600;
}

.category-item .cat-count {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg);
  padding: 2px 10px;
  border-radius: 12px;
  flex-shrink: 0;
}

.category-item.hidden {
  display: none;
}

/* Loading Indicator */
.loading-indicator {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 13px;
}

.loading-indicator .spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-bottom: 8px;
}

.loading-full {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 50vh;
  padding: 32px;
  text-align: center;
}

.loading-full .spinner-lg {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-bottom: 16px;
}

.loading-full p {
  color: var(--text-muted);
  font-size: 14px;
}

/* Error */
.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 50vh;
  padding: 32px;
  text-align: center;
}

.error-state .error-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.error-state h3 {
  font-size: 18px;
  margin-bottom: 8px;
}

.error-state p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 16px;
}

.error-state .retry-btn {
  padding: 10px 24px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

/* End of content */
.end-marker {
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 13px;
}

/* Bottom Nav */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(56px + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--bg-white);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
}

.bottom-nav .nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 10px;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s;
  text-decoration: none;
  border: none;
  background: none;
  padding: 4px 0;
}

.bottom-nav .nav-item .nav-icon {
  font-size: 22px;
  line-height: 1;
}

.bottom-nav .nav-item.active {
  color: var(--primary);
}

.bottom-nav .nav-item:active {
  opacity: 0.7;
}

/* Install Prompt */
.install-prompt {
  position: fixed;
  bottom: calc(60px + var(--safe-bottom));
  left: 16px;
  right: 16px;
  background: var(--bg-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 200;
  animation: slideUp 0.3s ease;
  border: 1px solid var(--border);
}

@keyframes slideUp {
  from { transform: translateY(100px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.install-prompt .prompt-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
}

.install-prompt .prompt-text {
  flex: 1;
}

.install-prompt .prompt-text strong {
  display: block;
  font-size: 15px;
  margin-bottom: 2px;
}

.install-prompt .prompt-text span {
  font-size: 12px;
  color: var(--text-secondary);
}

.install-prompt .prompt-close {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.install-prompt .install-btn {
  padding: 8px 16px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

/* Floating Install Button */
.fab-install {
  position: fixed;
  bottom: calc(76px + var(--safe-bottom));
  right: 16px;
  background: var(--primary);
  color: #fff;
  border-radius: 28px;
  padding: 10px 18px 10px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 16px rgba(232,80,10,0.4);
  z-index: 200;
  cursor: pointer;
  animation: fabPulse 2s ease-in-out infinite;
  transition: transform 0.2s;
}

.fab-install:active {
  transform: scale(0.92);
}

.fab-install img {
  width: 28px;
  height: 28px;
  border-radius: 6px;
}

.fab-install span {
  font-size: 13px;
  font-weight: 700;
}

@keyframes fabPulse {
  0%, 100% { box-shadow: 0 4px 16px rgba(232,80,10,0.4); }
  50% { box-shadow: 0 4px 24px rgba(232,80,10,0.6); }
}

/* Toast */
.toast {
  position: fixed;
  bottom: calc(80px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: #323232;
  color: white;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 300;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
  white-space: nowrap;
  max-width: 90vw;
  text-align: center;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes toastOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* Error page */
.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  padding: 32px;
  text-align: center;
}

.error-page .err-icon {
  font-size: 64px;
  margin-bottom: 16px;
  opacity: 0.6;
}

.error-page h1 {
  font-size: 24px;
  margin-bottom: 8px;
}

.error-page p {
  color: var(--text-secondary);
  margin-bottom: 24px;
}

/* Utility */
.hidden { display: none; }
