/* Foliant – Papier & Tinte. Eigene Gestaltung, keine Fremd-Assets. */

:root {
  color-scheme: light;
  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --font-sans: ui-sans-serif, system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "Cascadia Mono", "Liberation Mono", Menlo, monospace;

  --bg: #f2ece0;
  --bg-deep: #e9e1d1;
  --surface: #fbf8f2;
  --surface-2: #f5efe3;
  --surface-3: #efe7d7;
  --ink: #1b2420;
  --ink-soft: #3d4841;
  --muted: #6c7268;
  --muted-2: #8a8f83;
  --line: #dbd2bf;
  --line-strong: #c5b9a2;
  --accent: #b2452b;
  --accent-ink: #fff7ec;
  --accent-soft: #f3ded3;
  --green: #2d5e4a;
  --green-soft: #dfe9e2;
  --amber: #9a6d18;
  --amber-soft: #f4e9cf;
  --danger: #a3352b;
  --danger-soft: #f6ddd8;
  --on-danger: #fff8ef;
  --code-bg: #17201b;
  --code-ink: #e9e2d0;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --shadow-sm: 0 1px 2px rgba(27, 36, 32, 0.06), 0 3px 10px rgba(27, 36, 32, 0.05);
  --shadow-md: 0 18px 48px -22px rgba(27, 36, 32, 0.35);
  --ring: 0 0 0 3px rgba(178, 69, 43, 0.22);
  --sans: var(--font-sans);
  --serif: var(--font-serif);
}

html[data-theme="nacht"] {
  color-scheme: dark;
  --bg: #0d1210;
  --bg-deep: #090e0b;
  --surface: #141c17;
  --surface-2: #19221c;
  --surface-3: #1f2a23;
  --ink: #ece6d7;
  --ink-soft: #cdc7b7;
  --muted: #969b8e;
  --muted-2: #7c8277;
  --line: #26322a;
  --line-strong: #38473c;
  --accent: #e0805f;
  --accent-ink: #1c110b;
  --accent-soft: #2b1d16;
  --green: #82c2a1;
  --green-soft: #182720;
  --amber: #d9ad5c;
  --amber-soft: #2a2314;
  --danger: #ee8b76;
  --danger-soft: #2c1915;
  --on-danger: #1a0d09;
  --code-bg: #0a0f0c;
  --code-ink: #e9e2d0;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 22px 50px -24px rgba(0, 0, 0, 0.75);
  --ring: 0 0 0 3px rgba(224, 128, 95, 0.28);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(1100px 620px at 88% -12%, rgba(178, 69, 43, 0.08), transparent 62%),
    radial-gradient(900px 520px at -12% 24%, rgba(45, 94, 74, 0.09), transparent 58%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15.5px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.35;
  background-image:
    repeating-linear-gradient(0deg, rgba(27, 36, 32, 0.025) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, rgba(27, 36, 32, 0.018) 0 1px, transparent 1px 4px);
  mix-blend-mode: multiply;
}

html[data-theme="nacht"] body::before {
  opacity: 0.2;
  mix-blend-mode: screen;
  background-image:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.02) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.015) 0 1px, transparent 1px 4px);
}

#root {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--serif);
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.15;
  margin: 0;
}

h1 { font-size: clamp(26px, 3.4vw, 36px); }
h2 { font-size: clamp(20px, 2.2vw, 24px); }
h3 { font-size: 18px; }
h4 { font-size: 16px; }

p { margin: 0; }

a { color: inherit; }

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button { cursor: pointer; }

img { max-width: 100%; }

code,
pre,
kbd {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

::selection {
  background: var(--accent-soft);
  color: var(--ink);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 100;
  padding: 10px 16px;
  background: var(--ink);
  color: var(--surface);
  border-radius: var(--radius-sm);
  transition: top 0.15s ease;
}

.skip-link:focus {
  top: 12px;
}

.noscript {
  max-width: 520px;
  margin: 80px auto;
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  text-align: center;
}

/* ---------- Icons & Spinner ---------- */

.icon {
  flex: none;
  display: inline-block;
  vertical-align: -0.18em;
}

.spinner {
  --spinner-size: 16px;
  width: var(--spinner-size);
  height: var(--spinner-size);
  display: inline-block;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  border-top-color: var(--accent);
  animation: spin 0.75s linear infinite;
  flex: none;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.stream-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
  animation: pulse 1.1s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1.1); }
}

/* ---------- Boot ---------- */

.boot {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  gap: 18px;
  align-content: center;
}

.boot-seal {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  font-family: var(--serif);
  font-size: 30px;
  color: var(--accent);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.boot-text {
  color: var(--muted);
  font-size: 14px;
  letter-spacing: 0.02em;
}

/* ---------- Auth-Gate ---------- */

.gate {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 40px 20px 48px;
  position: relative;
  overflow: hidden;
}

.gate-bg {
  position: absolute;
  right: -4vw;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--serif);
  font-size: min(52vw, 640px);
  line-height: 1;
  color: var(--ink);
  opacity: 0.035;
  pointer-events: none;
  user-select: none;
}

.gate-card {
  width: min(460px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 30px 28px 24px;
  box-shadow: var(--shadow-md);
  position: relative;
  z-index: 1;
}

.gate-card.fatal {
  text-align: left;
  display: grid;
  gap: 14px;
}

.gate-head {
  display: grid;
  gap: 14px;
  margin-bottom: 20px;
}

.gate-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.seal {
  width: 42px;
  height: 42px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: linear-gradient(160deg, var(--surface-2), var(--surface));
  font-family: var(--serif);
  font-size: 24px;
  color: var(--accent);
  box-shadow: inset 0 0 0 3px var(--surface), var(--shadow-sm);
}

.gate-title {
  font-size: 28px;
  letter-spacing: -0.02em;
}

.gate-lead {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

.gate-tabs {
  border-top: 1px solid var(--line);
  padding-top: 18px;
  display: grid;
  gap: 6px;
}

.gate-subtitle {
  font-size: 22px;
}

.gate-text {
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.55;
}

.gate-form {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.gate-foot {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 13.5px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.gate-foot code {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 1px 6px;
  font-size: 12.5px;
}

.gate-legal {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
  color: var(--muted-2);
  font-size: 11.5px;
  line-height: 1.5;
  display: flex;
  gap: 7px;
  align-items: baseline;
}

.mini-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  flex: none;
  transform: translateY(-1px);
}

.gate-note {
  margin-top: 16px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  z-index: 1;
}

.code-input {
  font-family: var(--font-mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.text-link {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid currentColor;
  font-weight: 600;
}

.text-link:hover {
  background: var(--accent-soft);
}

/* ---------- Formulare ---------- */

.field {
  display: grid;
  gap: 6px;
}

.field > span,
.field-label {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.input {
  width: 100%;
  min-height: 40px;
  padding: 9px 12px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  color: var(--ink);
  font-size: 14.5px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.input:hover {
  border-color: var(--muted-2);
}

.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
  background: var(--surface);
}

.input::placeholder {
  color: var(--muted-2);
}

.input.code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  letter-spacing: 0;
  text-transform: none;
}

textarea.input {
  resize: vertical;
  min-height: 90px;
  line-height: 1.55;
}

select.input {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 18px, calc(100% - 11px) 18px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

.form-error {
  background: var(--danger-soft);
  border: 1px solid var(--danger);
  color: var(--ink);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13px;
}

.hint {
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.55;
}

.hint .text-link {
  font-size: inherit;
}

.toggle-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 13.5px;
}

.toggle-row > span {
  display: grid;
  gap: 2px;
}

.toggle-row input[type="checkbox"] {
  margin-top: 3px;
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
  flex: none;
}

.toggle-row.compact {
  padding: 6px 10px;
  font-size: 12.5px;
  align-items: center;
}

.toggle-row.compact input {
  margin-top: 0;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: 10px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease, color 0.15s ease;
  white-space: nowrap;
}

.btn:hover {
  background: var(--surface-2);
  border-color: var(--muted-2);
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn.primary {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}

.btn.primary:hover:not(:disabled) {
  background: var(--ink-soft);
  border-color: var(--ink-soft);
}

.btn.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--on-danger);
}

.btn.danger:hover:not(:disabled) {
  filter: brightness(1.06);
}

.btn.ghost {
  background: transparent;
}

.btn.ghost:hover {
  background: var(--surface-2);
}

.btn.small {
  padding: 7px 11px;
  font-size: 13px;
}

.btn.tiny {
  padding: 4px 8px;
  font-size: 12px;
  gap: 5px;
  border-radius: 8px;
}

.btn.wide {
  width: 100%;
}

.danger-text {
  color: var(--danger);
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-soft);
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  flex: none;
}

.icon-btn:hover {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--ink);
}

.icon-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.icon-btn.tiny {
  width: 28px;
  height: 28px;
  border-radius: 7px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

/* ---------- Schale ---------- */

.shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  min-height: 100dvh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 14px 14px;
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
  border-right: 1px solid var(--line);
  min-height: 0;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  min-width: 0;
}

.brand .seal {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  font-size: 20px;
}

.brand-text {
  display: grid;
  min-width: 0;
}

.brand-text strong {
  font-family: var(--serif);
  font-size: 19px;
  letter-spacing: -0.015em;
  line-height: 1.1;
}

.brand-text span {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-close {
  display: none;
}

.new-chat {
  justify-content: center;
}

.search-field {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  min-height: 38px;
}

.search-field:focus-within {
  border-color: var(--accent);
  box-shadow: var(--ring);
}

.search-field input {
  border: 0;
  background: transparent;
  padding: 8px 0;
  width: 100%;
  outline: none;
  font-size: 13.5px;
  color: var(--ink);
}

.archive-toggle {
  align-self: flex-start;
  margin: 0 4px 10px;
}

.side-search {
  flex: none;
}

.chat-scroll {
  flex: 1;
  min-height: 80px;
  overflow-y: auto;
  overscroll-behavior: contain;
  margin: 0 -6px;
  padding: 2px 6px 6px;
  scrollbar-width: thin;
}

.chat-group {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted-2);
  margin: 12px 0 5px 8px;
}

.chat-group:first-child {
  margin-top: 2px;
}

.chat-item {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 8px 10px;
  border-radius: 9px;
  border-left: 2px solid transparent;
  text-decoration: none;
  color: var(--ink-soft);
  transition: background 0.12s ease, border-color 0.12s ease;
  margin-bottom: 1px;
}

.chat-item:hover {
  background: var(--surface-3);
  color: var(--ink);
}

.chat-item.active {
  background: var(--surface);
  border-left-color: var(--accent);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line);
}

.chat-item-title {
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-item-meta {
  font-size: 11px;
  color: var(--muted-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.side-empty {
  color: var(--muted);
  font-size: 12.5px;
  padding: 8px;
  line-height: 1.5;
}

.side-nav {
  border-top: 1px solid var(--line);
  padding-top: 8px;
  display: grid;
  gap: 1px;
  flex: none;
}

.side-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--ink-soft);
  font-size: 13.5px;
  font-weight: 500;
}

.side-link:hover {
  background: var(--surface-3);
  color: var(--ink);
}

.side-link.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

.side-link .tag {
  margin-left: auto;
}

.side-user {
  border-top: 1px solid var(--line);
  padding-top: 10px;
  display: flex;
  align-items: center;
  gap: 9px;
  flex: none;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: var(--surface);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  flex: none;
}

.side-user-text {
  display: grid;
  min-width: 0;
  flex: 1;
  line-height: 1.3;
}

.side-user-text strong {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.side-user-text span {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.scrim {
  display: none;
}

.shell-menu {
  display: none;
}

.main-wrap {
  min-width: 0;
  display: flex;
  justify-content: center;
}

.main {
  width: 100%;
  max-width: 980px;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 0 28px;
  outline: none;
}

.view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px 0 28px;
  scrollbar-width: thin;
}

.view-loading {
  flex: 1;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 13.5px;
  min-height: 200px;
}

.view-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 24px 0 18px;
  border-bottom: 1px solid var(--line);
  flex: none;
}

.view-head > div {
  min-width: 0;
}

.eyebrow {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 6px;
}

.view-sub {
  color: var(--muted);
  font-size: 13.5px;
  margin-top: 7px;
  max-width: 62ch;
  line-height: 1.55;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 12px;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink-soft);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.tag.tiny {
  font-size: 9px;
  padding: 1px 6px;
}

.tag.success {
  background: var(--green-soft);
  border-color: var(--green);
  color: var(--green);
}

.tag.danger {
  background: var(--danger-soft);
  border-color: var(--danger);
  color: var(--danger);
}

/* ---------- Panels & Callouts ---------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 18px;
  display: grid;
  gap: 14px;
  align-content: start;
  box-shadow: var(--shadow-sm);
}

.panel-title {
  font-size: 18px;
  letter-spacing: -0.01em;
}

.panel-note {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  display: grid;
  gap: 6px;
}

.panel-note h3 {
  font-size: 14px;
  font-family: var(--sans);
  font-weight: 700;
}

.panel-note p {
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.55;
}

.callout {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 11px 13px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 13px;
  line-height: 1.5;
}

.callout .icon {
  margin-top: 2px;
  color: var(--muted);
}

.callout-warn {
  background: var(--amber-soft);
  border-color: var(--amber);
}

.callout-warn .icon {
  color: var(--amber);
}

.callout-info {
  background: var(--surface-2);
}

.empty {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 36px 20px;
  text-align: center;
}

.empty-icon {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--accent);
}

.empty-title {
  font-size: 20px;
}

.empty-text {
  color: var(--muted);
  font-size: 13.5px;
  max-width: 46ch;
}

/* ---------- Chat ---------- */

.chat-view {
  overflow: hidden;
  padding-bottom: 0;
}

.chat-head {
  padding: 20px 0 14px;
  align-items: center;
}

.chat-heading {
  min-width: 0;
}

.chat-title {
  font-size: clamp(20px, 2.6vw, 26px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-sub {
  color: var(--muted);
  font-size: 11.5px;
  margin-top: 3px;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
}

.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px 2px 16px;
  scrollbar-width: thin;
  scroll-behavior: smooth;
}

.msg {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  position: relative;
}

.msg-avatar {
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  margin-top: 2px;
}

.msg-assistant .msg-avatar {
  background: var(--ink);
  color: var(--surface);
  border-color: var(--ink);
  font-family: var(--serif);
  font-size: 15px;
}

.msg-main {
  min-width: 0;
  flex: 1;
  max-width: 100%;
}

.msg-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 11px;
  color: var(--muted);
}

.msg-author {
  font-weight: 700;
  color: var(--ink-soft);
  font-size: 12px;
}

.msg-time {
  color: var(--muted-2);
  font-size: 10.5px;
}

.msg-content {
  font-size: 15px;
  line-height: 1.68;
}

.msg-assistant .msg-content {
  border-left: 2px solid var(--line);
  padding-left: 14px;
}

.msg-user {
  flex-direction: row-reverse;
}

.msg-user .msg-main {
  flex: 0 1 auto;
  max-width: min(78%, 640px);
  display: grid;
  justify-items: end;
}

.msg-user .msg-meta {
  justify-content: flex-end;
}

.msg-user .msg-content {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px 16px 4px 16px;
  padding: 10px 14px;
  box-shadow: var(--shadow-sm);
  text-align: left;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.msg-error .msg-content {
  border-color: var(--danger);
}

.msg-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.attach {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  text-decoration: none;
  font-size: 12px;
  color: var(--ink-soft);
  max-width: 240px;
}

.attach span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.attach-image {
  padding: 4px;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.attach-image img {
  width: 160px;
  height: 110px;
  object-fit: cover;
  border-radius: 6px;
  display: block;
}

.attach-image span {
  padding: 0 4px 2px;
  font-size: 11px;
  max-width: 160px;
}

.chat-intro {
  margin: auto;
  max-width: 520px;
  text-align: center;
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 32px 16px;
  color: var(--muted);
}

.intro-seal {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  border: 1px solid var(--line-strong);
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-size: 26px;
  color: var(--accent);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  margin-bottom: 4px;
}

.chat-intro h2 {
  color: var(--ink);
  font-size: 24px;
}

.chat-intro p {
  font-size: 13.5px;
  line-height: 1.6;
}

/* ---------- Composer ---------- */

.composer {
  flex: none;
  padding: 10px 0 16px;
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, var(--bg) 55%);
  display: grid;
  gap: 8px;
  position: relative;
  z-index: 2;
}

.composer.dropping {
  outline: 2px dashed var(--accent);
  outline-offset: 6px;
  border-radius: 14px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chips:empty {
  display: none;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px 4px 9px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  font-size: 12px;
  max-width: 260px;
}

.chip .icon {
  color: var(--accent);
}

.chip-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chip-size {
  color: var(--muted-2);
  font-size: 10.5px;
  flex: none;
}

.chip-x {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  flex: none;
}

.chip-x:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.composer-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  padding: 6px 6px 6px 8px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.composer-row:focus-within {
  border-color: var(--accent);
  box-shadow: var(--ring);
}

.attach-btn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
}

.chat-input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  resize: none;
  padding: 7px 2px;
  min-height: 34px;
  max-height: 300px;
  outline: none;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
}

.chat-input::placeholder {
  color: var(--muted-2);
}

.send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 0;
  background: var(--accent);
  color: var(--accent-ink);
  display: grid;
  place-items: center;
  flex: none;
  transition: transform 0.12s ease, filter 0.15s ease, opacity 0.15s ease;
}

.send-btn:hover:not(:disabled) {
  filter: brightness(1.06);
  transform: translateY(-1px);
}

.send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.composer-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  font-size: 11.5px;
  color: var(--muted);
}

.model-line {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.model-input {
  width: 150px;
  min-width: 90px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  font-size: 11.5px;
  font-family: var(--font-mono);
  color: var(--ink-soft);
}

.model-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--ring);
}

.mini-select {
  max-width: 150px;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  font-size: 11.5px;
  color: var(--ink-soft);
}

.mini-select:focus {
  outline: none;
  border-color: var(--accent);
}

.source-toggle {
  display: inline-flex;
  padding: 2px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  gap: 2px;
}

.source-toggle button {
  border: 0;
  background: transparent;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}

.source-toggle button.active {
  background: var(--ink);
  color: var(--bg);
}

.source-toggle button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.composer-note {
  flex: 1;
  min-width: 120px;
  color: var(--muted-2);
  font-size: 11px;
  line-height: 1.4;
}

.composer-note .text-link {
  font-size: inherit;
}

/* ---------- Markdown / Prosa ---------- */

.prose {
  overflow-wrap: anywhere;
}

.prose > *:first-child {
  margin-top: 0;
}

.prose > *:last-child {
  margin-bottom: 0;
}

.prose p {
  margin: 0 0 0.7em;
}

.prose h2,
.prose h3,
.prose h4,
.prose h5,
.prose h6 {
  margin: 1.05em 0 0.45em;
  font-family: var(--serif);
}

.prose h2 { font-size: 21px; }
.prose h3 { font-size: 18px; }
.prose h4 { font-size: 16px; }
.prose h5 { font-size: 14.5px; }
.prose h6 { font-size: 13px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }

.prose ul,
.prose ol {
  margin: 0 0 0.7em;
  padding-left: 1.35em;
}

.prose li {
  margin: 0.18em 0;
}

.prose strong {
  font-weight: 700;
}

.prose a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.prose blockquote {
  margin: 0.7em 0;
  padding: 2px 0 2px 14px;
  border-left: 2px solid var(--line-strong);
  color: var(--ink-soft);
}

.prose blockquote p {
  margin: 0.25em 0;
}

.prose hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 1.1em 0;
}

.prose code {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.1em 0.35em;
  font-size: 0.86em;
}

.prose .table-wrap {
  margin: 0.8em 0;
}

.prose table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
}

.prose th,
.prose td {
  border: 1px solid var(--line);
  padding: 6px 9px;
  text-align: left;
  vertical-align: top;
}

.prose th {
  background: var(--surface-2);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.prose .center {
  text-align: center;
}

.codeblock {
  margin: 0.8em 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--code-bg);
}

.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.05);
  color: #a9b3a6;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.code-copy {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
  padding: 2px 7px;
  background: transparent;
  color: #c8d0c2;
  font-family: var(--sans);
  font-size: 10.5px;
  text-transform: none;
  letter-spacing: 0;
}

.code-copy:hover {
  background: rgba(255, 255, 255, 0.08);
}

.codeblock pre {
  margin: 0;
  padding: 12px 14px;
  overflow-x: auto;
  color: var(--code-ink);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.55;
  tab-size: 2;
}

.codeblock pre code {
  background: none;
  border: 0;
  padding: 0;
  font-size: inherit;
  color: inherit;
}

/* ---------- Landing ---------- */

.landing {
  max-width: 820px;
  margin: 0 auto;
  width: 100%;
  padding: 54px 0 32px;
  gap: 22px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.landing-head {
  display: grid;
  gap: 10px;
}

.landing h1 {
  font-size: clamp(30px, 4.6vw, 46px);
  letter-spacing: -0.025em;
  max-width: 20ch;
}

.landing-lead {
  color: var(--muted);
  font-size: 14.5px;
  max-width: 64ch;
  line-height: 1.6;
}

.landing-composer {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  box-shadow: var(--shadow-sm);
  padding: 10px 12px 10px;
  display: grid;
  gap: 8px;
}

.landing-composer:focus-within {
  border-color: var(--accent);
  box-shadow: var(--ring);
}

.landing-composer textarea {
  border: 0;
  background: transparent;
  resize: none;
  padding: 8px 4px;
  min-height: 54px;
  outline: none;
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
}

.landing-composer textarea::placeholder {
  color: var(--muted-2);
}

.landing-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.idea-card {
  display: grid;
  gap: 6px;
  align-content: start;
  text-align: left;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: inherit;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
  box-shadow: var(--shadow-sm);
  font: inherit;
}

.idea-card:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-md);
}

.idea-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  margin-bottom: 2px;
}

.idea-card strong {
  font-size: 14.5px;
  font-family: var(--serif);
  letter-spacing: -0.01em;
}

.idea-card span:last-child {
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.5;
}

.landing-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  color: var(--muted-2);
  font-size: 11.5px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
  margin-top: 6px;
}

.landing-foot > span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.landing-foot .icon {
  color: var(--green);
}

/* ---------- Studio ---------- */

.studio-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  gap: 18px;
  padding: 20px 0 4px;
  align-items: start;
}

.studio-form {
  gap: 14px;
}

.kind-field {
  border: 0;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.kind-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.kind-card {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 12px 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--ink-soft);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.kind-card:hover {
  border-color: var(--line-strong);
  background: var(--surface);
}

.kind-card.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.kind-icon {
  color: inherit;
}

.studio-prompt {
  min-height: 118px;
  font-size: 14.5px;
  line-height: 1.6;
}

.studio-source {
  display: grid;
  gap: 8px;
}

.studio-result {
  min-height: 360px;
  align-content: start;
}

.result-empty {
  display: grid;
  justify-items: center;
  gap: 8px;
  text-align: center;
  padding: 54px 22px;
  color: var(--muted);
}

.result-empty h2 {
  color: var(--ink);
  font-size: 19px;
}

.result-empty p {
  font-size: 13px;
  max-width: 40ch;
  line-height: 1.55;
}

.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.result-head h2 {
  font-size: 19px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.website-wrap {
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}

.website-frame {
  width: 100%;
  height: 440px;
  border: 0;
  display: block;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.artifact-doc {
  max-height: 480px;
  overflow-y: auto;
  padding-right: 6px;
  font-size: 14px;
}

.raw-deck {
  margin: 0;
  padding: 12px;
  background: var(--code-bg);
  color: var(--code-ink);
  border-radius: 10px;
  overflow-x: auto;
  font-size: 12px;
  max-height: 360px;
}

.deck {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: linear-gradient(170deg, var(--surface), var(--surface-2));
}

.deck-slide {
  padding: 26px 26px 24px;
  min-height: 260px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  outline: none;
}

.deck:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.deck-kicker {
  font-size: 10.5px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}

.deck-slide h3 {
  font-size: 25px;
  letter-spacing: -0.02em;
}

.deck-slide ul {
  margin: 4px 0 0;
  padding-left: 1.2em;
  display: grid;
  gap: 6px;
}

.deck-slide li {
  font-size: 14.5px;
  line-height: 1.5;
}

.deck-notes {
  margin-top: auto;
  border-top: 1px dashed var(--line);
  padding-top: 10px;
  color: var(--muted);
  font-size: 12px;
  font-style: italic;
  line-height: 1.5;
}

.deck-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding: 8px 10px;
  background: var(--surface);
}

.deck-count {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--muted);
}

.studio-history {
  padding: 18px 0 6px;
}

.history-list {
  display: grid;
  gap: 6px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border: 1px solid transparent;
  border-radius: 10px;
}

.history-item:hover {
  background: var(--surface-2);
}

.history-item.active {
  border-color: var(--line);
  background: var(--surface);
}

.history-open {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  padding: 6px;
  text-align: left;
  font: inherit;
  color: inherit;
  border-radius: 8px;
}

.history-icon {
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--accent);
}

.history-text {
  display: grid;
  min-width: 0;
  line-height: 1.35;
}

.history-text strong {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-text span {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Dateien ---------- */

.files-view {
  gap: 4px;
}

.dropzone {
  margin: 20px 0 6px;
  padding: 26px 20px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  display: grid;
  justify-items: center;
  gap: 6px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.dropzone:hover,
.dropzone.dragging {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.dropzone.busy {
  pointer-events: none;
  opacity: 0.75;
}

.dropzone p {
  font-size: 13.5px;
}

.dropzone-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--accent);
  margin-bottom: 4px;
}

.files-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 16px 0 12px;
  flex-wrap: wrap;
}

.files-toolbar .search-field {
  max-width: 280px;
  flex: 1;
}

.file-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(218px, 1fr));
  gap: 12px;
}

.file-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.file-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.file-thumb {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--surface-2);
  display: grid;
  place-items: center;
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}

.file-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.file-icon {
  color: var(--line-strong);
}

.file-tag {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(251, 248, 242, 0.92);
  color: var(--ink);
  border-color: var(--line);
}

html[data-theme="nacht"] .file-tag {
  background: rgba(20, 28, 23, 0.9);
  color: var(--ink);
}

.file-body {
  padding: 10px 12px 12px;
  display: grid;
  gap: 2px;
}

.file-name {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  flex-wrap: wrap;
}

/* ---------- Erinnerung ---------- */

.memory-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  gap: 18px;
  padding: 20px 0;
  align-items: start;
}

.memory-add {
  position: sticky;
  top: 16px;
}

.memory-list-wrap {
  gap: 10px;
}

.memory-list {
  display: grid;
  gap: 8px;
}

.memory-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  padding: 12px;
  display: grid;
  gap: 6px;
}

.memory-item.pinned {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.memory-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 11px;
}

.memory-date {
  margin-left: auto;
}

.memory-text {
  font-size: 14px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.memory-actions {
  display: flex;
  gap: 2px;
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  padding-top: 6px;
}

/* ---------- Schlüssel ---------- */

.keys-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 18px;
  padding: 20px 0;
  align-items: start;
}

.key-list {
  display: grid;
  gap: 8px;
}

.key-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  padding: 11px 12px;
}

.key-item.disabled {
  opacity: 0.65;
}

.key-main {
  display: grid;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.key-head {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.key-head strong {
  font-size: 13.5px;
  overflow-wrap: anywhere;
}

.key-url,
.key-hint {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-soft);
  overflow-wrap: anywhere;
}

.key-hint {
  color: var(--muted);
}

.key-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: wrap;
  justify-content: flex-end;
  flex: none;
}

/* ---------- Konto ---------- */

.account-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  padding: 20px 0;
  align-items: start;
}

.count-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 2px;
}

.count-list li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 2px;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
}

.count-list li:last-child {
  border-bottom: 0;
}

.count-list span {
  color: var(--muted);
}

.count-list strong {
  font-variant-numeric: tabular-nums;
}

.session-list {
  display: grid;
  gap: 6px;
}

.session-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-2);
  font-size: 12.5px;
}

.session-item > div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.session-item strong {
  font-size: 13px;
}

.danger-zone {
  margin-top: 8px;
  border: 1px solid var(--danger);
  background: var(--danger-soft);
  border-radius: 10px;
  padding: 12px;
  display: grid;
  gap: 8px;
}

.danger-zone h3 {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--danger);
}

/* ---------- Administration ---------- */

.admin-tabs {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  padding-bottom: 0;
  flex: none;
  scrollbar-width: none;
}

.admin-tabs::-webkit-scrollbar {
  display: none;
}

.admin-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 11px;
  border-bottom: 2px solid transparent;
  text-decoration: none;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}

.admin-tab:hover {
  color: var(--ink);
  background: var(--surface-2);
}

.admin-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.admin-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px 0 8px;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.wide-panel {
  grid-column: 1 / -1;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.stat {
  display: grid;
  gap: 2px;
  padding: 13px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.stat-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.stat-value {
  font-family: var(--serif);
  font-size: 25px;
  letter-spacing: -0.02em;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.stat-note {
  font-size: 11px;
  color: var(--muted-2);
}

.chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 130px;
  padding: 8px 2px 0;
  border-bottom: 1px solid var(--line);
}

.bar {
  flex: 1;
  min-width: 4px;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 3px;
}

.bar-fill {
  width: 100%;
  max-width: 22px;
  background: linear-gradient(180deg, var(--accent), var(--accent-soft));
  border-radius: 3px 3px 0 0;
  min-height: 2px;
}

.bar-label {
  font-size: 9px;
  color: var(--muted-2);
  font-variant-numeric: tabular-nums;
}

.source-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  background: var(--surface);
}

.table th {
  text-align: left;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--surface-2);
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.table tr:last-child td {
  border-bottom: 0;
}

.table tbody tr:hover {
  background: var(--surface-2);
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  align-items: center;
  justify-content: flex-end;
}

.row-actions .btn {
  padding: 3px 7px;
  font-size: 11px;
  border-radius: 7px;
}

.row-actions .icon-btn {
  width: 24px;
  height: 24px;
}

.audit-list {
  display: grid;
  gap: 2px;
}

.audit-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
  padding: 6px 2px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}

.audit-row:last-child {
  border-bottom: 0;
}

.audit-text {
  flex: 1;
  min-width: 160px;
  overflow-wrap: anywhere;
}

.default-quota {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
  align-items: end;
}

.default-quota .field {
  gap: 4px;
}

.default-quota .input {
  min-height: 36px;
}

.inline-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.quota-list {
  display: grid;
  gap: 8px;
}

.quota-item {
  display: grid;
  grid-template-columns: minmax(150px, 0.9fr) minmax(0, 1.6fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
}

.quota-user {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.quota-user strong {
  font-size: 13px;
  overflow-wrap: anywhere;
}

.quota-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: flex-end;
}

.quota-fields label {
  display: grid;
  gap: 2px;
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.quota-fields input[type="number"] {
  width: 78px;
  padding: 4px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  font-size: 12px;
}

.quota-fields label.check {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  text-transform: none;
  letter-spacing: 0;
  padding-bottom: 4px;
}

.quota-fields label.check input {
  accent-color: var(--accent);
}

.quota-meta {
  display: grid;
  gap: 4px;
  justify-items: end;
  text-align: right;
}

.quota-buttons {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.invite-list {
  display: grid;
  gap: 6px;
}

.invite-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-2);
  flex-wrap: wrap;
}

.invite-code {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--accent);
}

.admin-settings {
  display: grid;
  gap: 14px;
}

.sticky-actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0), var(--bg) 55%);
  padding: 12px 0 4px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.secret-box {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  background: var(--surface-2);
}

.secret-box code {
  font-size: 15px;
  letter-spacing: 0.06em;
  overflow-wrap: anywhere;
  flex: 1;
  min-width: 140px;
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.admin-chat-log {
  max-height: 56dvh;
  overflow-y: auto;
  display: grid;
  gap: 12px;
  padding: 4px 2px;
}

.admin-msg {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--surface-2);
  display: grid;
  gap: 4px;
}

.admin-msg.assistant {
  background: var(--surface);
}

.admin-msg-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  font-size: 11.5px;
}

.admin-msg .prose {
  font-size: 13.5px;
}

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

.overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(13, 18, 16, 0.5);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  padding: 20px;
  animation: fadeIn 0.12s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.dialog {
  width: min(440px, 100%);
  max-height: 90dvh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 22px;
  display: grid;
  gap: 12px;
  animation: rise 0.16s ease;
}

@keyframes rise {
  from { transform: translateY(8px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.dialog.wide {
  width: min(720px, 100%);
}

.dialog-title {
  font-size: 21px;
}

.dialog-body {
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.55;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.popup-menu {
  position: fixed;
  z-index: 90;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  padding: 5px;
  display: grid;
  gap: 1px;
  animation: rise 0.12s ease;
}

.popup-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  border: 0;
  background: transparent;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 13.5px;
  color: var(--ink-soft);
  text-align: left;
  font-weight: 500;
}

.popup-item:hover,
.popup-item:focus-visible {
  background: var(--surface-2);
  color: var(--ink);
  outline: none;
}

.popup-item.danger {
  color: var(--danger);
}

.popup-item.danger:hover {
  background: var(--danger-soft);
}

.toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 100;
  display: grid;
  gap: 8px;
  width: min(380px, calc(100vw - 36px));
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  font-size: 13px;
  line-height: 1.45;
  animation: toastIn 0.18s ease;
}

@keyframes toastIn {
  from { transform: translateY(10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.toast.leaving {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  flex: none;
  margin-top: 6px;
}

.toast-success .toast-dot {
  background: var(--green);
}

.toast-error {
  border-color: var(--danger);
}

.toast-error .toast-dot {
  background: var(--danger);
}

.toast-text {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.toast-close {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  flex: none;
}

.toast-close:hover {
  background: var(--surface-2);
  color: var(--ink);
}

/* ---------- Scrollbars ---------- */

* {
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

*::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

*::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: content-box;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

/* ---------- Responsive ---------- */

@media (max-width: 1080px) {
  .studio-grid,
  .memory-grid,
  .keys-grid,
  .account-grid,
  .admin-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .memory-add {
    position: static;
  }
}

@media (max-width: 980px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 70;
    width: min(320px, 86vw);
    transform: translateX(-104%);
    transition: transform 0.22s ease;
    box-shadow: var(--shadow-md);
    border-right: 1px solid var(--line);
  }

  .shell.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-close {
    display: inline-grid;
  }

  .scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 65;
    background: rgba(13, 18, 16, 0.45);
    backdrop-filter: blur(2px);
  }

  .shell-menu {
    display: inline-grid;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 60;
    width: 38px;
    height: 38px;
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
  }

  .main {
    padding: 0 18px;
  }

  .view-head {
    padding-top: 62px;
  }

  .chat-head {
    padding-top: 60px;
  }

  .quick-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .kind-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .landing {
    padding: 62px 0 28px;
  }

  .quota-item {
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
  }

  .quota-meta {
    justify-items: start;
    text-align: left;
  }
}

@media (max-width: 640px) {
  body {
    font-size: 15px;
  }

  .main {
    padding: 0 14px;
  }

  .view-head {
    gap: 10px;
    flex-direction: column;
    align-items: stretch;
  }

  .chat-head {
    flex-direction: row;
    align-items: center;
  }

  .chat-actions .btn span {
    display: none;
  }

  .chat-title {
    font-size: 20px;
  }

  .kind-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
  }

  .kind-card {
    padding: 9px 4px;
    font-size: 11px;
  }

  .file-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }

  .website-frame {
    height: 320px;
  }

  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .default-quota,
  .inline-fields {
    grid-template-columns: 1fr;
  }

  .toasts {
    left: 12px;
    right: 12px;
    bottom: 12px;
    width: auto;
  }

  .msg-user .msg-main {
    max-width: 88%;
  }

  .model-input {
    width: 120px;
  }

  .composer-foot {
    gap: 8px;
  }

  .admin-tabs {
    margin: 0 -14px;
    padding: 0 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- Öffentlich / Funnel ---------- */

.funnel-status {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.funnel-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  margin-top: 9px;
  flex: none;
  background: var(--muted-2);
  box-shadow: 0 0 0 4px var(--surface-3);
}

.funnel-dot.ok {
  background: var(--green);
}

.funnel-dot.warn {
  background: var(--amber);
}

.funnel-dot.bad {
  background: var(--danger);
}

.funnel-status-text {
  min-width: 0;
}

.funnel-label {
  font-size: 18px;
  letter-spacing: -0.01em;
  margin: 0 0 2px;
}

.funnel-url {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  background: var(--surface-2);
}

.funnel-url-text {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--ink);
  word-break: break-all;
}

.funnel-url-actions {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

.funnel-login {
  display: grid;
  gap: 8px;
}

.funnel-steps {
  margin: 10px 0 0;
  padding-left: 20px;
  display: grid;
  gap: 4px;
  font-size: 13px;
  line-height: 1.45;
}

.funnel-steps li::marker {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.funnel-details summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 12.5px;
  padding: 2px 0;
}

.funnel-log {
  margin: 8px 0 0;
  padding: 12px;
  border-radius: 10px;
  background: var(--code-bg);
  color: var(--code-ink);
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 260px;
  overflow-y: auto;
}

.btn.spinning {
  opacity: 0.6;
}

@media (max-width: 720px) {
  .funnel-url-actions {
    margin-left: 0;
  }
}
