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

:root {
  --bg: #0f0f12;
  --surface: #18181d;
  --surface2: #222228;
  --border: #2e2e38;
  --accent: #7c3aed;
  --accent-lt: #9f67ff;
  --text: #e8e8f0;
  --muted: #888898;
  --danger: #e03e3e;
  --success: #2ecc71;
  --radius: 8px;
  --sidebar-w: 220px;
}

body {
  font-family: 'Montserrat', sans-serif;
  font-size: 14px;
  font-weight: 400;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── LOGIN ── */
body.auth-locked #app { display: none; }
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
#login-screen[hidden] { display: none; }
.login-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 3rem 2.5rem;
  width: 100%;
  max-width: 380px;
}
.login-logo {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 1rem;
}
.login-box h1 { font-size: 2rem; font-weight: 300; margin-bottom: 1.5rem; }
.login-box h1 em { font-style: italic; color: var(--accent-lt); }
.login-error { color: var(--danger); font-size: 0.82rem; margin-top: .75rem; }

/* ── Microsoft Login Button ── */
.btn-ms {
  display: flex; align-items: center; justify-content: center; gap: .75rem;
  width: 100%; padding: .7rem 1rem;
  background: #2F2F2F; border: 1px solid #444;
  color: #fff; font-family: inherit; font-size: .85rem; font-weight: 500;
  text-decoration: none; cursor: pointer;
  transition: background .15s, border-color .15s;
  margin-bottom: .75rem;
}
.btn-ms:hover { background: #3A3A3A; border-color: #666; }

/* ── Divider ── */
.login-divider {
  display: flex; align-items: center; gap: .75rem;
  margin: 1.25rem 0 1.25rem;
  color: var(--muted); font-size: .72rem;
}
.login-divider::before,
.login-divider::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

/* ── FORMS ── */
.field { display: flex; flex-direction: column; gap: .4rem; }
.field label { font-size: 0.72rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.field input, .field select, .field textarea {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: .65rem .9rem;
  font-family: inherit;
  font-size: 0.9rem;
  transition: border-color .15s;
  width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.field textarea { resize: vertical; min-height: 80px; }

/* ── BUTTONS ── */
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: .65rem 1.4rem;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
  white-space: nowrap;
}
.btn-primary:hover { background: var(--accent-lt); }
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .65rem 1.4rem;
  font-family: inherit;
  font-size: 0.82rem;
  cursor: pointer;
  transition: color .15s, border-color .15s;
  text-decoration: none;
  display: inline-block;
}
.btn-ghost:hover { color: var(--text); border-color: var(--muted); }
.btn-sm {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .45rem 1rem;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s;
  white-space: nowrap;
}
.btn-sm:hover { background: var(--border); }
.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: .3rem .6rem;
  font-family: inherit;
  font-size: 0.78rem;
  cursor: pointer;
  transition: background .15s;
}
.btn-danger:hover { background: rgba(224,62,62,.12); }
.btn-logout {
  background: none;
  border: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.78rem;
  cursor: pointer;
  text-decoration: underline;
}
.btn-logout:hover { color: var(--text); }

/* ── LAYOUT ── */
#app { display: flex; min-height: 100vh; }
/* Editor-Seiten (Topbar oben + Inhalt darunter statt Sidebar+Content nebeneinander) */
#app.app-stack { display: block; }
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}
.sidebar-head { padding: 1.8rem 1.4rem 1.2rem; border-bottom: 1px solid var(--border); }
.logo { font-size: 1.1rem; font-weight: 700; letter-spacing: .05em; }
.logo-sub { font-size: 0.65rem; color: var(--muted); letter-spacing: .1em; text-transform: uppercase; margin-top: .2rem; }
.nav { flex: 1; padding: 1rem 0; }
.nav-item {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .7rem 1.4rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  transition: color .15s, background .15s;
  border-radius: 0;
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-item:hover, .nav-item.active { color: var(--text); background: var(--surface2); }
.sidebar-foot { padding: 1rem 1.4rem; border-top: 1px solid var(--border); font-size: 0.78rem; color: var(--muted); }
#user-name { display: block; font-weight: 600; color: var(--text); margin-bottom: .4rem; }

.content { margin-left: var(--sidebar-w); flex: 1; padding: 2.5rem; }
.view-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 2rem;
  gap: 1rem;
}
.view-header h1 { font-size: 1.8rem; font-weight: 300; }
.view-header .sub { color: var(--muted); font-size: 0.82rem; margin-top: .2rem; }

/* ── BRAND GRID (Baum: Dachmarke + Untermarken) ── */
.brand-grid { display: flex; flex-direction: column; gap: 1.8rem; }
.brand-group { display: flex; flex-direction: column; gap: 1rem; }
.brand-group > .brand-card { max-width: 280px; }
.brand-subgrid {
  margin-left: 1.5rem;
  padding-left: 1.2rem;
  border-left: 2px solid var(--border);
}
.brand-subgrid-label { font-size: 0.7rem; font-weight: 600; color: var(--muted); margin-bottom: .8rem; letter-spacing: .03em; }
.brand-subgrid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1rem; }
.brand-subgrid-cards .brand-card { padding: 1.1rem; }
.brand-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.4rem;
  cursor: pointer;
  transition: border-color .15s, transform .15s;
  position: relative;
}
.brand-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.brand-card-type {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: .6rem;
}
.brand-card h3 { font-size: 1.1rem; font-weight: 600; margin-bottom: .3rem; }
.brand-card p { font-size: 0.8rem; color: var(--muted); }
.brand-card-colors { display: flex; gap: .3rem; margin-top: .8rem; flex-wrap: wrap; }
.brand-card-swatch { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--border); }
.brand-card-actions {
  position: absolute;
  top: .8rem; right: .8rem;
  display: flex; gap: .3rem;
  opacity: 0;
  transition: opacity .15s;
}
.brand-card:hover .brand-card-actions { opacity: 1; }

/* ── USERS TABLE ── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: left;
  padding: .6rem 1rem;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: .8rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}
.badge {
  display: inline-block;
  padding: .2rem .6rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
}
.badge-admin { background: rgba(124,58,237,.2); color: var(--accent-lt); }
.badge-editor { background: rgba(46,204,113,.15); color: #2ecc71; }
.badge-viewer { background: rgba(136,136,152,.15); color: var(--muted); }
.badge-active { background: rgba(46,204,113,.15); color: #2ecc71; }
.badge-inactive { background: rgba(224,62,62,.15); color: var(--danger); }

/* ── MODALS ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
}
.modal-overlay[hidden] { display: none; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  width: 100%;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-head h2 { font-size: 1.1rem; font-weight: 600; }
.modal-close { background: none; border: none; color: var(--muted); font-size: 1.1rem; cursor: pointer; }
.modal form { display: flex; flex-direction: column; gap: 1rem; }
.modal-actions { display: flex; gap: .8rem; justify-content: flex-end; margin-top: .5rem; }

/* ── EDITOR TOPBAR ── */
.editor-topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .8rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}
.back-link {
  display: flex;
  align-items: center;
  gap: .3rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.82rem;
  transition: color .15s;
  white-space: nowrap;
}
.back-link:hover { color: var(--text); }
.back-link svg { width: 16px; height: 16px; }
.editor-brand-title {
  flex: 1;
  display: flex;
  align-items: center;
  gap: .6rem;
  font-weight: 600;
  font-size: 0.95rem;
}
.version-tag {
  font-size: 0.65rem;
  color: var(--muted);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: .1rem .5rem;
}
.editor-actions { display: flex; gap: .8rem; align-items: center; }

/* ── EDITOR TABS ── */
.editor-layout { display: flex; min-height: calc(100vh - 55px); }
.editor-tabs {
  width: 180px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1rem 0;
  position: sticky;
  top: 55px;
  height: calc(100vh - 55px);
  overflow-y: auto;
}
.tab {
  background: none;
  border: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  padding: .65rem 1.2rem;
  text-align: left;
  cursor: pointer;
  transition: color .15s, background .15s;
  border-left: 2px solid transparent;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); background: var(--surface2); border-left-color: var(--accent); }
.editor-body { flex: 1; padding: 2rem; overflow-y: auto; max-width: 900px; }
.tab-panel { display: none; flex-direction: column; gap: 1.5rem; }
.tab-panel.active { display: flex; }
.tab-panel h2 { font-size: 1.3rem; font-weight: 400; margin-bottom: .5rem; }
.tab-panel h3 { font-size: 0.95rem; font-weight: 600; margin-bottom: .8rem; }
.section-header { display: flex; align-items: center; justify-content: space-between; }

/* ── FORM GRID ── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

/* ── COLORS ── */
.color-editor-list { display: flex; flex-direction: column; gap: .6rem; }
.color-row {
  display: grid;
  grid-template-columns: 48px 1fr 1fr auto;
  gap: .8rem;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .6rem .8rem;
}
.color-swatch-input { width: 48px; height: 36px; border: none; border-radius: 6px; cursor: pointer; background: none; padding: 0; }

/* ── ASSETS ── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s;
  position: relative;
}
.upload-zone:hover { border-color: var(--accent); }
.upload-zone input[type=file] {
  position: absolute; inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%; height: 100%;
}
.upload-icon { font-size: 2rem; margin-bottom: .5rem; color: var(--muted); }
.upload-hint { font-size: 0.75rem; color: var(--muted); margin-top: .3rem; }
.tag-filter-bar { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: 1rem; }
.tag-chip {
  background: var(--surface2);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: .25rem .75rem;
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.tag-chip:hover { color: var(--text); }
.tag-chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.asset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 1rem; margin-top: 1.2rem; }
.asset-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  position: relative;
}
.asset-item img { width: 100%; height: 100px; object-fit: contain; padding: .8rem; background: #222; }
.asset-item-label {
  padding: .4rem .6rem;
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-top: 1px solid var(--border);
  cursor: pointer;
}
.asset-item-label:hover { color: var(--text); }
.asset-item-tags {
  display: flex; flex-wrap: wrap; gap: .25rem;
  padding: 0 .6rem .5rem;
  border-top: 1px solid var(--border);
  padding-top: .4rem;
  cursor: pointer;
  min-height: 1.6rem;
}
.tag-chip-mini {
  background: var(--border);
  color: var(--muted);
  border-radius: 999px;
  padding: .1rem .5rem;
  font-size: 0.62rem;
  font-weight: 600;
  white-space: nowrap;
}
.asset-item-tags:hover .tag-chip-mini { color: var(--text); }
.tag-chip-empty { background: none; color: var(--muted); font-style: italic; opacity: .6; }
.asset-item-label-input {
  width: 100%;
  padding: .4rem .6rem;
  font-size: 0.72rem;
  font-family: inherit;
  color: var(--text);
  background: var(--surface2);
  border: none;
  border-top: 1px solid var(--accent);
  box-sizing: border-box;
}
.asset-delete {
  position: absolute; top: .3rem; right: .3rem;
  background: rgba(0,0,0,.7);
  border: none;
  border-radius: 4px;
  color: var(--danger);
  width: 22px; height: 22px;
  font-size: .8rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

/* ── SCHRIFTDATEIEN ── */
#font-file-list { display: flex; flex-direction: column; gap: .5rem; margin-top: 1rem; }
.font-file-item {
  display: flex; align-items: center; gap: .6rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .5rem .8rem;
}
.font-file-name { flex: 1; font-size: 0.82rem; color: var(--text); }
.font-file-item .btn-sm.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ── ARCHETYP-FOTO ── */
.arch-photo-box { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.arch-photo-preview { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }

/* ── ARCHETYPES ── */
#archetype-list { display: flex; flex-direction: column; gap: .8rem; }
.archetype-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: .8rem;
  align-items: start;
}

/* ── GUIDELINES ── */
.guidelines-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.guideline-header {
  font-size: 0.72rem; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  padding: .5rem 0; margin-bottom: .6rem;
  border-bottom: 2px solid;
}
.guideline-header.do { color: var(--success); border-color: var(--success); }
.guideline-header.dont { color: var(--danger); border-color: var(--danger); }
.guideline-item {
  display: flex; gap: .5rem; align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .5rem .7rem;
  margin-bottom: .5rem;
}
.guideline-item input { flex: 1; background: transparent; border: none; color: var(--text); font-family: inherit; font-size: 0.88rem; }
.guideline-item input:focus { outline: none; }

/* ── BUTTONS EDITOR ── */
#button-list { display: flex; flex-direction: column; gap: .8rem; }
.button-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .8rem 1rem;
  display: grid;
  grid-template-columns: 1fr 80px 80px 80px auto;
  gap: .8rem;
  align-items: center;
}

/* ── TYPO ── */
.typo-sections { display: flex; flex-direction: column; gap: 2rem; }
.typo-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.2rem;
}

/* ── CLAUDE ── */
.hint-text { font-size: 0.82rem; color: var(--muted); line-height: 1.6; }
.claude-actions { display: flex; gap: .8rem; margin-top: .5rem; }
#skill-list { display: flex; flex-direction: column; gap: 1.2rem; margin-top: 1.2rem; }
.skill-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: .6rem;
}
.skill-row-head { display: flex; gap: .8rem; align-items: center; flex-wrap: wrap; }
.skill-label {
  flex: 1;
  min-width: 200px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .5rem .8rem;
  color: var(--text);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
}
.skill-row-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.skill-content, .skill-notes {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .6rem .8rem;
  color: var(--text);
  font-family: inherit;
  font-size: 0.82rem;
  resize: vertical;
  box-sizing: border-box;
}
.skill-notes-label { font-size: 0.72rem; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin-top: .2rem; }
.skill-file-box {
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .5rem .8rem;
}
.skill-file-info { flex: 1; display: flex; align-items: center; gap: .5rem; font-size: 0.8rem; }
.skill-file-link { color: var(--accent-lt); text-decoration: none; }
.skill-file-link:hover { text-decoration: underline; }
.skill-file-empty { color: var(--muted); font-style: italic; }

/* ── TOAST ── */
.toast {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem 1.2rem;
  font-size: 0.85rem;
  transform: translateY(4rem);
  opacity: 0;
  transition: all .25s;
  z-index: 999;
  max-width: 320px;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { border-color: var(--success); color: var(--success); }
.toast.error { border-color: var(--danger); color: var(--danger); }

/* ---- Guideline PDF ---- */
.current-pdf-row {
  display: flex; align-items: center; gap: 0.75rem;
  background: var(--surface2); border: 1px solid var(--border);
  padding: 0.6rem 1rem; font-size: 0.82rem; color: var(--muted);
}
.current-pdf-row svg { flex-shrink: 0; color: var(--accent-lt); }
.current-pdf-row span { flex: 1; word-break: break-all; }
