/* Briefplattform – Designsystem (Dunkel Standard, optional Hell) */
@font-face { font-family: "Caveat"; src: url("../fonts/Caveat.ttf") format("truetype"); font-weight: 400 700; font-display: swap; }
@font-face { font-family: "Dancing Script"; src: url("../fonts/DancingScript.ttf") format("truetype"); font-weight: 400 700; font-display: swap; }
@font-face { font-family: "Reenie Beanie"; src: url("../fonts/ReenieBeanie.ttf") format("truetype"); font-display: swap; }

:root {
  --bg: #f4f5fb; --bg2: #ffffff; --panel: rgba(255,255,255,.85); --panel-solid: #ffffff; --border: rgba(15,23,60,.10);
  --text: #121530; --muted: #5d6482; --accent: #5b5bf0; --accent2: #8b5cf6; --accent-soft: rgba(91,91,240,.10);
  --ok: #059669; --warn: #d97706; --bad: #dc2626; --input: #ffffff; --shadow: 0 8px 30px rgba(30,30,90,.08);
}
.dark {
  --bg: #0a0b17; --bg2: #0f1122; --panel: rgba(255,255,255,.045); --panel-solid: #141630; --border: rgba(255,255,255,.09);
  --text: #e7e9ff; --muted: #9aa0c4; --accent: #7c83ff; --accent2: #a78bfa; --accent-soft: rgba(124,131,255,.14);
  --ok: #34d399; --warn: #fbbf24; --bad: #f87171; --input: rgba(255,255,255,.05); --shadow: 0 10px 40px rgba(0,0,0,.35);
}
html { color-scheme: light; } html.dark { color-scheme: dark; }
body { background: var(--bg); color: var(--text); font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; -webkit-font-smoothing: antialiased; }
.bg-glow::before { content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background: radial-gradient(900px 500px at 12% -10%, rgba(99,102,241,.22), transparent 60%), radial-gradient(700px 420px at 100% 0%, rgba(168,85,247,.16), transparent 60%); }
.light-only { display: block; } .dark-only { display: none; } .dark .light-only { display: none; } .dark .dark-only { display: block; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.card-pad { padding: 1.25rem 1.5rem; }
.card-title { font-weight: 650; font-size: 1.02rem; letter-spacing: -.01em; }
.muted { color: var(--muted); } .text-ok { color: var(--ok); } .text-warn { color: var(--warn); } .text-bad { color: var(--bad); }
.btn { display: inline-flex; align-items: center; gap: .45rem; padding: .55rem 1rem; border-radius: 12px; font-weight: 600; font-size: .9rem; border: 1px solid var(--border); background: var(--panel); color: var(--text); cursor: pointer; transition: background .15s, border-color .15s, box-shadow .15s, color .15s; text-decoration: none; line-height: 1.2; }
.btn:hover { background: var(--accent-soft); border-color: var(--accent); }
.btn:focus-visible, .input:focus-visible, a:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; border-color: transparent; box-shadow: 0 6px 20px rgba(110,100,240,.35); }
.btn-primary:hover { background: linear-gradient(135deg, var(--accent), var(--accent2)); filter: brightness(1.08); box-shadow: 0 8px 26px rgba(110,100,240,.5); }
.btn-danger { color: var(--bad); } .btn-danger:hover { background: rgba(220,38,38,.12); border-color: var(--bad); }
.btn-sm { padding: .35rem .7rem; font-size: .8rem; border-radius: 10px; } .btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-icon { padding: .5rem; width: 2.3rem; height: 2.3rem; justify-content: center; }
.input, select.input, textarea.input { width: 100%; background: var(--input); border: 1px solid var(--border); border-radius: 12px; padding: .6rem .8rem; color: var(--text); font-size: .92rem; transition: border-color .15s, box-shadow .15s; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none; }
.input::placeholder { color: var(--muted); opacity: .7; }
select.input option { background: var(--panel-solid); color: var(--text); }
.label { display: block; font-size: .78rem; font-weight: 600; color: var(--muted); margin-bottom: .3rem; letter-spacing: .02em; }
.hint { font-size: .76rem; color: var(--muted); margin-top: .25rem; }
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .18rem .6rem; border-radius: 999px; font-size: .72rem; font-weight: 650; border: 1px solid transparent; white-space: nowrap; }
.badge-gray { background: rgba(148,152,190,.16); color: var(--muted); } .badge-blue { background: rgba(99,102,241,.16); color: var(--accent); }
.badge-green { background: rgba(16,185,129,.16); color: var(--ok); } .badge-amber { background: rgba(245,158,11,.16); color: var(--warn); }
.badge-red { background: rgba(239,68,68,.16); color: var(--bad); } .badge-violet { background: rgba(139,92,246,.18); color: var(--accent2); }
.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; } .tbl th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: .65rem .9rem; border-bottom: 1px solid var(--border); font-weight: 650; }
.tbl td { padding: .75rem .9rem; border-bottom: 1px solid var(--border); vertical-align: middle; } .tbl tr:last-child td { border-bottom: 0; } .tbl tbody tr:hover { background: var(--accent-soft); }
.navlink { display: flex; align-items: center; gap: .7rem; padding: .55rem .8rem; border-radius: 12px; color: var(--muted); font-weight: 550; font-size: .92rem; text-decoration: none; transition: background .15s, color .15s; }
.navlink i { font-size: 1.25rem; } .navlink:hover { background: var(--accent-soft); color: var(--text); }
.navlink.active { background: linear-gradient(135deg, rgba(99,102,241,.22), rgba(139,92,246,.16)); color: var(--text); box-shadow: inset 0 0 0 1px rgba(124,131,255,.35); }
.nav-sec { font-size: .68rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); padding: .9rem .8rem .3rem; font-weight: 700; opacity: .8; }
.stat { display: flex; flex-direction: column; gap: .2rem; } .stat .n { font-size: 1.9rem; font-weight: 750; letter-spacing: -.03em; } .stat .l { color: var(--muted); font-size: .8rem; }
.icon-chip { width: 2.6rem; height: 2.6rem; border-radius: 14px; display: grid; place-items: center; font-size: 1.4rem; background: linear-gradient(135deg, rgba(99,102,241,.25), rgba(139,92,246,.2)); color: var(--accent); }
.modal-back { position: fixed; inset: 0; background: rgba(5,6,18,.6); backdrop-filter: blur(4px); z-index: 80; display: none; align-items: center; justify-content: center; padding: 1rem; }
.modal-back.open { display: flex; } .modal { width: min(560px, 100%); max-height: 92vh; overflow: auto; background: var(--panel-solid); border: 1px solid var(--border); border-radius: 20px; box-shadow: 0 30px 80px rgba(0,0,0,.45); }
.modal.lg { width: min(860px, 100%); }
.toast-wrap { position: fixed; right: 1rem; bottom: 1rem; z-index: 100; display: flex; flex-direction: column; gap: .5rem; max-width: min(380px, calc(100vw - 2rem)); }
.toast { display: flex; gap: .7rem; align-items: flex-start; background: var(--panel-solid); border: 1px solid var(--border); border-left: 4px solid var(--accent); padding: .8rem 1rem; border-radius: 14px; box-shadow: var(--shadow); font-size: .9rem; }
.toast.ok { border-left-color: var(--ok); } .toast.err { border-left-color: var(--bad); } .toast.warn { border-left-color: var(--warn); }
.dropdown { position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px; background: var(--panel-solid); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow); padding: .4rem; z-index: 50; display: none; }
.dropdown.open { display: block; } .dropdown a, .dropdown button { display: flex; width: 100%; align-items: center; gap: .6rem; padding: .5rem .7rem; border-radius: 10px; color: var(--text); font-size: .9rem; text-decoration: none; background: none; border: 0; cursor: pointer; text-align: left; }
.dropdown a:hover, .dropdown button:hover { background: var(--accent-soft); }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); overflow-x: auto; } .tab { padding: .6rem 1rem; font-weight: 600; font-size: .9rem; color: var(--muted); border-bottom: 2px solid transparent; text-decoration: none; white-space: nowrap; cursor: pointer; background: none; border-top: 0; border-left: 0; border-right: 0; }
.tab:hover { color: var(--text); } .tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.alert { padding: .8rem 1rem; border-radius: 12px; font-size: .88rem; border: 1px solid; display: flex; gap: .6rem; align-items: flex-start; }
.alert-info { background: rgba(99,102,241,.1); border-color: rgba(99,102,241,.3); } .alert-warn { background: rgba(245,158,11,.1); border-color: rgba(245,158,11,.35); }
.alert-bad { background: rgba(239,68,68,.1); border-color: rgba(239,68,68,.35); } .alert-ok { background: rgba(16,185,129,.1); border-color: rgba(16,185,129,.35); }
.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex: none; } .switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: rgba(148,152,190,.35); border-radius: 999px; transition: background .2s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .2s; }
.switch input:checked + span { background: var(--accent); } .switch input:checked + span::before { transform: translateX(18px); }
.skeleton { background: linear-gradient(90deg, var(--accent-soft), transparent, var(--accent-soft)); background-size: 200% 100%; animation: sk 1.4s infinite; border-radius: 10px; } @keyframes sk { to { background-position: -200% 0; } }
.spinner { width: 1em; height: 1em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; display: inline-block; animation: spin .7s linear infinite; } @keyframes spin { to { transform: rotate(360deg); } }
.divider { height: 1px; background: var(--border); margin: 1rem 0; }
.kbd { font-family: ui-monospace, monospace; font-size: .72rem; padding: .1rem .4rem; border: 1px solid var(--border); border-radius: 6px; background: var(--panel); }
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); } .empty i { font-size: 2.6rem; opacity: .5; }
.tpl-card { transition: transform .18s, border-color .18s, box-shadow .18s; cursor: pointer; text-decoration: none; color: inherit; display: block; }
.tpl-card:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: 0 14px 40px rgba(99,102,241,.2); }
@media (prefers-reduced-motion: reduce) { * { animation-duration: .001ms !important; transition-duration: .001ms !important; } .tpl-card:hover { transform: none; } }

/* Editor */
.editor-shell { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 1rem; min-height: calc(100vh - 210px); }
.editor-shell.mode-source { grid-template-columns: 1fr; } .editor-shell.mode-source .pane-preview { display: none; }
.editor-shell.mode-preview { grid-template-columns: 1fr; } .editor-shell.mode-preview .pane-source { display: none; }
.editor-shell.fullscreen { position: fixed; inset: 0; z-index: 70; background: var(--bg); padding: 1rem; min-height: 0; overflow: hidden; }
.md-area { width: 100%; height: 100%; min-height: 520px; resize: none; font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .9rem; line-height: 1.6; background: var(--input); border: 1px solid var(--border); border-radius: 14px; padding: 1rem; color: var(--text); tab-size: 2; }
.md-area:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.tb { display: flex; flex-wrap: wrap; gap: .2rem; align-items: center; padding: .35rem; border: 1px solid var(--border); border-radius: 14px; background: var(--panel); }
.tb button { width: 2.15rem; height: 2.15rem; display: grid; place-items: center; border-radius: 9px; border: 0; background: none; color: var(--text); cursor: pointer; font-size: 1.15rem; }
.tb button:hover { background: var(--accent-soft); color: var(--accent); } .tb .sep { width: 1px; height: 1.4rem; background: var(--border); margin: 0 .2rem; }
.paper-wrap { overflow: auto; background: rgba(120,125,170,.14); border-radius: 14px; padding: 1.2rem; height: 100%; min-height: 520px; }
.paper-zoom { transform-origin: top center; margin: 0 auto; width: 210mm; }
.paper { position: relative; width: 210mm; height: 297mm; background: #fff; color: #111; margin: 0 auto 14px; box-shadow: 0 6px 30px rgba(0,0,0,.28); overflow: hidden; font-family: "DejaVu Sans", Verdana, system-ui, sans-serif; }
.paper .abs { position: absolute; } .paper .foot { position: absolute; left: 25mm; right: 20mm; bottom: 8mm; font-size: 6.5pt; color: #555; line-height: 1.35; }
.paper .foot-line { border-top: .5pt solid #999; margin-bottom: 1.2mm; } .paper .pg-head { position: absolute; left: 25mm; right: 20mm; top: 11mm; font-size: 7.5pt; color: #444; border-bottom: .4pt solid #bbb; padding-bottom: 1mm; }
.paper .org { font-size: 8.5pt; color: #333; line-height: 1.4; } .paper .org b { font-size: 10pt; color: #111; } .paper .small { font-size: 7.5pt; color: #444; line-height: 1.35; } .paper .tiny { font-size: 6.5pt; color: #555; }
.paper .addr { font-size: 10pt; line-height: 1.3; }
.paper .body { position: absolute; font-size: 10pt; line-height: 1.38; }
.letter-body h1 { font-size: 15pt; margin: 14pt 0 6pt; } .letter-body h2 { font-size: 13pt; margin: 12pt 0 5pt; } .letter-body h3 { font-size: 11.5pt; margin: 10pt 0 4pt; } .letter-body h4, .letter-body h5, .letter-body h6 { font-size: 10pt; margin: 8pt 0 3pt; }
.letter-body p { margin: 0 0 7pt; } .letter-body ul, .letter-body ol { margin: 0 0 7pt; padding-left: 5mm; } .letter-body ul { list-style: disc; } .letter-body ol { list-style: decimal; }
.letter-body li { margin-bottom: 2pt; } .letter-body blockquote { border-left: 2.5pt solid #bbb; margin: 6pt 0 8pt 2mm; padding: 1pt 0 1pt 4mm; color: #444; }
.letter-body pre { background: #f3f3f6; border: .5pt solid #ddd; padding: 3mm; font-size: 9pt; overflow: hidden; white-space: pre-wrap; } .letter-body code { font-family: ui-monospace, Menlo, monospace; background: #f0f0f4; font-size: 9pt; }
.letter-body pre code { background: none; } .letter-body table { border-collapse: collapse; margin: 3pt 0 8pt; width: 100%; } .letter-body th, .letter-body td { border: .5pt solid #999; padding: 1.5mm 2mm; text-align: left; vertical-align: top; }
.letter-body th { background: #eceef5; } .letter-body hr { border: 0; border-top: .6pt solid #888; margin: 8pt 0; } .letter-body img { max-width: 100%; } .letter-body a { color: #1d4ed8; text-decoration: underline; }
.letter-body .al-center { text-align: center; } .letter-body .al-right { text-align: right; } .letter-body .al-justify { text-align: justify; } .letter-body .subject { font-weight: bold; font-size: 11pt; margin: 0 0 9pt; } .letter-body .meta-line { margin-bottom: 9pt; }
.letter-body .pagebreak { height: 0; }
.letter-body strong, .letter-body b { font-weight: 700; } .letter-body em, .letter-body i { font-style: italic; } .letter-body del, .letter-body s { text-decoration: line-through; } .letter-body u { text-decoration: underline; }
.ph { background: rgba(250,204,21,.35); border-radius: 3px; padding: 0 2px; }
.sigpad { background: #fff; border: 1px dashed var(--border); border-radius: 14px; touch-action: none; cursor: crosshair; width: 100%; height: 220px; display: block; }
.dropzone { border: 2px dashed var(--border); border-radius: 18px; padding: 2.5rem 1rem; text-align: center; transition: border-color .2s, background .2s; cursor: pointer; }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.progress { height: 6px; border-radius: 999px; background: var(--accent-soft); overflow: hidden; } .progress > div { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width .2s; }
@media (max-width: 1024px) { .editor-shell { grid-template-columns: 1fr; } .editor-shell .pane-preview { display: none; } .editor-shell.mode-preview .pane-source { display: none; } .editor-shell.mode-preview .pane-preview { display: block; } }
@media print { aside, header.topbar, .no-print { display: none !important; } body { background: #fff; } }
