:root {
  --ink: #111820;
  --muted: #5d6570;
  --paper: #f7f9fb;
  --panel: #ffffff;
  --line: #d4dae1;
  --accent: #335f94;
  --accent-dark: #243544;
  --blue: #335f94;
  --green: #526f89;
  --gold: #8aa6bf;
  --shadow: 0 16px 42px rgba(17, 24, 32, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 88% 8%, rgba(51, 95, 148, 0.1), transparent 30%),
    linear-gradient(135deg, #f7f9fb 0%, #eef3f6 100%);
  font-family: "PingFang SC", "Microsoft YaHei", "Aptos", "Helvetica Neue", sans-serif;
}

button,
textarea,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.shell {
  width: min(1440px, calc(100vw - 40px));
  min-height: calc(100vh - 40px);
  margin: 20px auto;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 14px;
}

.topbar,
.toolbar,
.pane {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.topbar {
  min-height: 92px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 22px;
}

.brandmark {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  color: #f7f9fb;
  background: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.8);
  font-family: "Songti SC", "STSong", "SimSun", serif;
  font-size: 22px;
  letter-spacing: 0;
}

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

h1,
h2 {
  margin: 0;
}

h1 {
  font-family: "Songti SC", "STSong", "SimSun", serif;
  font-size: clamp(28px, 4vw, 48px);
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
  line-height: 1.2;
}

.status-pill {
  margin-left: auto;
  padding: 8px 12px;
  border: 1px solid var(--line);
  background: #eef3f6;
  color: var(--blue);
  font-size: 13px;
  font-weight: 700;
}

.status-pill.is-ready {
  color: #314b25;
  background: #e2ead4;
}

.status-pill.is-warning {
  color: var(--accent-dark);
  background: #f1d9cd;
}

.toolbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 12px;
}

.segmented,
.format-grid {
  display: flex;
  gap: 8px;
  min-width: 0;
}

.format-grid {
  justify-content: center;
  flex-wrap: wrap;
}

.segment,
.format,
.primary-action,
.plain-action,
.pick-file-btn,
.icon-btn,
.download-btn {
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease, color 160ms ease;
}

.segment,
.primary-action,
.plain-action,
.pick-file-btn,
.download-btn {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  font-weight: 700;
  text-decoration: none;
}

.format {
  min-width: 72px;
  height: 42px;
  font-size: 13px;
  font-weight: 800;
}

.segment:hover,
.format:hover,
.primary-action:hover,
.icon-btn:hover,
.download-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(21, 21, 19, 0.28);
}

.segment.is-active,
.format.is-active,
.primary-action {
  background: var(--ink);
  color: #f7f9fb;
}

.primary-action {
  background: var(--ink);
  border-color: var(--ink);
}

.plain-action {
  background: var(--blue);
  border-color: var(--blue);
  color: #f7f9fb;
}

.pick-file-btn {
  min-height: 36px;
  margin-top: 2px;
  background: var(--blue);
  color: #f7f9fb;
}

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 0.94fr) minmax(0, 1.06fr);
  gap: 14px;
}

.pane {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto 1fr;
  padding: 16px;
}

.result-pane {
  grid-template-rows: auto 1fr auto;
}

.pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
}

.download-btn.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

.dropzone {
  min-height: 118px;
  margin-bottom: 12px;
  display: grid;
  place-items: center;
  gap: 6px;
  padding: 18px;
  border: 1px dashed rgba(51, 95, 148, 0.28);
  background:
    linear-gradient(135deg, rgba(36, 76, 101, 0.08), transparent 54%),
    rgba(255, 255, 255, 0.74);
  text-align: center;
  cursor: pointer;
}

.file-queue {
  display: grid;
  gap: 8px;
  margin: 0 0 12px;
}

.url-box {
  display: grid;
  gap: 8px;
  margin: 0 0 12px;
  padding: 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
}

.url-box label {
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.url-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.url-row input {
  min-width: 0;
  min-height: 42px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
  padding: 0 12px;
  outline: none;
}

.url-row input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(36, 76, 101, 0.14);
}

.url-box small {
  color: var(--muted);
  line-height: 1.45;
}

.queue-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 12px;
  align-items: center;
  padding: 9px 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  font-size: 13px;
}

.queue-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.queue-status {
  padding: 4px 7px;
  background: #efe4ce;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

.queue-item.is-done .queue-status {
  color: #314b25;
  background: #e2ead4;
}

.queue-item.is-error .queue-status {
  color: var(--accent-dark);
  background: #f4ded4;
}

.queue-message {
  grid-column: 1 / -1;
  color: var(--muted);
  line-height: 1.35;
}

.dropzone.is-dragging {
  border-color: var(--accent);
  background-color: #fff4e4;
}

.dropzone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.drop-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  color: var(--blue);
  background: #e8eef0;
  border: 1px solid rgba(36, 76, 101, 0.14);
}

.dropzone strong {
  font-size: 16px;
}

.dropzone small {
  color: var(--muted);
}

textarea {
  width: 100%;
  min-height: 0;
  resize: none;
  border: 1px solid var(--line);
  outline: none;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  padding: 16px;
  line-height: 1.62;
  font-size: 15px;
}

textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(36, 76, 101, 0.14);
}

.preview-frame {
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--line);
  background: #ffffff;
}

.rendered-preview {
  max-width: 850px;
  margin: 0 auto;
  padding: 36px;
  line-height: 1.72;
}

.rendered-preview h1,
.rendered-preview h2,
.rendered-preview h3 {
  font-family: "Songti SC", "STSong", "SimSun", serif;
  line-height: 1.25;
}

.rendered-preview h1 {
  font-size: 32px;
  margin: 0 0 18px;
}

.rendered-preview h2 {
  margin-top: 28px;
  padding-top: 14px;
  border-top: 2px solid #dce7f0;
  color: var(--blue);
}

.rendered-preview table {
  width: 100%;
  border-collapse: collapse;
  margin: 18px 0;
  font-size: 14px;
}

.rendered-preview th,
.rendered-preview td {
  border: 1px solid var(--line);
  padding: 10px;
  text-align: left;
}

.rendered-preview th {
  background: #eef3f6;
}

.markdown-output {
  height: 100%;
  border: 0;
  box-shadow: none;
}

.notice {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding: 10px 12px;
  color: var(--muted);
  background: rgba(238, 243, 246, 0.9);
  border: 1px solid var(--line);
  font-size: 13px;
}

.notice.is-error {
  color: var(--accent-dark);
  background: #f4ded4;
}

svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.1;
}

@media (max-width: 980px) {
  .shell {
    width: min(100vw - 20px, 760px);
    margin: 10px auto;
  }

  .toolbar,
  .workspace {
    grid-template-columns: 1fr;
  }

  .segmented {
    width: 100%;
  }

  .segment {
    flex: 1;
  }

  .workspace {
    min-height: auto;
  }

  .pane {
    min-height: 520px;
  }
}

@media (max-width: 560px) {
  .topbar {
    align-items: flex-start;
    padding: 14px;
  }

  .brandmark {
    width: 48px;
    height: 48px;
    font-size: 18px;
  }

  .status-pill {
    display: none;
  }

  .format {
    flex: 1 1 78px;
  }

  .pane {
    padding: 12px;
  }

  .rendered-preview {
    padding: 22px;
  }
}
