:root {
  --doc-bg: #eef2f6;
  --doc-panel: #ffffff;
  --doc-text: #0f172a;
  --doc-muted: #64748b;
  --doc-border: #dbe4ef;
  --doc-border-strong: #cbd5e1;
  --doc-primary: #2563eb;
  --doc-primary-hover: #1d4ed8;
  --doc-danger: #b91c1c;
  --doc-radius: 14px;
  --doc-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 10px 28px rgba(15, 23, 42, 0.06);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body.doc-tool-page {
  margin: 0;
  min-height: 100vh;
  color: var(--doc-text);
  background: linear-gradient(180deg, #f8fafc 0%, var(--doc-bg) 36%, #edf2f7 100%);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  line-height: 1.6;
}

.doc-tool-header {
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--doc-border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.doc-tool-header-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.doc-tool-header h1 {
  margin: 0 0 0.18rem;
  font-size: 1.35rem;
  line-height: 1.25;
}

.doc-tool-header p {
  margin: 0;
  color: var(--doc-muted);
  font-size: 0.84rem;
}

.doc-tool-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.doc-tool-main {
  width: min(1240px, calc(100% - 2rem));
  margin: 1rem auto 2.5rem;
  display: grid;
  grid-template-columns: minmax(320px, 430px) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.doc-panel {
  background: var(--doc-panel);
  border: 1px solid var(--doc-border);
  border-radius: var(--doc-radius);
  box-shadow: var(--doc-shadow);
  padding: 1rem;
}

.doc-panel h2 {
  margin: 0 0 0.25rem;
  font-size: 1rem;
}

.doc-panel-subtitle {
  margin: 0 0 0.9rem;
  color: var(--doc-muted);
  font-size: 0.82rem;
}

.doc-field {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 0.82rem;
}

.doc-field label,
.doc-result label {
  font-size: 0.82rem;
  font-weight: 600;
  color: #334155;
}

.doc-field input[type="text"],
.doc-field input[type="file"],
.doc-field textarea,
.doc-result input {
  width: 100%;
  border: 1px solid var(--doc-border-strong);
  border-radius: 10px;
  background: #f8fafc;
  color: var(--doc-text);
  font: inherit;
  font-size: 0.9rem;
}

.doc-field input[type="text"],
.doc-result input {
  height: 2.5rem;
  padding: 0 0.7rem;
}

.doc-field input[type="file"] {
  padding: 0.58rem 0.7rem;
}

.doc-field textarea {
  min-height: 15rem;
  padding: 0.7rem;
  resize: vertical;
}

.doc-field input:focus,
.doc-field textarea:focus,
.doc-result input:focus {
  outline: none;
  border-color: var(--doc-primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.doc-hint {
  min-height: 1.1rem;
  color: var(--doc-muted);
  font-size: 0.75rem;
}

.doc-hint.is-error {
  color: var(--doc-danger);
}

.doc-btn {
  min-height: 2.35rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0.45rem 0.85rem;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

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

.doc-btn-primary {
  color: #fff;
  background: var(--doc-primary);
  border-color: var(--doc-primary);
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.18);
}

.doc-btn-primary:hover:not(:disabled) {
  background: var(--doc-primary-hover);
  border-color: var(--doc-primary-hover);
}

.doc-btn-secondary {
  color: #1e293b;
  background: #fff;
  border-color: var(--doc-border-strong);
}

.doc-btn-secondary:hover:not(:disabled) {
  background: #f8fafc;
  border-color: #94a3b8;
}

.doc-publish-box {
  margin: 1rem 0;
  padding: 0.85rem;
  border: 1px solid #bfdbfe;
  border-radius: 12px;
  background: #eff6ff;
}

.doc-publish-box p {
  margin: 0.55rem 0 0;
  color: #475569;
  font-size: 0.78rem;
}

.doc-result {
  display: grid;
  gap: 0.4rem;
}

.doc-result-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.45rem;
}

.doc-result p {
  margin: 0;
  color: var(--doc-muted);
  font-size: 0.76rem;
}

.doc-preview-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.doc-preview {
  min-height: 42rem;
  max-height: calc(100vh - 11rem);
  overflow: auto;
  padding: 1.25rem;
  border: 1px solid var(--doc-border);
  border-radius: 12px;
  background: #fff;
}

.doc-preview p,
.doc-preview li {
  font-size: 0.95rem;
  line-height: 1.85;
}

.doc-preview p {
  margin: 0 0 0.85rem;
}

.doc-preview h1,
.doc-preview h2,
.doc-preview h3 {
  line-height: 1.35;
}

.doc-preview table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  table-layout: fixed;
}

.doc-preview th,
.doc-preview td {
  border: 1px solid var(--doc-border-strong);
  padding: 0.55rem 0.65rem;
  vertical-align: top;
  word-break: break-word;
}

.doc-empty {
  color: var(--doc-muted);
}

.doc-toast {
  position: fixed;
  left: 50%;
  bottom: 1.2rem;
  z-index: 50;
  transform: translateX(-50%);
  max-width: min(520px, calc(100% - 2rem));
  padding: 0.7rem 0.95rem;
  border-radius: 999px;
  color: #fff;
  background: rgba(15, 23, 42, 0.92);
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.2);
  font-size: 0.86rem;
}

@media (max-width: 900px) {
  .doc-tool-header-inner,
  .doc-tool-main {
    width: min(100% - 1rem, 720px);
  }

  .doc-tool-header-inner {
    flex-direction: column;
    align-items: stretch;
  }

  .doc-tool-main {
    grid-template-columns: 1fr;
  }

  .doc-preview {
    min-height: 30rem;
    max-height: none;
  }
}
