:root {
  color-scheme: light;
  --bg: #f3f5f7;
  --card: #ffffff;
  --text: #1a1d21;
  --muted: #69717a;
  --line: #d9dee3;
  --accent: #0a63a8;
  --danger: #b42318;
  --success: #137a40;
  --shadow: 0 6px 24px rgba(0,0,0,.07);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin:0; min-height:100%; background:var(--bg); color:var(--text); }
body { padding-bottom: env(safe-area-inset-bottom); }
button, input, textarea, select { font: inherit; }
button { cursor:pointer; }
.app-header {
  position: sticky; top:0; z-index:30; background:rgba(255,255,255,.96);
  backdrop-filter: blur(14px); border-bottom:1px solid var(--line);
  padding: max(10px, env(safe-area-inset-top)) 18px 10px;
  display:flex; align-items:center; justify-content:space-between; gap:16px;
}
.brand-wrap { display:flex; align-items:center; gap:14px; min-width:0; }
.brand-logo { width:112px; max-height:52px; object-fit:contain; object-position:left center; }
.app-header h1 { font-size:21px; margin:0; line-height:1.15; }
.subline { color:var(--muted); font-size:12px; margin-top:3px; }
.header-actions { display:flex; gap:8px; flex-wrap:wrap; justify-content:flex-end; }
.storage-bar { background:#eef8f1; color:#175d35; border-bottom:1px solid #cce5d4; padding:8px 18px; font-size:13px; }
.app-main { max-width:1120px; margin:0 auto; padding:22px 18px 60px; }
.page-title { display:flex; align-items:flex-start; justify-content:space-between; gap:14px; margin-bottom:18px; }
.page-title h2 { margin:0; font-size:28px; }
.page-title p { margin:5px 0 0; color:var(--muted); }
.grid { display:grid; gap:14px; }
.object-grid { grid-template-columns:repeat(auto-fit,minmax(270px,1fr)); }
.card { background:var(--card); border:1px solid var(--line); border-radius:16px; padding:16px; box-shadow:var(--shadow); }
.object-card { display:flex; flex-direction:column; gap:8px; min-height:150px; }
.object-card h3 { margin:0; font-size:19px; }
.muted { color:var(--muted); }
.small-text { font-size:13px; }
.row { display:flex; gap:10px; align-items:center; flex-wrap:wrap; }
.row.between { justify-content:space-between; }
.stack { display:flex; flex-direction:column; gap:12px; }
button, .button {
  border:1px solid transparent; border-radius:11px; padding:10px 14px;
  background:var(--accent); color:#fff; font-weight:600; text-decoration:none;
  display:inline-flex; align-items:center; justify-content:center; gap:7px;
}
button.secondary, .button.secondary { background:#eef3f7; color:#17334a; border-color:#d8e0e7; }
button.ghost { background:#fff; color:#26333d; border-color:var(--line); }
button.danger { background:#fff2f0; color:var(--danger); border-color:#f1c6c0; }
button.small { padding:7px 10px; font-size:13px; }
button:disabled { opacity:.45; cursor:not-allowed; }
input[type=text], textarea, select {
  width:100%; border:1px solid #cfd5db; border-radius:10px; padding:11px 12px; background:#fff; color:var(--text);
}
textarea { resize:vertical; min-height:110px; }
label.field { display:flex; flex-direction:column; gap:6px; font-weight:600; font-size:14px; }
label.field span.help { font-size:12px; color:var(--muted); font-weight:400; }
.section-title { margin:0 0 12px; font-size:18px; }
.back-link { background:none; border:0; color:var(--accent); padding:0; font-weight:600; }
.notice { border-radius:12px; padding:12px 14px; background:#fff8e7; border:1px solid #f1dca1; color:#674d0a; }
.success { background:#eef8f1; border-color:#cce5d4; color:#175d35; }
.photo-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(230px,1fr)); gap:14px; }
.photo-card { overflow:hidden; padding:0; }
.photo-thumb { width:100%; height:180px; object-fit:cover; display:block; background:#e9edf0; }
.photo-card-body { padding:12px; display:flex; flex-direction:column; gap:9px; }
.rich-toolbar { display:flex; gap:6px; flex-wrap:wrap; align-items:center; padding:8px; background:#f6f8fa; border:1px solid var(--line); border-bottom:0; border-radius:10px 10px 0 0; }
.rich-editor { min-height:130px; background:#fff; border:1px solid var(--line); border-radius:0 0 10px 10px; padding:12px; outline:none; line-height:1.45; }
.rich-editor:focus { border-color:#7aaed4; box-shadow:0 0 0 3px rgba(10,99,168,.12); }
.color-dot { width:26px; height:26px; border-radius:50%; padding:0; border:2px solid #fff; box-shadow:0 0 0 1px #b9c0c6; }
.mode-toggle { display:flex; overflow:hidden; border:1px solid var(--line); border-radius:8px; }
.mode-toggle button { border:0; border-radius:0; padding:6px 9px; background:#fff; color:#333; font-size:12px; }
.mode-toggle button.active { background:#dceaf5; color:#124b72; }
.canvas-wrap { background:#15191d; border-radius:14px; overflow:hidden; display:flex; justify-content:center; align-items:center; min-height:240px; }
canvas.image-canvas { max-width:100%; height:auto; display:block; touch-action:none; }
.tool-row { display:flex; flex-wrap:wrap; gap:8px; align-items:center; }
.tool-choice.active { background:#dceaf5; color:#124b72; border-color:#8fb8d5; }
.crop-controls { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; }
.crop-controls label { font-size:13px; color:var(--muted); }
.crop-controls input[type=range] { width:100%; }
.segmented { display:flex; flex-wrap:wrap; gap:6px; }
.segmented button { background:#fff; color:#26333d; border:1px solid var(--line); padding:7px 10px; font-size:13px; }
.segmented button.active { background:#dceaf5; border-color:#8fb8d5; color:#124b72; }
.dialog-backdrop { position:fixed; inset:0; background:rgba(0,0,0,.35); z-index:80; display:flex; align-items:center; justify-content:center; padding:20px; }
.dialog { width:min(560px,100%); max-height:90vh; overflow:auto; background:#fff; border-radius:18px; padding:18px; box-shadow:0 22px 70px rgba(0,0,0,.25); }
.dialog h3 { margin-top:0; }
.toast { position:fixed; bottom:calc(22px + env(safe-area-inset-bottom)); left:50%; transform:translateX(-50%); background:#17202a; color:#fff; padding:10px 14px; border-radius:12px; z-index:100; box-shadow:var(--shadow); max-width:90%; text-align:center; }
.empty { text-align:center; padding:48px 20px; color:var(--muted); }
.empty .icon { font-size:50px; margin-bottom:8px; }
.pdf-choice { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.status-pill { display:inline-block; padding:4px 8px; border-radius:99px; font-size:12px; background:#eef3f7; color:#50606c; }
@media (max-width:700px) {
  .app-header { align-items:flex-start; }
  .brand-logo { width:82px; max-height:40px; }
  .app-header h1 { font-size:16px; }
  .subline { display:none; }
  .header-actions { gap:5px; }
  .header-actions button { font-size:11px; padding:6px 8px; }
  .app-main { padding:16px 12px 50px; }
  .page-title { flex-direction:column; }
  .page-title h2 { font-size:24px; }
  .crop-controls { grid-template-columns:1fr; }
  .pdf-choice { grid-template-columns:1fr; }
}
@media print {
  .no-print { display:none !important; }
}


/* v1.1: globaler Zurück-Button + integrierte PDF-Vorschau */
.header-back { flex:0 0 auto; white-space:nowrap; }
.pdf-preview-wrap { display:flex; flex-direction:column; gap:22px; align-items:center; }
.pdf-preview-page {
  width:min(100%, 794px); aspect-ratio:210/297; background:#fff; color:#111;
  box-shadow:0 10px 34px rgba(0,0,0,.12); padding:38px 42px 34px; position:relative; overflow:hidden;
}
.pdf-head { display:flex; justify-content:space-between; align-items:flex-start; gap:18px; }
.pdf-head img { width:150px; max-height:58px; object-fit:contain; object-position:right top; }
.pdf-contact { font-size:11px; line-height:1.35; color:#444; }
.pdf-doc-title { font-size:19px; font-weight:700; margin-top:10px; }
.pdf-rule { border-top:1px solid #bbb; margin:7px 0 11px; }
.pdf-object-meta { font-size:13px; color:#333; margin-bottom:14px; line-height:1.4; }
.pdf-instruction { font-size:15px; line-height:1.55; padding:12px 14px; background:#f7f7f7; border-radius:8px; }
.pdf-footer { position:absolute; bottom:22px; left:42px; right:42px; font-size:10px; color:#666; border-top:1px solid #ddd; padding-top:5px; }
.pdf-photo-grid { display:grid; grid-template-columns:1fr 1fr; gap:12px; height:calc(100% - 165px); }
.pdf-photo-grid.rows-2 { grid-template-rows:repeat(2,1fr); }
.pdf-photo-grid.rows-3 { grid-template-rows:repeat(3,1fr); }
.pdf-photo-item { border:1px solid #d6d6d6; border-radius:7px; padding:6px; display:flex; flex-direction:column; min-height:0; overflow:hidden; }
.pdf-photo-label { font-weight:700; font-size:11px; margin-bottom:4px; }
.pdf-img-box { flex:1; min-height:0; display:flex; align-items:center; justify-content:center; overflow:hidden; background:#fafafa; }
.pdf-img-box img { max-width:100%; max-height:100%; object-fit:contain; }
.pdf-caption { font-size:11px; line-height:1.25; margin-top:5px; max-height:48px; overflow:hidden; }
.pdf-photo-page.rows-3 .pdf-caption { font-size:9.5px; max-height:36px; }

@media (max-width:700px) {
  .app-header { gap:8px; }
  .header-back { padding:6px 8px; font-size:11px; }
  .pdf-preview-page { padding:20px 20px 26px; }
  .pdf-footer { left:20px; right:20px; bottom:12px; }
  .pdf-contact { font-size:8px; }
  .pdf-head img { width:100px; }
  .pdf-doc-title { font-size:15px; }
  .pdf-object-meta { font-size:10px; }
  .pdf-instruction { font-size:11px; }
  .pdf-photo-grid { height:calc(100% - 125px); gap:6px; }
  .pdf-photo-item { padding:4px; }
  .pdf-caption { font-size:8px; max-height:32px; }
  .pdf-photo-page.rows-3 .pdf-caption { font-size:7px; max-height:24px; }
}

@media print {
  body.printing-pdf-preview .app-header,
  body.printing-pdf-preview .storage-bar,
  body.printing-pdf-preview .no-print { display:none !important; }
  body.printing-pdf-preview { background:#fff !important; }
  body.printing-pdf-preview .app-main { max-width:none; margin:0; padding:0; }
  body.printing-pdf-preview .pdf-preview-wrap { display:block; }
  body.printing-pdf-preview .pdf-preview-page {
    width:210mm; height:297mm; aspect-ratio:auto; box-shadow:none; margin:0; padding:14mm;
    page-break-after:always; break-after:page;
  }
  body.printing-pdf-preview .pdf-preview-page:last-child { page-break-after:auto; break-after:auto; }
  body.printing-pdf-preview .pdf-footer { left:14mm; right:14mm; bottom:8mm; }
}
