:root {
  --cream: #F4EFE6; --white: #FFFFFF; --sand: #D9CBB5; --oyster: #CFC6B8;
  --oil: #523F31; --taupe: #9D8A7C; --line: #E4DCCF; --ink: #2E241C;
  --ok: #4E7A5A; --warn: #B7791F; --err: #A3412F; --info: #5B6F8A;
  --serif: "Cormorant Garamond", Georgia, serif; --sans: "Montserrat", system-ui, sans-serif;
  --r: 10px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--cream); color: var(--ink); font: 14px/1.5 var(--sans); }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; color: var(--oil); margin: 0; }
h1 { font-size: 30px; } h2 { font-size: 26px; } h3 { font-size: 20px; }
em { font-style: italic; }
button, select, input, textarea { font: inherit; color: inherit; }
.muted { color: var(--taupe); } .small { font-size: 12px; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 24px; padding: 12px 24px;
  background: var(--white); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font-family: var(--serif); font-size: 26px; color: var(--oil); font-weight: 600; }
.brand em { color: var(--taupe); }
nav { display: flex; gap: 4px; flex-wrap: wrap; }
nav button { border: 0; background: none; padding: 8px 14px; border-radius: 999px; cursor: pointer; color: var(--taupe); font-weight: 500; }
nav button.active { background: var(--oil); color: var(--cream); }
.badge:not(:empty) { background: var(--warn); color: white; border-radius: 999px; padding: 0 7px; font-size: 11px; margin-left: 4px; }
.pill { margin-left: auto; font-size: 12px; padding: 4px 10px; border-radius: 999px; background: var(--sand); color: var(--oil); }
.pill.live { background: var(--ok); color: white; }

main { padding: 20px 24px 60px; max-width: 1500px; margin: 0 auto; }
.view { display: none; } .view.active { display: block; }
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.spacer { flex: 1; }
button.primary, button.ok, button.ghost, button.warn, button.danger { border-radius: 8px; padding: 8px 14px; cursor: pointer; border: 1px solid var(--line); background: var(--white); }
button.primary { background: var(--oil); color: var(--cream); border-color: var(--oil); }
button.ok { background: var(--ok); color: white; border-color: var(--ok); font-weight: 600; }
button.warn { background: #FFF7E8; border-color: #EBCB94; color: #7A4F0E; }
button.danger { color: var(--err); }
button:disabled { opacity: .45; cursor: not-allowed; }
select, input, textarea { border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; background: var(--white); }
textarea { width: 100%; min-height: 90px; resize: vertical; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--white); }
.seg button { border: 0; background: none; padding: 7px 12px; cursor: pointer; }
.seg button.active { background: var(--sand); color: var(--oil); font-weight: 600; }

.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--taupe); margin-bottom: 10px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }
.s-idee { background: #C9C0B3; } .s-entwurf { background: var(--info); } .s-review { background: var(--warn); }
.s-freigegeben { background: var(--ok); } .s-veroeffentlicht { background: var(--oil); } .s-fehler, .s-abgelehnt { background: var(--err); }

/* Kalender */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.cal .dow { background: var(--cream); padding: 6px 8px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--taupe); }
.cal .day { background: var(--white); min-height: 118px; padding: 6px; display: flex; flex-direction: column; gap: 4px; }
.cal.week .day { min-height: 420px; }
.cal .day.out { background: #FAF7F2; } .cal .day.out .num { opacity: .4; }
.cal .day.today .num { background: var(--oil); color: var(--cream); border-radius: 999px; padding: 0 7px; }
.cal .num { font-size: 12px; color: var(--taupe); align-self: flex-start; }
.chip { border-radius: 6px; padding: 4px 6px; font-size: 11.5px; line-height: 1.3; cursor: pointer; background: var(--cream); border-left: 3px solid var(--taupe); }
.chip:hover { background: var(--sand); }
.chip .t { font-weight: 600; color: var(--oil); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.chip .m { color: var(--taupe); font-size: 10.5px; display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.chip.st-idee { border-color: #C9C0B3; } .chip.st-entwurf { border-color: var(--info); } .chip.st-review { border-color: var(--warn); }
.chip.st-freigegeben { border-color: var(--ok); } .chip.st-veroeffentlicht { border-color: var(--oil); opacity: .75; } .chip.st-fehler { border-color: var(--err); }
.pf { display: inline-block; font-size: 9.5px; font-weight: 600; padding: 0 4px; border-radius: 3px; background: var(--white); border: 1px solid var(--line); color: var(--oil); }
.trial { background: #EFE7F7; color: #5A3E7A; border-color: #DCCBEE; }

/* Karten */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 16px; }
.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.card .head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.card h3 { font-size: 21px; }
.preview { display: flex; gap: 10px; overflow-x: auto; }
.preview video, .preview img { height: 260px; border-radius: 8px; background: var(--sand); aspect-ratio: 9/16; object-fit: cover; }
.preview .slide { flex: 0 0 auto; width: 170px; aspect-ratio: 4/5; background: var(--cream); border: 1px solid var(--line); border-radius: 8px; padding: 12px; font-family: var(--serif); font-size: 15px; color: var(--oil); overflow: hidden; }
.preview .slide b { font-family: var(--sans); font-size: 10px; color: var(--taupe); display: block; margin-bottom: 6px; }
.ph { height: 200px; aspect-ratio: 9/16; border-radius: 8px; background: repeating-linear-gradient(45deg, var(--cream), var(--cream) 10px, #EFE8DC 10px, #EFE8DC 20px); display: grid; place-items: center; text-align: center; color: var(--taupe); font-size: 12px; padding: 10px; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 4px 10px; font-size: 13px; }
.kv dt { color: var(--taupe); } .kv dd { margin: 0; white-space: pre-wrap; }
.checks { display: flex; flex-wrap: wrap; gap: 6px; }
.check { font-size: 11.5px; padding: 2px 8px; border-radius: 999px; background: #EAF2EC; color: var(--ok); }
.check.no { background: #FBEDEA; color: var(--err); }
.errors { background: #FBEDEA; color: var(--err); border-radius: 8px; padding: 8px 10px; font-size: 12.5px; }
.note { background: #FFF7E8; border-radius: 8px; padding: 8px 10px; font-size: 12.5px; white-space: pre-wrap; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; }
.status-tag { font-size: 11px; padding: 2px 9px; border-radius: 999px; color: white; white-space: nowrap; }

/* Tabelle */
.tbl { width: 100%; border-collapse: collapse; background: var(--white); border-radius: var(--r); overflow: hidden; }
.tbl th, .tbl td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); font-size: 13px; }
.tbl th { background: var(--cream); color: var(--taupe); font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.tbl tr:hover td { background: #FBF8F3; cursor: pointer; }

/* Drawer */
#scrim { position: fixed; inset: 0; background: rgba(46,36,28,.25); display: none; z-index: 9; }
#scrim.on { display: block; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(760px, 100vw); background: var(--white); z-index: 10; transform: translateX(100%); transition: transform .2s; display: flex; flex-direction: column; box-shadow: -10px 0 30px rgba(0,0,0,.08); }
.drawer.on { transform: none; }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; padding: 18px 22px 10px; gap: 10px; }
.drawer > .seg { margin: 0 22px; align-self: flex-start; }
#d-body { flex: 1; overflow-y: auto; padding: 16px 22px; display: flex; flex-direction: column; gap: 14px; }
.drawer-foot { border-top: 1px solid var(--line); padding: 12px 22px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--taupe); }
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.clips { display: flex; flex-direction: column; gap: 6px; }
.clip { display: grid; grid-template-columns: 22px 1fr 70px 70px 50px 1fr 28px; gap: 6px; align-items: center; background: var(--cream); padding: 6px; border-radius: 8px; }
.clip input, .clip select { padding: 5px 6px; font-size: 12px; min-width: 0; }
.clip .n { color: var(--taupe); font-size: 12px; text-align: center; }
.hist { font-size: 12.5px; border-left: 2px solid var(--line); padding-left: 12px; display: flex; flex-direction: column; gap: 6px; }
.render-box { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.render-box video { width: 240px; aspect-ratio: 9/16; background: var(--ink); border-radius: 8px; }

/* Research */
.split { display: grid; grid-template-columns: 260px 1fr; gap: 16px; }
.doclist { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.doclist li { padding: 8px 10px; border-radius: 8px; cursor: pointer; background: var(--white); border: 1px solid var(--line); font-size: 13px; }
.doclist li.active { background: var(--oil); color: var(--cream); }
.doc { background: var(--white); border: 1px solid var(--line); border-radius: var(--r); padding: 24px 32px; overflow-x: auto; }
.doc table { border-collapse: collapse; font-size: 12.5px; margin: 10px 0; } .doc td, .doc th { border: 1px solid var(--line); padding: 5px 8px; vertical-align: top; }
.doc h1 { font-size: 30px; } .doc h2 { margin-top: 22px; } .doc h3 { margin-top: 16px; }

.statusgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--oil); color: var(--cream); padding: 10px 18px; border-radius: 8px; opacity: 0; transition: opacity .2s; z-index: 20; pointer-events: none; max-width: 90vw; }
#toast.on { opacity: 1; }

@media (max-width: 760px) {
  main { padding: 12px; } .top { padding: 10px 12px; gap: 10px; }
  .cal .day { min-height: 70px; } .chip .m { display: none; }
  .cards { grid-template-columns: 1fr; } .split { grid-template-columns: 1fr; }
  .clip { grid-template-columns: 1fr 1fr 1fr; }
}

/* ---------- Anmeldung ---------- */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth { width: min(420px, 100%); display: flex; flex-direction: column; gap: 18px; align-items: stretch; }
.brand.big { font-size: 40px; text-align: center; }
.auth-card { gap: 14px; padding: 24px; }
.auth-card input { font-size: 16px; padding: 11px 12px; }
button.wide { width: 100%; padding: 12px; font-size: 15px; }
[hidden] { display: none !important; }

/* ---------- Kopfzeile ---------- */
#btn-logout { border: 0; background: none; color: var(--taupe); cursor: pointer; padding: 6px 4px; }
#mode-pill { cursor: pointer; }

/* ---------- Liste (Agenda) ---------- */
.agenda { display: flex; flex-direction: column; gap: 6px; max-width: 760px; }
.ag-day { margin-top: 12px; font-family: var(--serif); font-size: 20px; color: var(--oil); text-transform: capitalize; }
.ag-day.today::after { content: " · heute"; color: var(--warn); font-size: 14px; }
.chip.ag { padding: 10px 12px; font-size: 14px; background: var(--white); border: 1px solid var(--line); border-left-width: 4px; }
.chip.ag .t { -webkit-line-clamp: 3; }
.chip.ag .m { display: flex !important; font-size: 12px; margin-top: 4px; }

/* ---------- Einstellungen ---------- */
.set-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; align-items: start; }
.set-card .field input, .set-card .field select { width: 100%; }
.test-result:empty { display: none; }
.test-result { padding: 8px 10px; border-radius: 8px; background: var(--cream); }
.test-result.ok { background: #EAF2EC; color: var(--ok); }
.test-result.bad { background: #FBEDEA; color: var(--err); }
.user-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
button.small { padding: 5px 10px; font-size: 12px; }
details.adv { margin-top: 18px; }
details.adv summary { cursor: pointer; color: var(--taupe); margin-bottom: 12px; }
.switch { display: flex; gap: 12px; align-items: center; cursor: pointer; }
.switch input { appearance: none; -webkit-appearance: none; width: 46px; height: 26px; border-radius: 999px; background: var(--oyster); position: relative; flex: 0 0 auto; transition: background .2s; border: 0; padding: 0; cursor: pointer; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: white; transition: left .2s; }
.switch input:checked { background: var(--ok); }
.switch input:checked::after { left: 23px; }
.switch span { display: none; }

/* ---------- Handy ---------- */
body { -webkit-tap-highlight-color: transparent; }
@media (max-width: 760px) {
  body { font-size: 15px; padding-bottom: env(safe-area-inset-bottom); }
  .top { padding-top: max(10px, env(safe-area-inset-top)); }
  .brand { font-size: 22px; }
  nav { order: 3; width: 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  nav::-webkit-scrollbar { display: none; }
  nav button { white-space: nowrap; padding: 9px 14px; }
  #mode-pill { margin-left: auto; }
  h1 { font-size: 24px; }
  .toolbar { gap: 8px; }
  .toolbar h1 { flex: 1 1 auto; min-width: 0; font-size: 22px; }
  #cal-filter, .toolbar .seg { flex: 1 1 auto; }
  #btn-new { width: 100%; }
  .legend { display: none; }
  .cal .day { min-height: 64px; padding: 3px; }
  .cal .dow { padding: 4px 2px; text-align: center; font-size: 10px; }
  .chip:not(.ag) { padding: 2px 3px; font-size: 10px; }
  .chip:not(.ag) .t { -webkit-line-clamp: 2; }
  .set-grid { grid-template-columns: 1fr; }
  .card { padding: 14px; }
  .preview video, .preview img { height: 220px; }
  .kv { grid-template-columns: 90px 1fr; }
  .drawer-head { padding: 14px 14px 8px; padding-top: max(14px, env(safe-area-inset-top)); }
  #d-body { padding: 12px 14px; }
  .drawer-foot { padding: 10px 14px max(10px, env(safe-area-inset-bottom)); }
  .drawer-foot button { flex: 1 1 auto; }
  .drawer > .seg { margin: 0 14px; }
  input, select, textarea { font-size: 16px; } /* verhindert Zoom beim Tippen auf iPhone */
  .tbl th:nth-child(3), .tbl td:nth-child(3), .tbl th:nth-child(5), .tbl td:nth-child(5) { display: none; }
  .tbl td, .tbl th { padding: 8px; }
}

/* Karten dürfen nie breiter als der Bildschirm werden */
.cards > .card, .set-grid > .card { min-width: 0; }
.card h3, .kv dd, .note, .errors { overflow-wrap: anywhere; }
.kv dd { min-width: 0; }
@media (max-width: 760px) { .cards { grid-template-columns: minmax(0, 1fr); } main { overflow-x: hidden; } }
#intro:empty { display: none; }
