:root {
  --bg: #f5f5f7; --panel: #ffffff; --panel-2: #fafafa; --line: #e5e5ea; --text: #1c1c1e; --muted: #6e6e73;
  --hover: #f0f0f3; --selected: #e9e9ef; --accent: #4f46e5; --accent-text: #fff; --accent-soft: color-mix(in srgb, var(--accent) 12%, transparent);
  --danger: #c0262d; --ok: #15803d; --warn: #b45309; --chip: #efeff2; --star: #e3a008; --rail: #1f1f2b; --rail-text: #c9c9d6;
  --shadow: 0 8px 30px rgb(0 0 0 / .12); --radius: 10px; --fs: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111113; --panel: #1a1a1d; --panel-2: #161618; --line: #2c2c31; --text: #ececf0; --muted: #9b9ba3;
    --hover: #232327; --selected: #2b2b31; --danger: #f87171; --ok: #4ade80; --warn: #fbbf24; --chip: #26262b; --rail: #0b0b0e; --shadow: 0 8px 30px rgb(0 0 0 / .5);
  }
}
:root[data-theme="dark"] {
  --bg: #111113; --panel: #1a1a1d; --panel-2: #161618; --line: #2c2c31; --text: #ececf0; --muted: #9b9ba3;
  --hover: #232327; --selected: #2b2b31; --danger: #f87171; --ok: #4ade80; --warn: #fbbf24; --chip: #26262b; --rail: #0b0b0e; --shadow: 0 8px 30px rgb(0 0 0 / .5);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: var(--fs)/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: var(--text); background: var(--panel); }
a { color: var(--accent); }
.i { width: 16px; height: 16px; flex: none; vertical-align: -3px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; gap: 8px; align-items: center; }
.wrap { flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- buttons + fields ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 6px 12px; text-decoration: none; color: var(--text); white-space: nowrap; }
.btn:hover { background: var(--hover); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.sm { padding: 3px 9px; font-size: 12px; }
.btn.ghost { border-color: transparent; background: none; }
.btn.ghost:hover { background: var(--hover); }
.icon-btn { border: 0; background: none; border-radius: 8px; width: 32px; height: 32px; display: inline-grid; place-items: center; color: var(--muted); flex: none; }
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.on { color: var(--star); }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-size: 12px; color: var(--muted); font-weight: 500; }
.input, .field input:not([type=checkbox]):not([type=radio]):not([type=color]):not([type=range]), .field select, .field textarea { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; outline: none; }
.field input[type=color] { width: 100%; height: 36px; border: 1px solid var(--line); border-radius: 8px; padding: 2px; background: var(--panel); }
.field input[type=range] { width: 100%; accent-color: var(--accent); }
.check { white-space: nowrap; }
.check.grow { white-space: normal; min-width: 0; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; flex: none; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field textarea { resize: vertical; min-height: 80px; }
.check { display: flex; gap: 8px; align-items: center; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--chip); border-radius: 999px; padding: 2px 9px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.chip.accent { background: var(--accent-soft); color: var(--accent); }
.chip.ok { color: var(--ok); } .chip.warn { color: var(--warn); } .chip.bad { color: var(--danger); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--panel); padding: 5px 12px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--selected); font-weight: 600; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center; font-weight: 600; font-size: 12px; color: #fff; flex: none; }
.avatar.sm { width: 24px; height: 24px; font-size: 10px; }
.avatar.lg { width: 56px; height: 56px; font-size: 20px; }
.empty { color: var(--muted); padding: 48px 20px; text-align: center; }
.empty .i { width: 36px; height: 36px; display: block; margin: 0 auto 10px; opacity: .5; }
.err { color: var(--danger); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.card.pad { padding: 18px; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 500; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr.click:hover td { background: var(--hover); cursor: pointer; }

/* ---------- auth screens ---------- */
.auth-wrap { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.auth-card { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px; box-shadow: var(--shadow); }
.auth-card h1 { margin: 6px 0 4px; font-size: 22px; }
.logo { width: 40px; height: 40px; border-radius: 10px; background: var(--accent); color: var(--accent-text); display: grid; place-items: center; }
.logo .i { width: 22px; height: 22px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 72px 1fr; grid-template-rows: 48px 1fr; height: 100vh; }
.topbar { grid-column: 1 / -1; background: var(--rail); color: #fff; display: flex; align-items: center; gap: 12px; padding: 0 12px 0 16px; }
.topbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 650; min-width: 0; }
.topbar .brand .logo { width: 28px; height: 28px; border-radius: 7px; }
.topbar .brand .logo .i { width: 16px; height: 16px; }
.topbar .search { flex: 1; max-width: 560px; margin: 0 auto; position: relative; }
.topbar .search input { width: 100%; border: 0; border-radius: 8px; padding: 7px 12px 7px 34px; background: rgb(255 255 255 / .12); color: #fff; outline: none; }
.topbar .search input::placeholder { color: rgb(255 255 255 / .6); }
.topbar .search .i { position: absolute; left: 10px; top: 8px; color: rgb(255 255 255 / .6); }
.topbar .me { border: 0; background: none; padding: 2px; border-radius: 50%; margin-left: auto; }
.rail { background: var(--rail); display: flex; flex-direction: column; align-items: center; padding: 6px 0; gap: 2px; overflow-y: auto; }
.rail button { position: relative; width: 64px; border: 0; background: none; color: var(--rail-text); border-radius: 10px; padding: 8px 0 6px; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10.5px; }
.rail button .i { width: 20px; height: 20px; }
.rail button:hover { background: rgb(255 255 255 / .08); color: #fff; }
.rail button.active { color: #fff; background: rgb(255 255 255 / .12); }
.rail button.active::before { content: ""; position: absolute; left: -4px; top: 10px; bottom: 10px; width: 3px; border-radius: 3px; background: var(--accent); }
.rail .badge { position: absolute; top: 3px; right: 12px; min-width: 17px; height: 17px; border-radius: 9px; background: #e11d48; color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; padding: 0 4px; }
.rail .spacer { flex: 1; }
.view { min-width: 0; min-height: 0; overflow: hidden; display: flex; }
.app-side { width: 250px; flex: none; border-right: 1px solid var(--line); background: var(--panel-2); display: flex; flex-direction: column; overflow-y: auto; padding: 12px 8px; gap: 1px; }
.app-side .head { display: flex; align-items: center; justify-content: space-between; padding: 2px 6px 10px; font-weight: 650; font-size: 16px; }
.side-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 14px 8px 4px; display: flex; justify-content: space-between; align-items: center; }
.nav { display: flex; align-items: center; gap: 9px; width: 100%; border: 0; background: none; text-align: left; padding: 7px 9px; border-radius: 7px; color: var(--text); }
.nav:hover { background: var(--hover); }
.nav.active { background: var(--selected); font-weight: 600; }
.nav .lbl { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav .i { color: var(--muted); }
.nav .count { font-size: 12px; color: var(--muted); }
.nav.unread .lbl { font-weight: 650; }
.nav .count.strong { color: var(--accent); font-weight: 700; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; background: var(--panel); }
.main-head { display: flex; align-items: center; gap: 10px; padding: 12px 18px; border-bottom: 1px solid var(--line); min-height: 56px; flex-wrap: wrap; }
.main-head h2 { margin: 0; font-size: 17px; font-weight: 650; }
.main-body { flex: 1; overflow: auto; }
.main-body.pad { padding: 18px; }
.mobile-only { display: none; }
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: 48px 1fr 60px; }
  .rail { grid-row: 3; flex-direction: row; justify-content: space-around; padding: 0; overflow-x: auto; }
  .rail button { width: auto; min-width: 54px; padding: 6px 4px; }
  .rail .spacer, .rail .rail-extra { display: none; }
  .rail button.active::before { left: 12px; right: 12px; top: -1px; bottom: auto; width: auto; height: 3px; }
  .topbar .search { display: none; }
  .app-side { position: fixed; inset: 48px 0 60px 0; width: auto; z-index: 20; display: none; }
  .view.side-open .app-side { display: flex; }
  .mobile-only { display: inline-grid; }
}

/* ---------- popovers, dialogs, toasts ---------- */
dialog { border: 1px solid var(--line); border-radius: 14px; padding: 0; background: var(--panel); color: var(--text); box-shadow: var(--shadow); max-width: 94vw; max-height: 92vh; }
dialog::backdrop { background: rgb(0 0 0 / .4); }
dialog .dlg-head { padding: 14px 18px; border-bottom: 1px solid var(--line); font-weight: 650; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
dialog .dlg-body { padding: 18px; overflow: auto; max-height: calc(92vh - 130px); }
dialog .dlg-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; align-items: center; }
.menu { position: fixed; z-index: 100; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 5px; min-width: 190px; }
.menu button { display: flex; width: 100%; align-items: center; gap: 9px; border: 0; background: none; padding: 7px 10px; border-radius: 6px; text-align: left; }
.menu button:hover { background: var(--hover); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.menu .menu-head { padding: 8px 10px; }
.toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 200; align-items: center; }
.toast { background: #1f1f2b; color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); font-size: 13px; display: flex; gap: 12px; align-items: center; max-width: 90vw; }
.toast.error { background: #9f1d24; }
.toast button { background: none; border: 0; color: #a5b4fc; font-weight: 600; padding: 0; }

/* ---------- people picker / address input ---------- */
.tokens { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 4px 6px; background: var(--panel); position: relative; min-height: 38px; }
.tokens.bare { border: 0; padding: 4px 0; }
.tokens input { border: 0; outline: none; flex: 1; min-width: 120px; padding: 4px; background: none; }
.token { display: inline-flex; align-items: center; gap: 4px; background: var(--chip); border-radius: 999px; padding: 2px 4px 2px 9px; font-size: 13px; max-width: 100%; }
.token.bad { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }
.token button { border: 0; background: none; padding: 0 3px; color: var(--muted); line-height: 1; }
.suggest { position: absolute; left: 0; right: 0; top: 100%; margin-top: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); z-index: 50; max-height: 260px; overflow: auto; padding: 4px; }
.suggest button { display: flex; width: 100%; gap: 10px; align-items: center; border: 0; background: none; padding: 6px 8px; border-radius: 6px; text-align: left; }
.suggest button.on, .suggest button:hover { background: var(--hover); }

/* ---------- mail ---------- */
.mail-list { width: 380px; flex: none; border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; background: var(--panel); }
.mail-list .items { flex: 1; overflow-y: auto; }
.mitem { display: flex; gap: 10px; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line); background: none; padding: 10px 12px 10px 20px; position: relative; }
.mitem:hover { background: var(--hover); }
.mitem.active { background: var(--selected); box-shadow: inset 3px 0 var(--accent); }
.mitem.unread::before { content: ""; position: absolute; left: 8px; top: 17px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.mitem .who { font-weight: 500; }
.mitem.unread .who, .mitem.unread .subj { font-weight: 650; }
.mitem .date { color: var(--muted); font-size: 12px; white-space: nowrap; }
.mitem .snip { color: var(--muted); font-size: 12.5px; }
.mitem .mbx { font-size: 11px; color: var(--muted); }
.reader { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.reader-head { padding: 18px 24px 12px; border-bottom: 1px solid var(--line); }
.reader-head > .row:first-child { flex-wrap: wrap; }
.reader-head h1 { font-size: 20px; margin: 0 0 12px; font-weight: 650; word-break: break-word; }
.reader-body { flex: 1; overflow: auto; padding: 16px 24px; }
.body-frame { width: 100%; border: 0; background: #fff; border-radius: 8px; min-height: 200px; display: block; }
.body-text { white-space: pre-wrap; margin: 0; font: inherit; word-break: break-word; }
.banner { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; background: var(--chip); border-radius: 8px; padding: 8px 12px; margin-bottom: 12px; color: var(--muted); }
.atts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.att { display: inline-flex; gap: 6px; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; text-decoration: none; color: var(--text); font-size: 13px; background: var(--panel); }
.att:hover { background: var(--hover); }
.att button { border: 0; background: none; color: var(--muted); padding: 0 0 0 4px; }
@media (max-width: 1100px) {
  .mail-list { width: 320px; }
}
@media (max-width: 900px) {
  .mail-wrap .mail-list { width: 100%; border-right: 0; }
  .mail-wrap.reading .mail-list, .mail-wrap:not(.reading) .reader { display: none; }
}
#composer { width: min(760px, 96vw); }
.cfield { display: grid; grid-template-columns: 64px 1fr auto; align-items: center; border-bottom: 1px solid var(--line); padding: 0 18px; gap: 6px; }
.cfield > span { color: var(--muted); font-size: 13px; }
.cfield > input, .cfield > select { border: 0; padding: 10px 0; outline: none; min-width: 0; background: none; }
.editor-tools { display: flex; gap: 2px; padding: 6px 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; align-items: center; }
.editor-tools .icon-btn { width: 30px; height: 30px; }
.editor { min-height: 280px; max-height: 52vh; overflow: auto; padding: 14px 18px; outline: none; }
.editor:empty::before { content: attr(data-placeholder); color: var(--muted); }
.editor blockquote { border-left: 3px solid var(--line); margin: 8px 0; padding-left: 12px; color: var(--muted); }

/* ---------- chat ---------- */
.chat-msgs { flex: 1; overflow-y: auto; padding: 12px 0; }
.msg { display: flex; gap: 10px; padding: 4px 20px; position: relative; }
.msg:hover { background: var(--hover); }
.msg .body { min-width: 0; flex: 1; }
.msg .meta { display: flex; gap: 8px; align-items: baseline; }
.msg .meta b { font-weight: 650; }
.msg .text { white-space: pre-wrap; word-break: break-word; }
.msg.cont { padding-top: 0; }
.msg.cont .avatar { visibility: hidden; height: 0; }
.msg .tools { position: absolute; right: 16px; top: -10px; display: none; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.msg:hover .tools { display: flex; }
.msg .deleted { color: var(--muted); font-style: italic; }
.day-sep { text-align: center; font-size: 12px; color: var(--muted); margin: 12px 0 6px; display: flex; align-items: center; gap: 10px; padding: 0 20px; }
.day-sep::before, .day-sep::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.chat-input { border-top: 1px solid var(--line); padding: 12px 20px 16px; }
.chat-input .box { border: 1px solid var(--line); border-radius: 12px; display: flex; align-items: flex-end; gap: 6px; padding: 6px; background: var(--panel); }
.chat-input textarea { flex: 1; border: 0; outline: none; resize: none; padding: 6px; max-height: 200px; background: none; }
.file-chip { display: inline-flex; gap: 6px; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; margin-top: 4px; text-decoration: none; color: var(--text); background: var(--panel-2); }

/* ---------- calendar ---------- */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); grid-auto-rows: minmax(110px, 1fr); border-left: 1px solid var(--line); border-top: 1px solid var(--line); }
.cal-dow { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-dow div { padding: 6px 8px; font-size: 12px; color: var(--muted); }
.cal-cell { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 4px; min-width: 0; overflow: hidden; cursor: pointer; }
.cal-cell:hover { background: var(--panel-2); }
.cal-cell.other { background: var(--panel-2); color: var(--muted); }
.cal-cell .d { font-size: 12px; padding: 2px 6px; display: inline-block; border-radius: 999px; }
.cal-cell.today .d { background: var(--accent); color: var(--accent-text); font-weight: 700; }
.ev { display: block; width: 100%; text-align: left; border: 0; border-radius: 5px; padding: 1px 6px; margin-top: 2px; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: var(--accent-soft); color: var(--text); border-left: 3px solid var(--accent); }
.ev.pending { opacity: .75; border-left-style: dashed; }
.ev.busy { background: var(--chip); border-left-color: var(--muted); }
.week { display: grid; grid-template-columns: 56px repeat(7, 1fr); position: relative; }
.week .hour { height: 48px; border-bottom: 1px solid var(--line); font-size: 11px; color: var(--muted); text-align: right; padding-right: 6px; }
.week .col { position: relative; border-left: 1px solid var(--line); }
.week .col .slot { height: 48px; border-bottom: 1px solid var(--line); }
.week .col .slot:hover { background: var(--panel-2); }
.week .wev { position: absolute; left: 3px; right: 3px; border-radius: 6px; padding: 3px 6px; font-size: 12px; overflow: hidden; background: var(--accent-soft); border-left: 3px solid var(--accent); cursor: pointer; text-align: left; border-top: 0; border-right: 0; border-bottom: 0; color: var(--text); }
.week-head { display: grid; grid-template-columns: 56px repeat(7, 1fr); border-bottom: 1px solid var(--line); }
.week-head div { padding: 6px; text-align: center; font-size: 12px; color: var(--muted); }
.week-head div.today b { color: var(--accent); }
.week-head b { display: block; font-size: 18px; color: var(--text); }
.allday { display: grid; grid-template-columns: 56px repeat(7, 1fr); border-bottom: 1px solid var(--line); min-height: 26px; }
.allday > div { border-left: 1px solid var(--line); padding: 2px; }

/* ---------- files ---------- */
.files-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; padding: 18px; }
.fitem { border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: var(--panel); text-align: left; display: flex; flex-direction: column; gap: 8px; position: relative; min-width: 0; }
.fitem:hover { background: var(--hover); }
.fitem .ficon { width: 100%; height: 86px; display: grid; place-items: center; border-radius: 8px; background: var(--panel-2); overflow: hidden; color: var(--muted); }
.fitem .ficon .i { width: 34px; height: 34px; }
.fitem .ficon img { width: 100%; height: 100%; object-fit: cover; }
.fitem .fname { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropzone { outline: 2px dashed var(--accent); outline-offset: -8px; background: var(--accent-soft); }
.crumbs { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.crumbs button { border: 0; background: none; padding: 2px 4px; border-radius: 4px; font-size: 16px; font-weight: 650; }
.crumbs button:hover { background: var(--hover); }

@media (max-width: 640px) { .hide-sm { display: none; } }
/* ---------- contacts ---------- */
.contact-card { display: flex; gap: 14px; align-items: center; }

/* ---------- marketing builder ---------- */
.builder { display: grid; grid-template-columns: 200px 1fr 320px; flex: 1; min-height: 0; }
.builder .palette, .builder .props { overflow-y: auto; padding: 14px; background: var(--panel-2); }
.builder .palette { border-right: 1px solid var(--line); }
.builder .props { border-left: 1px solid var(--line); }
.builder .canvas { overflow-y: auto; background: var(--bg); padding: 24px 16px 80px; }
.palette button { display: flex; width: 100%; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 8px 10px; margin-bottom: 6px; text-align: left; cursor: grab; }
.palette button:hover { border-color: var(--accent); }
.canvas-inner { margin: 0 auto; transition: max-width .2s; }
.bblock { position: relative; outline: 1px solid transparent; cursor: pointer; }
.bblock:hover { outline: 1px dashed var(--accent); }
.bblock.sel { outline: 2px solid var(--accent); z-index: 1; }
.bblock .btools { position: absolute; right: 4px; top: 4px; display: none; gap: 2px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 2px; box-shadow: var(--shadow); z-index: 2; }
.bblock.sel .btools, .bblock:hover .btools { display: flex; }
.bblock .btools .icon-btn { width: 26px; height: 26px; }
.drop-line { height: 4px; background: var(--accent); border-radius: 2px; margin: -2px 0; position: relative; z-index: 3; }
.bframe { width: 100%; border: 0; display: block; pointer-events: none; background: transparent; }
.props h4 { margin: 4px 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.props .field { margin-bottom: 12px; }
.rte { border: 1px solid var(--line); border-radius: 8px; min-height: 120px; padding: 8px 10px; outline: none; background: var(--panel); max-height: 300px; overflow: auto; }
.rte:focus { border-color: var(--accent); }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.tpl { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--panel); text-align: left; padding: 0; display: flex; flex-direction: column; }
.tpl:hover { border-color: var(--accent); }
.tpl .thumb { height: 220px; overflow: hidden; background: #f3f4f6; position: relative; }
.tpl .thumb iframe { width: 640px; height: 900px; border: 0; transform: scale(.36); transform-origin: 0 0; pointer-events: none; position: absolute; left: 0; top: 0; }
.tpl .meta { padding: 10px 12px; border-top: 1px solid var(--line); }
.progress { height: 8px; border-radius: 4px; background: var(--chip); overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); transition: width .3s; }
@media (max-width: 1000px) { .builder { grid-template-columns: 1fr; } .builder .palette, .builder .props { max-height: 260px; border: 0; border-bottom: 1px solid var(--line); } }
.stat { padding: 14px; }
.stat b { display: block; font-size: 22px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
