:root {
    color-scheme: dark;
    --bg: #111c2b;
    --panel: #1b293b;
    --panel-2: #223247;
    --input: #26364a;
    --text: #f3f6fa;
    --muted: #91a2b6;
    --blue: #2aabee;
    --outgoing: #2f80ed;
    --incoming: #253448;
    --green: #62c554;
    --danger: #ed6b78;
    --border: rgba(157, 183, 209, .14);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: radial-gradient(circle at 10% 0%, #1d3044 0, transparent 36%), var(--bg); color: var(--text); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
.editor-shell { width: min(1500px, calc(100% - 32px)); margin: 0 auto; padding: 28px 0 48px; }
.topbar, .section-heading, .preview-heading, .message-editor-head, .message-actions, .current-avatar { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.topbar { margin-bottom: 22px; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(24px, 4vw, 38px); letter-spacing: -.03em; }
h2 { font-size: 18px; }
.muted { color: var(--muted); }
.eyebrow { color: #6dc7f5; font-size: 11px; font-weight: 800; letter-spacing: .12em; }
.workspace { display: grid; grid-template-columns: minmax(0, 1.18fr) minmax(340px, .82fr); gap: 20px; align-items: start; }
.editor-panel { display: grid; gap: 16px; }
.card { background: rgba(27, 41, 59, .94); border: 1px solid var(--border); border-radius: 18px; padding: 18px; box-shadow: 0 18px 60px rgba(0, 0, 0, .18); }
.stack { display: grid; gap: 13px; margin-top: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
label { display: grid; gap: 7px; color: #c8d4e1; font-size: 12px; font-weight: 700; }
input, textarea, select { width: 100%; border: 1px solid var(--border); border-radius: 11px; background: var(--input); color: var(--text); padding: 11px 12px; outline: none; }
input:focus, textarea:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(42, 171, 238, .16); }
textarea { min-height: 86px; resize: vertical; line-height: 1.45; }
.button { border: 0; border-radius: 11px; padding: 10px 14px; color: var(--text); font-weight: 800; }
.button.primary { background: var(--blue); color: #071827; }
.button.ghost { background: var(--input); }
.button.danger { background: rgba(237, 107, 120, .16); color: #ffadb7; }
.button.tiny { padding: 7px 10px; background: var(--input); }
.flash { margin: 0 0 16px; padding: 12px 14px; border-radius: 12px; background: rgba(98, 197, 84, .16); color: #a5ef9d; border: 1px solid rgba(98, 197, 84, .35); }
.flash.error { background: rgba(237, 107, 120, .14); color: #ffadb7; border-color: rgba(237, 107, 120, .34); }
.message-editor-list { display: grid; gap: 10px; margin-top: 16px; }
.message-editor { background: rgba(15, 27, 42, .56); border: 1px solid var(--border); border-radius: 14px; padding: 13px; }
.message-editor.is-outgoing { border-color: rgba(47, 128, 237, .38); }
.message-editor-head { margin-bottom: 11px; }
.reorder-actions { display: flex; gap: 6px; justify-content: flex-end; }
.reorder-actions form { margin: 0; }
.current-avatar { justify-content: flex-start; flex-wrap: wrap; color: var(--muted); font-size: 12px; }
.current-avatar img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; border: 2px solid rgba(255,255,255,.2); }
.preview-panel { position: sticky; top: 16px; }
.preview-heading { margin: 0 4px 10px; }
.sync-dot { color: #9be78e; font-size: 10px; font-weight: 800; letter-spacing: .08em; }
.chat-preview, .phone-preview { width: min(100%, 420px); min-height: 720px; margin: 0 auto; overflow: hidden; border: 8px solid #0a1421; border-radius: 31px; background: var(--bg); box-shadow: 0 25px 70px rgba(0,0,0,.42); }
.phone-status { padding: 12px 18px 4px; color: #eef5fb; font-weight: 800; font-size: 12px; display: flex; justify-content: space-between; }
.phone-header { display: grid; grid-template-columns: 48px 1fr 48px; gap: 6px; align-items: center; padding: 7px 8px 12px; }
.phone-header button { width: 44px; height: 44px; border: 0; border-radius: 50%; background: #243449; color: white; font-size: 28px; }
.phone-profile { min-width: 0; display: flex; align-items: center; gap: 9px; padding: 7px 10px; border-radius: 26px; background: #1d293a; }
.phone-profile img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: white; }
.phone-profile strong, .phone-profile small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.phone-profile strong { font-size: 15px; }
.phone-profile small { color: var(--muted); font-size: 11px; margin-top: 2px; }
.phone-messages { min-height: 590px; padding: 4px 8px 12px; background-image: radial-gradient(circle at 20% 20%, rgba(115,143,169,.1) 0 2px, transparent 3px), radial-gradient(circle at 70% 70%, rgba(115,143,169,.08) 0 2px, transparent 3px); background-size: 54px 54px, 72px 72px; }
.date-pill { width: max-content; margin: 10px auto 11px; padding: 6px 13px; border-radius: 18px; background: var(--incoming); color: var(--text); font-size: 14px; font-weight: 800; }
.preview-row { display: flex; align-items: flex-end; gap: 6px; margin: 7px 0; }
.preview-row.outgoing { justify-content: flex-end; }
.preview-row.outgoing .preview-avatar { display: none; }
.preview-avatar { flex: 0 0 42px; width: 42px; height: 42px; border-radius: 50%; overflow: hidden; background: white; }
.preview-avatar img { width: 100%; height: 100%; object-fit: cover; }
.preview-bubble { position: relative; max-width: 78%; padding: 9px 11px 19px; border-radius: 14px 14px 14px 4px; background: var(--incoming); font-size: 14px; line-height: 1.25; }
.outgoing .preview-bubble { max-width: 80%; border-radius: 14px 14px 4px 14px; background: var(--outgoing); }
.preview-bubble .sender { color: #6dc7f5; font-size: 11px; font-weight: 800; margin-bottom: 3px; }
.preview-bubble .time { position: absolute; right: 9px; bottom: 4px; color: rgba(255,255,255,.65); font-size: 10px; }
.phone-composer { display: flex; align-items: center; gap: 13px; padding: 10px 12px; background: #1e3042; color: var(--muted); }
.phone-composer .placeholder { flex: 1; font-size: 14px; }
.phone-composer b { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--blue); color: white; }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(100%, 420px); padding: 26px; background: var(--panel); border: 1px solid var(--border); border-radius: 20px; box-shadow: 0 20px 70px rgba(0,0,0,.3); }
.login-card h1 { margin-top: 7px; font-size: 28px; }
.login-card > .muted { margin-top: 8px; }

@media (max-width: 900px) {
    .workspace { grid-template-columns: 1fr; }
    .preview-panel { position: static; }
    .phone-preview { width: min(100%, 460px); }
}
@media (max-width: 560px) {
    .editor-shell { width: min(100% - 20px, 520px); padding-top: 16px; }
    .topbar { align-items: flex-start; }
    .form-grid, .form-grid.three { grid-template-columns: 1fr; }
    .card { padding: 14px; border-radius: 15px; }
}
