/* Keyword DM: a quiet, Linear-like frame around an Instagram-style conversation editor. */
:root {
  --paper: #f6f7f9;
  --surface: #ffffff;
  --ink: #16171d;
  --mute: #5f6571;
  --faint: #6f7583;
  --line: #e4e6eb;
  --line-strong: #d2d5dc;
  --track-off: #8e94a1;
  --them: #eceef2;
  --you-a: #7a3fe4;
  --you-b: #3b6cf0;
  --link: #2f5bd8;
  --live: #0f7a4a;
  --warn: #9a5b00;
  --danger: #c93030;
  --danger-solid: #c93030;
  --focus: #3b6cf0;
  --shadow-pop: 0 1px 2px rgb(22 23 29 / 0.06), 0 8px 24px rgb(22 23 29 / 0.10);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  --font-kw: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
  --top: 56px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #12141b;
    --surface: #191c25;
    --ink: #eceef3;
    --mute: #a3a8b5;
    --faint: #8b91a1;
    --line: #262a35;
    --line-strong: #343947;
    --track-off: #6b7182;
    --them: #262a35;
    --link: #8aa8ff;
    --live: #3ccf8a;
    --warn: #f0b45a;
    --danger: #ff7a7a;
    --danger-solid: #d93636;
    --focus: #7d9cff;
    --shadow-pop: 0 1px 2px rgb(0 0 0 / 0.3), 0 10px 30px rgb(0 0 0 / 0.45);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scrollbar-color: var(--line-strong) transparent; }
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
::selection { background: color-mix(in srgb, var(--you-b) 30%, transparent); }
button, input, textarea { font: inherit; color: inherit; }
input, textarea { caret-color: var(--you-b); }
button { cursor: pointer; touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px;
  border: 1px solid var(--line-strong); border-radius: 9px;
  background: var(--surface); font-weight: 550; font-size: 14px; text-decoration: none; white-space: nowrap;
  transition: background-color 150ms var(--ease-out), transform 120ms var(--ease-out), border-color 150ms, color 150ms;
}
.btn:active { transform: scale(0.96); }
.btn-primary { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn-quiet { border-color: transparent; background: transparent; color: var(--mute); }
.btn-danger { color: var(--danger); }
.btn-danger-solid { background: var(--danger-solid); border-color: var(--danger-solid); color: #fff; }
.btn[disabled] { opacity: 0.55; cursor: default; }
@media (hover: hover) {
  .btn:hover { border-color: var(--faint); }
  .btn-primary:hover { opacity: 0.9; border-color: var(--ink); }
  .btn-quiet:hover { color: var(--ink); background: var(--them); border-color: transparent; }
  .btn-quiet.btn-danger:hover { color: var(--danger); }
}

/* ---------- login ---------- */
.auth {
  min-height: 100dvh; display: grid; place-items: center;
  padding: 24px max(16px, env(safe-area-inset-left));
}
.auth-card {
  width: min(380px, 100%);
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 28px 24px 24px; box-shadow: var(--shadow-pop);
}
.auth-card h1 { margin: 14px 0 4px; font-size: 22px; letter-spacing: -0.01em; text-wrap: balance; }
.auth-card p, .ed-sub, .note, .gate small, .act-tip, .backup p, dialog p, .empty-state p, .list-empty p { text-wrap: pretty; }
.auth-card p { margin: 0 0 20px; color: var(--mute); }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 550; color: var(--mute); }
.text-input {
  height: 44px; padding: 0 12px; font-size: 16px;
  border: 1px solid var(--line-strong); border-radius: 10px; background: var(--paper);
  transition: border-color 150ms, box-shadow 150ms;
}
.text-input::placeholder { color: var(--faint); }
.text-input:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent); }
.auth-card .btn-primary { width: 100%; height: 44px; font-size: 15px; }
.form-error { color: var(--danger); font-size: 14px; margin: -4px 0 12px; }

.logo { width: 32px; height: 32px; display: block; }

/* ---------- frame ---------- */
.top {
  position: sticky; top: 0; z-index: 6;
  height: calc(var(--top) + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 16px 0;
  display: flex; align-items: center; gap: 12px;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 650; letter-spacing: -0.01em; }
.brand .logo { width: 24px; height: 24px; }
.status { display: flex; align-items: center; gap: 7px; color: var(--mute); font-size: 13px; min-width: 0; }
.status .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex: none; }
.status.connected .dot { background: var(--live); box-shadow: 0 0 0 3px color-mix(in srgb, var(--live) 22%, transparent); }
.status > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .spacer { flex: 1; }

.layout {
  display: grid; grid-template-columns: 300px minmax(0, 1fr);
  min-height: calc(100dvh - var(--top) - env(safe-area-inset-top));
}

/* ---------- list ---------- */
.list-pane {
  border-right: 1px solid var(--line); padding: 14px 10px 40px;
  position: sticky; top: calc(var(--top) + env(safe-area-inset-top)); align-self: start;
  max-height: calc(100dvh - var(--top) - env(safe-area-inset-top)); overflow-y: auto;
}
.list-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 8px 10px; }
.list-head h2 { margin: 0; font-size: 13px; font-weight: 600; color: var(--mute); }
.rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 2px 10px;
  padding: 10px; border-radius: 10px; color: inherit; text-decoration: none;
  transition: background-color 120ms var(--ease-out);
}
.row[aria-current="page"] { background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
@media (hover: hover) { .row:not([aria-current="page"]):hover { background: color-mix(in srgb, var(--them) 70%, transparent); } }
.row:active { background: var(--them); }
.row-kw { font: 700 16px/1.2 var(--font-kw); letter-spacing: 0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-meta { grid-column: 1; font-size: 13px; color: var(--mute); font-variant-numeric: tabular-nums; }
.pill {
  grid-row: 1 / span 2; grid-column: 2;
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 650; color: var(--mute);
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--track-off); }
.pill.on { color: var(--live); }
.pill.on::before { background: var(--live); }

.new-form { display: grid; gap: 8px; padding: 10px; margin: 0 0 8px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); }
.new-form .text-input { height: 42px; font: 700 16px var(--font-kw); border-radius: 8px; }
.new-form .actions { display: flex; gap: 8px; justify-content: flex-end; }
.new-form .form-error { margin: 0; }
.new-form .form-error:empty { display: none; }

.list-empty { padding: 8px 10px; color: var(--mute); font-size: 14px; }
.list-empty p { margin: 0 0 12px; }
.list-empty .phone-only { display: none; }

/* ---------- editor ---------- */
.editor-pane { padding: 0 clamp(16px, 4vw, 48px) 80px; min-width: 0; }
.editor { max-width: 640px; margin: 0 auto; }

/* The keyword, save status and On switch stay in view while scrolling. */
.ed-head {
  position: sticky; top: calc(var(--top) + env(safe-area-inset-top)); z-index: 4;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "kw tools" "save save";
  align-items: center; column-gap: 12px;
  padding: 16px 0 8px;
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
}
/* A soft edge where the conversation scrolls under the header, instead of a hard line. */
.ed-head::after {
  content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 12px; pointer-events: none;
  background: linear-gradient(var(--paper), transparent);
}
.back { display: none; grid-area: back; }
.kw-input {
  grid-area: kw; min-width: 0;
  font: 800 30px/1.15 var(--font-kw); letter-spacing: -0.012em; text-overflow: ellipsis;
  border: 1px solid transparent; border-radius: 10px; background: transparent;
  padding: 2px 8px; margin-left: -9px;
  transition: border-color 150ms, background-color 150ms;
}
@media (hover: hover) { .kw-input:hover { border-color: var(--line); } }
.kw-input:focus { outline: none; border-color: var(--focus); background: var(--surface); }
.ed-tools { grid-area: tools; display: flex; align-items: center; gap: 12px; }
.save-state { grid-area: save; font-size: 13px; color: var(--mute); min-height: 18px; transition: color 200ms; }
.save-state.error { color: var(--danger); }
.save-state.pending { color: var(--warn); }
.ed-sub { margin: 14px 0 20px; color: var(--mute); font-size: 14px; max-width: 62ch; }
.ed-sub b { color: var(--ink); font-weight: 600; }
.field-error.head-error { margin: 8px 0 0; text-align: left; }

/* switch */
.switch { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; cursor: pointer; user-select: none; font-size: 14px; font-weight: 600; position: relative; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.track {
  width: 42px; height: 26px; border-radius: 999px; background: var(--track-off); position: relative; flex: none;
  transition: background-color 220ms var(--ease-out);
}
.thumb {
  position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / 0.25);
  transition: transform 240ms var(--ease-out);
}
.switch input:checked + .track { background: var(--live); }
.switch-blue input:checked + .track { background: var(--you-b); }
.switch input:checked + .track .thumb { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--focus); outline-offset: 2px; }
.switch:active .thumb { transform: scale(0.88); }
.switch:active input:checked + .track .thumb { transform: translateX(16px) scale(0.88); }
.switch-label { min-width: 24px; }

/* ---------- the conversation ---------- */
.thread {
  list-style: none; margin: 0; padding: 22px clamp(12px, 3vw, 22px) 24px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  display: flex; flex-direction: column; gap: 14px;
}
.step { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; min-width: 0; }
.cap { font-size: 13px; color: var(--mute); font-weight: 550; }
.you { justify-items: end; }
.you .cap { text-align: right; }

/* their side: what the commenter does */
.them { display: flex; align-items: center; gap: 10px; color: var(--mute); font-size: 14px; }
.them p { margin: 0; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--them); flex: none; display: grid; place-items: center; color: var(--faint); }
.avatar svg { width: 16px; height: 16px; }
.kwchip { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--them); color: var(--ink); font: 700 13px/1.6 var(--font-kw); }
.echo { color: var(--ink); font-weight: 600; }
.note { margin: -6px 0 0 38px; color: var(--mute); font-size: 13px; max-width: 58ch; }

/* your public reply, shown like an Instagram comment */
.comment { margin-left: 38px; display: grid; gap: 8px; }
.comment-row { display: flex; gap: 10px; align-items: flex-start; }
.me {
  width: 28px; height: 28px; border-radius: 50%; flex: none;
  background: linear-gradient(135deg, var(--you-a), var(--you-b)); color: #fff;
  display: grid; place-items: center; font: 800 11px var(--font-kw);
}
.comment-body { flex: 1; min-width: 0; }
.comment-name { font-size: 13px; font-weight: 650; }
.comment-text {
  display: block; width: 100%; resize: none; overflow: hidden;
  border: 1px solid transparent; border-radius: 8px; background: transparent;
  padding: 3px 6px; margin: 1px 0 0 -7px; font-size: 16px; line-height: 1.4;
  transition: border-color 150ms, background-color 150ms;
}
@media (hover: hover) { .comment-text:hover { border-color: var(--line); } }
.comment-text:focus { outline: none; border-color: var(--focus); background: var(--paper); }

.branch { margin-left: 38px; border-left: 1px solid var(--line-strong); padding: 2px 0 2px 12px; }
.branch summary { cursor: pointer; color: var(--mute); font-size: 13px; list-style: none; display: inline-flex; align-items: center; gap: 8px; min-height: 40px; }
.branch summary::-webkit-details-marker { display: none; }
.branch summary::before { content: ""; width: 6px; height: 6px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(-45deg); transition: transform 200ms var(--ease-out); }
.branch[open] summary::before { transform: rotate(45deg); }
.branch .comment-text { margin-top: 6px; }

/* your DMs: Instagram's purple-to-blue bubbles */
.bubble {
  width: min(100%, 440px);
  background: linear-gradient(135deg, var(--you-a) 0%, var(--you-b) 100%);
  border-radius: 22px 22px 6px 22px;
  padding: 2px;
  transition: filter 150ms var(--ease-out);
}
@media (hover: hover) { .bubble:hover { filter: brightness(1.06); } }
.bubble:focus-within { outline: 2px solid var(--focus); outline-offset: 3px; }
.bubble textarea {
  display: block; width: 100%; resize: none; overflow: hidden; border: 0; background: transparent;
  color: #fff; caret-color: #fff; padding: 10px 14px; font-size: 16px; line-height: 1.4;
}
.bubble textarea::placeholder { color: rgb(255 255 255 / 0.86); }
.bubble textarea::selection { background: rgb(255 255 255 / 0.32); }
.bubble textarea:focus { outline: none; }
.bubble.empty { background: transparent; border: 1.5px dashed var(--track-off); }
.bubble.empty textarea { color: var(--ink); caret-color: var(--you-b); }
.bubble.empty textarea::placeholder { color: var(--faint); }

/* quick-reply buttons under a DM */
.chip-input {
  height: 36px; padding: 0 16px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--link); font-weight: 600; font-size: 16px; text-align: center;
  field-sizing: content; min-width: 90px; max-width: 220px;
  transition: border-color 150ms;
}
@media (hover: hover) { .chip-input:hover { border-color: var(--faint); } }
.chip-input:focus { outline: none; border-color: var(--focus); }

/* the follow check, shown like a centred Instagram notice */
.gate {
  justify-items: center; text-align: center; padding: 8px 0;
  border-top: 1px dashed var(--line-strong); border-bottom: 1px dashed var(--line-strong);
}
.gate .switch { font-weight: 550; color: var(--ink); }
.gate small { color: var(--mute); font-size: 13px; max-width: 46ch; }
/* Opens and closes with the follow switch instead of jumping. */
.follow-part {
  display: grid; grid-template-rows: 1fr; opacity: 1;
  transition: grid-template-rows 240ms var(--ease-out), opacity 180ms var(--ease-out), margin-top 240ms var(--ease-out);
}
.follow-inner { min-height: 0; display: grid; gap: 14px; }
/* Clipped only while closed or moving, so focus rings aren't cut off when it's open. */
.follow-part.collapsed .follow-inner, .follow-part.clipping .follow-inner { overflow: hidden; }
.follow-part.collapsed { grid-template-rows: 0fr; opacity: 0; margin-top: -14px; }

/* the file they get: an attachment bubble, like in a chat */
.attach { width: min(100%, 440px); }
.file-card {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 10px 10px 12px;
  border-radius: 18px 18px 6px 18px; background: var(--them);
}
.file-icon { width: 38px; height: 38px; border-radius: 8px; display: grid; place-items: center; background: var(--surface); color: var(--mute); font: 800 10px var(--font-kw); flex: none; }
.file-meta { flex: 1 1 150px; min-width: 0; }
.file-name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { font-size: 13px; color: var(--mute); }
.file-actions { display: flex; gap: 2px; margin-left: auto; }
.file-actions .btn { height: 32px; padding: 0 10px; font-size: 13px; }
.file-actions .remove { margin-left: 10px; }
.drop {
  display: grid; place-items: center; gap: 2px; text-align: center; width: 100%;
  padding: 16px; border: 1.5px dashed var(--track-off); border-radius: 18px 18px 6px 18px; background: transparent;
  color: var(--mute); font-size: 14px;
  transition: border-color 150ms, background-color 150ms;
}
.drop strong { color: var(--ink); font-weight: 600; }
.drop.dragging { border-color: var(--focus); background: color-mix(in srgb, var(--focus) 8%, transparent); }
@media (hover: hover) { .drop:hover { border-color: var(--focus); background: color-mix(in srgb, var(--focus) 6%, transparent); } }
.progress { height: 4px; border-radius: 999px; background: var(--surface); overflow: hidden; margin-top: 8px; }
.progress span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--you-a), var(--you-b)); transition: width 160ms linear; }

.field-error { margin: 0; font-size: 13px; color: var(--danger); }
.counter { margin: 0; font-size: 13px; color: var(--mute); font-variant-numeric: tabular-nums; }
.counter.over { color: var(--danger); }
.you .counter { text-align: right; }
.link-btn {
  border: 0; background: none; padding: 0 2px; margin-left: 4px; min-height: 0;
  color: var(--link); font-weight: 600; font-size: inherit; text-decoration: underline; text-underline-offset: 2px;
}
.you .field-error { text-align: right; }

/* ---------- proof it works ---------- */
.activity { margin-top: 18px; padding: 16px 16px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.activity h3 { margin: 0 0 8px; font-size: 18px; font-weight: 650; letter-spacing: -0.01em; text-wrap: balance; }
.act-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.act {
  display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; gap: 10px; align-items: baseline;
  padding: 5px 0; font-size: 14px;
}
.act-mark { width: 18px; height: 18px; align-self: center; display: grid; place-items: center; color: var(--faint); }
.act-mark svg { width: 14px; height: 14px; }
.act.good .act-mark { color: var(--live); }
.act.warn .act-mark { color: var(--warn); }
.act.bad .act-mark { color: var(--danger); }
.act-text { min-width: 0; overflow-wrap: anywhere; }
/* New activity slides in as it happens; nothing moves on first load. */
.act { transition: opacity 220ms var(--ease-out), transform 260ms var(--ease-out); }
@starting-style { .act.fresh { opacity: 0; transform: translateY(-6px); } }
.act-time { color: var(--mute); font-size: 13px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.act-empty { color: var(--mute); font-size: 14px; margin: 0; }
.act-tip { margin: 12px 0 0; padding-top: 10px; border-top: 1px solid var(--line); color: var(--mute); font-size: 13px; }
.act-tip b { color: var(--ink); font-weight: 600; }

/* backup wording and delete */
.extras { margin-top: 12px; display: grid; gap: 10px; }
.backup { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.backup summary { cursor: pointer; padding: 13px 16px; font-weight: 650; font-size: 14px; list-style: none; display: flex; justify-content: space-between; align-items: center; }
.backup summary::-webkit-details-marker { display: none; }
.backup summary::after { content: ""; width: 7px; height: 7px; border-right: 1.5px solid var(--mute); border-bottom: 1.5px solid var(--mute); transform: rotate(45deg); transition: transform 200ms var(--ease-out); }
.backup[open] summary::after { transform: rotate(-135deg); }
.backup .inner { padding: 0 16px 16px; display: grid; gap: 14px; }
.backup p { margin: 0; color: var(--mute); font-size: 13px; }
.plain-area {
  width: 100%; resize: none; overflow: hidden; padding: 10px 12px; font-size: 16px; line-height: 1.4;
  border: 1px solid var(--line-strong); border-radius: 10px; background: var(--paper);
}
.plain-area:focus { outline: none; border-color: var(--focus); }
.delete-row { display: flex; justify-content: flex-end; }
.delete-row .btn { color: var(--mute); }
@media (hover: hover) { .delete-row .btn:hover { color: var(--danger); } }

/* nothing selected / no automations */
.empty-state { max-width: 440px; margin: 12vh auto 0; text-align: center; }
.empty-state .logo { margin: 0 auto; }
.empty-state h2 { font-size: 20px; margin: 16px 0 6px; letter-spacing: -0.01em; text-wrap: balance; }
.empty-state p { color: var(--mute); margin: 0 0 18px; }

/* toast */
#toast {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); z-index: 20;
  transform: translate(-50%, 12px); opacity: 0; pointer-events: none;
  max-width: min(92vw, 440px); padding: 10px 16px; border-radius: 12px;
  background: var(--ink); color: var(--paper); font-size: 14px; box-shadow: var(--shadow-pop);
  transition: opacity 200ms var(--ease-out), transform 240ms var(--ease-out);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* confirm dialog */
dialog {
  border: 1px solid var(--line); border-radius: 16px; padding: 22px; width: min(380px, calc(100vw - 32px));
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-pop);
  transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out), overlay 200ms allow-discrete, display 200ms allow-discrete;
}
dialog:not([open]) { opacity: 0; transform: scale(0.96); }
@starting-style { dialog[open] { opacity: 0; transform: scale(0.96); } }
dialog::backdrop {
  background: rgb(10 12 18 / 0.38);
  transition: opacity 200ms var(--ease-out), overlay 200ms allow-discrete, display 200ms allow-discrete;
}
dialog:not([open])::backdrop { opacity: 0; }
@starting-style { dialog[open]::backdrop { opacity: 0; } }
dialog h2 { margin: 0 0 6px; font-size: 18px; text-wrap: balance; }
dialog p { margin: 0 0 18px; color: var(--mute); }
dialog .actions { display: flex; justify-content: flex-end; gap: 8px; }
dialog .btn { height: 40px; padding: 0 16px; }

/* ---------- phone ---------- */
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .list-pane { border-right: 0; padding: 12px 8px 40px; position: static; max-height: none; overflow: visible; }
  body[data-view="editor"] .list-pane { display: none; }
  body[data-view="list"] .editor-pane { display: none; }
  .editor-pane { padding: 0 12px 60px; }
  .ed-head { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "back kw tools" ". save save"; column-gap: 6px; padding-top: 10px; }
  .back {
    display: inline-grid; place-items: center; width: 44px; height: 44px; margin-left: -10px;
    border: 0; border-radius: 12px; background: transparent; color: var(--ink);
  }
  .back:active { background: var(--them); }
  .kw-input { font-size: 25px; margin-left: -6px; }
  .top .status .long { display: none; }
  .row { padding: 14px 10px; grid-template-columns: minmax(0, 1fr) auto 12px; }
  .row::after {
    content: ""; grid-row: 1 / span 2; grid-column: 3; width: 7px; height: 7px; justify-self: end;
    border-right: 1.5px solid var(--faint); border-bottom: 1.5px solid var(--faint); transform: rotate(-45deg);
  }
  .comment { margin-left: 20px; }
  .branch, .note { margin-left: 20px; }
  .file-actions { width: 100%; }
  .btn, .file-actions .btn, dialog .btn { height: 44px; }
  .file-actions .btn { padding: 0 12px; font-size: 14px; }
  .chip-input { height: 40px; }
  .branch summary { min-height: 44px; }
  .file-actions .remove { margin-left: auto; }
  .list-empty .phone-only { display: block; }

  /* Opening an automation pushes in from the right; going back eases the list in. */
  .editor-pane, .list-pane { transition: opacity 220ms var(--ease-out), transform 280ms var(--ease-drawer); }
  @starting-style {
    body[data-nav="push"] .editor-pane { opacity: 0; transform: translateX(24px); }
    body[data-nav="pop"] .list-pane { opacity: 0; transform: translateX(-12px); }
  }
}
@media (max-width: 420px) {
  .brand-name { display: none; }
}

/* Reduce Transparency: solid bars instead of frosted ones. */
@media (prefers-reduced-transparency: reduce) {
  .top, .ed-head { background: var(--paper); backdrop-filter: none; -webkit-backdrop-filter: none; }
}
/* Increase Contrast: firmer edges everywhere. */
@media (prefers-contrast: more) {
  :root { --line: var(--track-off); --line-strong: var(--mute); }
}

/* Reduced motion keeps the fades that explain a change and drops the movement. */
@media (prefers-reduced-motion: reduce) {
  .thumb, .btn { transition: none; }
  .btn:active { transform: none; }
  #toast { transition: opacity 200ms var(--ease-out); }
  #toast, #toast.show { transform: translate(-50%, 0); }
  @starting-style {
    .act.fresh { transform: none; }
    dialog[open] { transform: none; }
    body[data-nav="push"] .editor-pane, body[data-nav="pop"] .list-pane { transform: none; }
  }
  dialog:not([open]) { transform: none; }
  .follow-part { transition: opacity 180ms var(--ease-out); }
}
