:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --panel-soft: #f8faff;
  --text: #152238;
  --muted: #6d7b91;
  --line: #dce4ef;
  --primary: #087cf0;
  --primary-dark: #0067ce;
  --danger: #e7352c;
  --shadow: 0 12px 34px rgba(22, 45, 78, 0.07);
  --topbar-height: 64px;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; min-height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  transition: background .2s ease, color .2s ease;
}

body[data-theme="warm"] {
  --bg: #f8f5ef;
  --panel: #fffdf8;
  --panel-soft: #fbf7ef;
  --line: #e7dfd1;
}

body[data-theme="dark"] {
  --bg: #0e1725;
  --panel: #152235;
  --panel-soft: #192a40;
  --text: #edf4ff;
  --muted: #9eb0c9;
  --line: #2b3c54;
  --shadow: 0 12px 34px rgba(0, 0, 0, .22);
  color-scheme: dark;
}

button, input, select { font: inherit; }
button, select, input[type="checkbox"], input[type="range"] { cursor: pointer; }

button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid rgba(8, 124, 240, .25);
  outline-offset: 2px;
}

.topbar {
  height: var(--topbar-height);
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(12px);
}

.brand-block { display: flex; align-items: center; min-width: 280px; }
.brand-icon {
  width: 38px; height: 38px; margin-right: 10px; border-radius: 11px;
  display: grid; place-items: center; color: #fff; background: #111827;
  font-size: 20px; font-weight: 800;
}
.brand-block h1 { font-size: 18px; line-height: 1.2; margin: 0; letter-spacing: -.3px; }
.brand-block p { font-size: 11px; margin: 3px 0 0; color: var(--muted); }
.separator { margin: 0 5px; }
.status-dot { width: 7px; height: 7px; display: inline-block; border-radius: 50%; margin-right: 5px; background: #f0a51b; }
.status-dot.connected { background: #19ae6f; box-shadow: 0 0 0 4px rgba(25, 174, 111, .1); }
.status-dot.error { background: var(--danger); }

.top-controls { display: flex; align-items: center; justify-content: flex-end; gap: 10px; font-size: 13px; }
.top-controls label { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
select, input {
  min-height: 34px; border: 1px solid var(--line); border-radius: 7px;
  color: var(--text); background: var(--panel); padding: 0 10px;
}
select:hover, input:hover { border-color: #aebcd0; }
input:focus, select:focus { border-color: var(--primary); }
.volume-control input { width: 125px; padding: 0; accent-color: var(--primary); }

button { border: 0; border-radius: 7px; transition: .18s ease; }
button:disabled { cursor: not-allowed; opacity: .55; }
.primary { padding: 10px 15px; color: #fff; background: var(--primary); font-weight: 650; box-shadow: 0 5px 13px rgba(8, 124, 240, .18); }
.primary:hover:not(:disabled) { background: var(--primary-dark); transform: translateY(-1px); }
.secondary { padding: 9px 14px; color: var(--text); background: var(--panel); border: 1px solid var(--line); font-weight: 600; }
.secondary:hover { background: var(--panel-soft); border-color: #b8c6d8; }
.compact { height: 38px; padding: 0 13px; }
#sound-toggle.off {
  background: #dc2626;
  box-shadow: 0 5px 14px rgba(220, 38, 38, .28);
}
#sound-toggle.off:hover:not(:disabled) { background: #b91c1c; }

.app-shell {
  height: calc(100vh - var(--topbar-height));
  padding: 14px;
  display: grid;
  grid-template-columns: 217px 217px minmax(0, 1fr);
  gap: 14px;
}

.sidebar, .accounts-panel, .feed-panel {
  min-height: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 11px; box-shadow: var(--shadow);
}
.sidebar, .accounts-panel { overflow-y: auto; overscroll-behavior: contain; }
.add-panel { padding: 16px 15px 18px; border-bottom: 1px solid var(--line); }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.eyebrow { display: block; color: var(--primary); font-size: 9px; font-weight: 800; letter-spacing: 1.4px; margin-bottom: 3px; }
h2 { margin: 0; font-size: 17px; letter-spacing: -.25px; }
.count-badge { min-width: 28px; height: 25px; display: grid; place-items: center; color: var(--primary); background: rgba(8, 124, 240, .09); border-radius: 8px; font-size: 12px; font-weight: 800; }
.add-panel form { margin-top: 14px; }
.add-panel label, .login-card label { display: block; margin: 9px 0 5px; font-size: 12px; color: var(--muted); font-weight: 650; }
.add-panel input { width: 100%; }
.add-button { width: 100%; margin-top: 12px; }
.form-error { min-height: 16px; margin: 7px 0 0; color: var(--danger); font-size: 11px; }

.primary-accounts-panel { padding: 0 15px 18px; }
.watchlist-panel { padding: 0 15px 18px; }
.all-accounts-row { min-height: 65px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.all-accounts-row h2 { font-size: 16px; }
.all-accounts-row p { margin: 3px 0 0; color: var(--muted); font-size: 10px; }
.switch { position: relative; display: inline-flex; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch span { width: 35px; height: 20px; display: block; border-radius: 99px; background: #c8d1dd; transition: .18s; }
.switch span::after { content: ""; width: 14px; height: 14px; position: absolute; top: 3px; left: 3px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.22); transition: .18s; }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::after { transform: translateX(15px); }

.accounts-list.show-empty:empty::after { content: "还没有监控账号"; display: block; padding: 26px 0 10px; text-align: center; color: var(--muted); font-size: 12px; }
.account-card { padding: 7px 0; border-bottom: 1px solid var(--line); }
.account-card:last-child { border-bottom: 0; }
.account-top { display: grid; grid-template-columns: 28px minmax(0,1fr) auto; gap: 7px; align-items: center; }
.account-avatar { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; color: #fff; background: linear-gradient(145deg, #15263e, #334c70); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.account-name { min-width: 0; }
.account-name strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.account-name span { color: var(--muted); font-size: 9px; }
.account-error { margin: 4px 0 0 35px; color: var(--danger); font-size: 9px; line-height: 1.3; }
.account-activity-controls { margin-top: 4px; display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.account-activity-controls label { display: inline-flex; align-items: center; gap: 2px; color: var(--muted); font-size: 10px; cursor: pointer; }
.account-activity-controls input { width: 12px; height: 12px; min-height: 0; margin: 0; padding: 0; accent-color: var(--primary); }
.account-controls { margin: 4px 0 0 35px; display: grid; grid-template-columns: 1fr 32px; gap: 6px; }
.account-controls select { width: 100%; height: 28px; min-height: 28px; font-size: 11px; }
.delete-button { height: 28px; color: var(--danger); background: rgba(231, 53, 44, .08); font-size: 15px; }
.delete-button:hover { color: #fff; background: var(--danger); }

.feed-panel { display: flex; flex-direction: column; overflow: hidden; position: relative; }
.feed-toolbar { min-height: 67px; padding: 14px 18px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); background: var(--panel); }
.feed-meta { display: flex; align-items: center; gap: 16px; color: var(--muted); font-size: 11px; }
.feed-meta strong { color: var(--text); }
.live-dot { width: 7px; height: 7px; display: inline-block; margin-right: 4px; border-radius: 50%; background: #19ae6f; box-shadow: 0 0 0 4px rgba(25, 174, 111, .12); }
.config-warning { margin: 12px 14px 0; padding: 11px 14px; display: flex; gap: 8px; align-items: center; border: 1px solid #f2c36e; border-radius: 8px; background: #fff8e8; color: #8f5e08; font-size: 12px; }
body[data-theme="dark"] .config-warning { background: #362d18; }
.alerts-list { overflow-y: auto; }
.alert-card { position: relative; padding: 16px 19px 17px 21px; border-bottom: 1px solid var(--line); animation: alert-in .28s ease-out both; }
.alert-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--accent, var(--primary)); }
.alert-card.category-exalted { --accent: #d89116; }
.alert-card.category-chaos { --accent: #8a6ee8; }
@keyframes alert-in { from { opacity: 0; transform: translateY(-7px); } }
.alert-head { display: flex; justify-content: space-between; gap: 14px; }
.alert-title { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; color: #e32620; font-size: 30px; font-weight: 800; }
.category-tag { padding: 3px 7px; border-radius: 99px; color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, transparent); font-size: 9px; letter-spacing: .4px; }
.alert-time { flex: 0 0 auto; color: var(--muted); font-size: 11px; }
.alert-byline { margin: 5px 0 12px; color: var(--muted); font-size: 11px; }
.tweet-text, .translated-text { margin: 0; white-space: pre-wrap; word-break: break-word; font-size: 14px; line-height: 1.65; }
.translated-text { margin-top: 9px; padding-top: 9px; border-top: 1px dashed var(--line); color: color-mix(in srgb, var(--text) 88%, var(--primary)); }
.tweet-link { display: inline-flex; align-items: center; gap: 4px; margin-top: 10px; color: var(--primary); font-size: 12px; text-decoration: none; }
.tweet-link:hover { text-decoration: underline; }

.empty-state { margin: auto; max-width: 470px; padding: 55px 20px; text-align: center; color: var(--muted); }
.empty-state h3 { margin: 20px 0 8px; color: var(--text); font-size: 18px; }
.empty-state p { margin: 0; font-size: 13px; line-height: 1.6; }
.empty-state small { display: block; margin-top: 10px; font-size: 10px; }
.radar { width: 64px; height: 64px; position: relative; margin: 0 auto; border: 1px solid rgba(8, 124, 240, .28); border-radius: 50%; background: repeating-radial-gradient(circle, transparent 0 12px, rgba(8, 124, 240, .09) 13px 14px); }
.radar::before, .radar::after { content: ""; position: absolute; background: rgba(8,124,240,.15); }
.radar::before { width: 1px; inset: 0 auto 0 50%; }
.radar::after { height: 1px; inset: 50% 0 auto; }
.radar span { position: absolute; width: 7px; height: 7px; right: 12px; top: 17px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 5px rgba(8,124,240,.12); }

.toast { position: fixed; left: 50%; bottom: 24px; z-index: 30; max-width: min(420px, calc(100% - 30px)); padding: 11px 16px; border-radius: 9px; color: #fff; background: #1c2a3d; box-shadow: 0 12px 32px rgba(0,0,0,.22); font-size: 12px; opacity: 0; transform: translate(-50%, 12px); pointer-events: none; transition: .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #bd2e28; }

.login-body { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at 20% 10%, #e7f2ff, transparent 38%), var(--bg); }
.login-card { width: min(410px, 100%); padding: 34px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); box-shadow: 0 24px 70px rgba(22, 45, 78, .14); }
.login-logo { width: 48px; height: 48px; margin-bottom: 18px; display: grid; place-items: center; border-radius: 14px; color: #fff; background: #111827; font-size: 25px; }
.login-card h1 { margin: 4px 0 8px; font-size: 25px; }
.login-card > p { margin: 0 0 22px; color: var(--muted); font-size: 13px; }
.login-card input, .login-card button { width: 100%; min-height: 42px; }

@media (max-width: 1100px) {
  .topbar { height: auto; min-height: var(--topbar-height); padding-block: 9px; }
  .top-controls { flex-wrap: wrap; }
  .volume-control { display: none !important; }
  .app-shell { height: calc(100vh - 75px); }
}

@media (max-width: 760px) {
  :root { --topbar-height: auto; }
  .topbar { position: static; align-items: flex-start; flex-direction: column; gap: 10px; }
  .top-controls { width: 100%; justify-content: flex-start; }
  .top-controls label:first-child { display: none; }
  .app-shell { height: auto; min-height: calc(100vh - 130px); padding: 9px; grid-template-columns: 1fr; }
  .sidebar, .accounts-panel { max-height: none; }
  .feed-panel { min-height: 560px; }
  .feed-toolbar { align-items: flex-start; }
  .feed-meta { flex-direction: column; align-items: flex-end; gap: 4px; }
  .config-warning { align-items: flex-start; flex-direction: column; }
}
