:root {
  color-scheme: light;
  --bg: #f7f9fc;
  --surface: #ffffff;
  --text: #172033;
  --muted: #637083;
  --line: #d9e2ee;
  --primary: #2563eb;
  --primary-strong: #1d4ed8;
  --primary-soft: #edf4ff;
  --accent: #b45309;
  --success: #15803d;
  --danger: #dc2626;
  --code-bg: #111827;
  --radius: 8px;
  font-family: "Microsoft YaHei UI", "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(180deg, #eef4ff 0, rgba(238, 244, 255, 0) 240px),
    var(--bg);
}

button,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.eyebrow,
.section-label {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.2;
  letter-spacing: 0;
}

h1 {
  font-size: 30px;
}

h2 {
  font-size: 20px;
}

.local-badge,
.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 12px;
  color: var(--success);
  background: var(--surface);
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

.badge-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 0.82fr) minmax(420px, 1.18fr);
  gap: 18px;
}

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

.input-panel,
.result-panel {
  padding: 20px;
}

.panel-head,
.result-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
}

.segment {
  min-height: 44px;
  border: 0;
  color: var(--muted);
  background: #fff;
  font-weight: 700;
  transition: background 160ms ease, color 160ms ease;
}

.segment + .segment {
  border-left: 1px solid var(--line);
}

.segment:hover,
.segment:focus-visible {
  color: var(--primary-strong);
  background: var(--primary-soft);
}

.segment.is-active {
  color: #fff;
  background: var(--primary);
}

.dropzone {
  display: grid;
  place-items: center;
  min-height: 210px;
  border: 2px dashed #a8b8ce;
  border-radius: var(--radius);
  padding: 24px;
  color: var(--muted);
  background: #fbfdff;
  text-align: center;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease;
  cursor: pointer;
}

.dropzone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.dropzone.is-dragging,
.dropzone:hover,
.dropzone:focus-within {
  border-color: var(--primary);
  color: var(--primary-strong);
  background: var(--primary-soft);
}

.drop-icon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  margin-bottom: 12px;
  border-radius: var(--radius);
  color: var(--primary);
  background: #e7f0ff;
}

svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.drop-title {
  display: block;
  margin-bottom: 6px;
  color: var(--text);
  font-size: 18px;
  font-weight: 800;
}

.drop-subtitle,
.privacy-note {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.file-meta {
  display: grid;
  gap: 10px;
  margin: 16px 0 0;
}

.file-meta div {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 10px;
  align-items: baseline;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.file-meta dt {
  color: var(--muted);
  font-size: 13px;
}

.file-meta dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: 700;
}

.privacy-note {
  margin: 14px 0 0;
}

.status-chip {
  color: var(--muted);
  border-radius: var(--radius);
}

.status-chip.is-success {
  color: var(--success);
}

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

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.stat {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #fbfdff;
}

.stat span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 13px;
}

.stat strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 22px;
  line-height: 1.2;
}

textarea {
  width: 100%;
  min-height: 340px;
  resize: vertical;
  border: 1px solid #263448;
  border-radius: var(--radius);
  padding: 14px;
  color: #e5e7eb;
  background: var(--code-bg);
  line-height: 1.55;
  outline: none;
}

textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

textarea::placeholder {
  color: #9ca3af;
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border-radius: var(--radius);
  padding: 0 16px;
  font-weight: 800;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, opacity 160ms ease;
}

.primary-button {
  border: 1px solid var(--primary);
  color: #fff;
  background: var(--primary);
}

.primary-button:hover,
.primary-button:focus-visible {
  background: var(--primary-strong);
  border-color: var(--primary-strong);
}

.secondary-button {
  border: 1px solid var(--line);
  color: var(--text);
  background: #fff;
}

.secondary-button:hover,
.secondary-button:focus-visible {
  color: var(--primary-strong);
  border-color: var(--primary);
  background: var(--primary-soft);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.button-icon {
  display: inline-grid;
  place-items: center;
}

@media (max-width: 860px) {
  .app-shell {
    width: min(100% - 24px, 680px);
    padding: 22px 0;
  }

  .topbar,
  .workspace {
    display: block;
  }

  .local-badge {
    margin-top: 14px;
  }

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

  .stats {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  h1 {
    font-size: 24px;
  }

  .segmented,
  .actions {
    grid-template-columns: 1fr;
  }

  .segmented,
  .actions {
    display: grid;
  }

  .segment + .segment {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .file-meta div {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
