/* WyvernLab – Farben und Formen wie WyvernDesk (public/assets/styles.css dort) */

:root {
  --bg: #141414;
  --pattern: url("/assets/hex-dark.svg");
  --panel: #1f1f1f;
  --panel-2: #262626;
  --panel-3: #2d2d2d;
  --editor: #181818;
  --border: #2e2e2e;
  --border-strong: #3a3a3a;
  --text: #ececec;
  --text-2: #cdcdcd;
  --muted: #8d8d8d;
  --accent: #74c236;
  --accent-2: #8fd94c;
  --accent-soft: rgba(116, 194, 54, 0.14);
  --accent-ink: #0f1a06;
  --danger: #e5534b;
  --danger-soft: rgba(229, 83, 75, 0.14);
  --warn: #e3b341;
  --overlay: rgba(6, 6, 6, 0.72);
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.38);
  --radius: 14px;
  --radius-sm: 9px;
  --topbar-h: 48px;
  --files-w: 260px;
  --claude-w: 420px;
  --mono: "JetBrains Mono", "Cascadia Code", Consolas, "SF Mono", Menlo, monospace;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
:root { scrollbar-width: thin; scrollbar-color: var(--panel-3) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--panel-3); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

html, body { margin: 0; height: 100%; }
body {
  background: var(--bg) var(--pattern) center top / 760px repeat fixed;
  color: var(--text);
  font: 14px/1.45 "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  display: flex; flex-direction: column;
  overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent-2); }
code, kbd, pre { font-family: var(--mono); }
kbd { background: var(--panel-3); border: 1px solid var(--border-strong); border-radius: 5px; padding: 0 5px; font-size: 12px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.spacer { flex: 1; }
.row { display: flex; gap: 10px; align-items: center; }
.row.end { justify-content: flex-end; }

.icon { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------------------------------------------------------------- Bausteine */

.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--panel-2);
  font-size: 13px; font-weight: 600; white-space: nowrap; text-decoration: none; color: var(--text);
  transition: background .15s, border-color .15s, color .15s, opacity .15s;
}
.btn:hover { background: var(--panel-3); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-2); }
.btn.danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.btn.danger:hover { background: var(--danger); color: #fff; }
.btn.block { width: 100%; height: 42px; }
.btn.sm { height: 30px; padding: 0 12px; font-size: 12.5px; }

.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px;
  border-radius: var(--radius-sm); border: 1px solid transparent;
  background: transparent; color: var(--text-2); transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
.icon-btn.sm { width: 28px; height: 28px; }
.icon-btn.sm .icon { width: 16px; height: 16px; }

.input, .field input {
  width: 100%; height: 40px; padding: 0 12px;
  background: var(--panel-2); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus, .field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field > span { font-size: 12.5px; color: var(--text-2); font-weight: 600; }

.select {
  height: 28px; padding: 0 26px 0 8px; max-width: 100%;
  background: var(--panel-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%238d8d8d' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 9px center;
  border: 1px solid var(--border); border-radius: 7px; appearance: none; outline: none; font-size: 12.5px;
}
.select:focus { border-color: var(--accent); }
.select option { background: var(--panel); }

/* ---------------------------------------------------------------- Login */

.login-page { display: grid; place-items: center; padding: 20px; overflow: auto; }
.login-card { width: min(400px, 100%); padding: 28px; }
.login-brand { display: flex; gap: 14px; align-items: center; margin-bottom: 22px; }
.login-brand h1 { margin: 0; font-size: 22px; }
.login-brand p { margin: 0; }
.login-step p { margin: 0 0 14px; }
.login-error { color: var(--danger); background: var(--danger-soft); border-radius: var(--radius-sm); padding: 9px 12px; margin: 14px 0 0; }
.code-input { font-family: var(--mono); font-size: 20px !important; letter-spacing: 4px; text-align: center; }
.qr { width: 196px; margin: 4px auto 12px; border-radius: 10px; overflow: hidden; }
.qr svg { display: block; width: 100%; height: auto; }
.setup-list { margin: 0 0 6px; padding-left: 20px; }
.setup-list li { margin-bottom: 4px; }
.secret { word-break: break-all; color: var(--accent-2); }
details { margin-bottom: 14px; }
summary { cursor: pointer; color: var(--muted); }
.recovery { background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 16px; columns: 2; font-size: 15px; line-height: 1.8; margin: 0 0 14px; }

/* ---------------------------------------------------------------- Topbar */

.topbar {
  height: var(--topbar-h); flex: none; display: flex; align-items: center; gap: 10px;
  padding: 0 10px 0 14px; background: rgba(20, 20, 20, .92); border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; gap: 9px; color: var(--text); text-decoration: none; font-weight: 700; font-size: 15px; }
.crumb { display: flex; align-items: center; gap: 10px; font-weight: 600; min-width: 0; }
.crumb span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crumb-sep { color: var(--border-strong); }
.user-name { font-size: 13px; }

/* ---------------------------------------------------------------- Startseite */

.home { flex: 1; display: grid; place-items: center; overflow: auto; padding: 24px 0; }
.home-inner { width: 100%; text-align: center; }
.home h2 { margin: 0 0 4px; font-size: 26px; }
.home .muted { margin: 0 0 28px; }
/* Alle Projekte in einer Reihe; bei vielen wird waagerecht gescrollt. */
.project-row {
  display: flex; gap: 16px; overflow-x: auto; padding: 8px 24px 18px;
  scroll-snap-type: x proximity; justify-content: safe center;
}
.project-card {
  flex: none; width: 184px; height: 168px; scroll-snap-align: center;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  padding: 16px; text-align: center; color: var(--text); text-decoration: none;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); transition: transform .15s, border-color .15s, background .15s;
}
.project-card:hover { transform: translateY(-3px); border-color: var(--accent); }
.project-card .p-icon {
  width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-2); font-weight: 800; font-size: 22px;
}
.project-card .p-name { font-weight: 700; font-size: 15px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-card .p-meta { font-size: 12px; color: var(--muted); }
.project-card.new { border-style: dashed; background: transparent; box-shadow: none; color: var(--muted); }
.project-card.new .p-icon { background: var(--panel-2); color: var(--muted); }
.project-card.new:hover { color: var(--accent-2); }
.project-card.new:hover .p-icon { color: var(--accent-2); background: var(--accent-soft); }

/* ---------------------------------------------------------------- Arbeitsbereich */

.workspace {
  flex: 1; min-height: 0; display: grid;
  grid-template-columns: var(--files-w) 5px minmax(240px, 1fr) 5px var(--claude-w);
}
.pane { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--panel); }
.pane-editor { background: var(--editor); }
.pane-head {
  height: 40px; flex: none; display: flex; align-items: center; gap: 4px;
  padding: 0 6px 0 12px; border-bottom: 1px solid var(--border);
}
.pane-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.splitter { background: var(--border); cursor: col-resize; position: relative; transition: background .15s; }
.splitter:hover, .splitter.dragging { background: var(--accent); }
.splitter::after { content: ""; position: absolute; inset: 0 -4px; }

/* Dateibaum */
.tree { flex: 1; overflow: auto; padding: 6px 0 20px; outline: none; font-size: 13px; user-select: none; }
.tree-row {
  display: flex; align-items: center; gap: 5px; height: 26px; padding-right: 8px;
  white-space: nowrap; cursor: pointer; color: var(--text-2); border-left: 2px solid transparent;
}
.tree-row:hover { background: var(--panel-2); }
.tree-row.active { background: var(--accent-soft); color: var(--text); border-left-color: var(--accent); }
.tree-row.dim { opacity: .55; }
.tree-row .chev { width: 14px; height: 14px; flex: none; color: var(--muted); transition: transform .12s; }
.tree-row.open .chev { transform: rotate(90deg); }
.tree-row .chev.blank { visibility: hidden; }
.tree-row .ficon { width: 16px; height: 16px; flex: none; }
.tree-row .fname { overflow: hidden; text-overflow: ellipsis; }
.tree-empty { padding: 14px; color: var(--muted); font-size: 12.5px; }
.ic-folder { color: var(--accent); }
.ic-file { color: var(--muted); }
.ic-code { color: #5aa9e6; }
.ic-image { color: #c27dff; }
.ic-text { color: #a4abb3; }
.ic-config { color: var(--warn); }

/* Tabs & Editor */
.tabs { height: 38px; flex: none; display: flex; overflow-x: auto; background: var(--panel); border-bottom: 1px solid var(--border); scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: flex; align-items: center; gap: 7px; padding: 0 8px 0 12px; height: 100%;
  border-right: 1px solid var(--border); font-size: 13px; color: var(--muted); cursor: pointer; white-space: nowrap;
  border-top: 2px solid transparent;
}
.tab:hover { color: var(--text-2); background: var(--panel-2); }
.tab.active { color: var(--text); background: var(--editor); border-top-color: var(--accent); }
.tab .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); display: none; }
.tab.dirty .dot { display: block; }
.tab .close { width: 20px; height: 20px; border-radius: 5px; display: grid; place-items: center; border: 0; background: none; color: inherit; padding: 0; opacity: .6; }
.tab .close:hover { background: var(--panel-3); opacity: 1; }
.tab .close .icon { width: 14px; height: 14px; }
.editor-area { flex: 1; min-height: 0; position: relative; }
.editor-host { position: absolute; inset: 0; }
.editor-empty, .editor-preview { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 6px; background: var(--editor); }
.editor-empty img { opacity: .35; margin-bottom: 8px; }
.editor-empty p { margin: 0; }
.editor-preview { padding: 20px; overflow: auto; }
.editor-preview img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; background: repeating-conic-gradient(#222 0 25%, #2a2a2a 0 50%) 0 0 / 16px 16px; }
.statusbar { height: 24px; flex: none; display: flex; align-items: center; gap: 14px; padding: 0 12px; font-size: 12px; color: var(--muted); background: var(--panel); border-top: 1px solid var(--border); white-space: nowrap; overflow: hidden; }
.statusbar .ok { color: var(--accent-2); }
.statusbar .warn { color: var(--warn); }

/* ---------------------------------------------------------------- Claude-Panel */

.chat-head { gap: 6px; }
.claude-mark { width: 18px; height: 18px; flex: none; border-radius: 5px; background: var(--accent); mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2l2.4 7.6L22 12l-7.6 2.4L12 22l-2.4-7.6L2 12l7.6-2.4z'/%3E%3C/svg%3E") center / contain no-repeat; }
.chat-select { flex: 1; min-width: 0; }
.chat-options { display: flex; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.chat-options label { display: flex; align-items: center; gap: 5px; color: var(--muted); }
.chat-options .icon { width: 15px; height: 15px; }

.messages { flex: 1; overflow-y: auto; padding: 14px 12px 20px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 100%; overflow-wrap: anywhere; }
.msg.user {
  align-self: flex-end; max-width: 88%;
  background: var(--accent-soft); border: 1px solid rgba(116, 194, 54, .28);
  padding: 8px 12px; border-radius: 12px 12px 4px 12px; white-space: pre-wrap;
}
.msg.user .imgs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.msg.user .imgs img { width: 84px; height: 84px; object-fit: cover; border-radius: 8px; cursor: zoom-in; }
.msg.assistant { line-height: 1.55; }
.msg.assistant.live::after { content: "▍"; color: var(--accent); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.msg.assistant p { margin: 0 0 8px; }
.msg.assistant p:last-child { margin-bottom: 0; }
.msg.assistant h1, .msg.assistant h2, .msg.assistant h3, .msg.assistant h4 { margin: 12px 0 6px; font-size: 14.5px; }
.msg.assistant ul, .msg.assistant ol { margin: 4px 0 8px; padding-left: 20px; }
.msg.assistant li { margin: 2px 0; }
.msg.assistant code { background: var(--panel-3); padding: 1px 5px; border-radius: 5px; font-size: 12.5px; }
.msg.assistant pre { background: var(--editor); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; overflow-x: auto; margin: 6px 0 10px; }
.msg.assistant pre code { background: none; padding: 0; font-size: 12.5px; }
.msg.assistant blockquote { margin: 6px 0; padding-left: 10px; border-left: 3px solid var(--border-strong); color: var(--text-2); }
.msg.assistant table { border-collapse: collapse; margin: 6px 0; font-size: 13px; display: block; overflow-x: auto; }
.msg.assistant th, .msg.assistant td { border: 1px solid var(--border-strong); padding: 4px 8px; }

.tool { border: 1px solid var(--border); border-radius: 8px; background: var(--panel-2); font-size: 12.5px; }
.tool summary { display: flex; align-items: center; gap: 7px; padding: 6px 10px; color: var(--text-2); list-style: none; }
.tool summary::-webkit-details-marker { display: none; }
.tool summary .t-sum { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.tool .t-state { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--warn); animation: pulse 1.2s infinite; }
.tool.ok .t-state { background: var(--accent); animation: none; }
.tool.err .t-state { background: var(--danger); animation: none; }
@keyframes pulse { 50% { opacity: .35; } }
.tool .t-name { font-family: var(--mono); font-size: 11.5px; color: var(--muted); flex: none; }
.tool pre { margin: 0; padding: 8px 10px; border-top: 1px solid var(--border); max-height: 260px; overflow: auto; font-size: 11.5px; white-space: pre-wrap; color: var(--text-2); }
.tool pre.out { color: var(--muted); }

.msg.note { align-self: center; font-size: 12px; color: var(--muted); text-align: center; }
.msg.error { background: var(--danger-soft); color: #ff8b84; border-radius: 8px; padding: 8px 12px; white-space: pre-wrap; font-size: 13px; }
.thinking { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; }
.thinking i { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: pulse 1s infinite; }
.thinking i:nth-child(2) { animation-delay: .15s; }
.thinking i:nth-child(3) { animation-delay: .3s; }
.chat-empty { margin: auto; text-align: center; color: var(--muted); padding: 20px; }
.chat-empty b { color: var(--text); display: block; font-size: 15px; margin-bottom: 4px; }

.composer { flex: none; border-top: 1px solid var(--border); padding: 10px; display: grid; gap: 8px; background: var(--panel); }
.composer.drop { outline: 2px dashed var(--accent); outline-offset: -6px; }
.composer textarea {
  width: 100%; resize: none; min-height: 44px; max-height: 40vh; padding: 9px 11px;
  background: var(--panel-2); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); outline: none; line-height: 1.45;
}
.composer textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer-bar { display: flex; align-items: center; gap: 8px; }
.attachments { display: flex; gap: 8px; flex-wrap: wrap; }
.attachment { position: relative; width: 64px; height: 64px; }
.attachment img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; border: 1px solid var(--border-strong); }
.attachment button { position: absolute; top: -6px; right: -6px; width: 20px; height: 20px; border-radius: 50%; border: 0; background: var(--danger); color: #fff; font-size: 13px; line-height: 1; padding: 0; }

/* ---------------------------------------------------------------- Menüs, Dialoge, Meldungen */

.ctxmenu { position: fixed; z-index: 50; min-width: 180px; padding: 5px; background: var(--panel); border: 1px solid var(--border-strong); border-radius: 10px; box-shadow: var(--shadow); }
.ctxmenu button { display: flex; align-items: center; gap: 9px; width: 100%; padding: 7px 10px; border: 0; background: none; border-radius: 6px; text-align: left; font-size: 13px; }
.ctxmenu button:hover { background: var(--panel-2); }
.ctxmenu button.danger { color: var(--danger); }
.ctxmenu .icon { width: 15px; height: 15px; }
.ctxmenu hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }

.modal { position: fixed; inset: 0; z-index: 60; background: var(--overlay); display: grid; place-items: center; padding: 20px; }
.modal-card { width: min(420px, 100%); padding: 20px; }
.modal-card h3 { margin: 0 0 6px; }
.modal-card p { margin: 0 0 14px; }
.modal-card .input { margin-bottom: 16px; }

.lightbox { position: fixed; inset: 0; z-index: 70; background: var(--overlay); display: grid; place-items: center; padding: 20px; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 10px; }

.toasts { position: fixed; z-index: 80; bottom: 16px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; pointer-events: none; }
.toast { background: var(--panel-3); border: 1px solid var(--border-strong); border-radius: 10px; padding: 9px 14px; box-shadow: var(--shadow); font-size: 13px; animation: toast-in .2s ease-out; }
.toast.error { border-color: var(--danger); color: #ff8b84; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.mobile-tabs { display: none; }

/* ---------------------------------------------------------------- Handy & schmale Fenster */

@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .splitter { display: none; }
  .workspace .pane { display: none; }
  .workspace[data-pane="files"] .pane-files,
  .workspace[data-pane="editor"] .pane-editor,
  .workspace[data-pane="claude"] .pane-claude { display: flex; }
  .mobile-tabs:not([hidden]) {
    display: flex; flex: none; border-top: 1px solid var(--border); background: var(--panel);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .mobile-tabs button {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 7px 0 6px; border: 0; background: none; color: var(--muted); font-size: 11.5px;
  }
  .mobile-tabs button.active { color: var(--accent-2); }
  .user-name { display: none; }
  .project-card { width: 150px; height: 150px; }
  .msg.user { max-width: 94%; }
  .composer textarea { font-size: 16px; } /* verhindert Auto-Zoom auf iOS */
}
