:root {
  --bg: #f6f6f8;
  --surface: #ffffff;
  --text: #161d3a;
  --muted: #6b6b7b;
  --border: #e6e6ee;
  --accent: #6039fe;
  --accent-2: #4b25e6;
  --accent-soft: #efebff;
  --coral: #fd776b;
  --ok: #128a4c;
  --ok-soft: #e6f6ed;
  --warn: #a86400;
  --warn-soft: #fff4e0;
  --err: #c52a2a;
  --err-soft: #fdecec;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(20, 20, 40, .05), 0 4px 16px rgba(20, 20, 40, .04);
  --grad: linear-gradient(135deg, #6039fe 0%, #7a55ff 55%, #fd776b 100%);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f0f14;
    --surface: #18181f;
    --text: #ececf2;
    --muted: #9a9aab;
    --border: #2a2a35;
    --accent: #8f74ff;
    --accent-2: #a690ff;
    --accent-soft: #2a2350;
    --ok-soft: #11301f;
    --warn-soft: #33260c;
    --err-soft: #3a1515;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 26px; margin: 0 0 4px; letter-spacing: -.02em; }
h2 { font-size: 18px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 0 0 8px; }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* App shell */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side {
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 20px 14px; display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; padding: 4px 10px 18px; color: var(--text); }
.logo-img { display: block; line-height: 0; }
.logo-img img { display: block; max-width: 100%; }
.mobile-top .brand { padding: 0; }
.brand:hover { text-decoration: none; }
.logo { width: 30px; height: 30px; border-radius: 9px; background: var(--grad); display: grid; place-items: center; color: #fff; font-size: 16px; }
.nav a { display: block; padding: 9px 12px; border-radius: 9px; color: var(--text); font-weight: 500; }
.nav a:hover { background: var(--bg); text-decoration: none; }
.nav a.on { background: var(--accent-soft); color: var(--accent); }
.side .foot { margin-top: auto; font-size: 13px; color: var(--muted); padding: 10px 12px; }
.main { padding: 28px 32px 60px; max-width: 1080px; width: 100%; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.mobile-top { display: none; }

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; position: fixed; inset: 0; z-index: 20; height: auto; }
  .side.open { display: flex; }
  .mobile-top { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--border); }
  .main { padding: 20px 16px 60px; }
}

/* Components */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 18px; }
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 820px) { .grid-4, .grid-3 { grid-template-columns: repeat(2, 1fr); } .grid-2 { grid-template-columns: 1fr; } }
.stat .n { font-size: 28px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .l { color: var(--muted); font-size: 13px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { text-decoration: none; border-color: var(--muted); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn-grad { background: var(--grad); border: 0; color: #fff; }
.btn-danger { color: var(--err); }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; }
form.inline { display: inline; }

label { display: block; font-weight: 600; margin: 14px 0 6px; font-size: 14px; }
.hint { font-weight: 400; color: var(--muted); font-size: 13px; }
input[type=text], input[type=email], input[type=password], input[type=url], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface); color: var(--text); font: inherit;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; margin: 12px 0; }
.check input { margin-top: 4px; accent-color: var(--accent); width: 16px; height: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; }

.flash { padding: 11px 14px; border-radius: 9px; margin-bottom: 14px; font-weight: 500; }
.flash-success { background: var(--ok-soft); color: var(--ok); }
.flash-error { background: var(--err-soft); color: var(--err); }

.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--bg); color: var(--muted); border: 1px solid var(--border); }
.badge-ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge-err { background: var(--err-soft); color: var(--err); border-color: transparent; }
.badge-accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }

.avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: var(--grad); }
.thumb { width: 48px; height: 48px; border-radius: 8px; object-fit: cover; background: var(--bg); }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .big { font-size: 40px; margin-bottom: 8px; }

.meter { height: 8px; background: var(--bg); border-radius: 99px; overflow: hidden; border: 1px solid var(--border); }
.meter > span { display: block; height: 100%; background: var(--grad); }

/* Automation builder */
.steps { counter-reset: step; }
.step { position: relative; padding-left: 44px; }
.step::before {
  counter-increment: step; content: counter(step);
  position: absolute; left: 0; top: 18px; width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; display: grid; place-items: center; font-size: 14px;
}
.step .card { margin-left: 0; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg label { margin: 0; padding: 8px 14px; cursor: pointer; font-weight: 500; border-right: 1px solid var(--border); }
.seg label:last-child { border-right: 0; }
.seg input { display: none; }
.seg input:checked + span { color: var(--accent); font-weight: 700; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; margin-top: 10px; max-height: 340px; overflow-y: auto; }
.media-grid button { padding: 0; border: 2px solid transparent; border-radius: 10px; overflow: hidden; cursor: pointer; background: var(--bg); aspect-ratio: 1; }
.media-grid button img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-grid button.on { border-color: var(--accent); }

.phone { background: var(--bg); border: 1px solid var(--border); border-radius: 22px; padding: 16px; position: sticky; top: 20px; }
.bubble { background: var(--surface); border: 1px solid var(--border); border-radius: 16px 16px 16px 4px; padding: 10px 12px; margin-bottom: 8px; font-size: 14px; white-space: pre-wrap; }
.bubble.me { background: var(--accent); color: #fff; border: 0; border-radius: 16px 16px 4px 16px; margin-left: 30%; }
.bubble .bbtn { display: block; text-align: center; border-top: 1px solid var(--border); margin: 8px -12px -10px; padding: 8px; color: var(--accent); font-weight: 600; }
.builder { display: grid; grid-template-columns: 1fr 300px; gap: 20px; align-items: start; }
@media (max-width: 980px) { .builder { grid-template-columns: 1fr; } .phone { position: static; } }

/* Public pages */
.public-nav { display: flex; justify-content: space-between; align-items: center; max-width: 1080px; margin: 0 auto; padding: 18px 20px; }
.hero { max-width: 820px; margin: 40px auto 30px; padding: 0 20px; text-align: center; }
.hero h1 { font-size: clamp(32px, 6vw, 52px); line-height: 1.08; margin-bottom: 16px; }
.grad-text { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { font-size: 18px; color: var(--muted); max-width: 620px; margin: 0 auto 26px; }
.section { max-width: 1080px; margin: 0 auto; padding: 30px 20px; }
.auth-box { max-width: 400px; margin: 40px auto; padding: 0 16px; }
.price { font-size: 30px; font-weight: 800; letter-spacing: -.02em; }
.plan-card.current { border-color: var(--accent); }
ul.ticks { list-style: none; padding: 0; margin: 12px 0 18px; }
ul.ticks li { padding: 4px 0 4px 24px; position: relative; }
ul.ticks li::before { content: "✓"; position: absolute; left: 0; color: var(--ok); font-weight: 700; }
.legal { max-width: 760px; margin: 0 auto; padding: 20px; }
footer.site { text-align: center; color: var(--muted); font-size: 13px; padding: 30px 20px; }

/* App updates */
.flash-warn { background: var(--warn-soft); color: var(--warn); }
[hidden] { display: none !important; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92em; background: var(--bg); padding: 1px 5px; border-radius: 5px; }
.progress { height: 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 99px; overflow: hidden; }
.progress > i { display: block; height: 100%; width: 0; background: var(--grad); transition: width .3s; }
.progress.anim > i { background-size: 200% 100%; animation: slide 1.4s linear infinite; }
.progress.done > i { background: var(--ok); }
.progress.err > i { background: var(--err); }
@keyframes slide { from { background-position: 0 0; } to { background-position: -200% 0; } }
ul.checks, ul.steps-list { list-style: none; padding: 0; margin: 14px 0; }
ul.checks li, ul.steps-list li { display: flex; gap: 12px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--border); }
ul.steps-list li { align-items: center; }
ul.checks li:last-child, ul.steps-list li:last-child { border-bottom: 0; }
.mk { flex: none; width: 22px; height: 22px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 12px; font-weight: 800; }
.mk-ok { background: var(--ok-soft); color: var(--ok); }
.mk-warn { background: var(--warn-soft); color: var(--warn); }
.mk-fail { background: var(--err-soft); color: var(--err); }
.mk-info { background: var(--bg); color: var(--muted); border: 1px solid var(--border); }
.mk-wait { border: 2px solid var(--border); }
.mk-spin { border: 2px solid var(--accent-soft); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.backup-row { display: flex; gap: 8px; align-items: center; padding: 10px 0; border-top: 1px solid var(--border); }
.restore-box { background: var(--bg); border-radius: 10px; padding: 12px; margin-bottom: 8px; }
input[type=file] { width: 100%; padding: 10px; border: 1px dashed var(--border); border-radius: 9px; background: var(--surface); color: var(--text); }

/* Install wizard */
.install-box { max-width: 640px; margin: 32px auto 40px; padding: 0 16px; }
.install-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.inst-steps { list-style: none; display: flex; gap: 6px; padding: 0; margin: 0 0 16px; flex-wrap: wrap; }
.inst-steps li { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; color: var(--muted); padding: 6px 10px 6px 6px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); }
.inst-steps li span { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--bg); font-size: 11px; }
.inst-steps li.on { color: var(--accent); border-color: var(--accent); }
.inst-steps li.on span { background: var(--accent); color: #fff; }
.inst-steps li.done span { background: var(--ok-soft); color: var(--ok); }
.inst-more { margin-top: 20px; border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; }
.inst-more summary { cursor: pointer; font-weight: 600; font-size: 14px; }
code.inst-copy { display: inline-block; word-break: break-all; user-select: all; }
