/* Claude-Chat - mobile first */
:root {
  --bg: #faf9f6;
  --bg-elev: #ffffff;
  --bg-sunk: #f1efe9;
  --line: #e3dfd5;
  --text: #22201c;
  --muted: #74706a;
  --accent: #c25f3a;
  --accent-soft: #f6e9e2;
  --user-bubble: #ece7dc;
  --radius: 16px;
  --sidebar: 280px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1b19;
    --bg-elev: #24231f;
    --bg-sunk: #2c2a26;
    --line: #38352f;
    --text: #ece9e2;
    --muted: #9a958c;
    --accent: #e0825c;
    --accent-soft: #38302b;
    --user-bubble: #312e28;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 16px; line-height: 1.55;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }

#app { display: flex; height: 100dvh; overflow: hidden; }

/* --- Seitenleiste --- */
#sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar); z-index: 40;
  background: var(--bg-elev); border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  transform: translateX(-100%); transition: transform .22s ease;
  padding-top: env(safe-area-inset-top);
}
#sidebar.open { transform: translateX(0); }
#overlay {
  position: fixed; inset: 0; z-index: 35; background: rgba(0,0,0,.4);
  opacity: 0; pointer-events: none; transition: opacity .22s ease;
}
#overlay.show { opacity: 1; pointer-events: auto; }
.side-head {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 14px 10px; border-bottom: 1px solid var(--line);
}
.side-head strong { flex: 1; font-size: 15px; letter-spacing: .2px; }
#chatlist { flex: 1; overflow-y: auto; padding: 8px; -webkit-overflow-scrolling: touch; }
.chat-item {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 10px; border-radius: 12px; cursor: pointer;
  font-size: 14.5px; color: var(--text);
}
.chat-item:hover { background: var(--bg-sunk); }
.chat-item.active { background: var(--accent-soft); }
.chat-item .t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item .mini {
  opacity: 0; border: 0; background: none; padding: 4px; border-radius: 8px;
  color: var(--muted); font-size: 13px; line-height: 1;
}
.chat-item:hover .mini, .chat-item.active .mini { opacity: 1; }
.chat-item .mini:hover { background: var(--bg); color: var(--text); }
.side-foot { padding: 10px 14px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); display: flex; gap: 10px; align-items: center; }
.side-foot a { color: var(--muted); text-decoration: none; }

/* --- Hauptbereich --- */
#main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
header {
  display: flex; align-items: center; gap: 10px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
  border-bottom: 1px solid var(--line); background: var(--bg);
  position: sticky; top: 0; z-index: 20;
}
header h1 {
  margin: 0; font-size: 16px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.head-text { flex: 1; min-width: 0; }
.usage {
  font-size: 11.5px; color: var(--muted); margin-top: 1px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.usage:empty { display: none; }
.icon-btn {
  border: 0; background: none; padding: 8px; border-radius: 10px;
  color: var(--text); display: grid; place-items: center;
}
.icon-btn:hover { background: var(--bg-sunk); }
.icon-btn svg { width: 21px; height: 21px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

#messages { flex: 1; overflow-y: auto; padding: 16px 14px 8px; -webkit-overflow-scrolling: touch; }
.wrap { max-width: 780px; margin: 0 auto; }

.msg { margin-bottom: 20px; }
.msg.user .bubble {
  background: var(--user-bubble); padding: 11px 14px; border-radius: var(--radius);
  border-top-right-radius: 5px; margin-left: auto; max-width: 85%; width: fit-content;
  white-space: pre-wrap; word-wrap: break-word;
}
.msg.assistant .bubble { max-width: 100%; }
.msg.assistant .bubble > *:first-child { margin-top: 0; }
.msg.assistant .bubble > *:last-child { margin-bottom: 0; }

/* Werkzeug-/Denk-Schritte */
.steps { margin: 0 0 10px; display: flex; flex-direction: column; gap: 6px; }
.step {
  font-size: 13.5px; color: var(--muted); background: var(--bg-sunk);
  border: 1px solid var(--line); border-radius: 12px; padding: 8px 11px;
}
.step summary { cursor: pointer; list-style: none; display: flex; gap: 8px; align-items: center; }
.step summary::-webkit-details-marker { display: none; }
.step .tag {
  font-family: var(--mono); font-size: 11.5px; text-transform: uppercase;
  letter-spacing: .4px; color: var(--accent);
}
.step .body { margin-top: 8px; white-space: pre-wrap; font-size: 13.5px; color: var(--text); opacity: .85; }
.step code { font-family: var(--mono); font-size: 12.5px; }

/* Markdown */
.bubble h1, .bubble h2, .bubble h3 { line-height: 1.3; margin: 1.1em 0 .5em; }
.bubble h1 { font-size: 1.35em; } .bubble h2 { font-size: 1.2em; } .bubble h3 { font-size: 1.05em; }
.bubble p { margin: .6em 0; }
.bubble ul, .bubble ol { margin: .6em 0; padding-left: 1.3em; }
.bubble li { margin: .25em 0; }
.bubble pre {
  background: var(--bg-sunk); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; overflow-x: auto; font-family: var(--mono); font-size: 13.5px;
}
.bubble :not(pre) > code {
  background: var(--bg-sunk); border-radius: 6px; padding: 1px 5px;
  font-family: var(--mono); font-size: .88em;
}
.bubble blockquote { margin: .6em 0; padding-left: 12px; border-left: 3px solid var(--line); color: var(--muted); }
.bubble table { border-collapse: collapse; width: 100%; font-size: 14px; display: block; overflow-x: auto; }
.bubble th, .bubble td { border: 1px solid var(--line); padding: 6px 9px; text-align: left; }
.bubble hr { border: 0; border-top: 1px solid var(--line); margin: 1em 0; }

.cursor { display: inline-block; width: 7px; height: 1.05em; background: var(--accent); vertical-align: -2px; animation: blink 1s steps(2) infinite; border-radius: 2px; }
@keyframes blink { 50% { opacity: 0; } }

.meta-line { font-size: 12px; color: var(--muted); margin-top: 6px; }
.error-box { background: #fdecea; border: 1px solid #f3b7ad; color: #8d2a1c; padding: 10px 12px; border-radius: 12px; font-size: 14px; }
@media (prefers-color-scheme: dark) { .error-box { background: #3a211c; border-color: #5e3328; color: #f0b3a4; } }

/* Begruessung */
.hello { text-align: center; color: var(--muted); padding: 12vh 10px; }
.hello h2 { color: var(--text); font-weight: 600; font-size: 22px; margin: 0 0 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 18px; }
.chip {
  border: 1px solid var(--line); background: var(--bg-elev); border-radius: 999px;
  padding: 8px 14px; font-size: 14px; color: var(--text);
}

/* Eingabe */
#composer {
  border-top: 1px solid var(--line); background: var(--bg);
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
}
.composer-inner {
  max-width: 780px; margin: 0 auto; display: flex; gap: 8px; align-items: flex-end;
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: 22px;
  padding: 6px 6px 6px 14px;
}
#input {
  flex: 1; border: 0; outline: 0; resize: none; background: none;
  max-height: 40vh; padding: 8px 0; font-size: 16px; line-height: 1.45;
}
#send {
  border: 0; border-radius: 50%; width: 38px; height: 38px; flex: none;
  background: var(--accent); color: #fff; display: grid; place-items: center;
}
#send:disabled { opacity: .35; }
#send svg { width: 19px; height: 19px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.hint { max-width: 780px; margin: 6px auto 0; font-size: 11.5px; color: var(--muted); text-align: center; }

/* Dialog Einstellungen */
dialog {
  border: 0; border-radius: 18px; padding: 0; width: min(520px, 94vw);
  background: var(--bg-elev); color: var(--text);
  box-shadow: 0 20px 60px rgba(0,0,0,.28);
}
dialog::backdrop { background: rgba(0,0,0,.45); }
.dlg-head { padding: 16px 18px 10px; border-bottom: 1px solid var(--line); display: flex; align-items: center; }
.dlg-head h2 { margin: 0; font-size: 17px; flex: 1; }
.dlg-body { padding: 16px 18px; max-height: 70dvh; overflow-y: auto; }
.dlg-foot { padding: 12px 18px calc(16px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 6px; }
.field .note { font-size: 12.5px; color: var(--muted); margin-top: 5px; }
.field input[type=text], .field input[type=password], .field select, .field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 11px;
  background: var(--bg); outline: 0;
}
.field textarea { resize: vertical; min-height: 72px; }
.switch { display: flex; align-items: center; gap: 10px; padding: 7px 0; font-size: 14.5px; }
.switch input { width: 20px; height: 20px; accent-color: var(--accent); }
.btn { border: 1px solid var(--line); background: var(--bg); border-radius: 11px; padding: 9px 16px; font-size: 14.5px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 11px; overflow: hidden; }
.seg button { flex: 1; border: 0; background: var(--bg); padding: 10px 8px; font-size: 14px; }
.seg button.on { background: var(--accent); color: #fff; }

@media (min-width: 900px) {
  #sidebar { position: relative; transform: none; }
  #overlay { display: none; }
  #burger { display: none; }
}

/* Rueckfrage von Claude */
.qcard {
  border: 1px solid var(--accent); background: var(--accent-soft);
  border-radius: var(--radius); padding: 14px; margin: 10px 0;
}
.qcard .q { font-weight: 600; margin-bottom: 4px; }
.qcard .qsub { font-size: 12.5px; color: var(--muted); margin-bottom: 12px; }
.qopts { display: flex; flex-direction: column; gap: 8px; }
.qopt {
  display: flex; gap: 10px; align-items: flex-start; text-align: left; width: 100%;
  border: 1px solid var(--line); background: var(--bg-elev); color: var(--text);
  border-radius: 12px; padding: 11px 13px; min-height: 44px;
}
.qopt:active { transform: scale(.99); }
.qopt.sel { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.qopt .ol { font-weight: 600; font-size: 14.5px; }
.qopt .od { font-size: 13px; color: var(--muted); margin-top: 2px; }
.qopt .mark { width: 20px; flex: none; color: var(--accent); font-size: 15px; }
.qother { display: flex; gap: 8px; margin-top: 10px; }
.qother input {
  flex: 1; border: 1px solid var(--line); border-radius: 12px; padding: 11px 13px;
  background: var(--bg-elev); outline: 0; min-height: 44px;
}
.qcard.done { border-color: var(--line); background: var(--bg-sunk); }
.qcard .answer { font-size: 14px; margin-top: 10px; color: var(--text); }
.qcard .answer b { color: var(--accent); }

/* Artefakt im Vollbild */
.artifact-view {
  position: fixed; inset: 0; z-index: 60; background: var(--bg);
  display: flex; flex-direction: column;
}
.artifact-view header h1 { font-size: 15px; }
#art-frame { flex: 1; width: 100%; border: 0; background: #fff; }

/* Abo-Anmeldung in den Einstellungen */
.oauth-box { border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: var(--bg); }
.oauth-row { display: flex; align-items: center; gap: 10px; font-size: 14.5px; }
.oauth-row span { flex: 1; }
.oauth-row .ok { color: var(--accent); font-weight: 600; }
#oauth-msg:empty { display: none; }
#oauth-msg { margin-top: 10px; }
