:root {
  --bg: #020617;
  --panel: #0f172a;
  --panel-2: #111827;
  --line: #243041;
  --text: #e5eefb;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-2: #0ea5e9;
  --success: #22c55e;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(0,0,0,.28);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top right, rgba(56,189,248,.18), transparent 26%),
    linear-gradient(180deg, #020617 0%, #08111f 100%);
  color: var(--text);
}
.wrap { width: min(1280px, calc(100% - 24px)); margin: 0 auto; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  backdrop-filter: blur(12px);
  background: rgba(2, 6, 23, .72);
  border-bottom: 1px solid rgba(148,163,184,.12);
}
.topbar-inner {
  display: flex; justify-content: space-between; align-items: center;
  min-height: 72px;
}
.brand {
  font-size: 1.3rem; font-weight: 800; letter-spacing: .08em;
}
.muted { color: var(--muted); }
.app-grid {
  display: grid; grid-template-columns: 320px 1fr; gap: 18px;
  padding: 20px 0 28px;
}
.card {
  background: rgba(15,23,42,.9);
  border: 1px solid rgba(148,163,184,.12);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.sidebar, .main { padding: 18px; }
.sidebar h2, .main h1 { margin-top: 0; }
.template-list { display: flex; flex-direction: column; gap: 10px; }
.template-item {
  display: flex; flex-direction: column; gap: 6px;
  padding: 14px; border-radius: 14px; text-decoration: none;
  border: 1px solid rgba(148,163,184,.12);
  color: var(--text); background: rgba(15, 23, 42, .72);
}
.template-item span { color: var(--muted); font-size: .95rem; }
.template-item.active, .template-item:hover {
  border-color: rgba(56,189,248,.55);
  transform: translateY(-1px);
}
.doc-header {
  display: flex; justify-content: space-between; gap: 12px; align-items: flex-start;
  margin-bottom: 14px;
}
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.primary-btn, .ghost-btn {
  border: 0; border-radius: 12px; padding: 12px 16px;
  font-weight: 700; cursor: pointer; text-decoration: none;
}
.primary-btn { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #001018; }
.ghost-btn {
  background: rgba(15,23,42,.8); color: var(--text);
  border: 1px solid rgba(148,163,184,.18);
}
.split { display: grid; grid-template-columns: 360px 1fr; gap: 16px; }
.form-panel {
  display: flex; flex-direction: column; gap: 12px;
}
.field { display: flex; flex-direction: column; gap: 8px; }
.field span { font-size: .95rem; color: var(--muted); }
.field input, .field textarea {
  width: 100%; background: #0b1220; color: var(--text);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; font: inherit;
}
.field input:focus, .field textarea:focus {
  outline: none; border-color: rgba(56,189,248,.7);
  box-shadow: 0 0 0 4px rgba(56,189,248,.12);
}
.preview-panel {
  min-height: 600px; display: flex; flex-direction: column;
  border: 1px dashed rgba(148,163,184,.15);
  border-radius: 16px; overflow: hidden;
}
.preview-toolbar {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid rgba(148,163,184,.1);
  background: rgba(2,6,23,.35);
}
.preview-paper {
  background: #fff; color: #111827; margin: 16px; padding: 28px;
  border-radius: 16px; min-height: 520px; line-height: 1.72;
  white-space: normal; box-shadow: 0 6px 24px rgba(15,23,42,.2);
}
.notice {
  margin-top: 18px; padding: 16px; border-radius: 16px;
  background: rgba(56,189,248,.08);
  border: 1px solid rgba(56,189,248,.16);
}
@media (max-width: 980px) {
  .app-grid, .split { grid-template-columns: 1fr; }
  .doc-header { flex-direction: column; }
}
@media print {
  body { background: #fff; color: #000; }
  .topbar, .sidebar, .doc-header, .form-panel, .notice, .preview-toolbar { display: none !important; }
  .wrap, .app-grid, .main, .preview-panel { width: 100%; margin: 0; padding: 0; border: 0; box-shadow: none; }
  .preview-paper { margin: 0; padding: 0; box-shadow: none; border-radius: 0; }
}
