/* ==========================================================================
   DeepSeek relay — base tokens & reset
   ========================================================================== */

:root {
  --ds-blue: #4d6bfe;
  --ds-blue-hover: #3d5af0;
  --ds-blue-soft: #eef2ff;
  --ds-blue-soft-2: #e4eaff;

  --bg: #ffffff;
  --bg-elevated: #ffffff;
  --sidebar-bg: #f9fbff;
  --bg-muted: #f4f5f7;
  --bg-hover: #eef1f7;
  --bg-active: #e6ecfd;

  --text: #1f1f1f;
  --text-2: #4a4a4a;
  --text-3: #8b8b8b;
  --text-4: #b4b4b4;

  --border: #e8e8ec;
  --border-strong: #dcdce2;
  --bubble-user: #eff3ff;

  --danger: #e5484d;
  --success: #12a150;
  --warn: #d97706;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --radius-xl: 26px;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow: 0 4px 16px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 12px 40px rgba(16, 24, 40, 0.14);

  --sidebar-w: 268px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
}

html[data-theme="dark"] {
  --bg: #1a1a1a;
  --bg-elevated: #232323;
  --sidebar-bg: #141414;
  --bg-muted: #2a2a2a;
  --bg-hover: #2c2c2c;
  --bg-active: #31384d;

  --text: #e8e8e8;
  --text-2: #c4c4c4;
  --text-3: #9a9a9a;
  --text-4: #6b6b6b;

  --border: #2f2f2f;
  --border-strong: #3d3d3d;
  --bubble-user: #2b3247;
  --ds-blue-soft: #262d40;
  --ds-blue-soft-2: #2d3650;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.55);
}

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

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}

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

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

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

a:hover {
  text-decoration: underline;
}

::selection {
  background: rgba(77, 107, 254, 0.22);
}

/* scrollbars */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(140, 140, 150, 0.35) transparent;
}
*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
*::-webkit-scrollbar-thumb {
  background: rgba(140, 140, 150, 0.32);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover {
  background: rgba(140, 140, 150, 0.55);
  background-clip: content-box;
}
*::-webkit-scrollbar-track {
  background: transparent;
}

/* --------------------------------------------------------------- helpers */

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  background: var(--bg-muted);
  color: var(--text);
  transition: background 0.15s ease, opacity 0.15s ease, transform 0.1s ease;
  white-space: nowrap;
  user-select: none;
}

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

.btn:active {
  transform: scale(0.985);
}

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

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

.btn-primary:hover {
  background: var(--ds-blue-hover);
}

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

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

.btn-danger {
  background: rgba(229, 72, 77, 0.1);
  color: var(--danger);
}

.btn-danger:hover {
  background: rgba(229, 72, 77, 0.18);
}

.btn-sm {
  height: 30px;
  padding: 0 11px;
  font-size: 13px;
  border-radius: 8px;
}

.btn-block {
  width: 100%;
}

.input {
  width: 100%;
  height: 42px;
  padding: 0 13px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  font-size: 14px;
}

.input:focus {
  border-color: var(--ds-blue);
  box-shadow: 0 0 0 3px rgba(77, 107, 254, 0.12);
}

.input::placeholder {
  color: var(--text-4);
}

textarea.input {
  height: auto;
  padding: 10px 13px;
  resize: vertical;
  line-height: 1.6;
}

.field {
  margin-bottom: 16px;
}

.field > label {
  display: block;
  margin-bottom: 7px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
}

.field .hint {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-3);
  line-height: 1.5;
}

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

/* toasts */
.toast-stack {
  position: fixed;
  z-index: 9999;
  left: 50%;
  top: 18px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}

.toast {
  min-width: 180px;
  max-width: min(90vw, 460px);
  padding: 10px 16px;
  border-radius: 10px;
  background: rgba(32, 33, 36, 0.94);
  color: #fff;
  font-size: 13.5px;
  line-height: 1.5;
  box-shadow: var(--shadow-lg);
  animation: toast-in 0.18s ease;
  word-break: break-word;
}

.toast.error {
  background: rgba(190, 40, 45, 0.96);
}

.toast.success {
  background: rgba(16, 130, 70, 0.96);
}

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

.spinner {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

.spinner.dark {
  border-color: rgba(0, 0, 0, 0.15);
  border-top-color: var(--ds-blue);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* modal */
.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(16, 18, 24, 0.45);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fade-in 0.15s ease;
}

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

.modal {
  width: min(520px, 100%);
  max-height: 88vh;
  overflow: auto;
  background: var(--bg-elevated);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  animation: modal-in 0.18s cubic-bezier(0.2, 0.9, 0.3, 1);
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 0;
  font-size: 16px;
  font-weight: 600;
}

.modal-body {
  padding: 16px 20px;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 0 20px 18px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  color: var(--text-3);
  transition: background 0.15s ease, color 0.15s ease;
}

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

.icon {
  width: 18px;
  height: 18px;
  stroke-width: 1.8;
  flex: none;
}
