:root {
  --bg: #0f1117;
  --bg-card: #1a1d27;
  --bg-hover: #232736;
  --border: #2d3348;
  --text: #e8eaef;
  --muted: #8b92a8;
  --accent: #4f8cff;
  --accent-dim: #3a6fd4;
  --highlight: #f5c542;
  --highlight-bg: rgba(245, 197, 66, 0.12);
  --danger: #ff6b6b;
  --success: #3dd68c;
  --radius: 10px;
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

.topbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-display {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  flex: 1;
  min-width: 200px;
}

.display-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-right: 0.25rem;
}

.display-field {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  margin: 0;
}

.display-field > span {
  color: var(--muted);
  white-space: nowrap;
}

.display-field.check {
  margin-bottom: 0;
}

.input-sm {
  padding: 0.3rem 0.45rem;
  font-size: 0.8rem;
  width: auto;
  min-width: 4.5rem;
}

.input-num {
  width: 3rem;
  min-width: 3rem;
}

.btn-sm {
  padding: 0.3rem 0.55rem;
  font-size: 0.75rem;
}

.btn-block {
  width: 100%;
  margin-top: 0.75rem;
}

.panel-settings {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.panel-settings .settings-panels {
  max-height: 42vh;
  overflow-y: auto;
  margin: 0.5rem 0;
}

.panel-settings .field {
  margin-bottom: 0.5rem;
}

.panel-settings .field > span {
  font-size: 0.72rem;
}

.panel-settings .hint {
  font-size: 0.72rem;
  margin-bottom: 0.5rem;
}

.panel-settings h3 {
  font-size: 0.78rem;
  margin: 0.5rem 0 0.25rem;
}

.webhook-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: stretch;
}

.webhook-row .input {
  flex: 1;
  min-width: 0;
}

.webhook-row .btn {
  flex-shrink: 0;
  white-space: nowrap;
}

.qq-advanced {
  margin: 0.5rem 0;
  font-size: 0.8rem;
}

.qq-advanced summary {
  cursor: pointer;
  color: var(--accent);
  margin-bottom: 0.35rem;
}

.hint.warn {
  color: var(--highlight);
}

.section-title {
  margin: 1rem 0 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.webhook-row textarea.input {
  flex: 1;
  min-width: 0;
  resize: vertical;
}

.hint a {
  color: var(--accent);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  flex-shrink: 0;
}

.brand-qr-btns {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  margin-left: 0.5rem;
}

.brand-qr-btn {
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.brand-qr-btn:hover {
  border-color: var(--success);
  color: var(--success);
}

.brand h1 {
  font-size: 1.1rem;
  font-weight: 600;
}

.subtitle {
  font-size: 0.75rem;
  color: var(--muted);
}

.logo {
  font-size: 1.5rem;
}

.status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}

.dot.live {
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}

.layout {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  grid-template-areas: "sidebar feed";
  gap: 0;
  width: 100%;
  max-width: none;
  margin: 0;
  min-height: calc(100vh - 56px);
}

.sidebar {
  grid-area: sidebar;
  border-right: 1px solid var(--border);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: sticky;
  top: 56px;
  align-self: start;
  max-height: calc(100vh - 56px);
  overflow-y: auto;
}

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
}

.panel h2 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.category-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  max-height: 160px;
  overflow-y: auto;
}

.cat-btn {
  text-align: left;
  padding: 0.45rem 0.6rem;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 0.85rem;
}

.cat-btn:hover {
  background: var(--bg-hover);
}

.cat-btn.active {
  background: var(--accent);
  color: #fff;
}

.check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
}

.input {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
}

.input:focus {
  outline: 2px solid var(--accent-dim);
  border-color: var(--accent);
}

.stats {
  font-size: 0.85rem;
}

.muted {
  color: var(--muted);
  font-size: 0.8rem;
}

.feed {
  grid-area: feed;
  min-width: 0;
  padding: 1rem 1.25rem;
  overflow-y: auto;
}

.feed-toolbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.feed-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  transition: border-color 0.2s;
}

.card:hover {
  border-color: var(--accent-dim);
}

.card.highlight {
  border-color: var(--highlight);
  background: var(--highlight-bg);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.badge {
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  background: var(--bg-hover);
  color: var(--muted);
  white-space: nowrap;
}

.badge.hl {
  background: var(--highlight);
  color: #1a1a1a;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  word-break: break-word;
}

.card-title mark {
  background: var(--highlight);
  color: #1a1a1a;
  padding: 0 2px;
  border-radius: 2px;
}

.card-content {
  font-size: 0.9rem;
  color: var(--muted);
  word-break: break-word;
  white-space: pre-wrap;
}

.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--muted);
}

.btn {
  padding: 0.45rem 0.9rem;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-size: 0.85rem;
  font-family: inherit;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-dim);
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--bg-hover);
}

.btn-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.85rem;
}

.btn-link:hover {
  text-decoration: underline;
}

.empty {
  text-align: center;
  padding: 3rem;
  color: var(--muted);
}

.hidden {
  display: none !important;
}

.dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text);
  padding: 0;
  max-width: 640px;
  width: 92vw;
}

.dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.dialog-body {
  padding: 1rem 1.25rem;
  max-height: 65vh;
  overflow-y: auto;
}

.dialog-body.settings-layout {
  overflow: hidden;
  max-height: 65vh;
}

.settings-layout {
  display: flex;
  gap: 1rem;
  align-items: stretch;
}

.settings-panels {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  max-height: calc(65vh - 2rem);
  padding-right: 0.25rem;
}

.dialog-body h3 {
  font-size: 0.9rem;
  margin: 0.5rem 0;
  color: var(--muted);
}

.dialog-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1rem 0;
}

.dialog-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  text-align: right;
}

.field {
  display: block;
  margin-bottom: 0.75rem;
}

.field > span {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.field textarea {
  resize: vertical;
  min-height: 60px;
}

.btn-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.settings-tabs {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0 0 0.5rem;
}

.settings-tabs .tab {
  padding: 0.35rem 0.55rem;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.75rem;
  width: auto;
}

.settings-tabs .tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
  line-height: 1.4;
}

.platform-cfg {
  padding: 0.5rem 0;
  margin-bottom: 0.25rem;
  border-bottom: 1px dashed var(--border);
}

.tab-panel h3 {
  font-size: 0.85rem;
  margin: 0.75rem 0 0.35rem;
  color: var(--accent);
}

.test-result {
  margin-top: 0.5rem;
  padding: 0.5rem;
  background: var(--bg);
  border-radius: 6px;
  font-size: 0.75rem;
  max-height: 120px;
  overflow: auto;
  white-space: pre-wrap;
}

.integration-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.5rem;
}

.tag {
  font-size: 0.65rem;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  background: var(--bg-hover);
  color: var(--muted);
}

.tag.on {
  background: var(--success);
  color: #0f1117;
}

.converted-links {
  margin-top: 0.5rem;
  font-size: 0.8rem;
}

.converted-links a {
  color: var(--success);
  word-break: break-all;
}

body.theme-light {
  --bg: #eef1f6;
  --bg-card: #ffffff;
  --bg-hover: #e4e8f0;
  --border: #d4d9e4;
  --text: #1a2030;
  --muted: #7a849a;
  --accent: #4f8cff;
  --accent-dim: #6b9fff;
  --highlight: #f5a623;
  --highlight-bg: rgba(245, 166, 35, 0.1);
  --danger: #f05c5c;
  --success: #3aad6a;
  --radius: 14px;
  --shadow-sm: 0 1px 4px rgba(60, 70, 100, 0.08);
  --shadow-md: 0 4px 16px rgba(60, 70, 100, 0.12);
  --shadow-lg: 0 8px 32px rgba(60, 70, 100, 0.15);
}

body.theme-light .topbar {
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px) saturate(1.4);
  box-shadow: 0 1px 0 var(--border);
}

body.theme-light .sidebar {
  background: transparent;
  border-right: 1px solid var(--border);
}

body.theme-light .panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  border-radius: var(--radius);
}

body.theme-light .panel h2 {
  color: var(--muted);
}

body.theme-light .cat-btn {
  color: var(--text);
  background: transparent;
  border-radius: 8px;
  transition: all 0.15s;
}

body.theme-light .cat-btn:hover {
  background: var(--bg-hover);
  color: var(--accent);
}

body.theme-light .cat-btn.active {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(79, 140, 255, 0.35);
}

body.theme-light .input {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-shadow: inset 0 1px 3px rgba(0,0,0,.04);
}

body.theme-light .input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.12), inset 0 1px 3px rgba(0,0,0,.04);
  outline: none;
}

body.theme-light select.input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%237a849a' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
  appearance: none;
  -webkit-appearance: none;
}

body.theme-light .input::placeholder {
  color: #b0b8cc;
}

body.theme-light textarea.input {
  border-radius: 10px;
  box-shadow: inset 0 1px 3px rgba(0,0,0,.04);
}

body.theme-light .check input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  min-width: 16px;
  border: 1.5px solid var(--border);
  border-radius: 4px;
  background: var(--bg-card);
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
}

body.theme-light .check input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}

body.theme-light .check input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 5px;
  height: 9px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
}

body.theme-light .settings-tabs {
  background: var(--bg-hover);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}

body.theme-light .settings-tabs .tab {
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  padding: 0.4rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 500;
  transition: all 0.2s;
}

body.theme-light .settings-tabs .tab.active {
  background: var(--bg-card);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

body.theme-light .btn {
  border-radius: 10px;
  font-weight: 500;
  transition: all 0.2s;
}

body.theme-light .btn-primary {
  background: var(--accent);
  box-shadow: 0 2px 8px rgba(79, 140, 255, 0.3);
}

body.theme-light .btn-primary:hover {
  background: var(--accent-dim);
  box-shadow: 0 4px 14px rgba(79, 140, 255, 0.4);
  transform: translateY(-1px);
}

body.theme-light .btn-ghost {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  color: var(--text);
}

body.theme-light .btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(79, 140, 255, 0.04);
}

body.theme-light .card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  border-radius: var(--radius);
}

body.theme-light .card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--accent);
}

body.theme-light .card.highlight {
  border-color: var(--highlight);
  background: var(--highlight-bg);
  box-shadow: 0 2px 12px rgba(245, 166, 35, 0.15);
}

body.theme-light .badge {
  background: var(--bg-hover);
  color: var(--muted);
}

body.theme-light .tag {
  background: var(--bg-hover);
  color: var(--muted);
}

body.theme-light .tag.on {
  background: var(--success);
  color: #fff;
}

body.theme-light .dot.live {
  box-shadow: 0 0 6px var(--success);
}

body.theme-light .panel-settings .settings-panels {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

body.theme-light .panel-settings .settings-panels::-webkit-scrollbar {
  width: 4px;
}

body.theme-light .panel-settings .settings-panels::-webkit-scrollbar-track {
  background: transparent;
}

body.theme-light .panel-settings .settings-panels::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

body.theme-light .brand-qr-btn {
  border-color: var(--border);
  color: var(--muted);
  background: var(--bg-card);
}

body.theme-light .brand-qr-btn:hover {
  border-color: var(--success);
  color: var(--success);
  background: rgba(58, 173, 106, 0.04);
}

body.theme-light .feed-toolbar .btn-primary {
  box-shadow: 0 2px 8px rgba(79, 140, 255, 0.3);
}

body.theme-light .panel-settings {
  background: transparent;
}

body.theme-light .qq-advanced summary {
  color: var(--accent);
}

body.theme-light .feed-toolbar .muted {
  color: var(--muted);
}

body.theme-light .test-result {
  background: var(--bg-hover);
  color: var(--text);
  border: 1px solid var(--border);
}

/* ============================================
   深色模式精细优化
   ============================================ */
body:not(.theme-light) .panel {
  border-radius: 12px;
}

body:not(.theme-light) .cat-btn {
  border-radius: 8px;
}

body:not(.theme-light) .card {
  border-radius: 12px;
}

body:not(.theme-light) .input {
  border-radius: 8px;
}

body:not(.theme-light) .input:focus {
  box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.15);
}

body:not(.theme-light) .btn {
  border-radius: 8px;
}

body:not(.theme-light) .check input[type="checkbox"] {
  border-radius: 4px;
}

body:not(.theme-light) .brand-qr-btn {
  border-radius: 8px;
}

body:not(.theme-light) select.input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238b92a8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
  appearance: none;
  -webkit-appearance: none;
}

body:not(.theme-light) .panel-settings .settings-panels {
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

body:not(.theme-light) .panel-settings .settings-panels::-webkit-scrollbar {
  width: 4px;
}

body:not(.theme-light) .panel-settings .settings-panels::-webkit-scrollbar-track {
  background: transparent;
}

body:not(.theme-light) .panel-settings .settings-panels::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

@keyframes lkSlideUpMobile {
  from { opacity: 0; transform: translateY(60px) scale(.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 768px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "sidebar"
      "feed";
  }

  .sidebar {
    position: static;
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 0.75rem;
  }

  .category-list {
    flex-direction: row;
    flex-wrap: wrap;
    max-height: none;
  }

  .topbar {
    padding: 0.6rem 0.75rem;
    gap: 0.5rem;
  }

  .topbar-display {
    order: 3;
    width: 100%;
  }

  .brand h1 {
    font-size: 0.95rem;
  }

  .subtitle {
    display: none;
  }

  .logo {
    font-size: 1.2rem;
  }

  .brand-qr-btns {
    gap: 0.3rem;
    margin-left: 0.3rem;
  }

  .brand-qr-btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.7rem;
    border-radius: 6px;
  }

  .panel-settings .settings-panels {
    max-height: 40vh;
  }

  .feed {
    padding: 0.75rem;
  }

  .feed-toolbar {
    gap: 0.5rem;
    margin-bottom: 0.75rem;
  }

  .feed-toolbar .btn {
    padding: 0.35rem 0.65rem;
    font-size: 0.78rem;
  }

  .card {
    padding: 0.75rem;
    border-radius: 10px;
  }

  .card-title {
    font-size: 0.9rem;
  }

  .card-content {
    font-size: 0.82rem;
  }

  .card-footer {
    font-size: 0.72rem;
  }

  /* 弹窗移动端优化 */
  #lk-gate-overlay,
  #lk-info-overlay {
    padding: 12px;
    align-items: flex-end;
  }

  .lk-gate-modal,
  .lk-modal {
    border-radius: 20px 20px 16px 16px !important;
    max-width: 100% !important;
    width: 100% !important;
    padding: 28px 20px 24px !important;
    animation: lkSlideUpMobile .35s cubic-bezier(.16, 1, .3, 1) !important;
  }

  @keyframes lkSlideUpMobile {
    from { opacity: 0; transform: translateY(60px) scale(.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
  }

  .lk-modal-title {
    font-size: 1.05rem !important;
  }

  .lk-qr-img {
    width: 140px !important;
    height: 140px !important;
  }

  .lk-modal-badge {
    padding: 4px 12px !important;
  }

  /* 设置弹窗移动端 */
  .dialog {
    max-width: 100vw;
    width: 100vw;
    border-radius: 16px 16px 0 0;
    max-height: 90vh;
  }

  .dialog-body.settings-layout {
    flex-direction: column;
  }

  .settings-panels {
    max-height: calc(90vh - 3rem) !important;
  }

  .settings-tabs {
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .settings-tabs::-webkit-scrollbar {
    display: none;
  }

  .settings-tabs .tab {
    white-space: nowrap;
    flex-shrink: 0;
  }

  /* 输入框移动端 */
  .field input,
  .field textarea,
  .input {
    font-size: 16px !important; /* 防止iOS自动缩放 */
  }
}

@media (max-width: 400px) {
  .brand-qr-btns {
    display: none;
  }

  .topbar-display {
    order: 2;
  }

  .status {
    order: 3;
  }
}
