:root {
  --color-bg: #e8edf5;
  --color-bg-elevated: #ffffff;
  --color-text: #0f172a;
  --color-text-muted: #64748b;
  --color-border: #e2e8f0;
  --color-border-focus: #93c5fd;
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-primary-subtle: #eff6ff;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md:
    0 4px 6px -1px rgba(15, 23, 42, 0.08),
    0 10px 24px -6px rgba(15, 23, 42, 0.1);
  --font:
    "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, "PingFang SC",
    "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, "Cascadia Code", "Sarasa Term SC", Consolas, monospace;
}
* {
  box-sizing: border-box;
}
body {
  font-family: var(--font);
  margin: 0;
  min-height: 100vh;
  color: var(--color-text);
  line-height: 1.5;
  background: var(--color-bg);
  background-image:
    radial-gradient(
      ellipse 120% 80% at 50% -20%,
      rgba(37, 99, 235, 0.12),
      transparent 55%
    ),
    radial-gradient(
      ellipse 90% 60% at 100% 100%,
      rgba(99, 102, 241, 0.08),
      transparent 50%
    ),
    radial-gradient(
      ellipse 60% 40% at 0% 80%,
      rgba(14, 165, 233, 0.06),
      transparent 45%
    );
}
.wrap {
  /* max-width: 980px; */
  max-width: 75%;
  margin: 2rem auto;
  padding: 2.25rem 2.5rem 2.5rem;
  background: var(--color-bg-elevated);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(148, 163, 184, 0.18);
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}
.wrap::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #2563eb, #4f46e5, #0ea5e9);
  opacity: 0.9;
}
h1 {
  margin: 0.35rem 0 0.5rem;
  font-size: 1.5rem;
  font-weight: 650;
  letter-spacing: -0.025em;
  line-height: 1.3;
  color: var(--color-text);
}
.muted {
  color: var(--color-text-muted);
  font-size: 0.875rem;
  line-height: 1.65;
  max-width: 58em;
  margin: 0 0 1.25rem;
}
.muted code {
  font-family: var(--mono);
  font-size: 0.8125em;
  padding: 0.15em 0.4em;
  background: #f1f5f9;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  color: #334155;
}
.row {
  display: grid;
  grid-template-columns: minmax(140px, 200px) 1fr;
  gap: 0.75rem 1.25rem;
  align-items: center;
  padding: 0.85rem 0;
  border-bottom: 1px solid #f1f5f9;
}
.row:has(+ .actions) {
  border-bottom: none;
}
p.muted + .row {
  margin-top: 0.5rem;
  padding-top: 1.1rem;
  border-top: 1px solid #e2e8f0;
  border-bottom: 1px solid #f1f5f9;
}
.row label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: #475569;
  line-height: 1.4;
  padding-top: 2px;
}
/* 自定义提示词 */
.row label .insert-btn {
  width: 100px;
  /* height: 30px; */
  background-color: #f4f4f5;
  padding: 2px;
  box-sizing: border-box;
  border-radius: 4px;
  border: 1px solid rgb(200, 201, 204);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 12px;
  font-weight: 500;
  color: #909399;
  font-family: "Inter";
  margin-top: 4px;
}
.row label .insert-btn:hover {
  background-color: #909399;
  border-color: rgb(200, 201, 204);
  color: rgb(244, 244, 245);
}
.row label .insert-btn:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 2px #fff,
    0 0 0 4px var(--color-border-focus);
}
/* 隐藏自定义提示词按钮 */
.row label .insert-btn[hidden] {
  display: none !important;
}

html.modal-scroll-lock,
body.modal-scroll-lock {
  overflow: hidden !important;
  overscroll-behavior: none;
}

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  box-sizing: border-box;
  overscroll-behavior: contain;
  contain: layout style;
}
.modal-root[hidden] {
  display: none !important;
}
#aiPromptTemplateModal.modal-root {
  z-index: 5100;
}
#authGuardModal.modal-root {
  z-index: 6000;
}
.auth-guard-modal .modal-backdrop {
  cursor: default;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  cursor: pointer;
}
.modal-panel {
  position: relative;
  z-index: 1;
  width: min(640px, 100%);
  max-height: min(88vh, 720px);
  display: flex;
  flex-direction: column;
  background: var(--color-bg-elevated);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  transform: translateZ(0);
  isolation: isolate;
}
.modal-panel-wide {
  width: min(720px, 100%);
}
.modal-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}
.modal-header h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 650;
  color: var(--color-text);
}
.modal-header .modal-sub {
  margin: 0.35rem 0 0;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  line-height: 1.5;
}
.modal-body {
  padding: 1rem 1.25rem;
  overflow: auto;
  flex: 1;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.modal-footer {
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--color-border);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
  flex-shrink: 0;
}
.modal-footer .btn-ghost {
  background: #f8fafc;
  color: var(--color-text);
  border: 1px solid var(--color-border);
  font-weight: 500;
}
.modal-footer .btn-ghost:hover:not([disabled]) {
  background: #f1f5f9;
  filter: none;
  box-shadow: none;
}
.modal-textarea {
  width: 100%;
  min-height: 220px;
  max-height: min(48vh, 420px);
  padding: 0.65rem 0.75rem;
  font-family: var(--mono);
  font-size: 0.8125rem;
  line-height: 1.55;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  resize: vertical;
  box-sizing: border-box;
  overflow: auto;
}
.modal-textarea:focus {
  outline: none;
  border-color: var(--color-border-focus);
  box-shadow: 0 0 0 3px var(--color-primary-subtle);
}
.modal-prompt-tabs {
  display: flex;
  gap: 0.35rem;
  margin-top: 12px;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}
.modal-prompt-tab {
  margin: 0;
  padding: 0.4rem 0.85rem;
  font-size: 0.8125rem;
  font-weight: 600;
  border: 1px solid var(--color-border);
  background: #f1f5f9;
  color: var(--color-text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  min-height: unset;
  box-shadow: none;
  filter: none;
}
.modal-prompt-tab:hover:not([disabled]) {
  background: #e2e8f0;
  filter: none;
  box-shadow: none;
}
.modal-prompt-tab.is-active {
  background: var(--color-primary-subtle);
  border-color: var(--color-border-focus);
  color: var(--color-primary);
}
.modal-prompt-tab:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 2px #fff,
    0 0 0 4px var(--color-border-focus);
}
.modal-prompt-panel[hidden] {
  display: none !important;
}
.template-cards {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.template-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  background: #f8fafc;
}
.template-card h3 {
  margin: 0 0 0.35rem;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--color-text);
}
.template-card p {
  margin: 0 0 0.65rem;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  line-height: 1.55;
}
.template-card pre {
  margin: 0 0 0.65rem;
  padding: 0.5rem 0.6rem;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 0.72rem;
  line-height: 1.45;
  max-height: 120px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.template-card .btn-apply {
  min-height: 2rem;
  padding: 0.35rem 0.85rem;
  font-size: 0.8125rem;
  font-weight: 600;
}

input,
button {
  font-family: inherit;
  font-size: 0.875rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: #fafbfc;
  color: var(--color-text);
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    background 0.15s ease;
}
select {
  font-family: inherit;
  font-size: 0.875rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}
input:not([type="file"]):not([type="checkbox"]):not([type="radio"]),
select {
  width: 100%;
  min-width: 0;
  padding: 0.5rem 0.75rem;
}
input[type="checkbox"],
input[type="radio"] {
  width: auto;
  min-width: auto;
  margin: 0;
  accent-color: var(--color-primary);
  cursor: pointer;
}
.row.row-radio {
  align-items: start;
}
.row-radio-heading {
  font-size: 0.8125rem;
  font-weight: 500;
  color: #475569;
  line-height: 1.4;
  padding-top: 2px;
}
.row-radio-options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 1rem 1.25rem;
}
.radio-option {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--color-text);
  cursor: pointer;
  user-select: none;
}
input:not([type="file"]):not([type="checkbox"]):not([type="radio"]):hover,
select:hover {
  border-color: #cbd5e1;
  background-color: #fff;
}
input:not([type="file"]):not([type="checkbox"]):not([type="radio"]):focus,
select:focus {
  outline: none;
  border-color: var(--color-primary);
  background-color: #fff;
  box-shadow: 0 0 0 3px var(--color-primary-subtle);
}
input::placeholder {
  color: #94a3b8;
}
select {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-color: #fafbfc;
  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='%2364748b' d='M3 4.5L6 7.5L9 4.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.65rem center;
  padding-right: 2rem;
}
select:disabled {
  opacity: 0.72;
  cursor: not-allowed;
  background-color: #f1f5f9;
}
/** 禁用输入框 */
input:not([type="file"]):not([type="checkbox"]):not([type="radio"]):disabled {
  opacity: 0.72;
  cursor: not-allowed;
  background-color: #f1f5f9;
  color: #64748b;
}
input:not([type="file"]):not([type="checkbox"]):not(
    [type="radio"]
  ):disabled:hover {
  border-color: var(--color-border);
  background-color: #f1f5f9;
}
input:not([type="file"]):not([type="checkbox"]):not(
    [type="radio"]
  ):disabled:focus {
  border-color: var(--color-border);
  box-shadow: none;
}
select::-ms-expand {
  display: none;
}
input[type="file"] {
  width: 100%;
  max-width: 100%;
  padding: 0.5rem 0.65rem;
  font-size: 0.8125rem;
  cursor: pointer;
  background: #fff;
}
input[type="file"]::file-selector-button {
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  margin-right: 0.75rem;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: linear-gradient(180deg, #fff, #f8fafc);
  color: #334155;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s;
}
input[type="file"]:disabled {
  opacity: 0.72;
  cursor: not-allowed;
  background: #f1f5f9;
}
input[type="file"]:disabled::file-selector-button {
  cursor: not-allowed;
  opacity: 0.85;
}
input[type="file"]::file-selector-button:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.5rem;
  padding: 0.5rem 1.35rem;
  font-weight: 600;
  background: linear-gradient(180deg, #3b82f6, var(--color-primary));
  color: #fff;
  border: 1px solid rgba(30, 64, 175, 0.35);
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition:
    transform 0.12s ease,
    box-shadow 0.15s ease,
    filter 0.15s ease;
}
button:hover:not([disabled]) {
  /* transition: all 0.3s ease; */
  filter: brightness(1.05);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
  /* transform: translateY(-1px); */
}
button:active:not([disabled]) {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12);
}
button:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 3px var(--color-primary-subtle),
    0 1px 2px rgba(15, 23, 42, 0.12);
}
button[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
  filter: none;
  transform: none;
}
.actions {
  margin-top: 1.35rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}
button.btn-save-prefs {
  background: linear-gradient(180deg, #f8fafc, #e2e8f0);
  color: #334155;
  border: 1px solid var(--color-border);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}
button.btn-save-prefs:hover:not([disabled]) {
  filter: brightness(1.02);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.08);
}
.progress-section {
  margin-top: 1.75rem;
  display: none;
}
.progress-section.visible {
  display: block;
}
.progress-bar-wrap {
  height: 9px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 1.6rem;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.06);
}
.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #1d4ed8, #3b82f6, #60a5fa);
  border-radius: 999px;
  transition: width 0.35s ease;
  box-shadow: 0 0 12px rgba(37, 99, 235, 0.35);
}
.progress-bar-fill.indeterminate {
  width: 40%;
  animation: progress-indeterminate 1.5s ease-in-out infinite;
}
@keyframes progress-indeterminate {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(350%);
  }
}
.steps {
  display: flex;
  justify-content: space-between;
  position: relative;
  margin-bottom: 0.5rem;
  padding: 0.25rem 0;
}
.steps::before {
  content: "";
  position: absolute;
  top: 15px;
  left: 9%;
  right: 9%;
  height: 2px;
  background: linear-gradient(90deg, #e2e8f0, #e2e8f0);
  border-radius: 1px;
  z-index: 0;
}
.step {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  z-index: 1;
}
.step-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #f1f5f9;
  color: #94a3b8;
  border: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  transition:
    background 0.25s,
    color 0.25s,
    box-shadow 0.25s,
    border-color 0.25s;
}
.step--running .step-icon {
  background: #dbeafe;
  color: #1d4ed8;
  border-color: #93c5fd;
  box-shadow:
    0 0 0 2px #bfdbfe,
    0 2px 8px rgba(37, 99, 235, 0.2);
}
.step--running .step-icon.spin {
  animation: step-spin 0.8s linear infinite;
}
@keyframes step-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}
.step--done .step-icon {
  background: #dcfce7;
  color: #16a34a;
  border-color: #86efac;
  font-size: 0;
  box-shadow: 0 1px 3px rgba(22, 163, 74, 0.2);
}
.step--done .step-icon::after {
  content: "✓";
  font-size: 14px;
  font-weight: 700;
}
.step--error .step-icon {
  background: #fee2e2;
  color: #dc2626;
  border-color: #fecaca;
  font-size: 0;
  box-shadow: 0 1px 3px rgba(220, 38, 38, 0.15);
}
.step--error .step-icon::after {
  content: "!";
  font-size: 14px;
  font-weight: 800;
}
.step-label {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 500;
  color: #64748b;
}
.step--running .step-label,
.step--done .step-label {
  color: #0f172a;
}
.step--error .step-label {
  color: #b91c1c;
}
.step-detail {
  font-size: 10px;
  color: #94a3b8;
  margin-top: 3px;
  max-width: 100px;
  text-align: center;
  line-height: 1.35;
}
.log-section {
  margin-top: 1.75rem;
  padding-top: 1.25rem;
  border-top: 1px solid #e2e8f0;
}
.log-section h3 {
  margin: 0 0 0.6rem;
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #64748b;
}
pre#logBox {
  font-family: var(--mono);
  background: #0b1220;
  color: #e2e8f0;
  margin: 0;
  padding: 1rem 1.1rem;
  border-radius: var(--radius-md);
  border: 1px solid #1e293b;
  overflow: auto;
  font-size: 0.75rem;
  line-height: 1.55;
  max-height: 240px;
  white-space: pre-wrap;
  word-break: break-all;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.04),
    0 8px 24px rgba(15, 23, 42, 0.35);
}
.back-link {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;

  font-size: 0.8125rem;
  margin: 0 0 0.5rem;
}

.user-info {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.8125rem;
  min-width: 0;
  max-width: 100%;
  &:hover {
    color: var(--color-primary);
    cursor: pointer;
  }
}
.user-info-icon {
  display: inline-flex;
  flex-shrink: 0;
  color: inherit;
}
.user-info-icon svg {
  width: 1.55em;
  height: 1.55em;
  vertical-align: -0.125em;
}
.user-info-name {
  font-size: 16px;
  font-weight: 500;
  font-family: var(--font);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-info-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  max-width: min(46vw, 295px);
  min-width: 0;
}
.user-info-wrap .user-info:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 2px #fff,
    0 0 0 4px var(--color-border-focus);
  border-radius: 6px;
}
.user-info-popover {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 10px;
  box-sizing: border-box;
  width: 270px;
  max-width: min(92vw, 280px);
  z-index: 2000;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  /* 不要用 overflow:hidden，否则会裁掉指向上方的 .user-info-popover-arrow */
  overflow: visible;
  box-shadow:
    0 3px 6px -4px rgba(15, 23, 42, 0.12),
    0 6px 16px rgba(15, 23, 42, 0.08),
    0 9px 28px 8px rgba(15, 23, 42, 0.05);
}
.user-info-popover[hidden] {
  display: none !important;
}
.user-info-popover-arrow {
  position: absolute;
  top: -5px;
  right: 14px;
  z-index: 1;
  pointer-events: none;
  width: 8px;
  height: 8px;
  background: var(--color-bg-elevated);
  border-left: 1px solid var(--color-border);
  border-top: 1px solid var(--color-border);
  transform: rotate(45deg);
}
.user-info-popover-body {
  padding: 16px;
  min-width: 0;
  overflow: hidden;
}
.user-info-popover-hint {
  margin: 0;
  font-size: 14px;
  color: var(--color-text-muted);
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-info-popover-account {
  margin: 6px 0 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.35;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-info-logout-btn {
  display: block;
  width: 100%;
  margin: 0;
  padding: 10px 12px;
  border: none;
  border-top: 1px solid var(--color-border);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  background: transparent;
  color: #dc2626;
  font-size: 14px;
  font-family: var(--font);
  font-weight: 500;
  text-align: center;
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s;
}
.user-info-logout-btn:hover {
  background: #fef2f2;
  color: #b91c1c;
}
.user-info-logout-btn:focus-visible {
  outline: none;
  /* box-shadow: inset 0 0 0 2px var(--color-border-focus); */
  box-shadow: none;
}

.back-link a {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  color: #2563eb;
  text-decoration: none;
  font-size: 16px;
  font-weight: 500;
  padding: 0.2rem 0.35rem;
  margin: -0.2rem -0.35rem;
  border-radius: 6px;
  transition:
    background 0.15s,
    color 0.15s;
}
.back-link a:hover {
  background: #eff6ff;
  color: #1d4ed8;
}
.back-link a:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 2px #fff,
    0 0 0 4px #93c5fd;
}
@media (max-width: 640px) {
  .wrap {
    margin: 1rem;
    padding: 1.25rem 1.1rem;
  }
  .row {
    grid-template-columns: 1fr;
    gap: 0.35rem;
    align-items: start;
  }
  .row .row-label {
    padding-top: 0;
  }
  .row-radio-heading {
    padding-top: 0;
  }
  .steps {
    flex-wrap: wrap;
    gap: 0.75rem;
  }
  .steps::before {
    display: none;
  }
  .step {
    flex: 0 0 calc(50% - 0.4rem);
  }
}
