
:root {
  --paper:      #faf7f0;
  --paper-2:    #f2ede1;
  --paper-3:    #e8e1d1;
  --ink:        #2a2620;
  --ink-2:      #5c554a;
  --ink-3:      #8a8073;
  --green:      #3f5c43;
  --green-2:    #587a5c;
  --green-pale: #e4ece4;
  --rust:       #9c4a2f;
  --rust-pale:  #f7e6e0;
  --amber:      #a8761f;
  --amber-pale: #f9eed6;
  --line:       #ddd4c2;
  --radius:     6px;
  --shadow:     0 1px 2px rgba(42,38,32,.06), 0 4px 12px rgba(42,38,32,.05);
  --font-sans:  ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --font-mono:  ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--font-sans); font-size: 16px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--font-serif); font-weight: 600; line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: 1.75rem; } h2 { font-size: 1.3rem; } h3 { font-size: 1.08rem; }
p { margin: 0 0 1em; }
a { color: var(--green); text-decoration-color: var(--line); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }
small, .small { font-size: .82rem; color: var(--ink-2); }
.muted { color: var(--ink-3); }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.5rem 0; }
:focus-visible { outline: 2px solid var(--green-2); outline-offset: 2px; border-radius: 3px; }

/* ── shell ───────────────────────────────────────────── */
.shell { min-height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: .75rem; padding: .6rem 1rem;
  background: var(--paper-2); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
}
.brand { font-family: var(--font-serif); font-size: 1.05rem; font-weight: 600; color: var(--green); text-decoration: none; white-space: nowrap; }
.brand span { color: var(--ink-3); font-weight: 400; }
.topbar nav { display: flex; gap: .15rem; flex-wrap: wrap; flex: 1; }
.topbar nav a {
  padding: .35rem .6rem; border-radius: var(--radius); font-size: .9rem;
  color: var(--ink-2); text-decoration: none; white-space: nowrap;
}
.topbar nav a:hover { background: var(--paper-3); color: var(--ink); }
.topbar nav a[aria-current="page"] { background: var(--green); color: #fff; }
.topbar .meta { display: flex; align-items: center; gap: .5rem; font-size: .82rem; color: var(--ink-3); }
main { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: 1.5rem 1rem 4rem; }
main.wide { max-width: 1500px; }
main.narrow { max-width: 640px; }

.page-head { display: flex; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-head h1 { margin: 0; }
.page-head .spacer { flex: 1; }

/* ── cards / panels ──────────────────────────────────── */
.card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem; box-shadow: var(--shadow);
}
.card + .card { margin-top: 1rem; }
.card h2:first-child, .card h3:first-child { margin-top: 0; }
.stack > * + * { margin-top: 1rem; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.row.tight { gap: .3rem; }
.grid { display: grid; gap: 1rem; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }

/* ── forms ───────────────────────────────────────────── */
label { display: block; font-size: .84rem; font-weight: 600; color: var(--ink-2); margin-bottom: .25rem; }
input[type=text], input[type=email], input[type=url], input[type=number],
input[type=search], input[type=date], input[type=datetime-local], select, textarea {
  width: 100%; padding: .5rem .6rem; font: inherit; font-size: .95rem; color: var(--ink);
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
}
textarea { min-height: 7rem; resize: vertical; line-height: 1.55; }
input:disabled, textarea:disabled, select:disabled { background: var(--paper-2); color: var(--ink-3); }
.field + .field { margin-top: .85rem; }
.field .hint { font-size: .78rem; color: var(--ink-3); margin-top: .25rem; font-weight: 400; }

.btn {
  display: inline-flex; align-items: center; gap: .4rem; justify-content: center;
  padding: .5rem .9rem; font: inherit; font-size: .9rem; font-weight: 500;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: #fff; color: var(--ink); cursor: pointer; text-decoration: none;
  min-height: 40px;
}
.btn:hover { background: var(--paper-2); }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.primary:hover { background: var(--green-2); }
.btn.danger { color: var(--rust); border-color: #e3c8bf; }
.btn.danger:hover { background: var(--rust-pale); }
.btn.small { padding: .28rem .55rem; font-size: .8rem; min-height: 30px; }
.btn:disabled, .btn[aria-disabled=true] { opacity: .5; cursor: not-allowed; }
.btn-group { display: flex; gap: .4rem; flex-wrap: wrap; }

/* ── chips / badges ──────────────────────────────────── */
.chip {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .15rem .5rem; border-radius: 999px; font-size: .76rem; line-height: 1.5;
  background: var(--paper-2); border: 1px solid var(--line); color: var(--ink-2);
  white-space: nowrap;
}
.chip.ai      { background: var(--amber-pale); border-color: #e8d5a8; color: #7a5613; }
.chip.human   { background: var(--green-pale); border-color: #c6d8c6; color: var(--green); }
.chip.warn    { background: var(--rust-pale); border-color: #e3c8bf; color: var(--rust); }
.chip button  { border: 0; background: none; cursor: pointer; color: inherit; padding: 0 0 0 .1rem; font-size: .9em; line-height: 1; }

.badge-status { font-size: .74rem; padding: .12rem .45rem; border-radius: 3px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.st-idee            { background: var(--paper-3); color: var(--ink-2); }
.st-entwurf         { background: var(--amber-pale); color: #7a5613; }
.st-freigegeben     { background: var(--green-pale); color: var(--green); }
.st-geplant         { background: #dde6f0; color: #2f4a66; }
.st-veroeffentlicht { background: var(--green); color: #fff; }

/* ── tables ──────────────────────────────────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: .5rem .6rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); font-weight: 600; white-space: nowrap; }
tbody tr:hover { background: var(--paper); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ── alerts ──────────────────────────────────────────── */
.alert { padding: .7rem .9rem; border-radius: var(--radius); border: 1px solid; font-size: .9rem; }
.alert p:last-child { margin-bottom: 0; }
.alert.info  { background: var(--paper-2); border-color: var(--line); color: var(--ink-2); }
.alert.ok    { background: var(--green-pale); border-color: #c6d8c6; color: var(--green); }
.alert.warn  { background: var(--amber-pale); border-color: #e8d5a8; color: #7a5613; }
.alert.error { background: var(--rust-pale); border-color: #e3c8bf; color: var(--rust); }

/* ── empty states ────────────────────────────────────── */
.empty { text-align: center; padding: 3rem 1rem; color: var(--ink-3); }
.empty h2 { font-size: 1.1rem; color: var(--ink-2); }
.empty p { max-width: 34ch; margin-inline: auto; font-size: .92rem; }

/* ── media grid ──────────────────────────────────────── */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; }
.media-tile {
  position: relative; aspect-ratio: 1; border-radius: var(--radius); overflow: hidden;
  background: var(--paper-3); border: 1px solid var(--line); cursor: pointer; display: block;
}
.media-tile img, .media-tile video { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-tile .cap {
  position: absolute; inset: auto 0 0 0; padding: .3rem .4rem; font-size: .72rem; color: #fff;
  background: linear-gradient(transparent, rgba(0,0,0,.72)); line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.media-tile .pill { position: absolute; top: .3rem; left: .3rem; background: rgba(0,0,0,.6); color: #fff; font-size: .68rem; padding: .05rem .35rem; border-radius: 3px; }
.media-tile.selected { outline: 3px solid var(--green); outline-offset: -3px; }
.media-tile input[type=checkbox] { position: absolute; top: .35rem; right: .35rem; width: 20px; height: 20px; accent-color: var(--green); }

/* ── calendar ────────────────────────────────────────── */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.cal .dow { background: var(--paper-2); padding: .35rem .5rem; font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); font-weight: 600; text-align: center; }
.cal .day { background: #fff; min-height: 108px; padding: .3rem; }
.cal .day.other { background: var(--paper); }
.cal .day.today { background: var(--green-pale); }
.cal .day .n { font-size: .76rem; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.cal .day.dragover { background: var(--amber-pale); }
.cal-item {
  display: block; font-size: .74rem; padding: .15rem .3rem; margin-top: .2rem; border-radius: 3px;
  background: var(--paper-2); border-left: 3px solid var(--green); color: var(--ink);
  text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: grab;
}
.cal-item:hover { background: var(--paper-3); }

/* ── progress ────────────────────────────────────────── */
.bar { height: 6px; background: var(--paper-3); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--green); transition: width .2s ease; }

/* ── utility ─────────────────────────────────────────── */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.mono { font-family: var(--font-mono); font-size: .85em; }
.nowrap { white-space: nowrap; }
.htmx-request { opacity: .55; transition: opacity .15s; }
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline-block; }

/* ── mobile ──────────────────────────────────────────── */
@media (max-width: 640px) {
  body { font-size: 17px; }
  main { padding: 1rem .75rem 5rem; }
  .topbar { flex-wrap: wrap; padding: .5rem .75rem; }
  /* flex-basis beats width on a flex item — the base rule's flex:1 sets
     basis 0%, which squeezed this to 1px instead of wrapping to its own row. */
  .topbar nav { order: 3; flex: 1 0 100%; overflow-x: auto; flex-wrap: nowrap;
                padding-bottom: .2rem; scrollbar-width: none; }
  .topbar nav::-webkit-scrollbar { display: none; }
  .topbar .meta { margin-left: auto; }
  h1 { font-size: 1.45rem; }
  .btn { min-height: 44px; padding: .6rem 1rem; }
  .media-grid { grid-template-columns: repeat(auto-fill, minmax(105px, 1fr)); gap: .4rem; }
  .cal { grid-template-columns: 1fr; }
  .cal .dow { display: none; }
  .cal .day { min-height: auto; }
  .cal .day.other { display: none; }
}

@media print {
  .topbar, .btn, .no-print { display: none !important; }
  body { background: #fff; }
}
