/* ═══════════════════════════════════════════
   KUDOVOX Design Editor — Full Stylesheet
   ═══════════════════════════════════════════ */

/* ── Reset & Variables ── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --pr: #6366f1;
  --prs: #eef2ff;
  --prh: #4f46e5;
  --bd: #e5e7eb;
  --bg: #f3f4f6;
  --card: #ffffff;
  --tx: #111827;
  --tx2: #374151;
  --mt: #9ca3af;
  --ok: #10b981;
  --er: #ef4444;
  --wr: #f59e0b;
  --inf: #3b82f6;
  --sh: 0 1px 3px rgba(0, 0, 0, .08), 0 1px 2px rgba(0, 0, 0, .04);
  --sh2: 0 4px 12px rgba(0, 0, 0, .1);
  --rad: 10px;
  --font: 'Manrope', system-ui, -apple-system, sans-serif;
}

html,
body,
#root {
  height: 100%;
  width: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--tx);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button {
  cursor: pointer;
  font-family: var(--font);
  border: none;
  background: none;
}

input,
select,
textarea {
  font-family: var(--font);
}

.fi {
  display: flex;
}

/* ── Keyframes ── */
@keyframes driftA {

  0%,
  100% {
    transform: translate(0, 0) rotate(0deg);
  }

  25% {
    transform: translate(20px, -15px) rotate(5deg);
  }

  50% {
    transform: translate(-10px, 20px) rotate(-3deg);
  }

  75% {
    transform: translate(15px, 10px) rotate(2deg);
  }
}

@keyframes driftB {

  0%,
  100% {
    transform: translate(0, 0) rotate(0deg);
  }

  33% {
    transform: translate(-20px, 15px) rotate(-5deg);
  }

  66% {
    transform: translate(15px, -20px) rotate(4deg);
  }
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(40px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ═══════════════════════════════════════════
   TOAST SYSTEM
   ═══════════════════════════════════════════ */

.toast-box {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 10px;
  background: #1e1e2e;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 500;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .2);
  animation: toastIn .3s ease-out;
  pointer-events: auto;
}

.toast.ok {
  background: #065f46;
}

.toast.er {
  background: #991b1b;
}

.toast.wr {
  background: #92400e;
}

.toast.inf {
  background: #1e3a5f;
}

.toast i {
  font-size: 0.9rem;
}

/* ═══════════════════════════════════════════
   AUTH SCREEN
   ═══════════════════════════════════════════ */

.auth-wrap {
  width: 100%;
  height: 100vh;
  display: flex;
  background: var(--bg);
}

.auth-left {
  width: 46%;
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #4338ca 100%);
  color: #fff;
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.auth-left h1 {
  font-size: 2.8rem;
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 16px;
}

.auth-left p {
  font-size: 1rem;
  opacity: .85;
  line-height: 1.6;
  max-width: 420px;
  margin-bottom: 32px;
}

.auth-tag {
  display: inline-block;
  background: rgba(255, 255, 255, .15);
  border: 1px solid rgba(255, 255, 255, .2);
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 18px;
}

.feat-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.feat-item {
  display: flex;
  align-items: center;
  gap: 12px;
}

.feat-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.feat-item strong {
  display: block;
  font-size: 0.88rem;
}

.feat-item span {
  display: block;
  font-size: 0.74rem;
  opacity: .7;
}

.floater {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: .4;
}

.auth-right {
  width: 54%;
  background: var(--card);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px;
}

.auth-right.su {
  overflow-y: auto;
}

.mode-switch {
  display: flex;
  background: var(--bg);
  border-radius: 10px;
  padding: 3px;
  margin-bottom: 24px;
  width: 100%;
  max-width: 360px;
}

.mode-btn {
  flex: 1;
  padding: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  border-radius: 8px;
  color: var(--mt);
  transition: all .2s;
}

.mode-btn.on {
  background: var(--card);
  color: var(--tx);
  box-shadow: var(--sh);
}

.auth-server-err {
  width: 100%;
  max-width: 360px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.form-grid {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--tx2);
  margin-bottom: 5px;
}

.field input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--bd);
  border-radius: 8px;
  font-size: 0.88rem;
  background: var(--card);
  transition: border .2s;
}

.field input:focus {
  outline: none;
  border-color: var(--pr);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, .1);
}

.field input.err {
  border-color: var(--er);
}

.field-err {
  font-size: 0.72rem;
  color: var(--er);
  margin-top: 3px;
}

.pw-wrap {
  position: relative;
}

.pw-wrap input {
  width: 100%;
  padding-right: 40px;
}

.pw-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--mt);
  font-size: 0.9rem;
  padding: 4px;
}

.pw-str-bar {
  height: 4px;
  border-radius: 2px;
  background: var(--bd);
  margin-top: 6px;
  overflow: hidden;
}

.pw-str-fill {
  height: 100%;
  border-radius: 2px;
  transition: width .3s, background .3s;
}

.pw-str-label {
  font-size: 0.66rem;
  margin-top: 2px;
  font-weight: 600;
}

.btn-primary {
  width: 100%;
  padding: 12px;
  background: var(--pr);
  color: #fff;
  font-size: 0.92rem;
  font-weight: 700;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  transition: background .2s;
}

.btn-primary:hover {
  background: var(--prh);
}

.btn-primary:disabled {
  opacity: .6;
  cursor: not-allowed;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  max-width: 360px;
  margin: 20px 0;
}

.auth-divider-line {
  flex: 1;
  height: 1px;
  background: var(--bd);
}

.auth-divider-text {
  font-size: 0.72rem;
  color: var(--mt);
  font-weight: 600;
  text-transform: uppercase;
}

.google-btn-container {
  width: 100;
  max-width: 360px;
  min-height: 42px;
}
.bg-title {
  font-family: Inter, Manrope, sans-serif;

  font-size: 12px;

  font-weight: 700;

  color: #6b7280;

  letter-spacing: .08em;

  text-transform: uppercase;

  margin-bottom: 8px;

  padding-left: 2px;
}
.auth-hint {
  font-size: 0.78rem;
  color: var(--mt);
  margin-top: 18px;
}

.auth-hint button {
  color: var(--pr);
  font-weight: 700;
  text-decoration: underline;
}

/* ═══════════════════════════════════════════
   AVATAR
   ═══════════════════════════════════════════ */

.avatar-sm {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.62rem;
  font-weight: 700;
  color: #fff;
  overflow: hidden;
  flex-shrink: 0;
}

.avatar-lg {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 700;
  color: #fff;
  overflow: hidden;
  flex-shrink: 0;
}

.avatar-sm img,
.avatar-lg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ═══════════════════════════════════════════
   EDITOR LAYOUT
   ═══════════════════════════════════════════ */

.app-root {
  flex-direction: column;
  height: 100vh;
  width: 100%;
}

/* ── Top Bar ── */
.topbar {
  height: 50px;
  background: var(--card);
  border-bottom: 1px solid var(--bd);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 6px;
  flex-shrink: 0;
}

.tb-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px;
}

.tb-logo .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--pr);
}

.tb-logo b {
  font-size: 0.82rem;
  letter-spacing: .06em;
  color: var(--tx);
}

.tb-sep {
  width: 1px;
  height: 24px;
  background: var(--bd);
  margin: 0 4px;
  flex-shrink: 0;
}

.tb-name {
  border: none;
  background: transparent;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--tx);
  width: 160px;
  padding: 4px 8px;
  border-radius: 6px;
}

.tb-name:focus {
  outline: none;
  background: var(--bg);
}

.tb-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.tb-select {
  border: 1px solid var(--bd);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.76rem;
  background: var(--card);
  color: var(--tx);
  cursor: pointer;
}

.zm {
  background: var(--bg);
  border-radius: 8px;
  padding: 2px 6px;
}

.zoom-txt {
  font-size: 0.72rem;
  font-weight: 600;
  min-width: 38px;
  text-align: center;
  color: var(--tx2);
}

.ib {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  color: var(--tx2);
  transition: all .15s;
}

.ib:hover {
  background: var(--bd);
}

.ib.on {
  background: var(--prs);
  color: var(--pr);
}

.tb-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-sec {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--card);
  border: 1.5px solid var(--bd);
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--tx2);
  transition: all .15s;
}

.btn-sec:hover {
  border-color: var(--pr);
  color: var(--pr);
}

.btn-sec.on {
  border-color: var(--pr);
  background: var(--prs);
  color: var(--pr);
}

.room-members {
  display: flex;
  align-items: center;
  padding: 0 6px 0 2px;
  min-width: 34px;
}

.room-members .avatar-sm {
  box-shadow: 0 1px 4px rgba(0, 0, 0, .18);
}

.member-more {
  margin-left: -7px;
  min-width: 24px;
  height: 24px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--tx);
  color: #fff;
  border: 2px solid #fff;
  font-size: 0.58rem;
  font-weight: 800;
}

.tb-profile {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s;
}

.tb-profile:hover {
  background: var(--bg);
}

.tb-pro-name {
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--tx2);
}

/* ═══════════════════════════════════════════
   PEN TOOL BANNER
   ═══════════════════════════════════════════ */

.pen-banner {
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 100%);
  color: #fff;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-shrink: 0;
  animation: slideDown .25s ease-out;
  border-bottom: 1px solid rgba(99, 102, 241, .4);
}

.pen-banner-left {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 600;
}

.pen-banner-left i {
  color: #a5b4fc;
  font-size: 0.9rem;
}

.pen-hint {
  font-weight: 400;
  opacity: .65;
  font-size: 0.74rem;
}

.pen-banner-controls {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.pen-ctrl-group {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
}

.pen-ctrl-group label {
  color: #c7d2fe;
  font-weight: 500;
  white-space: nowrap;
}

.pen-width-slider {
  width: 80px !important;
}

.pen-select {
  background: rgba(255, 255, 255, .1) !important;
  border: 1px solid rgba(255, 255, 255, .2) !important;
  color: #fff !important;
  font-size: 0.72rem !important;
  padding: 2px 6px !important;
  border-radius: 4px;
}

.pen-select option {
  background: #1e1b4b;
  color: #fff;
}

.pen-exit-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  background: rgba(239, 68, 68, .2);
  border: 1px solid rgba(239, 68, 68, .4);
  color: #fca5a5;
  border-radius: 6px;
  font-size: 0.74rem;
  font-weight: 600;
  transition: all .15s;
}

.pen-exit-btn:hover {
  background: rgba(239, 68, 68, .35);
  color: #fecaca;
}

/* ── Main Grid ── */
.main-grid {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* ── Panels ── */
.panel {
  width: 240px;
  background: var(--card);
  border-right: 1px solid var(--bd);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}

.panel-r {
  border-right: none;
  border-left: 1px solid var(--bd);
}

.p-tabs {
  display: flex;
  border-bottom: 1px solid var(--bd);
  padding: 4px 6px;
  gap: 2px;
}

.p-tab {
  flex: 1;
  padding: 7px 6px;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 6px;
  color: var(--mt);
  transition: all .15s;
  text-align: center;
}

.p-tab:hover {
  color: var(--tx2);
}

.p-tab.on {
  background: var(--prs);
  color: var(--pr);
}

.p-body {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
}

/* ── Element buttons ── */
.p-sec {
  margin-bottom: 16px;
}

.p-sec-title {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--mt);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 8px;
}

.el-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
}

.el-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 4px;
  border: 1.5px solid var(--bd);
  border-radius: 8px;
  font-size: 0.66rem;
  color: var(--tx2);
  font-weight: 500;
  transition: all .15s;
  background: var(--card);
}

.el-btn i {
  font-size: 1rem;
  color: var(--pr);
}

.el-emoji {
  font-size: 1.1rem;
}

.el-btn:hover {
  border-color: var(--pr);
  background: var(--prs);
}

.icon-library {
  margin-top: 14px;
}

.icon-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  max-height: 190px;
  overflow-y: auto;
  padding-right: 4px;
}

.icon-pick {
  height: 36px;
  border: 1px solid var(--bd);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--tx2);
  background: #fff;
  transition: all .15s;
}

.icon-pick:hover {
  border-color: var(--pr);
  color: var(--pr);
  background: var(--prs);
}

.save-wide {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--bd);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--tx2);
  font-size: 0.74rem;
  font-weight: 700;
  background: #fff;
}

.save-wide:hover {
  border-color: var(--pr);
  color: var(--pr);
  background: var(--prs);
}

.design-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 26px 26px;
  align-items: center;
  gap: 7px;
  padding: 7px;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 6px;
  border: 1px solid transparent;
}

.design-card:hover {
  background: var(--bg);
}

.design-card.on {
  background: var(--prs);
  border-color: rgba(99, 102, 241, .2);
}

.design-thumb {
  width: 42px;
  height: 34px;
  border-radius: 6px;
  border: 1px solid var(--bd);
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  overflow: hidden;
}

.design-thumb span {
  margin: 3px;
  padding: 1px 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .82);
  color: var(--tx2);
  font-size: 0.56rem;
  font-weight: 800;
}

.design-info {
  min-width: 0;
}

.design-info strong {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 0.74rem;
}

.design-info span {
  display: block;
  font-size: 0.62rem;
  color: var(--mt);
}

.design-icon {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--mt);
  font-size: 0.68rem;
}

.design-icon:hover,
.design-icon.on {
  color: #f59e0b;
  background: #fffbeb;
}

.design-icon.red:hover {
  color: var(--er);
  background: #fef2f2;
}

/* ── Pen tool button ── */
.pen-tool-btn {
  position: relative;
}

.pen-tool-btn.active {
  border-color: var(--pr) !important;
  background: var(--prs) !important;
  color: var(--pr) !important;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, .25);
}

.pen-tool-btn.active i {
  color: var(--pr);
}

.pen-tool-btn.active::after {
  content: '';
  position: absolute;
  top: -3px;
  right: -3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--pr);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {

  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }

  50% {
    transform: scale(1.3);
    opacity: .6;
  }
}

.pen-instructions {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--prs);
  border-radius: 8px;
  border: 1px solid rgba(99, 102, 241, .2);
}

.pen-instructions i {
  color: var(--pr);
  font-size: 0.72rem;
  margin-top: 1px;
  flex-shrink: 0;
}

.pen-instructions span {
  font-size: 0.66rem;
  color: var(--tx2);
  line-height: 1.4;
}

/* ── Templates ── */
.tmpl-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s;
  margin-bottom: 6px;
}

.tmpl-card:hover {
  background: var(--bg);
}

.tmpl-thumb {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  flex-shrink: 0;
  border: 1px solid var(--bd);
}

.tmpl-info {
  display: flex;
  flex-direction: column;
}

.tmpl-info strong {
  font-size: 0.78rem;
}

.tmpl-info span {
  font-size: 0.66rem;
  color: var(--mt);
}

/* ── Layers ── */
.layer-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: background .1s;
  margin-bottom: 2px;
}

.layer-item:hover {
  background: var(--bg);
}

.layer-item.on {
  background: var(--prs);
}

.layer-nm {
  font-size: 0.74rem;
  font-weight: 500;
}

.la {
  padding: 2px;
  font-size: 0.68rem;
  opacity: 0;
  transition: opacity .1s;
}

.layer-item:hover .la {
  opacity: 1;
}

/* ── Canvas Area ── */
.canvas-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  overflow: hidden;
  padding: 12px;
}

.canvas-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--sh2);
  border-radius: 4px;
  overflow: hidden;
  background: repeating-conic-gradient(#e5e7eb 0% 25%, transparent 0% 50%) 50% / 16px 16px;
}

#cv {
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .06);
}

/* Pen cursor for canvas */
#cv.pen-cursor {
  cursor: crosshair;
}

/* ── Grid overlay ── */
.cv-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 9998;
  background-image:
    linear-gradient(rgba(0, 0, 0, .04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 0, 0, .04) 1px, transparent 1px);
  background-size: 40px 40px;
}

/* ── Canvas Element ── */
.cv-el {
  position: absolute;
  user-select: none;
  transition: box-shadow .1s;
  cursor: move;
}

.cv-el.sel {
  /* Selection highlight */
}

.text-placeholder {
  opacity: .55;
}

.text-editor:empty::before {
  content: attr(data-placeholder);
  color: currentColor;
  opacity: .45;
  pointer-events: none;
}

.inline-icon {
  display: inline-flex;
  vertical-align: baseline;
  margin: 0 .08em;
}

.inline-gif {
  width: 1.65em;
  height: 1.65em;
  object-fit: cover;
  border-radius: .25em;
  vertical-align: middle;
  margin: 0 .12em;
}

/* ── Pen SVG element ── */
.cv-pen-el {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
}

.cv-pen-el.sel {
  outline: 2px dashed rgba(99, 102, 241, .5);
  outline-offset: 2px;
}

/* ── Selection box ── */
.sel-box {
  position: absolute;
  inset: -2px;
  border: 2px solid var(--pr);
  border-radius: 2px;
  pointer-events: none;
  z-index: 10;
}

/* ── Resize handles ── */
.rh {
  position: absolute;
  width: 8px;
  height: 8px;
  background: #fff;
  border: 1.5px solid var(--pr);
  border-radius: 2px;
  z-index: 20;
}

.rh.se {
  bottom: -4px;
  right: -4px;
  cursor: se-resize;
}

.rh.nw {
  top: -4px;
  left: -4px;
  cursor: nw-resize;
}

.rh.ne {
  top: -4px;
  right: -4px;
  cursor: ne-resize;
}

.rh.sw {
  bottom: -4px;
  left: -4px;
  cursor: sw-resize;
}

.rh.n {
  top: -4px;
  left: 50%;
  transform: translateX(-50%);
  cursor: n-resize;
}

.rh.s {
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  cursor: s-resize;
}

.rh.w {
  left: -4px;
  top: 50%;
  transform: translateY(-50%);
  cursor: w-resize;
}

.rh.e {
  right: -4px;
  top: 50%;
  transform: translateY(-50%);
  cursor: e-resize;
}

/* ── Rotation handle ── */
.rot-h {
  position: absolute;
  top: -28px;
  left: 50%;
  transform: translateX(-50%);
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--pr);
  border: 2px solid #fff;
  cursor: grab;
  z-index: 20;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .2);
}

.rot-h:active {
  cursor: grabbing;
}

.move-handle {
  position: absolute;
  top: -30px;
  left: -2px;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--pr);
  color: #fff;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: move;
  z-index: 25;
  font-size: .72rem;
}

/* ═══════════════════════════════════════════
   PROPERTIES PANEL
   ═══════════════════════════════════════════ */

.pg {
  margin-bottom: 14px;
}

.pg-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--mt);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 6px;
}

.pg-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.pg-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.pg-cell span {
  font-size: 0.62rem;
  color: var(--mt);
  font-weight: 500;
}

.pg-in {
  width: 100%;
  padding: 5px 8px;
  border: 1px solid var(--bd);
  border-radius: 6px;
  font-size: 0.76rem;
  background: var(--card);
  color: var(--tx);
}

.pg-in:focus {
  outline: none;
  border-color: var(--pr);
}

.pg-sm {
  width: 70px;
}

.pg-slider {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--bd);
  border-radius: 2px;
  outline: none;
  border: none;
  padding: 0;
}

.pg-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--pr);
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .2);
}

.pg-color {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pg-ci {
  width: 28px;
  height: 28px;
  border: 2px solid var(--bd);
  border-radius: 6px;
  cursor: pointer;
  padding: 0;
  background: none;
}

.pg-ci::-webkit-color-swatch-wrapper {
  padding: 0;
}

.pg-ci::-webkit-color-swatch {
  border: none;
  border-radius: 4px;
}

.font-search {
  margin-bottom: 7px;
}

.font-panel {
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
  border: 1px solid var(--bd);
  border-radius: 8px;
  background: #fff;
}

.font-choice {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 34px;
  padding: 6px 8px;
  border-radius: 6px;
  color: var(--tx2);
  font-size: 0.82rem;
  text-align: left;
}

.font-choice:hover {
  background: var(--bg);
}

.font-choice.on {
  background: var(--prs);
  color: var(--pr);
  font-weight: 800;
}

.font-choice span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* ── Actions ── */
.act-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}

.act-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 8px;
  border: 1px solid var(--bd);
  border-radius: 6px;
  font-size: 0.7rem;
  color: var(--tx2);
  font-weight: 500;
  transition: all .15s;
}

.act-btn:hover {
  border-color: var(--pr);
  color: var(--pr);
}

.act-btn.red {
  color: var(--er);
  border-color: #fecaca;
}

.act-btn.red:hover {
  background: #fef2f2;
}

/* ── Background swatches ── */
.bg-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.quick-bg-grid {
  margin-bottom: 10px;
}

.bg-sw {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 2px solid var(--bd);
  cursor: pointer;
  transition: all .15s;
}

.bg-sw:hover {
  transform: scale(1.1);
}

.bg-sw.on {
  border-color: var(--pr);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, .3);
}

.bg-panel {
  border: 1px solid var(--bd);
  border-radius: 8px;
  background: #fff;
  padding: 8px;
  max-height: 360px;
  overflow-y: auto;
}

.bg-preview {
  height: 68px;
  border-radius: 6px;
  border: 1px solid var(--bd);
  margin-bottom: 8px;
}

.bg-custom-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0 10px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--bd);
  font-size: 0.72rem;
  color: var(--tx2);
  font-weight: 700;
}

.bg-section {
  margin-bottom: 10px;
}

.bg-section-title {
  font-size: 0.66rem;
  font-weight: 800;
  color: var(--mt);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin: 0 0 6px;
}

.bg-tile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.bg-tile {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--bd);
  border-radius: 7px;
  padding: 5px;
  background: #fff;
  color: var(--tx2);
  font-size: 0.68rem;
  font-weight: 600;
}

.bg-tile:hover {
  border-color: var(--pr);
  background: var(--prs);
  color: var(--pr);
}

.bg-tile.on {
  border-color: var(--pr);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, .18);
}

.bg-tile-swatch {
  width: 24px;
  height: 20px;
  border-radius: 5px;
  border: 1px solid rgba(0, 0, 0, .08);
  flex-shrink: 0;
}

.bg-tile span:last-child {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* ── Empty state ── */
.empty-st {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--mt);
  font-size: 0.78rem;
  text-align: center;
}

.empty-st i {
  font-size: 1.4rem;
  opacity: .5;
}

.empty-st p {
  font-size: 0.74rem;
}

/* ═══════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════ */
/* GIF LIBRARY */

.gif-library {
  height: 320px;

  display: flex;
  flex-direction: column;

  overflow: hidden;
}

/* SEARCH BAR */

.gif-search {
  display: flex;
  align-items: center;

  background: #ffffff;

  border: 1px solid #dfe3ea;

  border-radius: 14px;

  overflow: hidden;

  height: 44px;

  margin-bottom: 14px;

  flex-shrink: 0;

  transition: all .15s ease;
}

.gif-search:focus-within {
  border-color: #6366f1;

  box-shadow:
    0 0 0 3px rgba(99, 102, 241, 0.08);
}

.gif-search input {
  flex: 1;

  border: none;
  outline: none;

  background: transparent;

  padding: 0 14px;

  font-size: 0.88rem;

  color: #1f2937;
}

.gif-search input::placeholder {
  color: #9ca3af;
}

.gif-search button {
  width: 44px;
  height: 44px;

  border: none;

  background: transparent;

  color: #6366f1;

  cursor: pointer;

  display: flex;
  align-items: center;
  justify-content: center;

  transition: background .15s ease;
}

.gif-search button:hover {
  background: rgba(99, 102, 241, 0.06);
}

.gif-library {
  display: flex;
  flex-direction: column;

  height: 320px;

  overflow: hidden;

  margin-bottom: 14px;
}

/* EMOJI LIBRARY */

.emoji-library {
  margin-top: 14px;
}

.emoji-grid {
  display: grid;

  grid-template-columns: repeat(4, 1fr);

  gap: 8px;

  max-height: 180px;

  overflow-y: auto;

  padding-right: 4px;
}

.emoji-grid::-webkit-scrollbar {
  width: 6px;
}

.emoji-grid::-webkit-scrollbar-thumb {
  background: rgba(99, 102, 241, 0.25);

  border-radius: 999px;
}

.emoji-btn {
  height: 48px;

  border: 1px solid #e5e7eb;

  border-radius: 12px;

  background: white;

  font-size: 1.4rem;

  cursor: pointer;

  transition:
    transform .15s ease,
    box-shadow .15s ease,
    background .15s ease;
}

.emoji-btn:hover {
  transform: translateY(-2px);

  background: #f8fafc;

  box-shadow:
    0 6px 18px rgba(0, 0, 0, 0.08);
}

.gif-grid {
  flex: 1;

  overflow-y: auto;

  display: grid;

  grid-template-columns: repeat(2, 1fr);

  gap: 10px;

  min-height: 0;

  padding-right: 4px;
}

/* GIF GRID */
.gif-grid {
  flex: 1;

  overflow-y: auto;

  display: grid;

  grid-template-columns: repeat(2, 1fr);

  gap: 10px;

  padding-right: 4px;

  min-height: 0;
}

/* SCROLLBAR */

.gif-grid::-webkit-scrollbar {
  width: 6px;
}

.gif-grid::-webkit-scrollbar-track {
  background: transparent;
}

.gif-grid::-webkit-scrollbar-thumb {
  background: rgba(99, 102, 241, 0.25);

  border-radius: 999px;
}

.gif-grid::-webkit-scrollbar-thumb:hover {
  background: rgba(99, 102, 241, 0.45);
}

/* GIF CARD */

.gif-card {
  border-radius: 12px;

  overflow: hidden;

  background: white;

  border: 1px solid #e5e7eb;
  height: 90px;
  cursor: pointer;

  transition:
    transform .15s ease,
    box-shadow .15s ease;
}

.gif-card:hover {
  transform: translateY(-2px);

  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.08);
}

/* GIF IMAGE */

.gif-thumb {
  width: 100%;

  height: 90px;

  object-fit: cover;

  display: block;
}

@media (max-width: 900px) {
  .auth-left {
    display: none;
  }

  .auth-right {
    width: 100%;
  }

  .panel {
    width: 200px;
  }
}

@media (max-width: 700px) {
  .panel-r {
    display: none;
  }

  .panel {
    width: 180px;
  }
}

/* ═══════════════════════════════════════════
   SCROLLBAR
   ═══════════════════════════════════════════ */

::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--bd);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--mt);
}
