:root {
  --saudi-green: #0B5C35;
  --saudi-green-dark: #074028;
  --saudi-green-mid: #0f6b3f;
  --saudi-green-soft: #e7f3ec;
  --gold: #C5A572;
  --gold-soft: #f5edd9;
  --gold-deep: #a8884f;
  --cream: #f7f2e8;
  --cream-card: #fffcf6;
  --paper: #faf6ee;
  --text: #1c241e;
  --text-muted: #5c665f;
  --border: #e4dccb;
  --shadow: 0 4px 20px rgba(11, 92, 53, 0.09);
  --shadow-hover: 0 8px 28px rgba(11, 92, 53, 0.14);
  --radius: 16px;
  --base: 18.5px;
  --chip-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

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

html {
  font-size: var(--base);
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei",
    "Source Han Sans SC", system-ui, -apple-system, sans-serif;
  background-color: var(--cream);
  background-image:
    radial-gradient(ellipse at 20% 0%, rgba(197, 165, 114, 0.12) 0%, transparent 50%),
    radial-gradient(ellipse at 90% 10%, rgba(11, 92, 53, 0.06) 0%, transparent 45%),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 23px,
      rgba(197, 165, 114, 0.03) 23px,
      rgba(197, 165, 114, 0.03) 24px
    );
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
}

a { color: var(--saudi-green); text-decoration: none; }
a:hover { color: var(--gold-deep); text-decoration: underline; }

/* —— Header —— */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: linear-gradient(165deg, var(--saudi-green-mid) 0%, var(--saudi-green) 45%, var(--saudi-green-dark) 100%);
  color: #fff;
  box-shadow: 0 3px 20px rgba(0, 0, 0, 0.22);
  overflow: hidden;
}

.header-pattern {
  position: absolute;
  inset: 0;
  opacity: 0.18;
  background-image:
    repeating-linear-gradient(
      60deg,
      transparent 0,
      transparent 14px,
      rgba(197, 165, 114, 0.45) 14px,
      rgba(197, 165, 114, 0.45) 15px
    ),
    repeating-linear-gradient(
      -60deg,
      transparent 0,
      transparent 14px,
      rgba(255, 255, 255, 0.08) 14px,
      rgba(255, 255, 255, 0.08) 15px
    );
  pointer-events: none;
}

.header-inner {
  position: relative;
  max-width: 740px;
  margin: 0 auto;
  padding: 0.95rem 1.05rem 0.85rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-mark {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  overflow: hidden;
  isolation: isolate;
  box-shadow: 0 0 0 2px rgba(197, 165, 114, 0.85), 0 2px 8px rgba(0,0,0,0.25);
  background: transparent;
}

.brand-mark img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* slight zoom so any fringe / square corners stay inside the circle */
  transform: scale(1.06);
  transform-origin: center;
}

.brand h1 {
  font-size: 1.12rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: 0.02em;
}

.brand .subtitle {
  font-size: 0.72rem;
  opacity: 0.92;
  font-weight: 400;
  margin-top: 0.18rem;
  letter-spacing: 0.04em;
  color: var(--gold-soft);
}

.main {
  max-width: 740px;
  margin: 0 auto;
  padding: 1rem 0.9rem 3.5rem;
}

/* —— Toolbar —— */
.toolbar {
  background: var(--cream-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 0.85rem 0.75rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
  position: relative;
}

.toolbar::before {
  content: "";
  position: absolute;
  top: 0; left: 1rem; right: 1rem;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.date-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.7rem;
}

.date-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, #fff 0%, var(--gold-soft) 100%);
  color: var(--saudi-green-dark);
  border-radius: 12px;
  padding: 0.5rem 0.75rem;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  min-width: 2.7rem;
  transition: transform 0.12s, box-shadow 0.12s;
  box-shadow: var(--chip-shadow);
}
.date-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(197, 165, 114, 0.35);
}
.date-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.date-select {
  flex: 1;
  font-size: 0.98rem;
  padding: 0.55rem 0.7rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-family: inherit;
  font-weight: 500;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.03);
}

.status-line {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
  padding-left: 0.15rem;
}

.chips {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.45rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0.1rem 0.1rem 0.35rem;
  scrollbar-width: thin;
  scrollbar-color: var(--gold) transparent;
  mask-image: linear-gradient(90deg, #000 92%, transparent);
}

.chip {
  appearance: none;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 999px;
  padding: 0.42rem 0.9rem;
  font-size: 0.84rem;
  white-space: nowrap;
  cursor: pointer;
  font-family: inherit;
  flex-shrink: 0;
  box-shadow: var(--chip-shadow);
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.12s;
}
.chip:hover {
  border-color: var(--gold);
  transform: translateY(-1px);
}
.chip.active {
  background: linear-gradient(145deg, var(--saudi-green-mid), var(--saudi-green-dark));
  border-color: var(--saudi-green);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 10px rgba(11, 92, 53, 0.35);
}

/* —— Cards —— */
.feed { display: flex; flex-direction: column; gap: 1.1rem; }

.card {
  background: var(--cream-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s, transform 0.2s;
}
.card:hover {
  box-shadow: var(--shadow-hover);
}

.card-media {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background:
    linear-gradient(135deg, var(--saudi-green-soft), var(--gold-soft));
  overflow: hidden;
}

.card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-body { padding: 1.05rem 1.1rem 1.2rem; }

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.65rem;
  align-items: center;
  margin-bottom: 0.6rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.badge {
  border-radius: 999px;
  padding: 0.18rem 0.6rem;
  font-weight: 650;
  font-size: 0.74rem;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
}

/* Category color coding */
.badge-cat-王室与政府 { background: #e8f0ff; color: #1e3a6e; border-color: #c5d4f0; }
.badge-cat-经济与能源 { background: #fff3e0; color: #8a4b00; border-color: #f0d4a8; }
.badge-cat-社会与民生 { background: #e8f7ef; color: #0b5c35; border-color: #b8dfc8; }
.badge-cat-地缘政治 { background: #f3e8ff; color: #5b2a86; border-color: #d8c0ef; }
.badge-cat-外交与往来 { background: #e6f4fb; color: #0a4f6e; border-color: #b5d7e8; }
.badge-cat-宗教 { background: #f5edd9; color: #7a5a22; border-color: #e0cfa0; }
.badge-cat-文化艺术 { background: #fce8f0; color: #8a2a55; border-color: #efc0d4; }
.badge-cat-体育 { background: #eaf8e4; color: #2d6a1e; border-color: #b9dfad; }
.badge-cat-其他 { background: #f0eee9; color: #555; border-color: #d8d4cb; }

.card h2 {
  font-size: 1.16rem;
  line-height: 1.42;
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: #122418;
  letter-spacing: 0.01em;
}

.article-body {
  font-size: 1.02rem;
  line-height: 1.82;
  color: #2a322c;
}
.article-body p { margin-bottom: 0.9rem; }
.article-body p:last-child { margin-bottom: 0; }

.source-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 1.05rem;
  font-size: 0.84rem;
  font-weight: 600;
  padding: 0.48rem 0.85rem;
  border-radius: 10px;
  background: linear-gradient(180deg, var(--saudi-green-soft), #d9ebe0);
  color: var(--saudi-green-dark);
  border: 1px solid rgba(11, 92, 53, 0.15);
  text-decoration: none;
  transition: background 0.15s;
}
.source-link:hover {
  background: var(--gold-soft);
  color: var(--gold-deep);
  text-decoration: none;
}
.source-link::after {
  content: "↗";
  font-size: 0.9em;
  opacity: 0.75;
}

/* —— States —— */
.empty, .loading, .error {
  text-align: center;
  padding: 3rem 1.25rem;
  color: var(--text-muted);
  font-size: 1.02rem;
  background: var(--cream-card);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.loading::before {
  content: "";
  display: block;
  width: 28px;
  height: 28px;
  margin: 0 auto 0.85rem;
  border: 3px solid var(--saudi-green-soft);
  border-top-color: var(--saudi-green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.empty::before {
  content: "☪";
  display: block;
  font-size: 1.6rem;
  color: var(--gold);
  margin-bottom: 0.5rem;
  opacity: 0.85;
}

.error {
  border-color: #e8b4b4;
  color: #8a3030;
  background: #fff8f8;
}

.footer {
  text-align: center;
  padding: 1.75rem 1rem 2.25rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.65;
  max-width: 740px;
  margin: 0 auto;
}

.footer-accent {
  width: 48px;
  height: 3px;
  margin: 0 auto 0.85rem;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--saudi-green), var(--gold));
}

@media (min-width: 640px) {
  :root { --base: 19px; }
  .brand h1 { font-size: 1.2rem; }
  .card h2 { font-size: 1.22rem; }
}
