:root { --blue:#2f6fb5; --line:#d0d7de; --bg:#f6f8fa; --warn:#b54708; --bad:#b42318; }
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { height: 100dvh; }
body { font: 14px/1.4 system-ui, "Segoe UI", sans-serif; color: #1f2328; display: flex; flex-direction: column; }
header { display: flex; align-items: center; gap: 12px; padding: 8px 14px; background: #fff; border-bottom: 1px solid var(--line); }
.grow { flex: 1; }
.badge { padding: 2px 10px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); font-size: 12px; }
.badge.ok { background: #e7f6ec; border-color: #9bd3ae; }
.badge.bad { background: #fdecea; border-color: #f1a9a0; }
.badge.wait { background: #fff4e0; border-color: #f0c987; }
main { flex: 1; display: flex; min-height: 0; }
#editor { flex: 1; border: 0; min-width: 0; }
aside { width: 380px; overflow-y: auto; padding: 10px; background: var(--bg); border-left: 1px solid var(--line); }
section { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; }
h2 { margin: 0 0 8px; font-size: 14px; }
textarea, input[type=search] { width: 100%; padding: 8px; font: inherit; border: 1px solid var(--line); border-radius: 6px; }
button, .button { font: inherit; padding: 6px 12px; border: 1px solid var(--line); border-radius: 6px; background: #fff; cursor: pointer; display: inline-block; }
button:hover:not(:disabled), .button:hover { background: var(--bg); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
button.primary:hover:not(:disabled) { background: #265d9a; }
.row { display: flex; gap: 8px; margin: 8px 0; flex-wrap: wrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.chips button { font-size: 12px; padding: 3px 9px; border-radius: 999px; }
ul.plain { list-style: none; margin: 0; padding: 0; }
ul.plain li { padding: 3px 0; }
ul.small { font-size: 12px; color: #57606a; }
ul.warn li { color: var(--warn); font-size: 12px; }
ol { padding-left: 20px; margin: 6px 0; }
ol li.del { color: var(--bad); font-weight: 600; }
.hint { color: #57606a; font-size: 12px; margin: 6px 0; }
#aiPreview { max-width: 100%; max-height: 220px; border: 1px solid var(--line); border-radius: 6px; background: #fff; display: block; margin: 6px 0; }
#navResults li { cursor: pointer; padding: 4px 6px; border-radius: 4px; }
#navResults li:hover { background: var(--bg); }
.peer-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
code { background: var(--bg); padding: 0 4px; border-radius: 3px; }

[hidden] { display: none !important; }

.edit-toggle { font-size: 12px; padding: 3px 10px; border-radius: 999px; }
.edit-toggle.on { background: #fff4e0; border-color: #f0c987; }
#mbar { display: none; }
#history li { padding: 3px 0; border-bottom: 1px solid var(--bg); }
#history .who { font-weight: 600; }
#history .when { color: #57606a; margin-right: 4px; }
#targetHint button { font-size: 12px; padding: 2px 8px; }
#navResults li.target { background: #e8f1fb; }

/* Handy: Diagramm füllt den Bildschirm, Bedienung liegt in einer Schublade */
@media (max-width: 800px) {
  header { padding: 3px 8px; gap: 6px; }
  header strong, #editToggleTop { display: none; }
  #roomLabel { font-size: 12px; font-weight: 600; }
  .badge { font-size: 10px; padding: 1px 7px; }
  main { position: relative; }
  body.editing main { margin-bottom: 62px; }

  aside {
    display: none; position: fixed; left: 0; right: 0; bottom: 0; width: auto;
    max-height: 58dvh; padding: 10px 10px calc(66px + env(safe-area-inset-bottom));
    border-left: 0; border-top: 1px solid var(--line); border-radius: 16px 16px 0 0;
    z-index: 20; background: #fff;
  }
  body[data-panel] aside { display: block; }
  aside section[data-tab] { display: none; }
  body[data-panel="ki"] aside section[data-tab="ki"],
  body[data-panel="suche"] aside section[data-tab="suche"],
  body[data-panel="gruppe"] aside section[data-tab="gruppe"],
  body[data-panel="mehr"] aside section[data-tab="mehr"] { display: block; }
  textarea, input[type=search] { font-size: 16px; }
  #aiInstruction { min-height: 64px; }
  button, .button { min-height: 40px; }
  .chips button { min-height: 32px; }

  #mbar {
    display: flex; position: fixed; left: 12px; right: 12px;
    bottom: calc(10px + env(safe-area-inset-bottom)); height: 46px; border-radius: 23px;
    background: #1f2328; z-index: 30; justify-content: space-around; align-items: center;
  }
  #mbar button {
    background: none; border: 0; color: #d0d7de; display: flex; flex-direction: column;
    align-items: center; gap: 2px; font-size: 10px; padding: 2px 10px; min-height: 0; border-radius: 12px;
  }
  #mbar button i { display: block; width: 15px; height: 15px; border: 1.5px solid #d0d7de; border-radius: 4px; }
  #mbar button.on { color: #fff; }
  #mbar button.on i { background: #2f6fb5; border-color: #2f6fb5; }
}
