:root {
  --bg: #050914;
  --bg-soft: #08101f;
  --panel: rgba(11, 23, 45, 0.78);
  --panel-solid: #0b172d;
  --line: rgba(127, 163, 220, 0.14);
  --line-strong: rgba(73, 209, 255, 0.55);
  --text: #edf5ff;
  --muted: #8193ae;
  --muted-2: #5d6e88;
  --cyan: #43d5ff;
  --cyan-deep: #0d9fd8;
  --gold: #ffd95c;
  --green: #31dea0;
  --pink: #ff5ca8;
  --orange: #ff973f;
  --radius: 18px;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.32);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 50% -20%, rgba(31, 115, 190, 0.17), transparent 40%),
    linear-gradient(180deg, #060a13 0%, var(--bg) 55%, #040711 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

button, input { font: inherit; }
button { color: inherit; }
a { color: inherit; }
svg { display: block; }
kbd {
  min-width: 20px;
  padding: 2px 6px;
  color: #71839e;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 6px;
  font: 600 11px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
  text-align: center;
}

.ambient { position: fixed; inset: auto; pointer-events: none; filter: blur(90px); opacity: .18; }
.ambient-one { width: 340px; height: 340px; top: 130px; left: -180px; background: #047ff0; }
.ambient-two { width: 400px; height: 400px; right: -220px; bottom: 10%; background: #0a98c5; }
.app-shell { position: relative; z-index: 1; max-width: 1540px; margin: 0 auto; padding: 0 32px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 90px;
  gap: 30px;
  margin: 0 -32px;
  padding: 16px 32px;
  background: rgba(5, 9, 20, .82);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(20px);
}

.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; min-width: 235px; }
.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  background: linear-gradient(145deg, rgba(255,133,67,.12), rgba(255,74,134,.08));
  border: 1px solid rgba(255, 137, 67, .18);
  border-radius: 13px;
}
.brand-mark svg { width: 27px; fill: url(#none); color: var(--orange); }
.brand-mark path { fill: var(--orange); }
.brand strong { display: block; font-size: 19px; letter-spacing: -.02em; }
.brand small { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }

.header-actions { display: flex; align-items: center; justify-content: flex-end; gap: 12px; flex: 1; }
.search-box {
  display: flex;
  align-items: center;
  width: min(390px, 34vw);
  height: 44px;
  padding: 0 12px;
  gap: 9px;
  background: rgba(14, 31, 61, .72);
  border: 1px solid rgba(72, 138, 210, .22);
  border-radius: 13px;
  transition: border-color .2s, box-shadow .2s;
}
.search-box:focus-within { border-color: var(--line-strong); box-shadow: 0 0 0 3px rgba(67,213,255,.08); }
.search-box svg { width: 18px; fill: none; stroke: var(--cyan); stroke-width: 2; }
.search-box input { flex: 1; min-width: 0; color: var(--text); background: transparent; border: 0; outline: 0; font-size: 13px; }
.search-box input::placeholder { color: #61718a; }
.live-pill { display: flex; align-items: center; gap: 8px; min-width: 162px; height: 42px; padding: 0 14px; color: #a9b8cc; background: rgba(12,22,39,.62); border: 1px solid var(--line); border-radius: 999px; font-size: 12px; white-space: nowrap; }
.status-dot { width: 7px; height: 7px; background: var(--green); border-radius: 50%; box-shadow: 0 0 0 5px rgba(49,222,160,.08), 0 0 12px rgba(49,222,160,.6); }
.live-pill.error .status-dot { background: #ff6b72; box-shadow: 0 0 0 5px rgba(255,107,114,.08); }
.live-pill.loading .status-dot { background: var(--gold); animation: blink 1s ease-in-out infinite; }
.language-button { display: flex; align-items: center; justify-content: center; height: 42px; padding: 0 13px; gap: 7px; color: #b8c9dc; background: rgba(12,22,39,.7); border: 1px solid var(--line); border-radius: 11px; cursor: pointer; font-size: 11px; font-weight: 800; white-space: nowrap; transition: border-color .2s, color .2s, background .2s; }
.language-button:hover { color: white; border-color: rgba(67,213,255,.42); }
.language-button[aria-pressed="true"] { color: #dff9ff; background: rgba(24,85,115,.42); border-color: rgba(67,213,255,.34); }
.language-icon { display: grid; width: 22px; height: 22px; place-items: center; color: #061523; background: var(--cyan); border-radius: 6px; font-size: 11px; }
.refresh-button { display: flex; align-items: center; justify-content: center; height: 44px; padding: 0 17px; gap: 8px; color: #031321; background: linear-gradient(135deg, #3bd9ff, #22a8ef); border: 0; border-radius: 13px; box-shadow: 0 8px 28px rgba(33, 178, 238, .25); cursor: pointer; font-weight: 800; font-size: 13px; transition: transform .2s, filter .2s; }
.refresh-button:hover { transform: translateY(-1px); filter: brightness(1.08); }
.refresh-button:disabled { cursor: wait; opacity: .65; }
.refresh-button svg { width: 17px; fill: none; stroke: currentColor; stroke-width: 2; }
.refresh-button.loading svg { animation: spin .8s linear infinite; }
.refresh-button.guest-mode {
  background: rgba(18, 38, 70, .85);
  color: #799bbb;
  box-shadow: none;
  border: 1px dashed rgba(67, 213, 255, .28);
}
.refresh-button.guest-mode:hover {
  transform: none;
  filter: none;
  color: #aed5fc;
  border-color: rgba(67, 213, 255, .55);
}

.auth-box { display: flex; align-items: center; }
.login-link-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 42px;
  padding: 0 14px;
  color: #92b5db;
  background: rgba(14, 27, 50, .75);
  border: 1px solid rgba(72, 138, 210, .28);
  border-radius: 11px;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
  transition: all .2s ease;
}
.login-link-btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; }
.login-link-btn:hover {
  color: #ffffff;
  background: rgba(22, 45, 80, .9);
  border-color: rgba(67, 213, 255, .5);
  box-shadow: 0 4px 16px rgba(0, 0, 0, .25);
}

.admin-profile { display: flex; align-items: center; gap: 8px; }
.admin-badge {
  display: inline-flex;
  align-items: center;
  height: 42px;
  padding: 0 12px;
  font-size: 11px;
  font-weight: 700;
  color: #a6f3d0;
  background: rgba(16, 42, 36, .7);
  border: 1px solid rgba(52, 211, 153, .3);
  border-radius: 11px;
  white-space: nowrap;
}

.logout-button { display: grid; width: 42px; height: 42px; flex: 0 0 auto; place-items: center; color: #7f94ae; background: rgba(12,22,39,.7); border: 1px solid var(--line); border-radius: 11px; cursor: pointer; transition: color .2s, border-color .2s; }
.logout-button:hover { color: #ff8c94; border-color: rgba(255,107,114,.4); }
.logout-button:disabled { cursor: wait; opacity: .45; }
.logout-button svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; }

main { padding: 24px 0 40px; }
.control-deck { position: sticky; top: 90px; z-index: 18; display: flex; align-items: center; justify-content: space-between; gap: 22px; margin: 0 -32px; padding: 12px 32px; background: rgba(5,9,20,.9); border-bottom: 1px solid var(--line); box-shadow: 0 12px 30px rgba(0,0,0,.14); backdrop-filter: blur(20px); }
.tabs { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: 0 0 auto; height: 38px; padding: 0 14px; color: #93a3ba; background: rgba(12, 23, 44, .7); border: 1px solid rgba(91, 125, 180, .18); border-radius: 10px; cursor: pointer; font-size: 12px; font-weight: 700; transition: .2s ease; }
.tab span { margin-right: 6px; color: var(--cyan); }
.tab:hover { color: var(--text); border-color: rgba(67,213,255,.35); }
.tab.active { color: white; background: linear-gradient(180deg, rgba(26,81,119,.9), rgba(13,48,81,.9)); border-color: var(--cyan); box-shadow: inset 0 0 0 1px rgba(67,213,255,.18), 0 0 20px rgba(67,213,255,.1); }
.date-nav { display: flex; align-items: center; gap: 7px; flex: 0 0 auto; }
.icon-button, .ghost-button, .details-toggle { background: rgba(12,23,44,.7); border: 1px solid var(--line); border-radius: 9px; cursor: pointer; }
.icon-button { display: grid; width: 36px; height: 36px; place-items: center; }
.icon-button:disabled { opacity: .3; cursor: not-allowed; }
.icon-button svg { width: 16px; fill: none; stroke: #9dafc6; stroke-width: 2; }
.date-picker { display: flex; align-items: center; gap: 9px; height: 38px; padding: 0 12px; color: var(--muted); background: rgba(12,23,44,.7); border: 1px solid var(--line); border-radius: 9px; font-size: 11px; }
.date-picker input { color: #dcecff; background: transparent; border: 0; outline: 0; color-scheme: dark; font-size: 12px; }
.ghost-button { height: 38px; padding: 0 12px; color: #9fb4cc; font-size: 11px; }
.ghost-button:hover, .icon-button:hover, .details-toggle:hover { border-color: rgba(67,213,255,.4); color: white; }

.pulse-strip { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 30px; padding: 42px 0 34px; }
.eyebrow { display: inline-flex; align-items: center; gap: 7px; color: #5ccff5; font: 800 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .16em; }
.pulse-icon { width: 7px; height: 7px; background: var(--cyan); border-radius: 50%; box-shadow: 0 0 12px var(--cyan); animation: blink 1.8s ease-in-out infinite; }
.pulse-copy h1 { margin: 12px 0 10px; font-size: clamp(28px, 3vw, 43px); line-height: 1.05; letter-spacing: -.045em; }
.pulse-copy p { margin: 0; color: var(--muted); font-size: 13px; }
.metrics { display: flex; gap: 12px; }
.metric { min-width: 118px; padding: 14px 16px; background: rgba(10,21,41,.64); border: 1px solid var(--line); border-radius: 13px; }
.metric strong { display: block; color: #eef8ff; font-size: 20px; letter-spacing: -.03em; }
.metric span { display: block; margin-top: 4px; color: var(--muted-2); font-size: 10px; }

.source-health { display: flex; align-items: center; min-height: 56px; gap: 13px; padding: 8px 12px; background: rgba(7,14,28,.55); border: 1px solid var(--line); border-radius: 13px; }
.section-label { color: var(--muted-2); font-size: 10px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.source-chips { display: flex; align-items: center; gap: 7px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.source-chip { display: flex; align-items: center; gap: 7px; padding: 7px 10px; color: #aab9cc; background: rgba(255,255,255,.025); border: 1px solid rgba(255,255,255,.055); border-radius: 999px; font-size: 11px; white-space: nowrap; }
.source-chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 8px rgba(49,222,160,.45); }
.source-chip.offline::before { background: #ff6b72; box-shadow: none; }
.source-chip b { color: white; font-weight: 800; }
.details-toggle { padding: 8px 11px; color: #7f95b0; font-size: 10px; white-space: nowrap; }
.status-panel { margin-top: 10px; padding: 15px; color: var(--muted); background: rgba(9,18,35,.86); border: 1px solid var(--line); border-radius: 13px; box-shadow: var(--shadow); }
.status-panel > div { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.status-row { padding: 9px; background: rgba(255,255,255,.025); border-radius: 8px; font-size: 10px; }
.status-row strong { display: block; color: #dce8f6; margin-bottom: 3px; }
.status-row.error strong { color: #ff8a91; }
.status-panel p { margin: 12px 0 0; color: #5f718b; font-size: 10px; }

.feed-section { padding-top: 35px; }
.feed-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.feed-heading h2 { margin: 8px 0 0; font-size: 19px; letter-spacing: -.02em; }
.result-count { color: var(--muted); font-size: 11px; }
.cards-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.hot-card { position: relative; display: flex; flex-direction: column; min-height: 205px; padding: 18px; overflow: hidden; text-decoration: none; background: linear-gradient(145deg, rgba(13,31,61,.9), rgba(8,20,41,.92)); border: 1px solid rgba(75,118,176,.2); border-radius: var(--radius); box-shadow: 0 8px 28px rgba(0,0,0,.14); transition: transform .22s ease, border-color .22s ease, box-shadow .22s ease; }
.hot-card::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(circle at 82% 0%, rgba(52,194,255,.085), transparent 36%); opacity: 0; transition: opacity .22s; }
.hot-card:hover { transform: translateY(-3px); border-color: rgba(67,213,255,.7); box-shadow: 0 16px 40px rgba(0,0,0,.28), inset 0 0 0 1px rgba(67,213,255,.08); }
.hot-card:hover::after { opacity: 1; }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.source-name { display: flex; align-items: center; gap: 8px; color: #86a3c2; font-size: 10px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.source-avatar { display: grid; width: 24px; height: 24px; place-items: center; color: #03101b; background: var(--cyan); border-radius: 7px; font-size: 11px; }
.rank { color: #5d718e; font: 700 11px ui-monospace, SFMono-Regular, Menlo, monospace; }
.external-icon { position: absolute; right: 17px; top: 49px; width: 14px; height: 14px; fill: none; stroke: #7890aa; stroke-width: 1.8; }
.hot-card h3 { margin: 14px 28px 8px 0; color: #f1f7ff; font-size: 15px; line-height: 1.42; letter-spacing: -.01em; }
.summary { display: -webkit-box; margin: 0; overflow: hidden; color: #91a7bf; font-size: 12px; line-height: 1.55; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.card-footer { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-top: auto; padding-top: 15px; border-top: 1px solid rgba(130,160,205,.09); }
.badge { display: inline-flex; align-items: center; min-height: 24px; padding: 4px 8px; color: #8fb4cf; background: rgba(78,132,185,.09); border: 1px solid rgba(103,158,211,.1); border-radius: 7px; font-size: 9px; font-weight: 750; }
.badge.score { color: #ffe275; background: rgba(180,135,20,.13); border-color: rgba(255,215,80,.24); }
.badge.translated { color: #83efff; background: rgba(35,183,221,.1); border-color: rgba(67,213,255,.22); }
.card-time { margin-left: auto; color: #526782; font-size: 9px; white-space: nowrap; }
.skeleton { min-height: 205px; background: linear-gradient(110deg, rgba(15,31,56,.8) 8%, rgba(24,48,81,.8) 18%, rgba(15,31,56,.8) 33%); background-size: 200% 100%; border: 1px solid var(--line); border-radius: var(--radius); animation: shimmer 1.4s linear infinite; }
.empty-state { padding: 70px 20px; text-align: center; background: rgba(10,20,39,.45); border: 1px dashed rgba(111,147,197,.22); border-radius: var(--radius); }
.empty-state > span { display: block; color: var(--cyan); font-size: 34px; }
.empty-state h3 { margin: 12px 0 7px; font-size: 16px; }
.empty-state p { margin: 0; color: var(--muted); font-size: 12px; }

footer { display: flex; justify-content: space-between; gap: 20px; padding: 24px 0 34px; color: #4f6078; border-top: 1px solid var(--line); font-size: 10px; }
.toast { position: fixed; z-index: 50; left: 50%; bottom: 30px; max-width: min(460px, calc(100vw - 40px)); padding: 12px 16px; color: #dff7ff; background: rgba(10,27,49,.94); border: 1px solid rgba(67,213,255,.34); border-radius: 11px; box-shadow: var(--shadow); transform: translate(-50%, 30px); opacity: 0; pointer-events: none; transition: .25s ease; font-size: 12px; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.back-to-top { position: fixed; z-index: 40; right: 24px; bottom: 24px; display: flex; align-items: center; justify-content: center; width: 54px; height: 54px; padding: 0; flex-direction: column; gap: 1px; color: #dff8ff; background: rgba(13,39,66,.9); border: 1px solid rgba(67,213,255,.34); border-radius: 16px; box-shadow: 0 14px 38px rgba(0,0,0,.34); backdrop-filter: blur(14px); cursor: pointer; opacity: 0; pointer-events: none; transform: translateY(12px); transition: opacity .2s, transform .2s, border-color .2s; }
.back-to-top.visible { opacity: 1; pointer-events: auto; transform: translateY(0); }
.back-to-top:hover { border-color: var(--cyan); transform: translateY(-2px); }
.back-to-top svg { width: 18px; fill: none; stroke: var(--cyan); stroke-width: 2; }
.back-to-top span { font-size: 9px; font-weight: 800; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes blink { 50% { opacity: .35; transform: scale(.85); } }
@keyframes shimmer { to { background-position-x: -200%; } }

@media (max-width: 1080px) {
  .topbar { align-items: flex-start; }
  .header-actions { flex-wrap: wrap; }
  .search-box { width: 100%; order: 3; }
  .control-deck { position: static; align-items: flex-start; flex-direction: column; margin: 0; padding: 0 0 22px; background: transparent; box-shadow: none; backdrop-filter: none; }
  .tabs { width: 100%; }
  .pulse-strip { grid-template-columns: 1fr; }
  .metrics { justify-content: stretch; }
  .metric { flex: 1; }
  .cards-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .status-panel > div { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 700px) {
  .app-shell { padding: 0 16px; }
  .topbar { position: relative; margin: 0 -16px; padding: 16px; flex-direction: column; gap: 14px; }
  .header-actions { width: 100%; justify-content: flex-start; }
  .live-pill { flex: 1; min-width: 0; }
  .language-button { flex: 0 0 auto; }
  .logout-button { flex: 0 0 auto; }
  .refresh-button { flex: 0 0 auto; }
  .control-deck { padding-top: 5px; }
  .date-nav { width: 100%; }
  .date-picker { flex: 1; }
  .date-picker input { width: 100%; }
  .ghost-button { display: none; }
  .pulse-strip { padding: 32px 0 28px; }
  .metrics { gap: 7px; }
  .metric { min-width: 0; padding: 11px; }
  .metric strong { font-size: 17px; }
  .source-health { align-items: flex-start; flex-wrap: wrap; }
  .section-label { padding-top: 8px; }
  .source-chips { order: 3; width: 100%; flex-basis: 100%; }
  .status-panel > div { grid-template-columns: 1fr 1fr; }
  .cards-grid { grid-template-columns: 1fr; }
  .hot-card { min-height: 190px; }
  footer { flex-direction: column; }
  .back-to-top { right: 16px; bottom: 16px; width: 48px; height: 48px; border-radius: 14px; }
}
