/* Bewerbungs-Coach – Oberfläche. Keine externen Ressourcen (CSP: self). */
:root {
  --bg: #f6f5f2;
  --bg-elev: #ffffff;
  --bg-sunk: #eeece7;
  --border: #dedad2;
  --border-strong: #c8c3b8;
  --text: #1d1f21;
  --text-muted: #5f6570;
  --text-faint: #8b9099;
  --accent: #1f6f5c;
  --accent-soft: #e4efe9;
  --accent-text: #14503f;
  --user-bubble: #1f6f5c;
  --user-text: #f6fbf8;
  --warn: #8a5a00;
  --warn-soft: #fdf3dc;
  --danger: #a3341f;
  --danger-soft: #fbe9e5;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(20, 25, 30, .06), 0 8px 24px rgba(20, 25, 30, .06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --serif: Georgia, "Times New Roman", serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161a;
    --bg-elev: #1b1e23;
    --bg-sunk: #101216;
    --border: #2b3037;
    --border-strong: #3c434c;
    --text: #e9eaec;
    --text-muted: #a3aab4;
    --text-faint: #7b828c;
    --accent: #4fbf9f;
    --accent-soft: #17302a;
    --accent-text: #8fdcc5;
    --user-bubble: #2a5d51;
    --user-text: #eafaf4;
    --warn: #e4b95f;
    --warn-soft: #2e2617;
    --danger: #f0907c;
    --danger-soft: #33201c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .28);
  }
}
:root[data-theme="dark"] {
  --bg: #14161a;
  --bg-elev: #1b1e23;
  --bg-sunk: #101216;
  --border: #2b3037;
  --border-strong: #3c434c;
  --text: #e9eaec;
  --text-muted: #a3aab4;
  --text-faint: #7b828c;
  --accent: #4fbf9f;
  --accent-soft: #17302a;
  --accent-text: #8fdcc5;
  --user-bubble: #2a5d51;
  --user-text: #eafaf4;
  --warn: #e4b95f;
  --warn-soft: #2e2617;
  --danger: #f0907c;
  --danger-soft: #33201c;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .28);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3 { line-height: 1.25; }

.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; z-index: 99; background: var(--bg-elev); padding: 8px 12px; border-radius: 8px; }

/* Topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px 16px; background: var(--bg-elev); border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.mark {
  width: 34px; height: 34px; border-radius: 10px; background: var(--accent); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 13px; letter-spacing: .04em;
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font-size: 15px; }
.brand-text .sub { font-size: 11.5px; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.field { display: flex; align-items: center; gap: 6px; }
.field-label { font-size: 12px; color: var(--text-muted); }
select, input[type="password"] {
  font: inherit; font-size: 13px; padding: 5px 8px; border-radius: 8px;
  border: 1px solid var(--border-strong); background: var(--bg); color: var(--text);
}
.icon-btn {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px;
  background: transparent; border: 1px solid var(--border); transition: background .15s, border-color .15s;
}
.icon-btn:hover { background: var(--bg-sunk); border-color: var(--border-strong); }
.ghost-btn {
  background: transparent; border: 1px solid var(--border); border-radius: 8px;
  padding: 5px 10px; font-size: 13px; transition: background .15s, border-color .15s;
}
.ghost-btn:hover { background: var(--bg-sunk); border-color: var(--border-strong); }
.send-btn {
  display: inline-flex; align-items: center; gap: 7px; background: var(--accent); color: #fff;
  border: 1px solid transparent; border-radius: 10px; padding: 9px 14px; font-weight: 600; font-size: 14px;
  transition: filter .15s;
}
.send-btn:hover { filter: brightness(1.07); }
.send-btn:disabled, .icon-btn:disabled { opacity: .5; cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Layout */
.shell {
  flex: 1 1 auto; min-height: 0;
  display: grid; grid-template-columns: 290px minmax(0, 1fr) minmax(0, 0.95fr);
  gap: 12px; padding: 12px; overflow: hidden;
}
.panel {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); display: flex; flex-direction: column; min-height: 0; overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 14px; border-bottom: 1px solid var(--border); flex: 0 0 auto;
}
.panel-head.tight { border-top: 1px solid var(--border); border-bottom: none; padding-bottom: 4px; }
.panel-head h2 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-muted); }
.hint { font-size: 11px; color: var(--text-faint); }

/* Unterlagen */
.documents { overflow-y: auto; }
.dropzone {
  margin: 12px; padding: 18px 14px; border: 1.5px dashed var(--border-strong); border-radius: var(--radius-sm);
  background: var(--bg-sunk); text-align: center; color: var(--text-muted); transition: border-color .15s, background .15s;
}
.dropzone p { margin: 8px 0 0; font-size: 12.5px; }
.dropzone svg { width: 24px; height: 24px; color: var(--accent); }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }
.doclist { list-style: none; margin: 0; padding: 0 12px; display: flex; flex-direction: column; gap: 8px; }
.doc-item {
  display: flex; align-items: flex-start; gap: 9px; padding: 9px 10px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--bg);
}
.doc-item.inactive { opacity: .55; }
.doc-item input[type="checkbox"] { margin-top: 3px; accent-color: var(--accent); }
.doc-main { min-width: 0; flex: 1 1 auto; }
.doc-name { font-size: 13px; font-weight: 600; word-break: break-word; }
.doc-meta { font-size: 11px; color: var(--text-faint); }
.doc-kind {
  display: inline-block; font-size: 10px; text-transform: uppercase; letter-spacing: .05em;
  background: var(--accent-soft); color: var(--accent-text); padding: 1px 6px; border-radius: 5px; margin-top: 3px;
}
.doc-del { background: none; border: none; color: var(--text-faint); padding: 2px; border-radius: 6px; }
.doc-del:hover { color: var(--danger); background: var(--danger-soft); }
.empty { margin: 4px 14px 14px; font-size: 12px; color: var(--text-faint); }
.actions { display: flex; flex-wrap: wrap; gap: 7px; padding: 10px 12px 14px; }
.actions button {
  background: var(--bg); border: 1px solid var(--border); border-radius: 999px; padding: 6px 11px;
  font-size: 12.5px; transition: background .15s, border-color .15s, color .15s;
}
.actions button:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); }
.panel-foot { margin-top: auto; padding: 12px 14px; border-top: 1px solid var(--border); }
.panel-foot p { margin: 0 0 6px; font-size: 11px; color: var(--text-muted); }
.muted { color: var(--text-faint) !important; }

/* Chat */
.messages { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 18px 20px 8px; scroll-behavior: smooth; }
.msg { display: flex; flex-direction: column; gap: 6px; margin-bottom: 20px; max-width: 760px; }
.msg.user { margin-left: auto; align-items: flex-end; }
.msg-role { font-size: 11px; color: var(--text-faint); letter-spacing: .04em; text-transform: uppercase; }
.bubble { border-radius: var(--radius); padding: 12px 15px; background: var(--bg-sunk); border: 1px solid var(--border); }
.msg.user .bubble { background: var(--user-bubble); color: var(--user-text); border-color: transparent; }
.msg.user .bubble a { color: inherit; }
.bubble > :first-child { margin-top: 0; }
.bubble > :last-child { margin-bottom: 0; }
.bubble p { margin: 0 0 10px; }
.bubble h1, .bubble h2, .bubble h3 { margin: 14px 0 7px; font-size: 1.03em; }
.bubble ul, .bubble ol { margin: 0 0 10px; padding-left: 22px; }
.bubble li { margin-bottom: 4px; }
.bubble code { font-family: var(--mono); font-size: .89em; background: var(--bg); padding: 1px 5px; border-radius: 5px; }
.bubble pre { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px; overflow-x: auto; }
.bubble pre code { background: none; padding: 0; }
.bubble blockquote { margin: 0 0 10px; padding-left: 12px; border-left: 3px solid var(--border-strong); color: var(--text-muted); }
.bubble table { border-collapse: collapse; width: 100%; margin-bottom: 10px; font-size: .94em; }
.bubble th, .bubble td { border: 1px solid var(--border); padding: 5px 8px; text-align: left; }
.bubble hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }
.msg-tools { display: flex; gap: 6px; }
.msg-tools button { background: none; border: none; color: var(--text-faint); font-size: 12px; padding: 2px 6px; border-radius: 6px; }
.msg-tools button:hover { color: var(--accent-text); background: var(--accent-soft); }

.reasoning { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg); overflow: hidden; }
.reasoning summary {
  cursor: pointer; padding: 7px 12px; font-size: 12px; color: var(--text-muted);
  display: flex; align-items: center; gap: 7px; list-style: none;
}
.reasoning summary::-webkit-details-marker { display: none; }
.reasoning summary::before { content: "▸"; font-size: 10px; }
.reasoning[open] summary::before { content: "▾"; }
.reasoning .reason-text {
  padding: 0 12px 10px; font-size: 12.5px; color: var(--text-muted); white-space: pre-wrap;
  max-height: 240px; overflow-y: auto; font-family: var(--mono); line-height: 1.5;
}
.doc-note {
  display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; padding: 7px 11px;
  border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--accent-text); border: 1px solid transparent;
  cursor: pointer; text-align: left;
}
.typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-faint); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }

/* Composer */
.composer { flex: 0 0 auto; border-top: 1px solid var(--border); padding: 12px 16px 14px; background: var(--bg-elev); }
.composer-row { display: flex; gap: 9px; align-items: flex-end; }
#input {
  flex: 1 1 auto; font: inherit; resize: none; max-height: 190px; padding: 11px 13px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--bg); color: var(--text);
}
#input:focus { border-color: var(--accent); outline: none; }
.composer-buttons { display: flex; gap: 8px; align-items: center; }
.icon-btn.mic { width: 42px; height: 42px; }
.icon-btn.mic.recording { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); animation: pulse 1.4s infinite; }
.icon-btn.mic.busy { opacity: .6; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(163, 52, 31, .35); } 50% { box-shadow: 0 0 0 7px rgba(163, 52, 31, 0); } }
.composer-meta { display: flex; align-items: center; gap: 12px; margin-top: 9px; font-size: 12px; color: var(--text-muted); }
.composer-meta .spacer { flex: 1 1 auto; }
.switch { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; }
.switch input { accent-color: var(--accent); }
.switch small { color: var(--text-faint); }
.status { font-size: 12px; color: var(--text-faint); }
.status.busy { color: var(--accent-text); }

/* Vorschau */
.preview-actions { display: flex; gap: 6px; align-items: center; }
.menu { display: flex; gap: 5px; }
.tabs { display: flex; gap: 6px; overflow-x: auto; padding: 9px 12px; border-bottom: 1px solid var(--border); flex: 0 0 auto; }
.tabs:empty { display: none; }
.tab {
  border: 1px solid var(--border); background: var(--bg); border-radius: 999px; padding: 5px 12px;
  font-size: 12.5px; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px;
}
.tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.tab .ver { font-size: 10px; opacity: .75; }
.doc-view { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 22px 26px 30px; }
.preview-empty { max-width: 340px; margin: 12% auto 0; text-align: center; color: var(--text-muted); }
.preview-empty svg { width: 34px; height: 34px; color: var(--text-faint); margin-bottom: 10px; }
.preview-empty p { margin: 0 0 8px; font-size: 13px; }
.doc-body { font-family: var(--serif); font-size: 15px; line-height: 1.62; max-width: 62ch; }
.doc-body h1 { font-size: 1.6em; margin: 0 0 4px; font-family: var(--font); }
.doc-body h2 { font-size: 1.12em; margin: 22px 0 7px; font-family: var(--font); letter-spacing: .01em;
  padding-bottom: 4px; border-bottom: 1px solid var(--border); }
.doc-body h3 { font-size: 1em; margin: 16px 0 5px; font-family: var(--font); }
.doc-body p { margin: 0 0 11px; }
.doc-body ul, .doc-body ol { margin: 0 0 12px; padding-left: 22px; }
.doc-body li { margin-bottom: 5px; }
.doc-body table { border-collapse: collapse; width: 100%; margin-bottom: 12px; font-family: var(--font); font-size: .93em; }
.doc-body th, .doc-body td { border: 1px solid var(--border); padding: 6px 9px; text-align: left; vertical-align: top; }
.doc-body hr { border: none; border-top: 1px solid var(--border); margin: 18px 0; }
.doc-body blockquote { margin: 0 0 12px; padding-left: 13px; border-left: 3px solid var(--border-strong); color: var(--text-muted); }
.doc-body mark { background: var(--warn-soft); color: var(--warn); padding: 0 3px; border-radius: 4px; font-family: var(--font); font-size: .9em; }
.doc-edit {
  width: 100%; min-height: 70vh; font-family: var(--mono); font-size: 13px; line-height: 1.6;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 12px;
  background: var(--bg); color: var(--text); resize: vertical;
}

/* Mobile */
.mobile-tabs { display: none; }
@media (max-width: 1100px) {
  .shell { grid-template-columns: 250px minmax(0, 1fr); }
  .panel.preview { display: none; }
  .shell.show-preview { grid-template-columns: 250px minmax(0, 1fr); }
  .shell.show-preview .panel.chat { display: none; }
  .shell.show-preview .panel.preview { display: flex; }
}
@media (max-width: 760px) {
  body { overflow: auto; }
  .shell { grid-template-columns: minmax(0, 1fr); padding: 8px 8px 60px; }
  .panel.documents, .panel.preview { display: none; }
  .shell[data-view="docs"] .panel.documents { display: flex; }
  .shell[data-view="docs"] .panel.chat { display: none; }
  .shell[data-view="preview"] .panel.preview { display: flex; }
  .shell[data-view="preview"] .panel.chat { display: none; }
  .mobile-tabs {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
    background: var(--bg-elev); border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .mobile-tabs button {
    flex: 1 1 0; background: none; border: none; padding: 12px 4px; font-size: 12.5px; color: var(--text-muted);
    position: relative;
  }
  .mobile-tabs button.active { color: var(--accent-text); font-weight: 600; box-shadow: inset 0 2px 0 var(--accent); }
  .mobile-tabs .dot { position: absolute; top: 8px; right: 14px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
  .topbar { padding: 8px 12px; }
  .topbar .field.compact { display: none; }
  .topbar .ghost-btn { white-space: nowrap; font-size: 12px; padding: 5px 9px; }
  .brand-text .sub { max-width: 40vw; }
  #input { font-size: 16px; } /* iOS zoomt sonst beim Fokus */
  .messages { padding: 14px 12px 4px; }
  .doc-view { padding: 16px 16px 24px; }
  .msg { max-width: 100%; }
}

/* Toasts */
.toasts { position: fixed; right: 14px; bottom: 14px; z-index: 40; display: flex; flex-direction: column; gap: 8px; max-width: min(380px, 92vw); }
.toast {
  background: var(--bg-elev); border: 1px solid var(--border-strong); border-left: 3px solid var(--accent);
  border-radius: 10px; padding: 10px 13px; font-size: 13px; box-shadow: var(--shadow); animation: slide .2s ease-out;
}
.toast.error { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warn); }
@keyframes slide { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

dialog {
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-elev); color: var(--text);
  box-shadow: var(--shadow); padding: 22px; max-width: 360px;
}
dialog::backdrop { background: rgba(10, 12, 15, .45); }
dialog h2 { margin: 0 0 8px; font-size: 16px; }
dialog p { margin: 0 0 14px; font-size: 13px; color: var(--text-muted); }
dialog input { width: 100%; margin-bottom: 12px; padding: 9px 11px; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
