/* Pulse — true black info wall */

:root {
  --bg: #000000;
  --surface: rgba(255, 255, 255, 0.07);
  --surface-hi: rgba(255, 255, 255, 0.11);
  --surface-elevated: rgba(28, 28, 30, 0.92);
  --line: rgba(255, 255, 255, 0.08);

  --text: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.72);
  --muted: rgba(255, 255, 255, 0.45);
  --subtle: rgba(255, 255, 255, 0.28);

  --accent: #6ee7c8;
  --accent-soft: rgba(110, 231, 200, 0.18);
  --accent-glow: rgba(110, 231, 200, 0.35);
  --positive: #6ee7c8;
  --negative: #ff6b6b;

  --radius: 18px;
  --radius-sm: 14px;
  --radius-xs: 10px;
  --gap: 14px;
  --sidebar-w: min(340px, 28%);
  --hdr-h: 44px;

  --font: 'Inter', 'Noto Sans Arabic', -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'SF Arabic', system-ui, sans-serif;
  --mono: 'Roboto Mono', 'SF Mono', ui-monospace, monospace;

  --cat-tunisia: #fbbf24;
  --cat-maghreb: #f472b6;
  --cat-uae: #38bdf8;
  --cat-gulf: #60a5fa;
  --cat-global: #94a3b8;
  --cat-tech: #4ade80;
  --cat-business: #facc15;
  --cat-markets: #fb923c;
  --cat-science: #a78bfa;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-soft: cubic-bezier(0.4, 0, 0.2, 1);
  --motion-swap: 400ms;
  --motion-enter: 440ms;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

body.pulse-app {
  background: var(--bg) !important;
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
}

:lang(ar), [dir="rtl"] {
  font-family: 'Noto Sans Arabic', 'Inter', -apple-system, BlinkMacSystemFont, 'SF Arabic', sans-serif;
  line-height: 1.4;
}

/* ── Board ── */
.board {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  min-height: 0;
  background: var(--bg);
  padding: max(10px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  gap: 10px;
}

/* ── Header ── */
.top-bar {
  flex: 0 0 var(--hdr-h);
  min-height: var(--hdr-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 4px;
}

.top-bar-left {
  display: flex;
  align-items: center;
  min-width: 0;
}

.top-datetime {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: var(--radius-xs);
  background: var(--surface);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.top-time {
  font-weight: 600;
  color: var(--text);
}

.top-datetime-sep {
  color: var(--subtle);
  font-weight: 400;
  user-select: none;
}

.top-date {
  font-weight: 500;
  color: var(--muted);
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

.top-batt b { color: var(--text-secondary); font-weight: 600; }

.top-reload {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: var(--surface);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.25s var(--ease-soft), color 0.25s var(--ease-soft), transform 0.25s var(--ease-out);
}

.top-reload:hover {
  background: var(--surface-hi);
  color: var(--text);
}

.top-reload:active {
  transform: scale(0.92);
}

.led {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--subtle);
  flex-shrink: 0;
}

.layout-switch {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: 10px;
  background: var(--surface);
  flex-shrink: 0;
}

.layout-btn {
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  transition: background 0.2s var(--ease-soft), color 0.2s var(--ease-soft);
}

.layout-btn:focus {
  outline: none;
}

.layout-btn:hover {
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.06);
}

.layout-btn.active {
  color: var(--accent);
  background: var(--surface-hi);
}

.layout-btn:active {
  transform: scale(0.92);
}

.led.on { background: var(--positive); box-shadow: 0 0 6px var(--accent-glow); }

/* ── Main grid ── */
.main-area {
  flex: 1;
  min-width: 0;
  min-height: calc(100vh - var(--hdr-h) - 30px);
  min-height: calc(100dvh - var(--hdr-h) - 30px);
  display: grid;
  grid-template-columns: 1fr var(--sidebar-w);
  gap: var(--gap);
  overflow: hidden;
}

/* ── Sync dots ── */
.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  opacity: 0;
  transform: scale(0.4);
  pointer-events: none;
  transition: opacity 0.35s, transform 0.35s, background 0.35s, box-shadow 0.35s;
}

.sync-dot.on { opacity: 1; transform: scale(1); animation: syncPulse 1.1s ease-in-out infinite; }
.sync-dot.ok { opacity: 1; transform: scale(1); animation: none; background: var(--positive); box-shadow: 0 0 6px var(--accent-glow); }

.sync-float {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
}

@keyframes syncPulse {
  0%, 100% { opacity: 0.45; transform: scale(0.88); }
  50% { opacity: 1; transform: scale(1.12); }
}

/* ── News: 2×2 carousel ── */
.news-col {
  position: relative;
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.news-panel {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.news-wall {
  position: relative;
  flex: 1;
  width: 100%;
  height: 100%;
  min-height: 0;
}

.news-grid {
  display: grid;
  gap: var(--gap);
  width: 100%;
  height: 100%;
  min-height: 180px;
}

.news-grid.layout-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
}

.news-grid.layout-row {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: minmax(0, 1fr);
}

.news-grid.layout-single {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
}

.news-grid.layout-single .story-card .headline {
  font-size: clamp(28px, 3.2vw, 44px);
  -webkit-line-clamp: 3;
}

.news-grid.layout-row .story-card .headline {
  font-size: clamp(20px, 2vw, 30px);
  -webkit-line-clamp: 3;
}

.news-slot {
  min-width: 0;
  min-height: 0;
  height: 100%;
}

.news-slot-inner {
  width: 100%;
  height: 100%;
  opacity: 1;
  transition: opacity 360ms var(--ease-soft);
}

.news-slot.slot-swapping .news-slot-inner,
.news-slot.slot-pending .news-slot-inner {
  opacity: 0;
  pointer-events: none;
}

.news-slot .story-card {
  opacity: 1;
  transform: none;
}

.news-grid.is-booting .news-slot .story-card {
  animation: newsCardIn var(--motion-enter) var(--ease-out) backwards;
}

.news-grid.is-booting .news-slot:nth-child(1) .story-card { animation-delay: 0ms; }
.news-grid.is-booting .news-slot:nth-child(2) .story-card { animation-delay: 80ms; }
.news-grid.is-booting .news-slot:nth-child(3) .story-card { animation-delay: 160ms; }
.news-grid.is-booting .news-slot:nth-child(4) .story-card { animation-delay: 240ms; }

.news-grid.is-booting .news-slot:nth-child(1) .tag { animation: tagFadeIn 0.38s var(--ease-out) 0.1s backwards; }
.news-grid.is-booting .news-slot:nth-child(2) .tag { animation: tagFadeIn 0.38s var(--ease-out) 0.16s backwards; }
.news-grid.is-booting .news-slot:nth-child(3) .tag { animation: tagFadeIn 0.38s var(--ease-out) 0.22s backwards; }
.news-grid.is-booting .news-slot:nth-child(4) .tag { animation: tagFadeIn 0.38s var(--ease-out) 0.28s backwards; }

@keyframes newsCardIn {
  from {
    opacity: 0;
    transform: scale(1.012) translateY(-6px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes tagFadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

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

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

.story-card {
  position: relative;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--surface-hi);
}

.story-card-link {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.news-slot:not(.slot-swapping):not(.slot-pending):not(.slot-enter) .story-card-link:hover {
  transform: scale(1.006);
  transition: transform 0.28s var(--ease-out);
}

.news-slot:not(.slot-swapping):not(.slot-pending):not(.slot-enter) .story-card-link:active {
  transform: scale(0.985);
  transition-duration: 0.12s;
}

.story-card-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.45;
  transform: scale(1.04);
  transition: opacity 0.5s var(--ease-soft);
}

.story-card.img-ready .story-card-img {
  opacity: 1;
  transform: scale(1.04);
}

.story-card.img-ready.img-settled .story-card-img {
  animation: imgKenBurns 24s var(--ease-soft) forwards;
}

@keyframes imgKenBurns {
  from { transform: scale(1.04); }
  to { transform: scale(1); }
}

.story-card-shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(
      to top,
      rgba(0, 0, 0, 0.97) 0%,
      rgba(0, 0, 0, 0.88) 22%,
      rgba(0, 0, 0, 0.55) 48%,
      rgba(0, 0, 0, 0.18) 72%,
      transparent 100%
    ),
    radial-gradient(ellipse 130% 90% at 50% 100%, rgba(0, 0, 0, 0.55) 0%, transparent 62%);
}

.story-card-body {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 6px;
  padding: 16px 18px 18px;
  min-width: 0;
}

.story-card .tag {
  position: absolute;
  top: 14px;
  left: 16px;
  z-index: 2;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
}

.story-card .tag.c-Tech { color: #bbf7d0; background: rgba(20, 83, 45, 0.72); border-color: rgba(74, 222, 128, 0.65); }
.story-card .tag.c-UAE { color: #bae6fd; background: rgba(12, 74, 110, 0.72); border-color: rgba(56, 189, 248, 0.65); }
.story-card .tag.c-Tunisia { color: #fde68a; background: rgba(120, 53, 15, 0.72); border-color: rgba(251, 191, 36, 0.65); }
.story-card .tag.c-Science { color: #ddd6fe; background: rgba(76, 29, 149, 0.72); border-color: rgba(167, 139, 250, 0.65); }
.story-card .tag.c-Business { color: #fef9c3; background: rgba(113, 63, 18, 0.72); border-color: rgba(250, 204, 21, 0.65); }
.story-card .tag.c-Markets { color: #fed7aa; background: rgba(124, 45, 18, 0.72); border-color: rgba(251, 146, 60, 0.65); }
.story-card .tag.c-Maghreb { color: #fbcfe8; background: rgba(131, 24, 67, 0.72); border-color: rgba(244, 114, 182, 0.65); }
.story-card .tag.c-Gulf { color: #bfdbfe; background: rgba(30, 58, 138, 0.72); border-color: rgba(96, 165, 250, 0.65); }
.story-card .tag.c-Global { color: #e2e8f0; background: rgba(51, 65, 85, 0.72); border-color: rgba(148, 163, 184, 0.55); }

.story-card .headline {
  font-weight: 600;
  font-size: clamp(18px, 1.55vw, 26px);
  line-height: 1.25;
  color: #fff;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  text-shadow:
    0 1px 2px rgba(0, 0, 0, 0.95),
    0 2px 10px rgba(0, 0, 0, 0.85),
    0 0 24px rgba(0, 0, 0, 0.55);
}

.story-card .headline[lang="ar"] {
  font-family: 'Noto Sans Arabic', 'Inter', sans-serif;
  letter-spacing: 0;
  line-height: 1.4;
}

.story-card .meta {
  font-family: var(--mono);
  font-size: 12px;
  color: rgba(255, 255, 255, 0.82);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.story-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-height: 120px;
  color: var(--muted);
  background: var(--surface);
  border-radius: var(--radius);
  animation: emptyPulse 2.4s ease-in-out infinite;
}

@keyframes emptyPulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 0.85; }
}

.g-Tunisia { background: linear-gradient(135deg, #2a1e0c, #181008) !important; }
.g-Maghreb { background: linear-gradient(135deg, #2a1020, #180c14) !important; }
.g-UAE { background: linear-gradient(135deg, #0c2438, #081820) !important; }
.g-Gulf { background: linear-gradient(135deg, #101c38, #0a1224) !important; }
.g-Global { background: linear-gradient(135deg, #1c1e26, #12161f) !important; }
.g-Tech { background: linear-gradient(135deg, #0f2418, #0a1810) !important; }
.g-Business { background: linear-gradient(135deg, #2a2210, #181408) !important; }
.g-Markets { background: linear-gradient(135deg, #2a180c, #181008) !important; }
.g-Science { background: linear-gradient(135deg, #1e1438, #120c24) !important; }

/* ── Sidebar widgets ── */
.widgets-col {
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: var(--gap);
  overflow: hidden;
}

.widget {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.widget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px 6px;
  flex-shrink: 0;
}

.widget-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
}

.widget-header-end {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.widget-sub {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
}

/* Weather — stacked city rows */
.widget.weather {
  padding: 12px 12px 14px;
  flex-shrink: 0;
}

.wx-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wx-mini {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  text-align: left;
  padding: 12px 14px;
  background: var(--surface-hi);
  border-radius: var(--radius-xs);
  min-width: 0;
}

.wx-mini .city {
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0;
  min-width: 0;
  flex: 1;
}

.wx-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

.wx-mini .ico {
  font-size: 2rem;
  line-height: 1;
  flex-shrink: 0;
}

.wx-mini .temp {
  font-family: var(--mono);
  font-weight: 700;
  font-size: clamp(28px, 2.2vw, 34px);
  font-variant-numeric: tabular-nums;
  color: var(--text);
  line-height: 1;
  min-width: 2.6em;
  text-align: right;
}

/* Currency — 2×2 grid, no title */
.widget.fx {
  position: relative;
  padding: 10px 12px 12px;
}

.fx-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.fx-cell {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 0;
  padding: 14px 16px;
  background: var(--surface-hi);
  border-radius: var(--radius-xs);
  font-family: var(--mono);
  min-width: 0;
}

.fx-cell .fx-top {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  width: 100%;
  line-height: 1;
}

.fx-cell .flag {
  width: 32px;
  height: 22px;
  border-radius: 3px;
  object-fit: cover;
  flex-shrink: 0;
}

.fx-cell .code {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-secondary);
  flex-shrink: 0;
  line-height: 1;
}

.fx-cell .val {
  margin: 0;
  margin-top: 6px;
  font-size: 32px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  line-height: 1;
  letter-spacing: -0.03em;
}

/* Gold — fills remaining space */
.widget.gold {
  min-height: 0;
}

.gold-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 14px 14px;
}

.gold-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  flex-shrink: 0;
}

.gold-head .price {
  font-family: var(--mono);
  font-weight: 700;
  font-size: clamp(22px, 2vw, 30px);
  color: var(--accent);
}

.gold-head .unit {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.06);
}

.gold-delta.up { color: var(--positive); background: rgba(110, 231, 200, 0.12); }
.gold-delta.down { color: var(--negative); background: rgba(255, 107, 107, 0.12); }
.gold-delta.flat { color: var(--muted); background: rgba(255, 255, 255, 0.06); }

.gold-range {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
  flex-shrink: 0;
}

.gold-range span:first-child { color: var(--negative); opacity: 0.85; }
.gold-range span:last-child { color: var(--positive); opacity: 0.85; }

.gold-chart {
  flex: 1 1 auto;
  min-height: 90px;
  width: 100%;
  position: relative;
  border-radius: var(--radius-xs);
  overflow: hidden;
  background: rgba(255, 255, 255, 0.03);
}

.gold-chart canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* ── Login ── */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 1050;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.92);
}

.login-overlay.hidden { display: none !important; }

.login-card {
  width: min(100%, 400px);
  background: var(--surface-elevated);
  border-radius: var(--radius);
  padding: 36px 32px;
}

.login-card h1 {
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.06em;
  margin: 0 0 6px;
}

.login-card p { font-size: 1rem; color: var(--muted); margin: 0 0 22px; }

.login-card .form-label {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--subtle);
  display: block;
  margin-bottom: 8px;
}

.login-card .form-input {
  width: 100%;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  color: var(--text);
  font-family: var(--mono);
  outline: none;
}

.login-card .form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.login-card .form-pin {
  text-align: center;
  font-size: 1.6rem;
  letter-spacing: 0.35em;
  font-variant-numeric: tabular-nums;
  padding-left: 0.5em;
}

.login-card .err {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--negative);
  min-height: 1.2em;
  margin-top: 10px;
}

.login-card .btn-unlock {
  width: 100%;
  margin-top: 18px;
  padding: 14px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  color: #000;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
}

.board.locked {
  pointer-events: none;
  user-select: none;
  opacity: 0.35;
}

/* ── Article reader ── */
.article-overlay {
  position: fixed;
  inset: 0;
  z-index: 1040;
  display: flex;
  flex-direction: column;
  padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  background: rgba(0, 0, 0, 0);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.38s var(--ease-soft),
    visibility 0.38s var(--ease-soft),
    background 0.38s var(--ease-soft);
}

.article-overlay:not(.hidden) {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  background: rgba(0, 0, 0, 0.9);
}

.article-overlay.hidden { /* keep class for JS toggling */ }

.article-modal {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  transform: scale(0.96) translateY(14px);
  opacity: 0;
  transition:
    transform 0.42s var(--ease-out),
    opacity 0.32s var(--ease-soft);
}

.article-overlay:not(.hidden) .article-modal {
  transform: scale(1) translateY(0);
  opacity: 1;
}

.article-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface-elevated);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.article-source {
  font-size: 14px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.article-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.article-external {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-xs);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 18px;
  line-height: 1;
}

.article-external:hover { color: var(--accent); }

.article-close {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: var(--radius-xs);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.article-close:hover { background: rgba(255, 255, 255, 0.14); }

.article-frame {
  flex: 1;
  width: 100%;
  min-height: 0;
  border: none;
  background: #fff;
}

body.article-open { overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .story-card.img-ready.img-settled .story-card-img,
  .story-card.img-ready .story-card-img {
    animation: none;
    transform: none;
  }

  .story-empty {
    animation: none;
    opacity: 0.7;
  }
}

/* ── Portrait / vertical display (e.g. 15.6" rotated → ~1080×1920) ── */
@media (orientation: portrait), (max-aspect-ratio: 10/11) {
  :root {
    --gap: 12px;
    --hdr-h: 46px;
    --widgets-h: clamp(240px, 26vh, 340px);
  }

  body.pulse-app { font-size: 15px; }

  .board {
    padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    gap: 10px;
  }

  .main-area {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) var(--widgets-h);
    min-height: 0;
  }

  .news-col,
  .widgets-col {
    height: 100%;
    min-height: 0;
  }

  .widgets-col {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr) minmax(0, 1.2fr);
    grid-template-rows: minmax(0, 1fr);
    gap: var(--gap);
  }

  .widget.weather,
  .widget.fx,
  .widget.gold {
    height: 100%;
    min-height: 0;
    flex-shrink: 1;
  }

  .widget.weather {
    padding: 10px;
    display: flex;
  }

  .wx-grid {
    flex: 1;
    min-height: 0;
    gap: 8px;
    justify-content: stretch;
  }

  .wx-mini {
    flex: 1;
    padding: 10px 14px;
  }

  .wx-mini .city { font-size: 24px; }
  .wx-mini .temp { font-size: clamp(28px, 2.6vh, 36px); min-width: 2.6em; }
  .wx-mini .ico { font-size: 2rem; }

  .widget.fx {
    padding: 10px;
    display: flex;
  }

  .fx-grid {
    flex: 1;
    min-height: 0;
    gap: 8px;
    align-content: stretch;
  }

  .fx-cell {
    padding: 14px 16px;
    gap: 0;
    justify-content: center;
  }

  .fx-cell .fx-top { gap: 9px; }
  .fx-cell .flag { width: 34px; height: 23px; }
  .fx-cell .code { font-size: 18px; }
  .fx-cell .val { font-size: 34px; margin-top: 6px; }

  .widget.gold {
    display: flex;
    flex-direction: column;
  }

  .gold-body {
    flex: 1;
    min-height: 0;
    padding: 0 14px 14px;
    gap: 6px;
  }

  .widget-title { font-size: 17px; }
  .widget-sub { font-size: 13px; }
  .gold-head .price { font-size: clamp(24px, 2.4vh, 32px); }
  .gold-head .unit { font-size: 13px; }
  .gold-range { font-size: 13px; }
  .gold-chart { min-height: 0; flex: 1 1 auto; }

  .story-card-body {
    padding: 16px 18px 18px;
    gap: 6px;
  }

  .story-card .tag {
    top: 14px;
    left: 16px;
    font-size: 11px;
    padding: 4px 10px;
  }

  .story-card .headline {
    font-size: clamp(18px, 2.2vh, 28px);
    -webkit-line-clamp: 3;
    line-height: 1.28;
  }

  .story-card .meta { font-size: 12px; }

  .news-grid.layout-single .story-card .headline {
    font-size: clamp(28px, 3.6vh, 48px);
    -webkit-line-clamp: 4;
  }

  .news-grid.layout-row .story-card .headline {
    font-size: clamp(20px, 2.6vh, 34px);
    -webkit-line-clamp: 4;
  }

  .top-bar-right { gap: 10px; font-size: 12px; }
}

@media (orientation: portrait) and (min-height: 1400px) {
  :root {
    --widgets-h: clamp(280px, 24vh, 380px);
    --gap: 14px;
  }

  .wx-mini .city { font-size: 26px; }
  .wx-mini .temp { font-size: 36px; }
  .fx-cell .code { font-size: 19px; }
  .fx-cell .val { font-size: 36px; }
  .gold-head .price { font-size: 34px; }

  .story-card .headline {
    font-size: clamp(20px, 2vh, 30px);
  }

  .news-grid.layout-single .story-card .headline {
    font-size: clamp(32px, 3.4vh, 52px);
  }
}

/* Landscape tablet / laptop — side-by-side (default), tighten mid widths */
@media (orientation: landscape) and (max-width: 1200px) {
  :root {
    --sidebar-w: min(300px, 30%);
    --gap: 12px;
    --hdr-h: 42px;
  }
}

@media (orientation: landscape) and (max-width: 900px) {
  :root {
    --sidebar-w: min(260px, 32%);
    --gap: 10px;
    --hdr-h: 38px;
  }

  body.pulse-app { font-size: 13px; }

  .story-card .headline { font-size: clamp(15px, 2vw, 20px); }
  .story-card-body { padding: 12px 14px 14px; gap: 4px; }
  .gold-chart { min-height: 64px; }
}

/* Narrow phones — stack widgets under news */
@media (max-width: 700px) {
  :root {
    --sidebar-w: 100%;
    --gap: 8px;
    --hdr-h: 36px;
    --widgets-h: auto;
  }

  body.pulse-app { font-size: 12px; }

  .board {
    padding: max(4px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(4px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    gap: 4px;
  }

  .main-area {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) auto;
  }

  .widgets-col {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto minmax(120px, 22vh);
    height: auto;
  }

  .widget.weather,
  .widget.fx {
    height: auto;
  }

  .story-card .headline { font-size: clamp(14px, 3.2vw, 18px); -webkit-line-clamp: 2; }
  .story-card .tag { font-size: 9px; padding: 2px 6px; top: 8px; left: 10px; }
  .story-card .meta { font-size: 9px; }
  .story-card-body { padding: 8px 10px 9px; gap: 3px; }

  .news-grid.layout-single .story-card .headline {
    font-size: clamp(18px, 5vw, 28px);
    -webkit-line-clamp: 3;
  }

  .news-grid.layout-row .story-card .headline {
    font-size: clamp(14px, 3.5vw, 20px);
    -webkit-line-clamp: 3;
  }

  .wx-mini .temp { font-size: clamp(16px, 2.4vw, 20px); }
  .fx-cell .val { font-size: 12.5px; }
  .gold-head .price { font-size: clamp(13px, 1.8vw, 16px); }
  .gold-chart { min-height: 72px; }
  .login-card { width: min(100%, 320px); padding: 24px 20px; }

  .top-bar { gap: 8px; }
  .top-bar-right { gap: 6px; font-size: 10px; }
  .top-datetime { font-size: 12px; padding: 5px 10px; }
}

/* Very short landscape (unusual) — keep side-by-side but denser */
@media (orientation: landscape) and (max-height: 700px) {
  :root {
    --gap: 8px;
    --hdr-h: 34px;
    --sidebar-w: min(240px, 28%);
  }

  body.pulse-app { font-size: 12px; }
  .story-card-body { padding: 10px 12px 12px; }
  .story-card .headline { font-size: clamp(13px, 2.2vh, 18px); -webkit-line-clamp: 2; }
  .widget.weather { padding: 8px; }
  .widget.fx { padding: 6px 8px; }
  .gold-body { padding: 0 8px 8px; gap: 4px; }
  .gold-chart { min-height: 48px; }
}
