:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #059669;
  --accent-ink: #047857;
  --accent-soft: #ecfdf5;
  --danger: #dc2626;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.7 -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: inherit;
  text-decoration: none;
}

h1,
h2,
p {
  margin: 0;
}

/* 布局 */
.header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 24px;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 20px;
  font-size: 15px;
}

.nav-link {
  color: var(--muted);
  padding: 6px 0;
}

.nav-link:hover,
.nav-link.is-active {
  color: var(--ink);
}

.nav-link.is-active {
  box-shadow: inset 0 -2px 0 var(--accent);
}

.nav-user {
  max-width: 180px;
  color: var(--muted);
}

.main {
  flex: 1;
}

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 40px 24px 64px;
}

.container.narrow {
  max-width: 760px;
}

.footer {
  padding: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  border-top: 1px solid var(--line);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.stack-sm {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.center {
  display: flex;
  justify-content: center;
  margin-top: 16px;
}

.muted {
  color: var(--muted);
  font-size: 14px;
}

.ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty {
  padding: 48px 0;
  text-align: center;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

/* 首页 */
.hero {
  padding: 56px 0 40px;
  text-align: center;
}

.hero-title {
  font-size: clamp(32px, 6vw, 52px);
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.hero-sub {
  margin-top: 16px;
  font-size: 18px;
  color: var(--muted);
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.tool-card {
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.tool-card:hover {
  border-color: var(--accent);
  box-shadow: 0 10px 30px -18px rgba(5, 150, 105, 0.6);
  transform: translateY(-2px);
}

.tool-name {
  font-size: 22px;
  font-weight: 700;
}

.tool-go {
  margin-top: 8px;
  color: var(--accent-ink);
  font-weight: 600;
  font-size: 15px;
}

/* 页面标题与分节 */
.page-title {
  font-size: 28px;
  font-weight: 800;
  line-height: 1.3;
}

.page-intro {
  margin: 8px 0 28px;
  color: var(--muted);
}

.section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px 0;
  border-top: 1px solid var(--line);
}

.section-title {
  font-size: 16px;
  font-weight: 600;
}

.hint {
  color: var(--muted);
  font-size: 14px;
}

.submit-bar {
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

/* 表单控件 */
.input {
  width: 100%;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

.input:focus-visible,
.btn:focus-visible,
.dropzone:focus-visible,
.switch:focus-visible,
.tab:focus-visible,
.link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.textarea {
  resize: vertical;
}

.select {
  width: auto;
  max-width: 100%;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 14px;
  font-weight: 600;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: 8px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

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

.btn-primary {
  background: var(--ink);
  color: #fff;
  font-size: 16px;
}

.btn-primary:hover:not(:disabled) {
  background: #1e293b;
}

.btn-outline {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}

.btn-outline:hover:not(:disabled) {
  border-color: var(--ink);
}

.btn-sm {
  min-height: 34px;
  padding: 0 14px;
  font-size: 14px;
}

.btn-lg {
  padding: 0 36px;
}

.btn-block {
  width: 100%;
}

.link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent-ink);
  font: inherit;
  font-size: 14px;
  text-decoration: underline;
  cursor: pointer;
}

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

.switch {
  appearance: none;
  flex: none;
  width: 40px;
  height: 22px;
  margin: 0;
  border-radius: 11px;
  background: #cbd5e1;
  position: relative;
  cursor: pointer;
  transition: background 0.15s;
}

.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s;
}

.switch:checked {
  background: var(--accent);
}

.switch:checked::after {
  transform: translateX(18px);
}

input[type="checkbox"]:not(.switch) {
  width: 16px;
  height: 16px;
  margin: 0;
  flex: none;
  accent-color: var(--accent);
}

.range {
  flex: 1;
  accent-color: var(--accent);
}

.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 8px 16px;
  padding: 12px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--line);
  font-size: 15px;
}

/* 上传 */
.dropzone {
  padding: 32px 16px;
  border: 1.5px dashed #cbd5e1;
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.dropzone:hover,
.dropzone.is-over {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.dropzone-title {
  font-weight: 600;
}

.file-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  font-size: 15px;
}

.file-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 登录注册 */
.auth-wrap {
  display: flex;
  justify-content: center;
  padding: 56px 24px;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.auth-title {
  font-size: 24px;
  font-weight: 800;
}

.auth-foot {
  display: flex;
  justify-content: space-between;
}

/* 任务 */
.task-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 24px;
}

.task-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
}

.task-row:hover {
  border-color: var(--ink);
}

.task-main {
  min-width: 0;
}

.task-name {
  font-weight: 600;
}

.task-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex: none;
}

.task-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface);
}

.badge-finished {
  color: var(--accent-ink);
  border-color: #a7f3d0;
  background: var(--accent-soft);
}

.badge-failed {
  color: var(--danger);
  border-color: #fecaca;
  background: #fef2f2;
}

.waiting {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 56px 16px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

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

/* 结果 */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
}

.stat {
  padding: 16px;
}

.stat-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.block {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.compare {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.compare-label {
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}

.preview {
  margin: 0;
  padding: 12px;
  max-height: 320px;
  overflow: auto;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--line);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-all;
}

.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.tabs {
  display: inline-flex;
  padding: 4px;
  border-radius: 10px;
  background: #e2e8f0;
}

.tab {
  min-height: 36px;
  padding: 0 16px;
  border: 0;
  border-radius: 7px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.tab.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12);
}

.bars {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: 110px 1fr 130px;
  align-items: center;
  gap: 4px 12px;
  font-size: 14px;
}

.bar-label {
  font-weight: 600;
}

.bar-track {
  height: 10px;
  border-radius: 5px;
  background: var(--bg);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  min-width: 2px;
  border-radius: 5px;
  background: var(--accent);
}

.bar-value {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.bar-examples {
  grid-column: 2 / -1;
  font-size: 13px;
}

.tokens {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 420px;
  overflow: auto;
}

.token {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  font-size: 15px;
}

.token.is-content {
  background: var(--accent-soft);
  border-color: #a7f3d0;
}

.token i {
  font-style: normal;
  font-size: 11px;
  color: var(--muted);
}

/* 提示条 */
#toasts {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 10px 18px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-size: 14px;
  box-shadow: 0 8px 24px -8px rgba(15, 23, 42, 0.4);
}

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

.toast-success {
  background: var(--accent-ink);
}

@media (max-width: 640px) {
  .container {
    padding: 28px 16px 48px;
  }

  .bar-row {
    grid-template-columns: 84px 1fr;
  }

  .bar-value {
    grid-column: 1 / -1;
    text-align: left;
  }

  .bar-examples {
    grid-column: 1 / -1;
  }

  .nav-user {
    display: none;
  }
}
