/* ==========================================================================
   基础样式：设计变量、重置、通用组件
   ========================================================================== */

:root {
  --brand: #2b6cf6;
  --brand-weak: #eef4ff;
  --brand-strong: #1a5ae0;

  --bg: #f6f7f9;
  --bg-panel: #ffffff;
  --bg-sunken: #f1f2f4;
  --bg-hover: #f2f4f7;
  --bg-active: #e9ebef;
  --bg-mask: rgba(0, 0, 0, 0.45);

  --text: #1f2329;
  --text-2: #646a73;
  --text-3: #8f959e;
  --text-inverse: #ffffff;

  --border: #e5e6eb;
  --border-strong: #d0d3d9;

  --yellow: #f5c142;
  --green: #3cc47c;
  --pink: #f56c9c;
  --purple: #9a6cf5;
  --blue: #4c8bf5;
  --gray: #a7abb3;

  --danger: #e94b4b;
  --success: #21a366;

  --radius-sm: 4px;
  --radius: 8px;
  --radius-lg: 12px;

  --shadow-sm: 0 1px 2px rgba(31, 35, 41, 0.08);
  --shadow: 0 4px 16px rgba(31, 35, 41, 0.12);
  --shadow-lg: 0 12px 32px rgba(31, 35, 41, 0.18);

  --sidebar-w: 232px;
  --list-w: 336px;
  --header-h: 52px;

  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB',
    'Microsoft YaHei', 'Helvetica Neue', Arial, sans-serif;
}

html[data-theme='dark'] {
  --brand: #4c8bf5;
  --brand-weak: #1c2740;
  --brand-strong: #6ba1ff;

  --bg: #17181a;
  --bg-panel: #1f2023;
  --bg-sunken: #26272b;
  --bg-hover: #2a2b30;
  --bg-active: #323339;
  --bg-mask: rgba(0, 0, 0, 0.6);

  --text: #e6e7ea;
  --text-2: #a8adb7;
  --text-3: #7c828c;

  --border: #32343a;
  --border-strong: #43464d;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.6);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
}

a {
  color: var(--brand);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

ul,
ol {
  margin: 0;
  padding: 0;
}

[hidden] {
  display: none !important;
}

::selection {
  background: rgba(43, 108, 246, 0.22);
}

/* 滚动条 */
.scroll-y {
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.scroll-y::-webkit-scrollbar {
  width: 8px;
}

.scroll-y::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 4px;
}

.scroll-y::-webkit-scrollbar-thumb:hover {
  background: var(--text-3);
}

.scroll-y::-webkit-scrollbar-track {
  background: transparent;
}

/* --------------------------------- 图标 --------------------------------- */

.icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 1em;
  height: 1em;
}

.icon svg {
  width: 100%;
  height: 100%;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* --------------------------------- 按钮 --------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text-2);
  background: transparent;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}

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

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

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--brand);
  color: #fff;
  font-weight: 500;
}

.btn-primary:hover {
  background: var(--brand-strong);
  color: #fff;
}

.btn-outline {
  border: 1px solid var(--border-strong);
  background: var(--bg-panel);
  color: var(--text);
}

.btn-danger {
  color: var(--danger);
}

.btn-danger:hover {
  background: rgba(233, 75, 75, 0.1);
  color: var(--danger);
}

.btn-ghost-sm {
  height: 28px;
  padding: 0 8px;
  font-size: 13px;
}

.btn-block {
  width: 100%;
}

/* 纯图标按钮 */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  font-size: 17px;
  color: var(--text-2);
  transition: background 0.15s, color 0.15s;
}

.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.icon-btn:active {
  background: var(--bg-active);
}

.icon-btn.is-active {
  background: var(--brand-weak);
  color: var(--brand);
}

.icon-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  background: none;
}

/* -------------------------------- 输入框 -------------------------------- */

.field {
  display: block;
  margin-bottom: 14px;
}

.field > span {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--text-2);
}

.input {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-panel);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(43, 108, 246, 0.14);
}

/* -------------------------------- 提示条 -------------------------------- */

.toast-host {
  position: fixed;
  left: 50%;
  bottom: 40px;
  transform: translateX(-50%);
  z-index: 999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 9px 16px;
  border-radius: var(--radius);
  background: rgba(31, 35, 41, 0.9);
  color: #fff;
  font-size: 13px;
  box-shadow: var(--shadow);
  animation: toast-in 0.18s ease-out;
  max-width: 80vw;
}

html[data-theme='dark'] .toast {
  background: rgba(240, 241, 243, 0.94);
  color: #1f2329;
}

.toast-error {
  background: var(--danger);
  color: #fff;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* --------------------------------- 弹窗 --------------------------------- */

.dialog {
  position: fixed;
  inset: 0;
  z-index: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.dialog-mask {
  position: absolute;
  inset: 0;
  background: var(--bg-mask);
  animation: fade-in 0.15s ease-out;
}

.dialog-panel {
  position: relative;
  width: 100%;
  max-width: 400px;
  max-height: 86vh;
  overflow: auto;
  background: var(--bg-panel);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 20px;
  animation: panel-in 0.18s ease-out;
}

.dialog-panel h3 {
  margin: 0 0 4px;
  font-size: 16px;
}

.dialog-desc {
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--text-3);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

.dialog-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--border);
}

.dialog-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 2px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.dialog-list li > span:first-child {
  color: var(--text-2);
}

kbd {
  display: inline-block;
  min-width: 22px;
  padding: 1px 6px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm);
  background: var(--bg-sunken);
  font-family: var(--font);
  font-size: 12px;
  text-align: center;
  color: var(--text-2);
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ------------------------------- 顶部提示条 ------------------------------- */

.app-banner {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 900;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: min(92vw, 520px);
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-panel);
  box-shadow: var(--shadow);
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  animation: toast-in 0.2s ease-out;
}

.app-banner .icon {
  font-size: 15px;
  color: var(--brand);
}

/* ------------------------------- 空状态 ------------------------------- */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 60px 24px;
  color: var(--text-3);
  text-align: center;
}

.empty .icon {
  font-size: 34px;
  opacity: 0.5;
}

.empty p {
  margin: 0;
  font-size: 13px;
}

.empty .btn {
  margin-top: 4px;
}
