:root {
  --bg: #070814;
  --panel: #0f1021;
  --panel-soft: #17192e;
  --line: #232744;
  --text: #e9ecff;
  --muted: #9aa2c4;
  --accent: #6d4dff;
  --accent-2: #5b39ec;
  --error: #ff6c6c;
  font-family: Inter, "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; }

.studio-body {
  background: radial-gradient(1200px 600px at 60% -10%, #1a1f4a 0%, #070814 55%);
  color: var(--text);
  min-height: 100vh;
}

.studio-shell {
  display: grid;
  grid-template-columns: 76px 320px 1fr;
  min-height: 100vh;
}

.studio-nav {
  border-right: 1px solid var(--line);
  background: #090a16;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem 0.4rem;
  gap: 0.55rem;
}

.brand-dot {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: #fff;
  color: #101225;
  font-weight: 700;
  margin-bottom: 0.8rem;
}

.nav-item {
  width: 100%;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  padding: 0.48rem 0.2rem;
  font-size: 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  align-items: center;
}

.nav-icon {
  width: 18px;
  height: 18px;
  color: currentColor;
}

.nav-icon svg {
  width: 100%;
  height: 100%;
  display: block;
  fill: currentColor;
}

.nav-item.active,
.nav-item:hover {
  background: var(--panel-soft);
  color: #fff;
}

.studio-left {
  border-right: 1px solid var(--line);
  background: #0a0c1a;
  padding: 1rem 1rem 0.85rem;
  overflow: auto;
}

.studio-left h1 {
  margin: 0;
  font-size: 1.35rem;
}

.muted {
  color: var(--muted);
  font-size: 0.84rem;
}

.left-form {
  margin-top: 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.72rem;
}

.left-form h3 {
  margin: 0.2rem 0 0;
  font-size: 0.86rem;
  color: #cfd4ef;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.preview-box {
  border: 1px solid var(--line);
  border-radius: 11px;
  overflow: hidden;
  background: var(--panel-soft);
}

.ratio-16x9 {
  aspect-ratio: 16 / 9;
}

.ratio-16x9 img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.left-form label {
  font-size: 0.81rem;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
}

.left-form select,
.left-form input {
  border: 1px solid var(--line);
  background: var(--panel);
  color: #fff;
  border-radius: 9px;
  padding: 0.58rem 0.62rem;
}

.upload-box {
  border: 1px dashed #3f4680;
  border-radius: 10px;
  padding: 1rem 0.8rem;
  text-align: center;
  cursor: pointer;
}

.upload-box input {
  display: none;
}

.upload-box span {
  color: #cbd2f7;
  font-size: 0.84rem;
}

.generate-btn {
  border: 0;
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  padding: 0.72rem;
  font-weight: 700;
  cursor: pointer;
}

.generate-btn:hover { background: var(--accent-2); }

.bodytype-mini-grid {
  margin-top: 1rem;
  display: grid;
  gap: 0.55rem;
}

.body-chip {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 0.5rem;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.35rem 0.4rem;
  background: #0f1228;
}

.body-chip img {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: #fff;
}

.body-chip strong {
  display: block;
  font-size: 0.78rem;
}

.body-chip small {
  color: var(--muted);
  font-size: 0.7rem;
}

.studio-main {
  padding: 0.9rem;
  overflow: auto;
}

.main-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.8rem;
  gap: 0.65rem;
}

.main-head h2 {
  margin: 0;
  font-size: 1.15rem;
}

.chip-row {
  display: flex;
  gap: 0.38rem;
  flex-wrap: wrap;
  margin-bottom: 0.48rem;
}

.chip {
  text-decoration: none;
  color: #d0d6f3;
  font-size: 0.75rem;
  border: 1px solid var(--line);
  background: #11142b;
  border-radius: 999px;
  padding: 0.32rem 0.58rem;
}

.chip.on { background: #202651; border-color: #323b7d; color: #fff; }

.template-grid {
  margin-top: 0.8rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 0.7rem;
}

.template-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #0e1125;
  cursor: pointer;
  transition: transform 0.16s ease, border-color 0.16s ease;
}

.template-card:hover {
  transform: translateY(-1px);
}

.template-card.selected {
  border-color: #6d4dff;
  box-shadow: 0 0 0 2px rgba(109, 77, 255, 0.25);
}

.template-info {
  padding: 0.55rem 0.6rem 0.65rem;
}

.template-info h4 {
  margin: 0 0 0.3rem;
  font-size: 0.83rem;
  line-height: 1.3;
}

.template-meta span {
  color: var(--muted);
  font-size: 0.69rem;
  margin-right: 0.45rem;
}

.template-sizes,
.template-suggestions {
  color: #b6bfdc;
  font-size: 0.68rem;
  margin-top: 0.35rem;
  line-height: 1.35;
}

.empty.dark {
  margin-top: 1rem;
  border: 1px dashed var(--line);
  border-radius: 10px;
  color: var(--muted);
  background: #0f1229;
  padding: 0.9rem;
}

/* Shared pages (admin/result) */
.topbar {
  border-bottom: 1px solid var(--line);
  background: #0d1020;
}

.topbar-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0.9rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar h1 { margin: 0; font-size: 1.3rem; }
.tagline { margin: 0.2rem 0 0; color: var(--muted); font-size: 0.86rem; }

.link-btn {
  text-decoration: none;
  color: #fff;
  background: var(--accent);
  border-radius: 9px;
  padding: 0.54rem 0.74rem;
  font-size: 0.85rem;
}

.link-btn:hover { background: var(--accent-2); }

.admin-grid {
  max-width: 1240px;
  margin: 0 auto;
  padding: 1rem;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 0.75rem;
}

.panel {
  background: #101329;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.9rem;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.form label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.form input,
.form select {
  border: 1px solid var(--line);
  background: #0a0d1f;
  color: #fff;
  border-radius: 9px;
  padding: 0.55rem 0.6rem;
}

.form button {
  border: 0;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  padding: 0.58rem 0.72rem;
  cursor: pointer;
  font-weight: 600;
}

.form button:hover { background: var(--accent-2); }

.simple-list { color: var(--muted); }
.hint { color: var(--muted); font-size: 0.82rem; }

.panel-wide { grid-column: 1 / -1; }
.body-edit-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(240px,1fr)); gap: 0.65rem; }
.body-edit-form { border: 1px solid var(--line); border-radius: 10px; padding: 0.7rem; background: #0d1024; }
.body-edit-form h3 { margin: 0 0 0.5rem; font-size: 0.78rem; text-transform: uppercase; color: #cfd4ef; }
.body-edit-form h4 { margin: 0 0 0.5rem; font-size: 0.78rem; text-transform: uppercase; color: #cfd4ef; }

.admin-shell {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1rem;
  display: grid;
  grid-template-columns: 250px 1fr;
  gap: 0.9rem;
}

.admin-sidebar {
  position: sticky;
  top: 78px;
  align-self: start;
  background: #101329;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.85rem;
}

.admin-sidebar h2 {
  margin: 0 0 0.7rem;
  font-size: 0.95rem;
}

.admin-menu {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.admin-menu a {
  text-decoration: none;
  color: #dbe1ff;
  border: 1px solid var(--line);
  background: #0d1024;
  border-radius: 9px;
  padding: 0.5rem 0.6rem;
  font-size: 0.83rem;
}

.admin-menu a:hover {
  border-color: #3a4487;
  background: #151b3a;
}

.admin-kpis {
  margin-top: 0.85rem;
  display: grid;
  gap: 0.45rem;
}

.kpi {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0.55rem 0.6rem;
  background: #0b0e20;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.kpi span {
  color: var(--muted);
  font-size: 0.75rem;
}

.kpi strong {
  font-size: 1rem;
}

.admin-content {
  display: grid;
  gap: 0.95rem;
}

.admin-block {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0c0f23;
  padding: 0.8rem;
}

.admin-block > h2 {
  margin: 0;
  font-size: 1rem;
}

.admin-block > .hint {
  margin: 0.3rem 0 0.8rem;
}

.single {
  max-width: 980px;
  margin: 0 auto;
  padding: 1rem;
}

.result-figure {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}

.result-figure img { width: 100%; display: block; }

.error {
  color: #ffd1d1;
  border: 1px solid #5f2d36;
  background: #2c151a;
  border-radius: 10px;
  padding: 0.9rem;
}

.meta { color: var(--muted); font-size: 0.85rem; }

@media (max-width: 1180px) {
  .studio-shell { grid-template-columns: 64px 290px 1fr; }
  .template-grid { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
}

@media (max-width: 980px) {
  .studio-shell {
    grid-template-columns: 1fr;
    padding-bottom: 72px;
  }

  .studio-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 64px;
    z-index: 20;
    border-top: 1px solid var(--line);
    border-right: 0;
    flex-direction: row;
    justify-content: space-around;
    padding: 0.35rem 0.5rem;
    background: rgba(8, 9, 20, 0.95);
    backdrop-filter: blur(6px);
  }

  .brand-dot { display: none; }

  .nav-item {
    flex: 1;
    font-size: 0.67rem;
    padding: 0.35rem 0.1rem;
    border-radius: 10px;
  }

  .studio-left,
  .studio-main {
    border-right: 0;
    padding: 0.8rem;
  }

  .studio-left {
    border-bottom: 1px solid var(--line);
  }

  .main-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .head-actions { width: 100%; }
  .head-actions .link-btn { display: inline-block; width: 100%; text-align: center; }

  .chip-row {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 0.2rem;
    scrollbar-width: thin;
  }

  .chip { white-space: nowrap; }

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

  .template-info h4 {
    font-size: 0.78rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .upload-box {
    padding: 0.85rem 0.55rem;
  }

  .admin-shell {
    grid-template-columns: 1fr;
    padding: 0.8rem;
  }

  .admin-sidebar {
    position: static;
  }

  .admin-menu {
    flex-direction: row;
    overflow-x: auto;
  }

  .admin-menu a {
    white-space: nowrap;
  }
}

@media (max-width: 560px) {
  .studio-left h1 { font-size: 1.15rem; }
  .muted { font-size: 0.8rem; }

  .template-grid {
    grid-template-columns: 1fr;
  }

  .left-form select,
  .left-form input,
  .form select,
  .form input {
    min-height: 42px;
    font-size: 16px; /* evita zoom iOS */
  }

  .generate-btn,
  .form button,
  .link-btn {
    min-height: 44px;
  }
}
