@font-face { font-family: 'Lora'; src: url('/fonts/lora.woff') format('woff'); font-weight: 400 700; font-style: normal; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('/fonts/inter-400.woff') format('woff'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('/fonts/inter-600.woff') format('woff'); font-weight: 600; font-style: normal; font-display: swap; }

:root {
  --paper: #fbf6e9; --paper-2: #f3ecd9; --paper-3: #e9dfc6;
  --ink: #3b3226; --ink-2: #6b5f4d; --ink-3: #9a8d77;
  --sage: #6f8f5a; --moss: #4d6b3a; --leaf: #9cc45a;
  --terra: #b5603f; --ochre: #c99a2e; --plum: #6b4a6b; --sky: #7aa3b5;
  --ok: #5d8f46; --warn: #c99a2e; --bad: #b5503a;
  --line: rgba(74, 59, 44, 0.18);
  --shadow: 0 2px 10px rgba(74, 59, 44, 0.14), 0 1px 2px rgba(74, 59, 44, 0.12);
  --radius: 14px;
  --top: 56px;
  --serif: 'Lora', 'Iowan Old Style', Georgia, serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 15px/1.45 var(--sans); color: var(--ink); background: var(--paper);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='2' seed='4'/><feColorMatrix values='0 0 0 0 .45 0 0 0 0 .36 0 0 0 0 .22 0 0 0 .07 0'/></filter><rect width='240' height='240' filter='url(%23n)'/></svg>");
  overflow: hidden; -webkit-tap-highlight-color: transparent; overscroll-behavior: none;
}
h1, h2, h3 { font-family: var(--serif); font-weight: 600; margin: 0; letter-spacing: .1px; }
a { color: var(--moss); }
button, input, select { font: inherit; color: inherit; }
input[type='range'], input[type='checkbox'] { accent-color: var(--moss); }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid rgba(77, 107, 58, .55); outline-offset: 2px; border-radius: 8px; }

/* ---------- Kopfleiste ---------- */
.topbar { position: fixed; inset: 0 0 auto 0; height: var(--top); display: flex; align-items: center; gap: 14px; padding: 0 12px; z-index: 30;
  background: linear-gradient(var(--paper) 70%, rgba(251, 246, 233, .86)); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); }
.brand-leaf { width: 30px; height: 30px; display: block; }
.brand-leaf img { width: 100%; height: 100%; display: block; }
.brand-name { font: 600 20px/1 var(--serif); }
.tabs { display: flex; gap: 4px; }
.tab { white-space: nowrap; padding: 8px 12px; border-radius: 10px; text-decoration: none; color: var(--ink-2); font-weight: 600; font-size: 14px; }
.tab[aria-current='page'] { background: var(--paper-3); color: var(--ink); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.save-state { font-size: 12px; color: var(--ink-3); min-width: 90px; text-align: right; }
.save-state.bad { color: var(--bad); }

main#view { position: fixed; inset: var(--top) 0 0 0; }

/* ---------- Knöpfe ---------- */
.btn { min-height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--paper); font-weight: 600; box-shadow: 0 1px 0 rgba(74, 59, 44, .12); display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn:hover { background: var(--paper-2); }
.btn.primary { background: var(--moss); border-color: #3b5a2c; color: #fff; }
.btn.primary:hover { background: #42602f; }
.btn.danger { color: var(--bad); }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; border: 1px solid transparent; background: transparent; display: inline-flex; align-items: center; justify-content: center; color: var(--ink); padding: 0; }
.icon-btn:hover { background: var(--paper-2); }
.icon-btn[disabled] { opacity: .35; cursor: default; }
.icon-btn svg, .btn svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Planer ---------- */
.planer { position: absolute; inset: 0; display: grid; grid-template-columns: 56px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
.dock { grid-row: 1 / 3; grid-column: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 4px; overflow-y: auto; border-right: 1px solid var(--line); background: rgba(251, 246, 233, .92); z-index: 10; }
.dock .sep { width: 28px; height: 1px; background: var(--line); margin: 4px 0; }
.tool { width: 46px; height: 46px; border-radius: 12px; border: 1px solid transparent; background: transparent; display: flex; align-items: center; justify-content: center; padding: 0; position: relative; color: var(--ink); }
.tool svg { width: 26px; height: 26px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.tool:hover { background: var(--paper-2); }
.tool[aria-pressed='true'] { background: var(--moss); color: #fff; box-shadow: var(--shadow); }
.tool .tip { position: absolute; left: 54px; top: 50%; transform: translateY(-50%); background: var(--ink); color: var(--paper); font-size: 12px; padding: 4px 8px; border-radius: 6px; white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity .12s; z-index: 40; }
@media (hover: hover) { .tool:hover .tip { opacity: 1; } }

.stage { grid-column: 2; grid-row: 1; position: relative; overflow: hidden; background: #e6dcc0; touch-action: none; cursor: default; }
.stage.tool-draw, .stage.tool-plant { cursor: crosshair; }
.stage.panning { cursor: grabbing; }
#canvas { width: 100%; height: 100%; display: block; user-select: none; -webkit-user-select: none; touch-action: none; }
.hud { position: absolute; pointer-events: none; }
.hud > * { pointer-events: auto; }
.hud-tl { left: 10px; top: 10px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; max-width: calc(100% - 80px); }
.chip { background: rgba(251, 246, 233, .94); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 13px; box-shadow: var(--shadow); display: inline-flex; align-items: center; gap: 6px; }
.chip.bad { background: #f6dcd3; border-color: var(--bad); color: #7a2e1e; }
.chip button { border: 0; background: none; padding: 0 2px; font-weight: 600; color: var(--moss); }
.hud-br { right: 10px; bottom: 10px; display: flex; flex-direction: column; gap: 6px; }
.round { width: 44px; height: 44px; border-radius: 50%; background: rgba(251, 246, 233, .96); border: 1px solid var(--line); box-shadow: var(--shadow); display: flex; align-items: center; justify-content: center; padding: 0; }
.round svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; }
.round[aria-pressed='true'] { background: var(--moss); color: #fff; }
.hud-bl { left: 10px; bottom: 10px; }
.scalebar { background: rgba(251, 246, 233, .92); border: 1px solid var(--line); border-radius: 8px; padding: 4px 8px 3px; font-size: 12px; color: var(--ink-2); }
.scalebar i { display: block; height: 6px; border: 2px solid var(--ink-2); border-top: 0; margin-bottom: 2px; }
.hud-tr { right: 10px; top: 10px; }
.compass { width: 56px; height: 56px; border-radius: 50%; background: rgba(251, 246, 233, .94); border: 1px solid var(--line); box-shadow: var(--shadow); display: flex; align-items: center; justify-content: center; }
.compass svg { width: 44px; height: 44px; }

/* ---------- Saatkorb ---------- */
.basket { min-width: 0; grid-column: 2; grid-row: 2; background: rgba(251, 246, 233, .97); border-top: 1px solid var(--line); box-shadow: 0 -4px 14px rgba(74, 59, 44, .08); z-index: 10; padding: 6px 8px 8px; }
.basket-head { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; overflow-x: auto; scrollbar-width: none; }
.basket-head::-webkit-scrollbar { display: none; }
.cat { flex: none; padding: 5px 12px; min-height: 32px; border-radius: 999px; border: 1px solid var(--line); background: transparent; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.cat[aria-pressed='true'] { background: var(--paper-3); color: var(--ink); border-color: var(--ink-3); }
.search { flex: 1 0 120px; min-width: 110px; max-width: 220px; height: 32px; border-radius: 999px; border: 1px solid var(--line); padding: 0 12px; background: var(--paper); }
.basket-row { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 4px; scroll-snap-type: x proximity; scrollbar-width: thin; }
.seed { flex: none; width: 84px; scroll-snap-align: start; border: 1px solid var(--line); background: var(--paper); border-radius: 12px; padding: 4px 4px 6px; text-align: center; font-size: 12px; font-weight: 600; line-height: 1.15; }
.seed img { width: 62px; height: 62px; display: block; margin: 0 auto 2px; object-fit: contain; pointer-events: none; }
.seed:hover { background: var(--paper-2); }
.seed[aria-pressed='true'] { border-color: var(--moss); background: #e8f0d8; box-shadow: 0 0 0 2px rgba(77, 107, 58, .35); }
.seed small { display: block; font-weight: 400; color: var(--ink-3); font-size: 11px; }

/* ---------- Detailkarte ---------- */
.panel { position: absolute; z-index: 20; right: 10px; top: 76px; width: 290px; max-width: calc(100% - 76px); background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; display: none; }
.panel.open { display: block; }
.panel h3 { font-size: 17px; }
.panel .sub { color: var(--ink-3); font-size: 12px; margin: 0 0 10px; }
.panel .row { display: flex; gap: 8px; margin: 8px 0; align-items: center; }
.panel label { font-size: 12px; color: var(--ink-2); font-weight: 600; display: block; margin-bottom: 2px; }
.panel .field { flex: 1; }
.panel select { font-size: 13px; padding: 0 6px; }
.panel input[type='number'], .panel input[type='text'], .panel select, .dialog-body input, .dialog-body select { width: 100%; height: 40px; border: 1px solid var(--line); border-radius: 10px; background: #fff; padding: 0 10px; }
.panel .thumb { width: 72px; height: 72px; flex: none; }
.panel .thumb img { width: 100%; height: 100%; object-fit: contain; }
.panel .actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.panel .close { position: absolute; right: 6px; top: 6px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; font-size: 13px; margin: 8px 0 0; }
.facts dt { color: var(--ink-3); }
.facts dd { margin: 0; }
.note { font-size: 12px; color: var(--ink-3); margin-top: 8px; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.tag.ok { background: #e1edd3; color: #3b5a2c; }
.tag.warn { background: #f6e8bd; color: #7a5a10; }

/* ---------- Hinweis, Dialog ---------- */
.toast { position: fixed; left: 50%; bottom: 150px; transform: translate(-50%, 20px); background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 12px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 60; max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
dialog { border: 1px solid var(--line); border-radius: 18px; background: var(--paper); color: var(--ink); padding: 0; box-shadow: 0 10px 40px rgba(60, 45, 30, .35); max-width: min(520px, 94vw); width: 100%; }
dialog::backdrop { background: rgba(59, 50, 38, .42); }
.dialog-body { padding: 22px; }
.dialog-body h2 { font-size: 24px; margin-bottom: 4px; }
.dialog-body p { margin: 4px 0 14px; color: var(--ink-2); }
.dialog-body .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dialog-body label { font-size: 12px; font-weight: 600; color: var(--ink-2); display: block; margin-bottom: 2px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.check { display: flex; gap: 10px; align-items: center; margin: 12px 0 0; font-size: 14px; }
.check input { width: 20px; height: 20px; flex: none; }
.compass-pick { display: flex; align-items: center; gap: 14px; margin-top: 4px; }
.compass-pick svg { width: 64px; height: 64px; flex: none; }
.compass-pick input[type='range'] { flex: 1; padding: 0; height: 28px; }

/* ---------- Galerie ---------- */
.gallery { position: absolute; inset: 0; overflow-y: auto; padding: 18px 16px 60px; }
.gallery-inner { max-width: 1180px; margin: 0 auto; }
.gallery h1 { font-size: 30px; }
.gallery .lead { color: var(--ink-2); max-width: 720px; margin: 6px 0 14px; }
.gallery-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 12px 0 18px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--paper); }
.seg button { border: 0; background: transparent; padding: 8px 14px; min-height: 38px; font-weight: 600; color: var(--ink-2); }
.seg button[aria-pressed='true'] { background: var(--moss); color: #fff; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 16px 16px 12px; margin-bottom: 16px; }
.card-head { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: baseline; margin-bottom: 6px; }
.card-head h2 { font-size: 22px; }
.card-head .latin { font-style: italic; color: var(--ink-2); }
.card-head .meta { color: var(--ink-3); font-size: 13px; }
.stages { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; }
.stage-cell { flex: none; width: 168px; text-align: center; font-size: 12px; color: var(--ink-2); font-weight: 600; }
.stage-cell span { display: block; min-height: 2.6em; line-height: 1.25; }
.stage-cell img { width: 100%; display: block; margin-top: 2px; }
.pic.side img { background: linear-gradient(#fffaf0, #f6efdb); border-radius: 10px; }
.data-row { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13px; color: var(--ink-2); margin-top: 8px; border-top: 1px dashed var(--line); padding-top: 8px; }
.data-row b { color: var(--ink); font-weight: 600; }
.noscript { padding: 20px; }

/* ---------- Enge Bildschirme ---------- */
@media (max-width: 680px) {
  .tabs .tab { padding: 8px 8px; font-size: 13px; }
  .brand-name { display: none; }
  .topbar { gap: 6px; }
  .panel { left: 66px; right: 8px; top: auto; bottom: 8px; width: auto; max-width: none; position: fixed; z-index: 25; }
  .save-state { display: none; }
  .toast { top: 66px; bottom: auto; transform: translate(-50%, -12px); }
  .toast.show { transform: translate(-50%, 0); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
