:root {
  --steel: #e6ebed;
  --surface: #fbfcfc;
  --ink: #17252b;
  --muted: #5a6b72;
  --line: #c9d3d7;
  --petrol: #0f5c63;
  --petrol-ink: #ffffff;
  --brass: #a8771c;
  --danger: #a8322a;
  --radius: 10px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --steel: #0f1b20;
    --surface: #18272e;
    --ink: #e8eef0;
    --muted: #9db0b7;
    --line: #2f434b;
    --petrol: #58b9c1;
    --petrol-ink: #06262a;
    --brass: #dcae55;
    --danger: #ef8a80;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--steel);
  color: var(--ink);
  font: 17px/1.45 ui-rounded, "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

h1 { font-size: 1.75rem; line-height: 1.15; margin: 12px 0 8px; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 1.25rem; margin: 0 0 14px; font-weight: 700; }
p { margin: 0 0 12px; }

/* Bedienelemente */
button, input, textarea, .filebtn { font: inherit; color: inherit; }
button, .filebtn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  cursor: pointer; white-space: nowrap;
}
button:active, .filebtn:active { transform: translateY(1px); }
button.primary { background: var(--petrol); border-color: var(--petrol); color: var(--petrol-ink); font-weight: 600; }
button.danger { color: var(--danger); border-color: currentColor; background: transparent; }
button.quiet, .filebtn.quiet { background: transparent; border-color: transparent; color: var(--muted); text-decoration: underline; }
button:disabled { opacity: .6; cursor: progress; }
button.busy::after { content: " …"; }

.filebtn { position: relative; overflow: hidden; }
.filebtn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 0; }
.filebtn:focus-within { outline: 3px solid var(--brass); outline-offset: 2px; }

input[type="text"], input[type="password"], input[type="search"], textarea {
  width: 100%; min-height: 44px; padding: 9px 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
textarea { resize: vertical; }
input.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; letter-spacing: .02em; }
:focus-visible { outline: 3px solid var(--brass); outline-offset: 2px; }

label { display: block; margin: 14px 0 5px; font-size: .9rem; color: var(--muted); }
.err { color: var(--danger); min-height: 1.45em; margin: 8px 0; font-size: .95rem; }
.hint { color: var(--muted); font-size: .95rem; }

/* Einrichten und Sperrbildschirm */
.gate { max-width: 380px; margin: 0 auto; padding: 12vh 20px 40px; }
.gate img { border-radius: 16px; display: block; }
.gate form button { width: 100%; margin-top: 4px; }
.gate .filebtn { width: 100%; margin-top: 18px; }

/* Hauptansicht */
#main { max-width: 640px; margin: 0 auto; padding: 0 16px 48px; }
.bar {
  position: sticky; top: 0; z-index: 2;
  display: flex; gap: 8px; padding: 14px 0 10px;
  background: var(--steel);
}
.bar input { flex: 1; min-width: 0; }
#menuBtn.dirty::after {
  content: ""; width: 9px; height: 9px; margin-left: 8px;
  border-radius: 50%; background: var(--brass);
}

.chips { display: flex; gap: 8px; margin: 2px 0 14px; }
.chip { min-height: 36px; border-radius: 18px; font-size: .95rem; color: var(--muted); background: transparent; }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--steel); }

#list { list-style: none; margin: 0; padding: 0; }
.row {
  display: flex; align-items: stretch; gap: 8px;
  margin-bottom: 8px; padding: 6px 8px 6px 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  border-left: 6px solid var(--petrol);          /* Farbe zeigt den Bereich */
}
.row.arbeit { border-left-color: var(--brass); }
.row-open {
  flex: 1; min-width: 0; display: block; text-align: left;
  border: 0; background: transparent; padding: 6px 12px; white-space: normal;
}
.row-title, .row-sub { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-title { font-weight: 600; }
.row-sub { color: var(--muted); font-size: .9rem; }
.row-copy { align-self: center; font-size: .9rem; }
.empty { color: var(--muted); padding: 32px 4px; }

/* Dialoge */
dialog {
  width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px);
  padding: 20px; overflow: auto;
  background: var(--steel); color: var(--ink);
  border: 1px solid var(--line); border-radius: 16px;
}
dialog::backdrop { background: rgba(10, 24, 28, .55); }
.field { display: flex; gap: 8px; }
.field input { flex: 1; min-width: 0; }
.gen {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px;
  margin-top: 10px; padding: 10px 12px;
  border: 1px dashed var(--line); border-radius: var(--radius);
}
.gen label { margin: 0; }
.gen input[type="range"] { flex: 1; min-width: 110px; accent-color: var(--petrol); }
.gen output { font-weight: 600; color: var(--ink); }
.check { display: inline-flex; align-items: center; gap: 6px; }
.area { border: 0; padding: 0; margin: 14px 0 0; display: flex; gap: 18px; }
.area legend { font-size: .9rem; color: var(--muted); padding: 0; margin-bottom: 5px; }
.area label { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-size: 1rem; color: var(--ink); }
input[type="radio"], input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--petrol); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.grow { flex: 1; }
.menu { display: grid; gap: 8px; }

#toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  max-width: calc(100vw - 32px); padding: 10px 16px;
  background: var(--ink); color: var(--steel); border-radius: var(--radius);
  transition: opacity .2s, transform .2s; z-index: 10;
}
#toast.on { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 480px) {
  .row-copy { padding: 0 10px; white-space: normal; max-width: 96px; line-height: 1.15; text-align: center; }
  .field { flex-wrap: wrap; }
  .field input { flex-basis: 100%; }
  .field button { flex: 1; }
}
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }
