/* ===== Open-WebUI-Dark-Theme (Basis aus Money übernommen) ===== */
:root {
  --bg: #171717;
  --bg-side: #0d0d0d;
  --bg-elev: #212121;
  --bg-input: #262626;
  --bg-hover: rgba(255, 255, 255, 0.05);
  --bg-active: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.12);
  --text: #ececec;
  --text-2: #b4b4b4;
  --text-3: #8e8e8e;
  --text-4: #676767;
  --accent: #ececec;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #eab308;
  --pos: #b4b4b4;
  --neg: #fb923c;
  --radius: 0.75rem;
  --radius-lg: 1.25rem;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[x-cloak] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); line-height: 1.45; -webkit-font-smoothing: antialiased; }
html { font-size: 14.7px; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: #93c5fd; }
h1, h2, h3 { font-weight: 500; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.18); }
::-webkit-scrollbar-track { background: transparent; }
* { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.12) transparent; }

/* ===== Basis-Elemente ===== */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; border: none; cursor: pointer; border-radius: 9999px;
  padding: .5rem 1rem; font-weight: 500; font-size: .875rem; background: var(--bg-input); color: var(--text); transition: background .15s, opacity .15s;
  white-space: nowrap; flex-shrink: 0; text-decoration: none; }
.btn:hover { background: #303030; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: #fff; color: #000; }
.btn-primary:hover { background: #e5e5e5; }
.btn-accent { background: rgba(255,255,255,.1); color: var(--text); }
.btn-accent:hover { background: rgba(255,255,255,.16); }
.btn-danger { background: rgba(239,68,68,.15); color: #fca5a5; }
.btn-danger:hover { background: rgba(239,68,68,.25); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--bg-hover); }
.btn-sm { padding: .3rem .75rem; font-size: .8rem; }
.btn svg { width: 1.05rem; height: 1.05rem; }

.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 2rem; height: 2rem; border-radius: .6rem; border: none; cursor: pointer;
  background: transparent; color: var(--text-2); transition: background .15s, color .15s; flex-shrink: 0; }
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn:disabled { opacity: .4; cursor: default; }
.icon-btn svg, .nav-item svg { width: 1.1rem; height: 1.1rem; flex-shrink: 0; }
.icon-btn.sm { width: 1.6rem; height: 1.6rem; }
.icon-btn.sm svg { width: .95rem; height: .95rem; }

.input, .select, .textarea { width: 100%; background: var(--bg-input); border: 1px solid transparent; border-radius: var(--radius); padding: .55rem .85rem; outline: none; transition: border-color .15s; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--border-strong); }
.input.invalid { border-color: rgba(239,68,68,.6); }
.input::placeholder, .textarea::placeholder { color: var(--text-4); }
select { color-scheme: dark; }
select option { background-color: var(--bg-elev); color: var(--text); }
.textarea { resize: vertical; min-height: 4rem; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke-width='2' stroke='%23999'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='m19.5 8.25-7.5 7.5-7.5-7.5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .7rem center; background-size: 1rem; padding-right: 2.2rem; }
input[type="date"] { color-scheme: dark; }

label.field { display: flex; flex-direction: column; gap: .3rem; font-size: .8rem; color: var(--text-3); }
label.field > span { padding-left: .2rem; }
.row { display: flex; gap: .75rem; }
.row > * { flex: 1; min-width: 0; }
.row > .narrow { flex: 0 0 7rem; }
.check { display: flex; align-items: center; gap: .5rem; font-size: .85rem; color: var(--text-2); cursor: pointer; user-select: none; }
.check input { accent-color: #fff; width: 1rem; height: 1rem; }
/* Auswahl der Listen einer Übersicht */
.pick-list { border: 1px solid var(--border); border-radius: var(--radius); max-height: 16rem; overflow-y: auto; }
.pick-row { padding: .5rem .7rem; border-bottom: 1px solid var(--border); min-width: 0; }
.pick-row:last-child { border-bottom: none; }
.pick-row:hover { background: var(--bg-hover); }
.pick-row .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.pick-row .spacer { flex: 1; }
.pick-list > .muted { padding: .6rem .7rem; }
.pick-row { justify-content: space-between; cursor: default; }
.pick-row.on { background: var(--bg-active); }
.pick-main { flex: 1; min-width: 0; }
.pick-icon { width: .9rem; height: .9rem; display: inline-flex; flex: none; color: var(--text-3); }
.pick-sep { height: 1px; background: var(--border-strong); }
.factor { display: inline-flex; align-items: center; gap: .25rem; flex: none; font-size: .8rem; }
.factor .input { width: 4.2rem; padding: .25rem .45rem; font-size: .8rem; text-align: right; }
.factor .input.invalid { border-color: var(--danger); }
.factor-badge { display: inline-block; font-size: .68rem; padding: 0 .35rem; margin-right: .35rem; border-radius: 999px; background: rgba(59,130,246,.18); color: #93c5fd; vertical-align: 1px; }
/* Übersicht: Quellen als Chips */
.source-chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.source-chip { display: inline-flex; align-items: center; gap: .3rem; font-size: .75rem; padding: .15rem .55rem; border-radius: 999px; border: 1px solid var(--border); background: var(--bg-input); color: var(--text-2); cursor: pointer; }
.source-chip:hover { background: var(--bg-hover); color: var(--text); }
.source-chip.gone { cursor: default; opacity: .55; text-decoration: line-through; }
.seg { display: inline-flex; background: var(--bg-input); border-radius: 9999px; padding: .15rem; gap: .1rem; flex-wrap: wrap; }
.seg button { border: none; background: transparent; color: var(--text-3); padding: .3rem .8rem; border-radius: 9999px; cursor: pointer; font-size: .8rem; }
.seg button.on { background: #fff; color: #000; }

.muted { color: var(--text-3); }
.small { font-size: .8rem; }
.tiny { font-size: .72rem; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spacer { flex: 1; }
.error-box { background: rgba(239,68,68,.12); color: #fca5a5; padding: .6rem .9rem; border-radius: var(--radius); font-size: .85rem; }
.info-box { background: rgba(59,130,246,.12); color: #bfdbfe; padding: .6rem .9rem; border-radius: var(--radius); font-size: .85rem; }

.pos { color: var(--pos); }
.neg { color: var(--neg); }
.mixed { color: #fde68a; }


/* ===== App-Logo: weißes Quadrat, schwarzes Symbol ===== */
.logo { display: inline-flex; align-items: center; justify-content: center; background: #fff; color: #000; flex-shrink: 0; }
.logo .logo-icon { width: 70%; height: 70%; }

/* ===== Login ===== */
.auth-wrap { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 2rem; }
.auth-card { width: 100%; max-width: 24rem; display: flex; flex-direction: column; gap: 1rem; }
.auth-logo { display: flex; align-items: center; gap: .6rem; justify-content: center; font-size: 1.6rem; font-weight: 600; margin-bottom: .5rem; }
.auth-logo .logo { width: 44px; height: 44px; border-radius: 14px; }
.auth-card .input { padding: .75rem 1rem; }
.auth-card .btn { padding: .75rem; }
.auth-switch { text-align: center; font-size: .85rem; color: var(--text-3); }
.auth-switch button { background: none; border: none; color: var(--text); cursor: pointer; text-decoration: underline; }

/* ===== Layout ===== */
.app { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }
.sidebar { width: 260px; flex-shrink: 0; background: var(--bg-side); display: flex; flex-direction: column; transition: margin-left .2s ease; border-right: 1px solid rgba(255,255,255,0.03); z-index: 40; }
.sidebar.collapsed { margin-left: -260px; }
.sidebar-top { padding: .6rem .6rem .25rem; display: flex; flex-direction: column; gap: .15rem; position: relative; }
.brand { display: flex; align-items: center; gap: .55rem; padding: .35rem .5rem .6rem; font-weight: 600; font-size: 1rem; }
.brand .logo { width: 26px; height: 26px; border-radius: 8px; }
.sidebar-search { display: flex; align-items: center; gap: .45rem; margin: .2rem 0 .1rem; padding: .3rem .6rem; background: transparent; border-radius: .6rem; }
.sidebar-search:focus-within { background: var(--bg-input); }
.sidebar-search svg { width: .95rem; height: .95rem; color: var(--text-3); flex-shrink: 0; }
.sidebar-search input { flex: 1; min-width: 0; background: transparent; border: none; outline: none; font-size: .85rem; padding: .15rem 0; }
.sidebar-scroll { flex: 1; overflow-y: auto; padding: .25rem .6rem 1rem; }
.sidebar-section { margin-top: .9rem; }
.sidebar-label { font-size: .72rem; font-weight: 500; color: var(--text-4); padding: .2rem .55rem .35rem; display: flex; align-items: center; gap: .3rem; }
.sidebar-label .icon-btn { width: 1.4rem; height: 1.4rem; margin-left: auto; }
.sidebar-label .icon-btn svg { width: .9rem; height: .9rem; }
.sidebar-backdrop { display: none; }

.nav-sep { height: 1px; background: var(--border-strong); margin: .35rem .55rem; }
.nav-item { display: flex; align-items: center; gap: .55rem; width: 100%; padding: .45rem .55rem; border-radius: .6rem; border: none; background: transparent;
  color: var(--text-2); cursor: pointer; text-align: left; font-size: .875rem; transition: background .12s, color .12s; position: relative; }
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active { background: var(--bg-active); color: var(--text); }
.nav-item .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .nav-amount { font-size: .72rem; white-space: nowrap; }
.nav-item .emoji { width: 1.1rem; text-align: center; font-size: .95rem; flex-shrink: 0; }
.nav-item .avatar { width: 1.35rem; height: 1.35rem; font-size: .6rem; }
.nav-empty { font-size: .78rem; color: var(--text-4); padding: .3rem .55rem; }

.new-btn { display: flex; align-items: center; gap: .6rem; width: 100%; padding: .55rem .6rem; border-radius: .6rem; border: none; background: transparent; color: var(--text); cursor: pointer; font-weight: 500; }
.new-btn:hover { background: var(--bg-hover); }
.new-btn .plus { width: 1.6rem; height: 1.6rem; border-radius: 9999px; background: #fff; color: #000; display: flex; align-items: center; justify-content: center; }
.new-btn .plus svg { width: 1rem; height: 1rem; }

.sidebar-bottom { padding: .5rem .6rem .7rem; position: relative; }
.user-btn { display: flex; align-items: center; gap: .6rem; width: 100%; padding: .5rem; border-radius: .7rem; border: none; background: transparent; cursor: pointer; color: var(--text); text-align: left; }
.user-btn:hover { background: var(--bg-hover); }
.avatar { width: 2rem; height: 2rem; border-radius: 9999px; background: linear-gradient(135deg, #6366f1, #ec4899); display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: .78rem; color: #fff; flex-shrink: 0; text-transform: uppercase; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar.lg { width: 3rem; height: 3rem; font-size: 1.05rem; }
.avatar.sm { width: 1.6rem; height: 1.6rem; font-size: .62rem; }

.menu { position: absolute; z-index: 60; min-width: 13rem; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: .3rem; display: flex; flex-direction: column; }
.menu button { display: flex; align-items: center; gap: .55rem; padding: .5rem .65rem; border-radius: .55rem; border: none; background: none; cursor: pointer; text-align: left; color: var(--text); font-size: .85rem; }
.menu button:hover { background: var(--bg-hover); }
.menu button svg { width: 1rem; height: 1rem; color: var(--text-3); }
.menu .danger, .menu .danger svg { color: #fca5a5; }
.menu .menu-sep { height: 1px; background: var(--border); margin: .25rem .3rem; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg); position: relative; }
.topbar { height: 3.25rem; display: flex; align-items: center; gap: .5rem; padding: 0 .75rem; flex-shrink: 0; position: relative; }
.topbar h1 { font-size: 1.05rem; font-weight: 500; margin: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: .5rem; }
.page { flex: 1; overflow-y: auto; padding: 1rem 1.5rem 6rem; }
.page-inner { max-width: 52rem; margin: 0 auto; display: flex; flex-direction: column; gap: 1.25rem; }
/* Listen (Tabelle mit vielen Spalten) dürfen breiter werden */
.page-inner.wide { max-width: 72rem; }
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .6rem; color: var(--text-4); padding: 2.5rem 1rem; text-align: center; }
.empty svg { width: 2.6rem; height: 2.6rem; opacity: .5; }
.section-title { font-size: .8rem; color: var(--text-3); font-weight: 500; margin: 0 0 -.5rem .2rem; display: flex; align-items: center; gap: .5rem; }


.list { display: flex; flex-direction: column; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.list-row { display: flex; align-items: center; gap: .75rem; padding: .6rem .9rem; border-bottom: 1px solid var(--border); min-width: 0; }
.list-row:last-child { border-bottom: none; }
.list-row.click { cursor: pointer; transition: background .12s; }
.list-row.click:hover { background: var(--bg-hover); }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .title { font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row .sub { font-size: .75rem; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row .amount { text-align: right; flex-shrink: 0; }
.list-row .amount .lbl { font-size: .7rem; }
.list-row .amount .val { font-size: .9rem; font-weight: 500; }
.list-empty { padding: .9rem; font-size: .85rem; color: var(--text-4); text-align: center; }

.tabs { display: flex; gap: .2rem; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tabs button { border: none; background: none; color: var(--text-3); padding: .45rem .8rem; cursor: pointer; border-bottom: 2px solid transparent; font-size: .85rem; white-space: nowrap; }
.tabs button.on { color: var(--text); border-bottom-color: #fff; }

.notes { background: var(--bg-input); padding: .6rem .8rem; border-radius: var(--radius); font-size: .85rem; white-space: pre-wrap; word-break: break-word; color: var(--text-2); }

.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(2px); z-index: 80; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.modal { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); width: 100%; max-width: 32rem; max-height: 92vh; display: flex; flex-direction: column; }
.modal.wide { max-width: 38rem; }
.modal-head { display: flex; align-items: center; padding: 1rem 1.25rem .5rem; }
.modal-head h2 { margin: 0; font-size: 1.1rem; font-weight: 500; flex: 1; }
.modal-body { padding: .5rem 1.25rem 1rem; overflow-y: auto; display: flex; flex-direction: column; gap: .85rem; }
.modal-foot { display: flex; gap: .5rem; justify-content: flex-end; padding: .75rem 1.25rem 1.1rem; align-items: center; }

.chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.chip { display: inline-flex; align-items: center; gap: .35rem; background: var(--bg-input); border: 1px solid transparent; border-radius: 9999px; padding: .2rem .65rem .2rem .25rem; cursor: pointer; font-size: .82rem; color: var(--text-2); }
.chip.on { border-color: rgba(255,255,255,.5); color: var(--text); background: var(--bg-active); }
.chip .avatar { width: 1.35rem; height: 1.35rem; font-size: .55rem; }

.ai-scroll { flex: 1; overflow-y: auto; padding: .5rem 1rem 1rem; display: flex; flex-direction: column; gap: 1.1rem; }
.ai-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .9rem; text-align: center; color: var(--text-3); padding: 1rem; }
.ai-empty .hello { font-size: 1.35rem; color: var(--text); font-weight: 500; }
.ai-suggest { display: flex; flex-direction: column; gap: .45rem; width: 100%; max-width: 22rem; }
.ai-suggest button { text-align: left; background: var(--bg-input); border: 1px solid transparent; border-radius: var(--radius); padding: .6rem .8rem; cursor: pointer; color: var(--text-2); font-size: .85rem; }
.ai-suggest button:hover { border-color: var(--border-strong); color: var(--text); }
.ai-msg.user { align-self: flex-end; max-width: 85%; background: var(--bg-input); border-radius: 1.25rem; padding: .55rem .95rem; white-space: pre-wrap; word-break: break-word; }
.ai-msg.assistant { display: flex; gap: .65rem; align-items: flex-start; }
.ai-msg.assistant .ai-avatar { width: 1.75rem; height: 1.75rem; border-radius: 9999px; background: #fff; color: #000; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: .05rem; }
.ai-msg.assistant .ai-avatar svg { width: 1rem; height: 1rem; }
.ai-msg .ai-body { flex: 1; min-width: 0; line-height: 1.6; word-break: break-word; }
.ai-tool { display: inline-flex; align-items: center; gap: .4rem; font-size: .75rem; color: var(--text-3); background: var(--bg-elev); border: 1px solid var(--border); border-radius: 9999px; padding: .15rem .65rem .15rem .45rem; margin: 0 .3rem .35rem 0; }
.ai-tool svg { width: .85rem; height: .85rem; }
.ai-tool.error { color: #fca5a5; border-color: rgba(239, 68, 68, .35); }
.ai-tool .spinner { width: .75rem; height: .75rem; border-width: 1.5px; }
.ai-tool.done svg { color: var(--text-2); }
.ai-typing { display: inline-flex; gap: .25rem; padding: .3rem 0; }
.ai-typing span { width: .4rem; height: .4rem; border-radius: 9999px; background: var(--text-3); animation: aiblink 1.2s infinite ease-in-out; }
.ai-typing span:nth-child(2) { animation-delay: .2s; } .ai-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes aiblink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.ai-error { background: rgba(239, 68, 68, .12); color: #fca5a5; border-radius: var(--radius); padding: .55rem .8rem; font-size: .85rem; }
.ai-input-wrap { padding: .4rem .75rem .9rem; flex-shrink: 0; }
.ai-input { background: var(--bg-input); border: 1px solid var(--border); border-radius: 1.5rem; padding: .55rem .55rem .55rem 1rem; display: flex; align-items: flex-end; gap: .4rem; }
.ai-input:focus-within { border-color: var(--border-strong); }
.ai-input textarea { flex: 1; background: transparent; border: none; outline: none; resize: none; max-height: 12rem; min-height: 1.5rem; line-height: 1.5; padding: .2rem 0; }
.ai-input textarea::placeholder { color: var(--text-4); }
.ai-send { width: 2rem; height: 2rem; border-radius: 9999px; border: none; background: #fff; color: #000; display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; }
.ai-send:disabled { opacity: .3; cursor: default; }
.ai-send svg { width: 1rem; height: 1rem; }
.ai-hint { font-size: .68rem; color: var(--text-4); text-align: center; margin-top: .4rem; }
.md p { margin: 0 0 .6rem; } .md p:last-child { margin-bottom: 0; }
.md ul, .md ol { margin: .2rem 0 .6rem; padding-left: 1.3rem; } .md li { margin: .15rem 0; }
.md h1, .md h2, .md h3, .md h4 { font-size: 1rem; font-weight: 600; margin: .8rem 0 .4rem; }
.md code { font-family: var(--mono); font-size: .82em; background: rgba(255,255,255,.08); padding: .1rem .35rem; border-radius: .35rem; }
.md pre { background: #0d0d0d; border: 1px solid var(--border); border-radius: var(--radius); padding: .7rem .85rem; overflow-x: auto; margin: .4rem 0 .7rem; }
.md pre code { background: none; padding: 0; font-size: .8rem; }
.md blockquote { border-left: 2px solid var(--border-strong); margin: .4rem 0; padding-left: .8rem; color: var(--text-2); }
.md a { color: #93c5fd; }
.md table { border-collapse: collapse; margin: .4rem 0 .7rem; font-size: .82rem; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--border-strong); padding: .3rem .55rem; text-align: left; }
.md th { background: rgba(255,255,255,.04); font-weight: 600; }
.md hr { border: none; border-top: 1px solid var(--border); margin: .8rem 0; }
.md li.task { list-style: none; margin-left: -1.2rem; }
.md li.task input { accent-color: #fff; margin: 0 .35rem 0 0; vertical-align: -1px; }
.md del { opacity: .7; }

/* ===== Toasts ===== */
.toasts { position: fixed; right: 1.5rem; bottom: 1.5rem; z-index: 100; display: flex; flex-direction: column; gap: .5rem; align-items: flex-end; pointer-events: none; max-width: min(28rem, calc(100vw - 2rem)); }
.toast { background: var(--bg-elev); border: 1px solid var(--border-strong); padding: .6rem 1rem; border-radius: var(--radius); box-shadow: var(--shadow); font-size: .85rem; pointer-events: auto; display: flex; gap: .6rem; align-items: center; }
.toast.error { border-color: rgba(239,68,68,.5); color: #fca5a5; }
.toast.success { border-color: rgba(34,197,94,.4); }
.toast button { background: none; border: none; color: var(--text); text-decoration: underline; cursor: pointer; font-size: .82rem; padding: 0; }

.spinner { width: 1.2rem; height: 1.2rem; border: 2px solid rgba(255,255,255,.15); border-top-color: #fff; border-radius: 9999px; animation: spin .7s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===================================================================== */
/* ===== PlantDiary ===== */
.logo { border-radius: 8px; }
.logo.green { background: #fff; color: #000; }
.nav-thumb { width: 1.6rem; height: 1.6rem; border-radius: .45rem; object-fit: cover; flex-shrink: 0; background: var(--bg-input); display: inline-flex; align-items: center; justify-content: center; font-size: .8rem; overflow: hidden; }
.nav-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.nav-item .sub { font-size: .7rem; color: var(--text-4); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 5rem; }

.toolbar { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.toolbar .input { max-width: 18rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr)); gap: .85rem; }
.plant-card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; cursor: pointer; transition: border-color .15s, transform .15s; display: flex; flex-direction: column; text-align: left; padding: 0; color: inherit; }
.plant-card:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.plant-card .img { aspect-ratio: 1 / 1; background: var(--bg-input); display: flex; align-items: center; justify-content: center; color: var(--text-4); font-size: 2.5rem; }
.plant-card .img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.plant-card .body { padding: .55rem .75rem .7rem; display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.plant-card .name { font-weight: 500; font-size: .92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plant-card .species { font-size: .76rem; color: var(--text-3); font-style: italic; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plant-card .meta { font-size: .72rem; color: var(--text-4); display: flex; gap: .6rem; margin-top: .2rem; }
.group-title { font-size: .8rem; color: var(--text-3); font-weight: 500; margin: .4rem 0 -.3rem .2rem; }

/* Pflanzendetail */
.plant-head { display: flex; gap: 1.1rem; align-items: center; }
.plant-head .cover { width: 6.5rem; height: 6.5rem; border-radius: 1.1rem; object-fit: cover; background: var(--bg-input); flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 2.5rem; overflow: hidden; cursor: pointer; }
.plant-head .cover img { width: 100%; height: 100%; object-fit: cover; }
.plant-head h2 { margin: 0; font-size: 1.45rem; }
.plant-head .species { color: var(--text-3); font-style: italic; margin-top: .1rem; }
.plant-head .meta { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .45rem; }
.card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem; display: flex; flex-direction: column; gap: .7rem; }
.card h3 { margin: 0; font-size: .9rem; font-weight: 500; display: flex; align-items: center; gap: .5rem; }
.care-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: .6rem; }
.care-item { background: var(--bg-input); border-radius: var(--radius); padding: .55rem .7rem; font-size: .84rem; }
.care-item .k { font-size: .72rem; color: var(--text-3); margin-bottom: .15rem; display: flex; gap: .3rem; align-items: center; }
.kv { display: grid; grid-template-columns: 8rem 1fr; gap: .35rem .8rem; font-size: .87rem; }
.kv .k { color: var(--text-3); }
.conf { display: inline-flex; align-items: center; gap: .35rem; font-size: .75rem; padding: .1rem .5rem; border-radius: 999px; background: rgba(255,255,255,.08); color: var(--text-2); }
.conf.mid { background: rgba(234,179,8,.14); color: #fde68a; }
.conf.low { background: rgba(239,68,68,.14); color: #fca5a5; }

/* Galerie */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(8.5rem, 1fr)); gap: .5rem; }
.gallery .ph { position: relative; aspect-ratio: 1 / 1; border-radius: .8rem; overflow: hidden; background: var(--bg-input); cursor: pointer; border: 1px solid var(--border); padding: 0; }
.gallery .ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery .ph .tag { position: absolute; left: .35rem; top: .35rem; font-size: .65rem; padding: .05rem .4rem; border-radius: 999px; background: rgba(0,0,0,.6); color: #fff; }
.gallery .ph .star { position: absolute; right: .35rem; top: .3rem; font-size: .8rem; }
.gallery .ph .date { position: absolute; left: 0; right: 0; bottom: 0; font-size: .66rem; padding: .6rem .45rem .25rem; background: linear-gradient(transparent, rgba(0,0,0,.7)); color: #ddd; text-align: left; }
.gallery .ph.uploading { display: flex; align-items: center; justify-content: center; }
.dropzone { border: 1.5px dashed var(--border-strong); border-radius: var(--radius-lg); padding: 2rem 1rem; display: flex; flex-direction: column; align-items: center; gap: .7rem; text-align: center; color: var(--text-3); cursor: pointer; transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone.over { border-color: rgba(255,255,255,.4); background: var(--bg-hover); }
.dropzone svg { width: 2.4rem; height: 2.4rem; opacity: .6; }
.preview-img { width: 100%; max-height: 18rem; object-fit: contain; border-radius: var(--radius); background: #000; }
.progress { height: .3rem; border-radius: 999px; background: var(--bg-input); overflow: hidden; }
.progress > div { height: 100%; background: #fff; transition: width .15s; }

/* Lightbox */
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 90; display: flex; flex-direction: column; }
.lightbox .lb-head { display: flex; align-items: center; gap: .5rem; padding: .6rem .8rem; color: var(--text-2); }
.lightbox .lb-head .grow { flex: 1; min-width: 0; font-size: .85rem; }
.lightbox .lb-img { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 0; position: relative; }
.lightbox .lb-img img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lightbox .lb-nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(0,0,0,.5); }
.lightbox .lb-nav.prev { left: .6rem; } .lightbox .lb-nav.next { right: .6rem; }
.lightbox .lb-foot { padding: .6rem .9rem 1rem; display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.lightbox .lb-foot .input { flex: 1; min-width: 12rem; }

/* Chat (Open-WebUI-Stil) */
.chat-layout { flex: 1; display: flex; min-height: 0; }
.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-scroll { flex: 1; overflow-y: auto; padding: 1rem 1rem 1.5rem; }
.chat-inner { max-width: 48rem; margin: 0 auto; display: flex; flex-direction: column; gap: 1.2rem; }
.chat-list { width: 15rem; flex-shrink: 0; border-left: 1px solid var(--border); overflow-y: auto; padding: .6rem; display: flex; flex-direction: column; gap: .1rem; }
.chat-list .nav-item .date { font-size: .68rem; color: var(--text-4); }
.chat-input-wrap { padding: .4rem 1rem 1rem; flex-shrink: 0; }
.chat-input-wrap .ai-input { max-width: 48rem; margin: 0 auto; flex-direction: column; align-items: stretch; border-radius: 1.5rem; padding: .55rem .6rem .55rem 1rem; }
.chat-input-wrap .ai-input .row-b { display: flex; align-items: flex-end; gap: .4rem; }
.attachments { display: flex; gap: .45rem; flex-wrap: wrap; padding: .2rem 0 .4rem; }
.attachment { position: relative; width: 4rem; height: 4rem; border-radius: .7rem; overflow: hidden; background: var(--bg-elev); border: 1px solid var(--border); }
.attachment img { width: 100%; height: 100%; object-fit: cover; }
.attachment .x { position: absolute; top: .15rem; right: .15rem; width: 1.2rem; height: 1.2rem; border-radius: 999px; background: rgba(0,0,0,.7); color: #fff; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; }
.attachment .x svg { width: .75rem; height: .75rem; }
.attachment .ov { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0,0,0,.45); }
.attachment.failed { border-color: rgba(239,68,68,.6); }
.msg-photos { display: flex; gap: .4rem; flex-wrap: wrap; justify-content: flex-end; margin-bottom: .35rem; }
.msg-photos img, .msg-photos .gone { width: 7rem; height: 7rem; object-fit: cover; border-radius: .8rem; cursor: pointer; border: 1px solid var(--border); }
.msg-photos .gone { display: flex; align-items: center; justify-content: center; font-size: .72rem; color: var(--text-4); background: var(--bg-elev); cursor: default; }
.user-wrap { display: flex; flex-direction: column; align-items: flex-end; }
.chat-plant-bar { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.chat-plant-bar img, .chat-plant-bar .ph { width: 1.8rem; height: 1.8rem; border-radius: .5rem; object-fit: cover; background: var(--bg-input); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.drop-overlay { position: absolute; inset: 0; background: rgba(255,255,255,.04); border: 2px dashed rgba(255,255,255,.4); border-radius: var(--radius-lg); z-index: 30; display: flex; align-items: center; justify-content: center; color: var(--text); font-size: 1rem; pointer-events: none; }
.chat-empty { display: flex; flex-direction: column; align-items: center; gap: .8rem; padding: 3rem 1rem 1rem; text-align: center; color: var(--text-3); }
.chat-empty .cover { width: 5rem; height: 5rem; border-radius: 1.2rem; object-fit: cover; background: var(--bg-input); display: flex; align-items: center; justify-content: center; font-size: 2.4rem; overflow: hidden; }
.chat-empty .cover img { width: 100%; height: 100%; object-fit: cover; }
.chat-empty .hello { font-size: 1.4rem; color: var(--text); font-weight: 500; }

.suggestions { display: flex; flex-wrap: wrap; gap: .4rem; justify-content: center; max-width: 40rem; }
.suggestions button { background: var(--bg-input); border: 1px solid transparent; border-radius: 999px; padding: .4rem .85rem; cursor: pointer; color: var(--text-2); font-size: .82rem; }
.suggestions button:hover { border-color: var(--border-strong); color: var(--text); }
.alt-list { display: flex; flex-direction: column; gap: .3rem; }
.alt-list button { text-align: left; background: var(--bg-input); border: 1px solid transparent; border-radius: .7rem; padding: .45rem .7rem; cursor: pointer; color: var(--text-2); font-size: .82rem; display: flex; gap: .5rem; align-items: center; }
.alt-list button:hover { border-color: var(--border-strong); color: var(--text); }
.trash-row img { width: 2.4rem; height: 2.4rem; border-radius: .6rem; object-fit: cover; }

@media (max-width: 999px) {
  .chat-list { display: none; }
  .chat-list.open { display: flex; position: absolute; right: 0; top: 3.25rem; bottom: 0; background: var(--bg-side); z-index: 40; box-shadow: var(--shadow); }
}

/* ===== Mobil ===== */
@media (max-width: 799px) {
  .sidebar { position: fixed; top: 0; bottom: 0; left: 0; box-shadow: var(--shadow); }
  .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 35; }
  .page { padding: .75rem .9rem 6rem; }
  .toasts { right: 1rem; left: 1rem; bottom: 1rem; align-items: stretch; max-width: none; }
  .hide-mobile { display: none !important; }
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal { max-height: 96vh; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); gap: .6rem; }
  .plant-head .cover { width: 5rem; height: 5rem; }
  .kv { grid-template-columns: 6.5rem 1fr; }
  .chat-scroll { padding: .75rem .75rem 1rem; }
  .chat-input-wrap { padding: .3rem .5rem .6rem; }
  .msg-photos img, .msg-photos .gone { width: 5.5rem; height: 5.5rem; }
}
