:root {
  --e-bg: #f4f3f0; --e-panel: #ffffff; --e-text: #1f2328; --e-muted: #6b7078; --e-line: #e4e2dd;
  --e-primary: #7b5e3b; --e-primary-soft: #f3ece2; --e-danger: #b3403a; --e-wa: #1f9e55;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font: 14px/1.5 Inter, system-ui, sans-serif; color: var(--e-text); background: var(--e-bg); display: flex; flex-direction: column; }
button, input, select, textarea { font: inherit; color: inherit; }
code { background: var(--e-primary-soft); padding: 0 .3em; border-radius: 4px; font-size: .9em; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .6rem 1rem; background: var(--e-panel); border-bottom: 1px solid var(--e-line); flex-wrap: wrap; }
.brand { font-weight: 600; font-size: 1.05rem; display: flex; align-items: center; gap: .5rem; }
.logo { color: var(--e-primary); font-size: 1.4rem; }
.actions { display: flex; gap: .4rem; flex-wrap: wrap; }

.btn-s {
  display: inline-flex; align-items: center; gap: .35rem; padding: .42rem .8rem; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--e-primary); background: var(--e-primary); color: #fff; font-size: .82rem; font-weight: 500;
  text-decoration: none; white-space: nowrap;
}
.btn-s.ghost { background: transparent; color: var(--e-primary); }
.btn-s.wa { background: var(--e-wa); border-color: var(--e-wa); }
.btn-s:hover { filter: brightness(1.06); }

.workspace { flex: 1; display: grid; grid-template-columns: minmax(360px, 460px) 1fr; min-height: 0; }
.panel { display: grid; grid-template-columns: 76px 1fr; background: var(--e-panel); border-right: 1px solid var(--e-line); min-height: 0; }
.tabs { display: flex; flex-direction: column; gap: 2px; padding: .5rem .35rem; border-right: 1px solid var(--e-line); overflow-y: auto; }
.tabs button { display: grid; justify-items: center; gap: 2px; padding: .5rem .2rem; border: 0; background: none; border-radius: 10px; cursor: pointer; font-size: .7rem; color: var(--e-muted); }
.tabs button .ti { font-size: 1.15rem; }
.tabs button.active { background: var(--e-primary-soft); color: var(--e-primary); font-weight: 600; }
.tab-body { overflow-y: auto; padding: 1rem 1.1rem 3rem; }
.tab-title { margin: 0 0 1rem; font-size: 1.1rem; }

.fields { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; align-items: start; }
.fields > * { grid-column: span 2; }
.fields > .half { grid-column: span 1; }
.field { display: grid; gap: .3rem; min-width: 0; }
.lbl { font-size: .78rem; font-weight: 500; color: var(--e-muted); }
.field input[type=text], .field input[type=url], .field input[type=date], .field input[type=time], .field input[type=password],
.field input:not([type]), .field select, .field textarea, .img-actions input[type=url], .img-actions input[type=text], .img-actions input[type=password] {
  width: 100%; border: 1px solid var(--e-line); border-radius: 8px; padding: .5rem .6rem; background: #fff; min-width: 0;
}
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--e-primary-soft); border-color: var(--e-primary); }
.field input[type=color] { width: 44px; height: 34px; padding: 2px; border: 1px solid var(--e-line); border-radius: 8px; background: #fff; }
.field input[type=range] { width: 100%; accent-color: var(--e-primary); }
.field.toggle { grid-template-columns: auto 1fr; align-items: center; gap: .5rem; cursor: pointer; }
.field.toggle input { width: 18px; height: 18px; accent-color: var(--e-primary); margin: 0; }
.field.toggle .lbl { color: var(--e-text); font-size: .85rem; }
.hint { color: var(--e-muted); font-size: .74rem; }
.fx-try { align-self: end; }
.theme-bar { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }

.group { border: 1px solid var(--e-line); border-radius: 12px; padding: .8rem .9rem 1rem; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.group > * { grid-column: span 2; }
.group > .half { grid-column: span 1; }
.group legend { font-weight: 600; font-size: .82rem; padding: 0 .35rem; }

.img-row { display: grid; grid-template-columns: 72px 1fr; gap: .6rem; align-items: center; }
.thumb { width: 72px; height: 72px; border-radius: 10px; background: center / cover no-repeat var(--e-bg); border: 1px solid var(--e-line); }
.thumb.empty { background-image: repeating-linear-gradient(45deg, transparent 0 6px, rgba(0, 0, 0, .04) 6px 12px); }
.img-actions { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.img-actions input[type=url], .img-actions input[type=text], .img-actions input[type=password] { flex: 1 1 140px; }
.audio-prev { width: 100%; height: 36px; }

.themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: .6rem; }
.theme-card { border: 2px solid transparent; border-radius: 12px; padding: .7rem .5rem .6rem; cursor: pointer; display: grid; justify-items: center; gap: .15rem; box-shadow: 0 1px 0 var(--e-line), 0 0 0 1px var(--e-line); }
.theme-card.active { border-color: var(--e-primary); }
.tc-script { font-size: 1.6rem; line-height: 1.2; }
.tc-name { font-size: .78rem; }
.tc-sw { display: flex; gap: 3px; margin-top: .2rem; }
.tc-sw i { width: 14px; height: 14px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, .1); }

.list { display: grid; gap: .7rem; }
.list-item { border: 1px solid var(--e-line); border-radius: 12px; padding: .7rem .8rem .9rem; background: #fcfbf9; }
.list-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .6rem; gap: .5rem; }
.list-tools { display: flex; gap: 2px; }
.list-tools button, .gal-tools button { border: 1px solid var(--e-line); background: #fff; border-radius: 6px; width: 28px; height: 26px; cursor: pointer; }
.list-tools .danger, .gal-tools .danger { color: var(--e-danger); }
.btn-add { border: 1px dashed var(--e-primary); background: var(--e-primary-soft); color: var(--e-primary); border-radius: 10px; padding: .6rem; cursor: pointer; font-weight: 500; }

.gal { display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: .4rem; }
.gal-item { aspect-ratio: 1; border-radius: 8px; background: center / cover no-repeat var(--e-bg); position: relative; border: 1px solid var(--e-line); }
.gal-tools { position: absolute; right: 3px; bottom: 3px; display: flex; gap: 2px; }
.gal-tools button { width: 24px; height: 22px; font-size: .7rem; }

.guests { display: grid; gap: .4rem; }
.guest-tools { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; font-weight: 600; font-size: .8rem; }
.guest-tools span { margin-right: auto; }
.guest-row { display: grid; grid-template-columns: 1fr auto; gap: .5rem; align-items: center; border: 1px solid var(--e-line); border-radius: 10px; padding: .45rem .6rem; }
.guest-info { min-width: 0; display: grid; }
.guest-info a { font-size: .72rem; color: var(--e-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.guest-act { display: flex; gap: .25rem; }
.guest-act .btn-s { padding: .3rem .5rem; font-size: .74rem; }
.publish { display: grid; gap: .3rem; justify-items: start; padding-bottom: .4rem; border-bottom: 1px dashed var(--e-line); }
.publish:last-child { border-bottom: 0; }

.preview-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.preview-bar { display: flex; gap: .8rem; align-items: center; padding: .6rem 1rem; flex-wrap: wrap; border-bottom: 1px solid var(--e-line); background: #faf9f7; }
.seg { display: inline-flex; border: 1px solid var(--e-line); border-radius: 9px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: none; padding: .38rem .7rem; cursor: pointer; font-size: .8rem; }
.seg button.active { background: var(--e-primary); color: #fff; }
.inline { display: inline-flex; gap: .4rem; align-items: center; font-size: .8rem; color: var(--e-muted); }
.inline input[type=text] { border: 1px solid var(--e-line); border-radius: 8px; padding: .35rem .5rem; width: 190px; }
.inline input[type=checkbox] { accent-color: var(--e-primary); }
.warn { margin: 0; padding: .5rem 1rem; background: #fff4e5; color: #8a5300; font-size: .8rem; }
.stage { flex: 1; min-height: 0; display: grid; place-items: center; overflow: hidden; padding: 16px; }
.frame { position: relative; overflow: hidden; background: #fff; box-shadow: 0 20px 50px -20px rgba(0, 0, 0, .35), 0 0 0 1px var(--e-line); }
.frame.mobile { border-radius: 28px; }
.frame.desktop { border-radius: 10px; }
.frame iframe { border: 0; display: block; transform-origin: 0 0; background: #fff; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; background: #1f2328; color: #fff; padding: .6rem 1rem; border-radius: 10px; font-size: .84rem; transition: .3s; pointer-events: none; z-index: 10; max-width: 90vw; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 900px) {
  body { height: auto; }
  .workspace { grid-template-columns: 1fr; }
  .panel { grid-template-columns: 1fr; border-right: 0; }
  .tabs { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--e-line); position: sticky; top: 0; background: #fff; z-index: 2; }
  .tabs button { min-width: 62px; }
  .stage { height: 78vh; }
}
