:root {
  --bg: #0f1012;
  --bg-elevated: #15171a;
  --bg-soft: #1c1f23;
  --panel: rgba(24, 26, 30, 0.97);
  --panel-soft: rgba(30, 33, 38, 0.95);
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #eceef1;
  --muted: #8f959e;
  --accent: #78a8ff;
  --accent-soft: rgba(120, 168, 255, 0.14);
  --success: #78d7b1;
  --warning: #e4ba6a;
  --danger: #ff8f7f;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.28);
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  color: var(--text);
  font-family: "IBM Plex Sans", "Noto Sans SC", "Segoe UI", sans-serif;
  font-size: 14px;
  background:
    radial-gradient(circle at top left, rgba(120, 168, 255, 0.08), transparent 26rem),
    radial-gradient(circle at bottom right, rgba(255, 255, 255, 0.04), transparent 24rem),
    linear-gradient(180deg, #0d0f11 0%, #131519 100%);
}

.backdrop {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(0deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.5), transparent 92%);
}

h1,
h2,
h3,
h4,
p,
dl,
dd,
dt,
pre {
  margin: 0;
}

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

button,
input,
select,
textarea {
  width: 100%;
  border-radius: var(--radius-sm);
}

input,
select,
textarea {
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: rgba(13, 15, 18, 0.92);
  color: var(--text);
  outline: none;
  transition: border-color 140ms ease, background-color 140ms ease, box-shadow 140ms ease;
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--line-strong);
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(120, 168, 255, 0.58);
  box-shadow: 0 0 0 4px rgba(120, 168, 255, 0.11);
  background: rgba(15, 17, 21, 0.96);
}

input[type="file"] {
  padding: 10px 12px;
}

button {
  min-height: 42px;
  cursor: pointer;
  border: 1px solid transparent;
  color: #f5f8ff;
  font-weight: 600;
  background: linear-gradient(180deg, #5b7ea8 0%, #466482 100%);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.24);
}

button:hover {
  filter: brightness(1.05);
}

button.secondary {
  color: var(--text);
  border-color: var(--line-strong);
  background: linear-gradient(180deg, rgba(63, 68, 77, 0.9), rgba(42, 46, 53, 0.9));
  box-shadow: none;
}

button.ghost {
  min-width: 120px;
}

button:disabled {
  opacity: 0.65;
  cursor: wait;
}

label {
  display: grid;
  gap: 8px;
}

label span {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

code,
pre {
  font-family: "Iosevka", "SFMono-Regular", "Consolas", monospace;
}

.auth-shell,
.app-shell {
  width: min(1380px, calc(100vw - 40px));
  margin: 0 auto;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px 0;
}

.auth-brand {
  margin-bottom: 12px;
  text-align: center;
}

.auth-brand h1 {
  font-size: clamp(26px, 3vw, 34px);
  letter-spacing: -0.04em;
  font-weight: 600;
}

.auth-card,
.panel,
.card {
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.018), transparent 20%),
    var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.auth-card {
  width: min(420px, 100%);
  padding: 24px;
  border-radius: 16px;
}

.auth-card h2 {
  font-size: 16px;
  font-weight: 600;
}

.auth-form {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.inline-status {
  min-height: 22px;
  margin-top: 12px;
  font-size: 13px;
}

.inline-status.loading {
  color: var(--warning);
}

.inline-status.error {
  color: var(--danger);
}

.app-shell {
  padding: 18px 0 32px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(21, 23, 27, 0.92);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.26);
  backdrop-filter: blur(18px);
}

.brand-stack h1 {
  font-size: 22px;
  letter-spacing: -0.03em;
  font-weight: 600;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-badge {
  display: flex;
  align-items: center;
  min-width: 148px;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.035);
}

.user-badge strong {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.workspace {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 14px;
  margin-top: 14px;
  align-items: start;
}

.sidebar {
  display: grid;
  gap: 14px;
  position: sticky;
  top: 14px;
}

.results-column {
  min-width: 0;
}

.panel,
.card {
  border-radius: var(--radius-lg);
}

.panel {
  padding: 16px;
}

.panel-head {
  margin-bottom: 14px;
}

.panel-head h2,
.result-header h2,
.card h3 {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.panel-form .form-grid {
  display: grid;
  gap: 12px;
}

.actions {
  display: grid;
  gap: 8px;
  margin-top: 4px;
}

.status {
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.7;
}

.status.idle {
  background: rgba(120, 168, 255, 0.08);
  color: #9bc0ff;
}

.status.loading {
  background: rgba(228, 186, 106, 0.12);
  color: var(--warning);
}

.status.success {
  background: rgba(120, 215, 177, 0.12);
  color: var(--success);
}

.status.error {
  background: rgba(255, 143, 127, 0.12);
  color: var(--danger);
}

.warnings {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.warnings p {
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 143, 127, 0.1);
  color: var(--danger);
  line-height: 1.65;
}

.results {
  padding: 18px;
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.download-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.download-list a,
.download-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(120, 168, 255, 0.22);
  color: #a8c7ff;
  text-decoration: none;
  background: rgba(120, 168, 255, 0.08);
}

.download-action {
  width: auto;
  box-shadow: none;
}

.download-list a:hover,
.download-action:hover {
  background: rgba(120, 168, 255, 0.13);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.card {
  margin-top: 12px;
  padding: 14px;
  background: linear-gradient(180deg, rgba(46, 50, 58, 0.18), transparent 16%), var(--panel-soft);
}

.summary-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
  margin-top: 12px;
}

.summary-list div {
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.summary-list dt {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.summary-list dd {
  margin-top: 4px;
  font-size: 13px;
  line-height: 1.65;
}

.rich-text,
#quality-check {
  margin-top: 12px;
}

.text-block + .text-block {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.text-block h4 {
  color: var(--accent);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.text-block p,
.text-block ul,
pre {
  margin-top: 8px;
  font-size: 13px;
  color: #d9dee6;
  line-height: 1.8;
  white-space: pre-wrap;
  word-break: break-word;
}

.text-block ul {
  padding-left: 18px;
}

.raw-card {
  overflow: hidden;
}

.raw-card summary {
  cursor: pointer;
  list-style: none;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.raw-card summary::-webkit-details-marker {
  display: none;
}

.raw-card summary::after {
  content: "展开";
  float: right;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.raw-card[open] summary::after {
  content: "收起";
}

pre {
  padding: 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(12, 14, 17, 0.9);
  max-height: 460px;
  overflow: auto;
}

@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }
}

@media (max-width: 760px) {
  .app-shell,
  .auth-shell {
    width: min(100vw - 24px, 100%);
  }

  .topbar,
  .result-header,
  .top-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .summary-grid,
  .summary-list {
    grid-template-columns: 1fr;
  }

  .panel,
  .card,
  .auth-card {
    border-radius: 18px;
  }
}
