@font-face {
  font-family: "FS Magistral";
  src: url("../fonts/FS-Magistral/FS Magistral-Book.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "FS Magistral";
  src: url("../fonts/FS-Magistral/FS Magistral-Medium.ttf") format("truetype");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "FS Magistral";
  src: url("../fonts/FS-Magistral/FS Magistral-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "PF Beau Sans Pro";
  src: url("../fonts/FS-PFBeauSansPro/FS PFBeauSansPro-Light.ttf") format("truetype");
  font-weight: 300;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "PF Beau Sans Pro";
  src: url("../fonts/FS-PFBeauSansPro/FS PFBeauSansPro-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #0b1020;
  --panel: #121934;
  --line: rgba(255, 255, 255, 0.08);
  --text: #e5e7eb;
  --muted: #94a3b8;
  --primary: #3b82f6;
  --primary-strong: #2563eb;
  --danger: #ef4444;
  --white: #ffffff;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "PF Beau Sans Pro", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(59, 130, 246, 0.18), transparent 30%),
    radial-gradient(circle at bottom right, rgba(139, 92, 246, 0.12), transparent 28%),
    var(--bg);
  color: var(--text);
}

.app-shell {
  height: 100vh;
  overflow: hidden;
  display: grid;
  grid-template-columns: 1fr 450px;
}

.sidebar {
  order: 2;
  padding: 20px;
  border-left: 1px solid var(--line);
  background: rgba(10, 15, 31, 0.72);
  backdrop-filter: blur(12px);
  overflow-y: auto;
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 20px;
}

.brand__badge {
  width: 52px;
  height: 52px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  font-weight: 800;
  color: var(--white);
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  box-shadow: var(--shadow);
}

.brand h1 {
  margin: 0;
  font-size: 22px;
}

.brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.panel {
  background: linear-gradient(180deg, rgba(24, 33, 63, 0.92), rgba(18, 25, 52, 0.92));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.panel__title {
  font-weight: 700;
  margin-bottom: 14px;
  font-size: 15px;
}

.field {
  margin-bottom: 12px;
}

.field label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: #cbd5e1;
}

.field small {
  display: inline-block;
  margin-top: 6px;
  color: var(--muted);
}

input[type="text"],
input[type="date"],
select,
input[type="file"],
input[type="range"],
button {
  width: 100%;
}

input[type="text"],
input[type="date"],
select {
  height: 44px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  padding: 0 12px;
  background: #0f172a;
  color: var(--text);
}

input[type="file"] {
  border: 1px dashed rgba(255,255,255,0.15);
  border-radius: var(--radius);
  padding: 10px;
  background: #0f172a;
  color: var(--muted);
}

input[type="color"] {
  height: 44px;
  padding: 4px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #0f172a;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.actions {
  display: flex;
  gap: 10px;
}

.actions + .actions {
  margin-top: 10px;
}

.inline-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.inline-row input {
  flex: 1;
}

.inline-row .btn {
  width: auto;
  white-space: nowrap;
}

.actions--wrap {
  flex-wrap: wrap;
}

.btn {
  border: none;
  border-radius: var(--radius);
  padding: 12px 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .18s ease, opacity .18s ease, background .18s ease;
}

.btn:hover {
  transform: translateY(-1px);
  opacity: 0.96;
}

.btn--primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  color: var(--white);
}

.btn--secondary {
  background: #334155;
  color: var(--white);
}

.btn--ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--line);
}

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

.workspace {
  order: 1;
  padding: 24px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.workspace__top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

.workspace__top h2 {
  margin: 0 0 6px;
}

.workspace__top p,
.meta span {
  margin: 0;
  color: var(--muted);
}

.stage {
  flex: 1;
  min-height: 0;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0.01)),
    #0f172a;
  display: grid;
  place-items: center;
  padding: 24px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.02);
}

#previewCanvas {
  width: min(calc(100vh - 180px), calc(100vw - 550px));
  height: min(calc(100vh - 180px), calc(100vw - 550px));
  max-width: 100%;
  max-height: 100%;
  background: transparent;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
  cursor: grab;
  touch-action: none;
}

#previewCanvas.dragging {
  cursor: grabbing;
}

@media (max-width: 1100px) {
  .app-shell {
    height: auto;
    overflow: visible;
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-left: none;
    border-top: 1px solid var(--line);
  }

  .workspace {
    overflow: visible;
  }

  .stage {
    min-height: auto;
  }

  #previewCanvas {
    width: min(92vw, 760px);
    height: min(92vw, 760px);
    max-width: 92vw;
    max-height: none;
  }
}

@media (max-width: 640px) {
  .grid-2,
  .actions {
    grid-template-columns: 1fr;
    display: grid;
  }

  .workspace__top {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
}