:root {
  --bg-color: #f5f7fb;
  --card-bg: #ffffff;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --success: #059669;
  --danger: #dc2626;
}

/* 认证检查遮罩样式 */
.auth-check-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(255, 255, 255, 0.9);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.auth-check-content {
  text-align: center;
  padding: 2rem;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border);
  border-top: 4px solid var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* 页面头部操作区域 */
.page-header__actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  background-color: var(--bg-color);
  color: var(--text);
  line-height: 1.6;
}

#toast-container {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 1000;
  max-width: min(360px, calc(100% - 3rem));
}

.toast {
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
  background-color: var(--card-bg);
  border: 1px solid var(--border);
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.toast--error {
  border-color: rgba(220, 38, 38, 0.25);
  background-color: rgba(254, 242, 242, 0.95);
  color: var(--danger);
}

.toast--success {
  border-color: rgba(5, 150, 105, 0.3);
  background-color: rgba(236, 253, 245, 0.95);
  color: var(--success);
}

.page-header {
  background: linear-gradient(135deg, #1d4ed8, #1e40af);
  color: #ffffff;
  padding: 2.5rem 1.5rem;
}

.page-header__content {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.page-header h1 {
  margin: 0 0 0.5rem;
  font-weight: 600;
}

.page-header p {
  margin: 0;
  font-size: 1rem;
  opacity: 0.9;
}

.page-main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.tab-navigation {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  background-color: var(--card-bg);
  border-radius: 1rem;
  padding: 0 1.5rem;
  box-shadow: 0 24px 48px rgba(15, 23, 42, 0.08);
  border: 1px solid rgba(148, 163, 184, 0.16);
}

.tab-nav-container {
  display: flex;
  gap: 0;
  flex: 1;
}

.tab-button {
  background-color: transparent;
  color: var(--muted);
  border: none;
  padding: 1rem 1.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.2s ease, border-bottom 0.2s ease;
  border-bottom: 3px solid transparent;
  position: relative;
}

.tab-button:hover {
  color: var(--text);
}

.tab-button--active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-content {
  background-color: var(--card-bg);
  border-radius: 1rem;
  padding: 1.5rem;
  box-shadow: 0 24px 48px rgba(15, 23, 42, 0.08);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  border: 1px solid rgba(148, 163, 184, 0.16);
}

.tab-panel {
  display: none;
}

.tab-panel--active {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.tab-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.tab-header h2 {
  margin: 0;
  font-size: 1.35rem;
}

.tab-subtitle {
  margin: 0.25rem 0 0;
  font-size: 0.95rem;
  color: var(--muted);
}

.results-section {
  background-color: var(--card-bg);
  border-radius: 1rem;
  padding: 1.5rem;
  box-shadow: 0 24px 48px rgba(15, 23, 42, 0.08);
  border: 1px solid rgba(148, 163, 184, 0.16);
}

.results.hidden {
  display: none;
}

.feature {
  background-color: var(--card-bg);
  border-radius: 1rem;
  padding: 1.5rem;
  box-shadow: 0 24px 48px rgba(15, 23, 42, 0.08);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  border: 1px solid rgba(148, 163, 184, 0.16);
}

.feature__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.feature__header h2 {
  margin: 0;
  font-size: 1.35rem;
}

.feature__subtitle {
  margin: 0.25rem 0 0;
  font-size: 0.95rem;
  color: var(--muted);
}

.button {
  background-color: var(--primary);
  color: #ffffff;
  border: none;
  border-radius: 999px;
  padding: 0.6rem 1.4rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.button:hover {
  background-color: var(--primary-hover);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.65;
  transform: none;
}

.spinner {
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.6);
  border-top-color: #ffffff;
  animation: spin 0.8s linear infinite;
}

.button--ghost .spinner {
  border-color: rgba(37, 99, 235, 0.35);
  border-top-color: var(--primary);
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.button--ghost {
  background-color: transparent;
  color: var(--primary);
  border: 1px solid rgba(37, 99, 235, 0.3);
}

.button--ghost:hover {
  background-color: rgba(37, 99, 235, 0.08);
}

.settings-panel {
  border-radius: 0.9rem;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background-color: rgba(248, 250, 252, 0.9);
  padding: 1.25rem;
}

.settings-panel.hidden {
  display: none;
}

.settings-form h3 {
  margin: 0 0 1rem;
  font-size: 1.05rem;
}

.settings-grid {
  display: grid;
  gap: 1rem;
}

@media (min-width: 720px) {
  .settings-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.95rem;
}

.field--checkbox {
  flex-direction: row;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  background-color: #ffffff;
  border: 1px solid rgba(148, 163, 184, 0.28);
}

.field--fieldset {
  border: 1px dashed rgba(148, 163, 184, 0.6);
  border-radius: 0.75rem;
  padding: 0.75rem 1rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.field--fieldset legend {
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0 0.25rem;
}

.checkbox-option {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.9rem;
}

.checkbox-option input {
  width: 1.05rem;
  height: 1.05rem;
}

input[type="text"],
input[type="number"],
select,
textarea {
  font: inherit;
  padding: 0.65rem 0.8rem;
  border-radius: 0.75rem;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background-color: #ffffff;
  transition: border 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: rgba(37, 99, 235, 0.5);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

textarea {
  resize: vertical;
  min-height: 160px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
}

.settings-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.results {
  background-color: rgba(248, 250, 252, 0.7);
  border-radius: 0.9rem;
  border: 1px solid rgba(148, 163, 184, 0.2);
  padding: 1rem 1.25rem;
  font-size: 0.95rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  white-space: normal;
}

.results p {
  margin: 0;
}

.result-debug {
  margin-top: 0.5rem;
  border: 1px dashed rgba(148, 163, 184, 0.4);
  border-radius: 0.75rem;
  padding: 0.75rem 1rem;
  background-color: #ffffff;
  color: var(--muted);
  font-size: 0.85rem;
}

.result-debug summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
  outline: none;
}

.result-debug summary:focus-visible {
  outline: 2px solid rgba(37, 99, 235, 0.4);
  outline-offset: 4px;
}

.result-debug pre {
  margin: 0.75rem 0 0;
  font-family: "SFMono-Regular", "JetBrains Mono", "Fira Code", monospace;
  font-size: 0.8rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.result-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 0;
  margin: 0;
  list-style: none;
}

.result-item {
  border-radius: 0.75rem;
  padding: 0.75rem 1rem;
  background-color: #ffffff;
  border: 1px solid rgba(148, 163, 184, 0.25);
  box-shadow: 0 10px 16px rgba(15, 23, 42, 0.05);
}

.result-item h4 {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
}

.result-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 0.35rem;
}

.result-snippet {
  margin: 0.35rem 0 0;
  color: var(--text);
  white-space: pre-line;
}

.empty-state {
  text-align: center;
  color: var(--muted);
}

.error-state {
  color: var(--danger);
  font-weight: 600;
}

.hint {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0;
}

.page-footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

code {
  background-color: rgba(15, 23, 42, 0.08);
  padding: 0.1rem 0.4rem;
  border-radius: 0.4rem;
}

@media (max-width: 640px) {
  .feature__header {
    flex-direction: column;
    align-items: stretch;
  }
  .form-actions,
  .settings-actions {
    justify-content: flex-start;
  }
  .tab-navigation {
    flex-direction: column;
    align-items: stretch;
    padding: 0;
  }
  .tab-nav-container {
    flex-direction: column;
  }
  .tab-button {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
    border-bottom: 3px solid transparent;
  }
  .tab-button--active {
    border-bottom-color: var(--primary);
  }
  .tab-navigation button[data-settings-trigger] {
    width: 100%;
  }
}

/* 模态窗口样式 */
.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.modal--visible {
  display: flex;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
}

.modal-content {
  position: relative;
  background-color: #ffffff;
  border-radius: 1rem;
  box-shadow: 0 30px 60px rgba(15, 23, 42, 0.25);
  width: min(720px, calc(100% - 2.5rem));
  max-height: calc(100vh - 4rem);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 1;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem 1rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.modal-header h3 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 0.25rem 0.6rem;
}

.modal-close:hover {
  color: var(--primary);
}

.modal-body {
  padding: 1rem 1.5rem;
  overflow-y: auto;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-meta {
  background-color: rgba(248, 250, 252, 0.75);
  border-radius: 0.75rem;
  border: 1px solid rgba(148, 163, 184, 0.2);
  padding: 0.75rem 1rem;
  display: grid;
  gap: 0.5rem;
}

.modal-meta-item {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.modal-meta-label {
  font-weight: 600;
  color: var(--text);
}

.modal-content-section h4 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  font-weight: 600;
}

.modal-text {
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(148, 163, 184, 0.2);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* 结果项操作按钮 */
.result-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

.result-actions .button {
  font-size: 0.85rem;
  padding: 0.4rem 0.9rem;
}

/* 可点击的引用链接 */
.citation-link {
  color: var(--primary);
  text-decoration: none;
  cursor: pointer;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}

.citation-link:hover {
  border-bottom-color: var(--primary);
}

@media (max-width: 640px) {
  .modal-content {
    width: calc(100% - 1.5rem);
    max-height: calc(100vh - 2rem);
  }

  .modal-body {
    padding: 0.75rem 1rem;
  }

  .modal-footer {
    padding: 0.75rem 1rem;
    flex-direction: column;
  }

  .modal-footer .button {
    width: 100%;
  }
}
