:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #eef2f7;
  --ink: #111827;
  --muted: #667085;
  --soft: #98a2b3;
  --line: #e4e7ec;
  --line-strong: #cbd5e1;
  --accent: #19c6b7;
  --accent-2: #6d5dfc;
  --accent-dark: #0f766e;
  --danger: #e11d48;
  --warning: #f59e0b;
  --shadow-sm: 0 8px 24px rgba(15, 23, 42, 0.08);
  --shadow-md: 0 18px 50px rgba(15, 23, 42, 0.12);
  --shadow-lg: 0 28px 80px rgba(15, 23, 42, 0.16);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 12% 8%, rgba(25, 198, 183, 0.18), transparent 28%),
    radial-gradient(circle at 88% 12%, rgba(109, 93, 252, 0.16), transparent 30%),
    linear-gradient(180deg, #f9fbff 0%, #eef4fb 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(15, 23, 42, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 23, 42, 0.035) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,0.8), transparent 76%);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1540px, 100%);
  margin: 0 auto;
  padding: 28px;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px;
  margin-bottom: 18px;
  border: 1px solid rgba(226, 232, 240, 0.86);
  border-radius: var(--radius-xl);
  background: rgba(255, 255, 255, 0.84);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(18px);
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 54px;
  height: 54px;
  border-radius: 18px;
  color: white;
  background:
    linear-gradient(135deg, rgba(255,255,255,.24), transparent 36%),
    linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 14px 32px rgba(25, 198, 183, 0.26);
  font-size: 26px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 4px;
  font-size: clamp(24px, 2.4vw, 38px);
  line-height: 1.04;
  letter-spacing: -0.04em;
}

.header-copy {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

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

.primary-btn,
.secondary-btn,
.ghost-btn {
  min-height: 42px;
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 850;
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease, border-color .16s ease;
}

.primary-btn {
  color: white;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 14px 34px rgba(25, 198, 183, 0.26);
}

.primary-btn:hover,
.secondary-btn:hover,
.ghost-btn:hover {
  transform: translateY(-1px);
}

.primary-btn:hover {
  box-shadow: 0 18px 42px rgba(25, 198, 183, 0.32);
}

.secondary-btn,
.ghost-btn {
  color: #344054;
  background: #ffffff;
  border: 1px solid var(--line);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.06);
}

.secondary-btn:hover,
.ghost-btn:hover {
  border-color: var(--line-strong);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.09);
}

.secondary-btn.danger,
.ghost-btn.danger {
  color: var(--danger);
}

.studio-layout {
  display: grid;
  grid-template-columns: minmax(300px, 350px) minmax(430px, 1fr) minmax(280px, 330px);
  gap: 18px;
  align-items: start;
}

.tool-panel,
.canvas-card {
  border: 1px solid rgba(226, 232, 240, 0.94);
  border-radius: var(--radius-xl);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(18px);
}

.tool-panel {
  display: grid;
  gap: 14px;
  padding: 14px;
}

.left-panel,
.right-panel {
  position: sticky;
  top: 112px;
  max-height: calc(100vh - 132px);
  overflow: auto;
}

.panel-section {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
}

.compact-section,
.asset-library,
.inspector-panel,
.guide-panel,
.note-panel {
  background: var(--surface);
}

.section-title-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.section-title-row.small {
  margin-bottom: 12px;
}

.section-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  color: var(--accent-dark);
  background: rgba(25, 198, 183, 0.12);
  font-size: 12px;
  font-weight: 950;
}

.panel-section h2,
.canvas-topbar h2 {
  margin: 0 0 4px;
  font-size: 17px;
  letter-spacing: -0.02em;
}

.panel-section p,
.canvas-topbar p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.upload-card {
  position: relative;
  display: grid;
  place-items: center;
  gap: 6px;
  min-height: 132px;
  padding: 18px;
  border: 1.5px dashed var(--line-strong);
  border-radius: 20px;
  background:
    radial-gradient(circle at top left, rgba(25, 198, 183, 0.13), transparent 34%),
    linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  text-align: center;
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

.upload-card:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
  box-shadow: 0 14px 32px rgba(15, 23, 42, 0.09);
}

.upload-card input {
  display: none;
}

.upload-card strong {
  font-size: 14px;
  font-weight: 900;
}

.upload-card small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.upload-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 16px;
  color: white;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 12px 24px rgba(25, 198, 183, 0.22);
  font-size: 26px;
  font-weight: 700;
}

.upload-card.slim {
  min-height: 84px;
  align-items: center;
  justify-items: start;
  place-items: unset;
  padding: 14px 16px;
  margin-top: 10px;
  text-align: left;
}

.input-stack {
  display: grid;
  gap: 10px;
}

.text-input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0 14px;
  color: var(--ink);
  background: #ffffff;
  outline: none;
  font-weight: 750;
  transition: border-color .16s ease, box-shadow .16s ease;
}

.text-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(25, 198, 183, 0.14);
}

.full {
  width: 100%;
}

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

.tab-btn {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #475467;
  background: #ffffff;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 850;
  transition: background .16s ease, color .16s ease, border-color .16s ease, box-shadow .16s ease;
}

.tab-btn:hover {
  border-color: var(--line-strong);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
}

.tab-btn.active {
  color: #ffffff;
  border-color: transparent;
  background: linear-gradient(135deg, #111827, #344054);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.18);
}

.asset-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  max-height: 360px;
  overflow: auto;
  padding: 2px 4px 2px 0;
}

.asset-grid::-webkit-scrollbar,
.tool-panel::-webkit-scrollbar {
  width: 8px;
}

.asset-grid::-webkit-scrollbar-thumb,
.tool-panel::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: #d0d5dd;
}

.asset-card {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  aspect-ratio: 1;
  border: 1px solid var(--line);
  border-radius: 18px;
  background:
    linear-gradient(180deg, #ffffff, #f8fafc);
  user-select: none;
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}

.asset-card:hover {
  transform: translateY(-2px);
  border-color: rgba(25, 198, 183, 0.55);
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.1);
}

.asset-card img {
  width: 72%;
  height: 68%;
  object-fit: contain;
  pointer-events: none;
}

.asset-card span {
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 6px;
  overflow: hidden;
  color: #475467;
  font-size: 10px;
  font-weight: 850;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hint {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.canvas-panel {
  min-width: 0;
}

.canvas-card {
  padding: 18px;
}

.canvas-topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 14px;
}

.canvas-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  color: #344054;
  background: #ffffff;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.canvas-status span {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #12b76a;
  box-shadow: 0 0 0 4px rgba(18, 183, 106, 0.14);
}

.stage {
  position: relative;
  width: min(780px, 100%);
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid rgba(203, 213, 225, 0.9);
  border-radius: 30px;
  background:
    radial-gradient(circle at 32% 20%, rgba(255,255,255,.95), transparent 28%),
    radial-gradient(circle at 72% 76%, rgba(25, 198, 183, 0.14), transparent 24%),
    linear-gradient(135deg, #fbfaf7 0%, #f6f0e8 52%, #edf2f7 100%);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.9),
    inset 0 0 0 10px rgba(255,255,255,.24),
    0 24px 70px rgba(15, 23, 42, 0.16);
  touch-action: none;
}

.stage::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(15, 23, 42, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 23, 42, 0.045) 1px, transparent 1px);
  background-size: 32px 32px;
  opacity: 0.45;
}

.base-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: none;
  user-select: none;
  pointer-events: none;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 10px;
  padding: 42px;
  color: #344054;
  text-align: center;
}

.empty-state strong {
  font-size: clamp(22px, 2.2vw, 34px);
  letter-spacing: -0.03em;
}

.empty-state span {
  max-width: 500px;
  color: var(--muted);
  line-height: 1.55;
}

.empty-gem {
  display: grid;
  place-items: center;
  justify-self: center;
  width: 78px;
  height: 78px;
  border-radius: 26px;
  color: white;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 18px 40px rgba(25, 198, 183, 0.24);
  font-size: 34px;
}

.object-layer {
  position: absolute;
  inset: 0;
}

.canvas-object {
  position: absolute;
  left: 0;
  top: 0;
  width: 160px;
  height: 160px;
  transform-origin: center center;
  user-select: none;
  touch-action: none;
}

.canvas-object img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 8px 7px rgba(15, 23, 42, 0.18));
}

.canvas-object.text-object {
  display: grid;
  place-items: center;
  min-width: 130px;
  min-height: 42px;
  width: auto;
  height: auto;
  padding: 8px 18px;
  border: 1px solid rgba(203, 213, 225, 0.9);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.84);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
  color: #111827;
  font-size: 25px;
  font-weight: 950;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
  backdrop-filter: blur(10px);
}

.canvas-object.selected {
  outline: 2px solid var(--accent);
  outline-offset: 5px;
}

.resize-handle,
.rotate-handle {
  position: absolute;
  display: none;
  border: 2px solid #ffffff;
  background: var(--accent);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.2);
}

.canvas-object.selected .resize-handle,
.canvas-object.selected .rotate-handle {
  display: block;
}

.resize-handle {
  right: -12px;
  bottom: -12px;
  width: 20px;
  height: 20px;
  border-radius: 7px;
  cursor: nwse-resize;
}

.rotate-handle {
  left: 50%;
  top: -46px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  transform: translateX(-50%);
  cursor: grab;
}

.rotate-handle::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 22px;
  width: 2px;
  height: 22px;
  background: var(--accent);
  transform: translateX(-50%);
}

.selected-name {
  min-height: 46px;
  display: flex;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--muted);
  background: var(--surface-2);
  font-weight: 850;
}

.range-field {
  display: grid;
  gap: 8px;
  margin: 16px 0;
}

.range-field span {
  color: #344054;
  font-size: 13px;
  font-weight: 850;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.button-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.button-grid .secondary-btn {
  padding-inline: 10px;
  font-size: 13px;
}

.guide-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 20px;
  color: #475467;
  font-size: 13px;
  line-height: 1.5;
}

.guide-list strong {
  color: #111827;
}

.note-panel code {
  display: block;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  color: #0f766e;
  background: #f0fdfa;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  white-space: normal;
}

@media (max-width: 1260px) {
  .studio-layout {
    grid-template-columns: minmax(300px, 350px) minmax(420px, 1fr);
  }

  .right-panel {
    position: static;
    grid-column: 1 / -1;
    max-height: none;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 940px) {
  .app-shell {
    padding: 16px;
  }

  .app-header {
    position: static;
    align-items: flex-start;
    flex-direction: column;
  }

  .header-actions {
    width: 100%;
    justify-content: stretch;
  }

  .header-actions button {
    flex: 1;
  }

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

  .left-panel,
  .right-panel {
    position: static;
    max-height: none;
  }

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

  .asset-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    max-height: 300px;
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding: 10px;
  }

  .app-header,
  .tool-panel,
  .canvas-card {
    border-radius: 20px;
  }

  .brand-block {
    align-items: flex-start;
  }

  .brand-mark {
    width: 46px;
    height: 46px;
    border-radius: 15px;
  }

  .header-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

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

  .canvas-topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .canvas-status {
    width: fit-content;
  }

  .panel-section {
    padding: 14px;
  }
}
.creator-inline {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: rgba(226, 232, 240, 0.72);
}

.creator-inline strong {
  color: #ffffff;
  font-weight: 800;
}

.creator-inline .creator-handle,
.creator-inline a {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.42);
  color: rgba(226, 232, 240, 0.9);
  text-decoration: none;
}

.creator-inline a:hover {
  border-color: rgba(125, 211, 252, 0.45);
  color: #ffffff;
  background: rgba(14, 165, 233, 0.14);
}

.creator-panel {
  position: relative;
  overflow: hidden;
}

.creator-panel::before {
  content: "";
  position: absolute;
  inset: -80px -80px auto auto;
  width: 170px;
  height: 170px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(56, 189, 248, 0.22), transparent 65%);
  pointer-events: none;
}

.creator-card {
  position: relative;
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(15, 23, 42, 0.88), rgba(30, 41, 59, 0.68)),
    radial-gradient(circle at top right, rgba(56, 189, 248, 0.16), transparent 45%);
  box-shadow: 0 18px 45px rgba(2, 6, 23, 0.22);
}

.creator-avatar {
  width: 46px;
  height: 46px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  color: #ffffff;
  font-weight: 900;
  letter-spacing: -0.04em;
  background:
    linear-gradient(135deg, #38bdf8, #6366f1 48%, #a855f7),
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.8), transparent 28%);
  box-shadow: 0 12px 28px rgba(56, 189, 248, 0.28);
}

.creator-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.creator-info strong {
  color: #ffffff;
  font-size: 15px;
  font-weight: 850;
}

.creator-info span {
  color: rgba(226, 232, 240, 0.62);
  font-size: 12px;
}

.creator-links {
  position: relative;
  margin-top: 12px;
  display: grid;
  gap: 10px;
}

.creator-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 13px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.48);
  color: rgba(226, 232, 240, 0.76);
  text-decoration: none;
}

.creator-link span {
  font-size: 12px;
  color: rgba(226, 232, 240, 0.56);
}

.creator-link strong {
  font-size: 13px;
  color: #ffffff;
}

.creator-link.clickable:hover {
  border-color: rgba(56, 189, 248, 0.42);
  background: rgba(14, 165, 233, 0.12);
}

.app-footer {
  width: min(1480px, calc(100% - 32px));
  margin: 18px auto 28px;
  padding: 14px 18px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px 18px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 18px;
  background: rgba(15, 23, 42, 0.48);
  color: rgba(226, 232, 240, 0.66);
  font-size: 13px;
  backdrop-filter: blur(14px);
}

.app-footer strong {
  color: #ffffff;
}

.app-footer a {
  color: #7dd3fc;
  text-decoration: none;
  font-weight: 700;
}

.app-footer a:hover {
  color: #ffffff;
}

#logo {
  width: 100px;  /* Điều chỉnh kích thước logo */
  height: auto;  /* Tự động duy trì tỷ lệ */
  margin-right: 20px;  /* Khoảng cách từ logo tới các phần tử khác */
}

.brand-mark {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.brand-mark img {
  width: 36px;
  height: 36px;
  object-fit: contain;
}

.asset-card img {
  width: 76px;
  height: 76px;
  object-fit: contain;
}

#stage {
  position: relative;
  overflow: hidden;
}

#backgroundFrameLayer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  z-index: 1;
  pointer-events: none;
}

#baseImage {
  position: absolute;
  z-index: 5;
}

#objectLayer {
  position: absolute;
  inset: 0;
  z-index: 20;
}

.empty-state {
  position: relative;
  z-index: 30;
}
.asset-card.active-frame {
  border: 2px solid #14b8a6;
  background: #ecfeff;
  box-shadow: 0 0 0 4px rgba(20, 184, 166, 0.14);
}