/* HDW Kachel-Studio — CI: Dark #111217, Off-White #F5F2EA, Gold #C49A44 / #E1C870, Montserrat */
@font-face { font-family: Montserrat; src: url(fonts/Montserrat-Regular.ttf); font-weight: 400; }
@font-face { font-family: Montserrat; src: url(fonts/Montserrat-SemiBold.ttf); font-weight: 600; }
@font-face { font-family: Montserrat; src: url(fonts/Montserrat-Bold.ttf); font-weight: 700; }

:root {
  --dark: #111217; --panel: #191b22; --panel2: #20232c;
  --off: #F5F2EA; --gold: #C49A44; --gold2: #E1C870;
  --line: #2a2d38; --muted: #9a9dab;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
body { background: var(--dark); color: var(--off); font-family: Montserrat, sans-serif; }

/* ---------- Login ---------- */
.login-overlay { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(80% 60% at 50% 20%, #1a1d26 0%, var(--dark) 70%); z-index: 50; }
.login-card { width: min(360px, 90vw); background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 34px 30px; display: flex; flex-direction: column; gap: 12px; text-align: center; }
.login-logo { width: 130px; margin: 0 auto 6px; }
.login-card h1 { font-size: 22px; font-weight: 700; letter-spacing: .04em; }
.login-sub { color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.login-card input { background: var(--panel2); border: 1px solid var(--line); color: var(--off);
  border-radius: 8px; padding: 11px 12px; font: inherit; font-size: 14px; }
.login-card input:focus { outline: none; border-color: var(--gold); }
.login-card button { margin-top: 6px; background: linear-gradient(135deg, var(--gold), var(--gold2));
  color: #16130a; font-weight: 700; border: 0; border-radius: 8px; padding: 12px; font: inherit; cursor: pointer; }
.login-error { color: #e07a6a; font-size: 13px; }

/* ---------- Rahmen ---------- */
.topbar { display: flex; align-items: center; gap: 14px; padding: 10px 18px;
  border-bottom: 1px solid var(--line); background: rgba(17,18,23,.9); position: sticky; top: 0; z-index: 10; }
.topbar-logo { height: 34px; }
.topbar-title { font-weight: 700; letter-spacing: .06em; }
.topbar-hint { margin-left: auto; color: var(--muted); font-size: 12px; }

.layout { display: grid; grid-template-columns: minmax(320px, 460px) 1fr; gap: 0; height: calc(100vh - 55px); }

/* ---------- Bibliothek ---------- */
.library { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.lib-filter { display: flex; gap: 8px; padding: 12px; border-bottom: 1px solid var(--line); }
.lib-filter input, .lib-filter select { background: var(--panel2); color: var(--off); border: 1px solid var(--line);
  border-radius: 8px; padding: 9px 10px; font: inherit; font-size: 13px; }
.lib-filter input { flex: 1; min-width: 0; }
.lib-filter select { max-width: 46%; }
/* Feste Zeilenhöhe: aspect-ratio/%-Padding fließen in Chromes implizite
   Grid-Zeilen nicht ein (Kacheln überlappten) — 104px-Zeilen sind deterministisch. */
.grid { overflow-y: auto; padding: 12px; display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); grid-auto-rows: 104px; gap: 8px; }
.grid .tile { position: relative; height: 100%; border-radius: 8px; overflow: hidden; cursor: pointer;
  border: 2px solid transparent; background: var(--panel2); }
/* absolut, damit die Grid-Zeile ihre Höhe allein aus dem aspect-ratio des Tiles nimmt
   (sonst kollabieren die Zeilen und die Kacheln überlappen) */
.grid .tile img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.grid .tile:hover { border-color: var(--gold); }
.grid .tile.sel { border-color: var(--gold2); box-shadow: 0 0 0 2px rgba(225,200,112,.35); }
.grid .empty { grid-column: 1/-1; color: var(--muted); font-size: 13px; padding: 30px 10px; text-align: center; }

/* ---------- Editor ---------- */
.editor { display: grid; grid-template-columns: 1fr minmax(280px, 340px); min-height: 0; }
.stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.slot-tabs { display: flex; gap: 8px; padding: 10px 24px 0; background: var(--dark);
  border-bottom: 1px solid var(--line); }
.slot-tabs button { background: transparent; color: var(--muted); border: 1px solid transparent;
  border-bottom: 0; border-radius: 10px 10px 0 0; padding: 9px 26px; font: inherit;
  font-size: 13px; font-weight: 600; letter-spacing: .04em; cursor: pointer; }
.slot-tabs button.on { background: var(--panel); color: var(--gold2); border-color: var(--line);
  box-shadow: inset 0 2px 0 var(--gold); }
.canvas-wrap { display: flex; align-items: center; justify-content: center; position: relative;
  flex: 1; padding: 22px; min-width: 0; min-height: 0; background:
  radial-gradient(70% 50% at 50% 30%, #171922 0%, var(--dark) 75%); }
#cv { max-width: 100%; max-height: calc(100vh - 145px); border-radius: 6px;
  box-shadow: 0 24px 70px rgba(0,0,0,.55); cursor: grab; touch-action: none; }
#cv.dragging { cursor: grabbing; }
.canvas-hint { position: absolute; bottom: 10px; left: 0; right: 0; text-align: center;
  color: var(--muted); font-size: 12px; pointer-events: none; }

.controls { border-left: 1px solid var(--line); padding: 14px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 12px; background: var(--dark); }

/* Rubrik-Karten: jede Sektion klar abgegrenzt, nummeriert = Workflow-Reihenfolge */
.sec { display: flex; flex-direction: column; gap: 8px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 13px; }
.sec-head { display: flex; align-items: center; gap: 9px; font-size: 12px; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase; color: var(--off);
  padding-bottom: 8px; border-bottom: 1px solid var(--line); margin-bottom: 2px; }
.sec-num { flex: 0 0 auto; width: 21px; height: 21px; border-radius: 50%; display: flex;
  align-items: center; justify-content: center; font-size: 11.5px; font-weight: 700; letter-spacing: 0;
  background: linear-gradient(135deg, var(--gold), var(--gold2)); color: #16130a; }
.sec-final { border-color: var(--gold); }
.sub-label { font-size: 10.5px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase;
  color: var(--muted); }
.sec small { color: var(--muted); font-size: 11px; }
.sec input[type=text] { background: var(--panel2); border: 1px solid var(--line); color: var(--off);
  border-radius: 8px; padding: 10px 11px; font: inherit; font-size: 14px; }
.sec input[type=text]:focus { outline: none; border-color: var(--gold); }
.sec input[type=range] { accent-color: var(--gold); }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button { background: var(--panel2); color: var(--off); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 11px; font: inherit; font-size: 12.5px; cursor: pointer; }
.seg button.on { border-color: var(--gold); color: var(--gold2); font-weight: 600; }
.dl { margin-top: 4px; background: linear-gradient(135deg, var(--gold), var(--gold2)); color: #16130a;
  font-weight: 700; border: 0; border-radius: 10px; padding: 14px; font: inherit; font-size: 15px; cursor: pointer; }
.dl:disabled { opacity: .45; cursor: default; }

/* ---------- In-Canvas-Text-Editor ---------- */
.txedit { position: absolute; z-index: 5; resize: none; overflow: hidden;
  background: rgba(17,18,23,.6); color: var(--off); border: 2px solid var(--gold2);
  border-radius: 6px; padding: 4px 8px; font-family: Montserrat, sans-serif; line-height: 1.25;
  outline: none; box-shadow: 0 8px 30px rgba(0,0,0,.5); }

/* ---------- Sticker ---------- */
.sticker-tray { display: flex; flex-wrap: wrap; gap: 6px; }
.sticker-thumb { width: 54px; height: 54px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel2); cursor: pointer; padding: 5px; }
.sticker-thumb:hover { border-color: var(--gold); }
.sticker-thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
/* Geschäftsführung: eigener Bereich, runde größere Kacheln passend zu den Kreis-Porträts */
.gf-tray { gap: 8px; padding: 8px; background: var(--panel2); border: 1px solid var(--line);
  border-radius: 10px; }
.gf-thumb { width: 62px; height: 62px; border-radius: 50%; padding: 2px; background: transparent;
  border-color: transparent; }
.gf-thumb:hover { border-color: var(--gold2); }
.tray-empty { color: var(--muted); font-size: 12px; }
.sticker-ctl { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.ki-btn { background: linear-gradient(135deg, rgba(196,154,68,.18), rgba(225,200,112,.12));
  color: var(--gold2); border: 1px solid var(--gold); border-radius: 8px; padding: 10px 12px;
  font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer; }
.ki-btn:hover:not(:disabled) { background: linear-gradient(135deg, rgba(196,154,68,.32), rgba(225,200,112,.2)); }
.ki-btn:disabled { opacity: .45; cursor: default; }
.suggest-hint { color: var(--muted); }
.suggest-hint.error { color: #e07a6a; }
.ghost-btn { background: var(--panel2); color: var(--off); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; font: inherit; font-size: 12.5px; cursor: pointer; }
.ghost-btn:hover:not(:disabled) { border-color: var(--gold); }
.ghost-btn:disabled { opacity: .45; cursor: default; }
.ghost-btn.danger:hover { border-color: #e07a6a; color: #e07a6a; }
.sec code { color: var(--gold2); font-family: inherit; }

/* ---------- schmale Screens (Prototyp-Responsive) ---------- */
@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; height: auto; }
  .library { max-height: 42vh; border-right: 0; border-bottom: 1px solid var(--line); }
  .editor { grid-template-columns: 1fr; }
  .controls { border-left: 0; border-top: 1px solid var(--line); }
  #cv { max-height: 60vh; }
}
