:root {
  color-scheme: light;
  --ink: #162033;
  --muted: #617089;
  --line: #dce4ef;
  --surface: #ffffff;
  --surface-soft: #f2f6fb;
  --primary: #175cd3;
  --primary-dark: #124aa9;
  --focus: #8bb7ff;
  --success: #11643a;
  --success-bg: #e9f8ef;
  --warning: #8a4300;
  --warning-bg: #ffe8c2;
  --danger: #a1262f;
  --danger-bg: #fff0f1;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--surface-soft);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 0%, rgba(23, 92, 211, .12), transparent 30rem),
    var(--surface-soft);
  font-size: 16px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

a {
  color: var(--primary);
  text-underline-offset: .18em;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a,
input,
select,
textarea {
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.page-shell {
  width: 100%;
  min-height: calc(100dvh - 92px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(20px, env(safe-area-inset-top)) 16px 24px;
}

.auth-card,
.profile-card,
.welcome-card {
  width: 100%;
  max-width: 480px;
  padding: 24px 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 18px 48px rgba(25, 45, 75, .09);
}

.auth-heading {
  margin-bottom: 22px;
}

.auth-heading h1,
.welcome-card h1,
.profile-card h1 {
  margin: 4px 0 8px;
  font-size: clamp(1.65rem, 8vw, 2.15rem);
  line-height: 1.12;
  letter-spacing: -.025em;
}

.auth-heading p,
.welcome-card p {
  margin: 0;
  color: var(--muted);
}

.eyebrow {
  display: block;
  color: var(--primary);
  font-size: .75rem;
  font-weight: 800;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.form-stack {
  display: grid;
  gap: 18px;
}

.field {
  display: grid;
  gap: 7px;
}

.field label {
  font-size: .92rem;
  font-weight: 750;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 50px;
  padding: 11px 13px;
  border: 1px solid #bac7d8;
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font-size: 16px;
}

.field textarea {
  resize: vertical;
}

.field input:hover,
.field select:hover,
.field textarea:hover {
  border-color: #8ea2bc;
}

.field-hint,
.muted {
  color: var(--muted);
  font-size: .84rem;
}

.password-control {
  position: relative;
}

.password-control input {
  padding-right: 58px;
}

.password-toggle {
  position: absolute;
  top: 1px;
  right: 1px;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: #41536d;
  cursor: pointer;
  font-size: 1.35rem;
  line-height: 1;
}

.password-toggle span {
  display: block;
}

.password-toggle:hover {
  background: #edf3fb;
}

.consent-row {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 11px;
  align-items: start;
  color: #33435a;
  font-size: .9rem;
  cursor: pointer;
}

.consent-row input {
  width: 24px;
  height: 24px;
  margin: 1px 0 0;
  accent-color: var(--primary);
}

.registration-legal-links {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
  color: #33435a;
  font-size: .86rem;
}

.registration-legal-links code,
.consent-row code {
  font-size: .78em;
}

.button {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border: 1px solid transparent;
  border-radius: 12px;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.button-primary {
  background: var(--primary);
  color: #fff;
}

.button-primary:hover {
  background: var(--primary-dark);
}

.button-secondary {
  border-color: #b9c8db;
  background: #fff;
  color: #263750;
}

.button-quiet {
  min-width: 76px;
  border-color: var(--line);
  background: #fff;
  color: #33435a;
}

.button:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.form-row {
  display: flex;
  gap: 12px;
  align-items: center;
}

.form-row-between {
  justify-content: flex-end;
}

.auth-switch {
  margin: 22px 0 0;
  color: var(--muted);
  text-align: center;
}

.notice {
  margin: 0 0 18px;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: .92rem;
}

.notice-error {
  border: 1px solid #f0c5c8;
  background: var(--danger-bg);
  color: var(--danger);
}

.notice-success {
  border: 1px solid #bce3ca;
  background: var(--success-bg);
  color: var(--success);
}

.success-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  margin-bottom: 16px;
  border-radius: 50%;
  background: var(--success-bg);
  color: var(--success);
  font-size: 1.5rem;
  font-weight: 900;
}

.site-footer {
  min-height: 92px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  justify-content: center;
  padding: 18px 16px max(18px, env(safe-area-inset-bottom));
  color: var(--muted);
  font-size: .82rem;
  text-align: center;
}

.legal-page {
  background: var(--surface-soft);
}

.legal-header {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: max(10px, env(safe-area-inset-top)) 16px 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .96);
}

.legal-header .button {
  min-height: 44px;
  padding: 8px 12px;
  font-size: .88rem;
}

.legal-main {
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  padding: 20px 12px 32px;
}

.legal-document {
  padding: 22px 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 18px 48px rgba(25, 45, 75, .07);
}

.legal-document h1 {
  margin: 7px 0 18px;
  font-size: clamp(1.65rem, 8vw, 2.5rem);
  line-height: 1.1;
  letter-spacing: -.025em;
}

.legal-document h2 {
  margin: 30px 0 10px;
  font-size: clamp(1.15rem, 5vw, 1.4rem);
  line-height: 1.25;
}

.legal-document p,
.legal-document li {
  max-width: 75ch;
}

.legal-document ul,
.legal-document ol {
  padding-left: 22px;
}

.legal-document li + li {
  margin-top: 7px;
}

.legal-meta {
  display: grid;
  gap: 8px;
  margin: 0 0 20px;
  padding: 14px;
  border-radius: 12px;
  background: var(--surface-soft);
}

.legal-meta div {
  display: grid;
  gap: 2px;
}

.legal-meta dt {
  color: var(--muted);
  font-size: .76rem;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.legal-meta dd {
  margin: 0;
}

.legal-meta code {
  font-size: .78rem;
}

.legal-toc {
  margin: 22px 0;
  padding: 14px;
  border-left: 4px solid var(--primary);
  background: #f6f9fe;
}

.legal-toc ol {
  margin: 9px 0 0;
}

.legal-next-document {
  display: grid;
  gap: 4px;
  margin-top: 34px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.legal-next-document span {
  color: var(--muted);
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.cabinet-page .page-shell {
  min-height: auto;
  display: block;
  padding: 0;
}

.cabinet-header {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: max(10px, env(safe-area-inset-top)) 16px 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .94);
}

.brand {
  color: var(--ink);
  font-size: 1rem;
  font-weight: 900;
  text-decoration: none;
}

.brand span {
  color: var(--primary);
}

.cabinet-header form {
  margin: 0;
}

.cabinet-nav {
  display: flex;
  gap: 6px 14px;
  align-items: center;
  margin-left: auto;
  font-size: .88rem;
  font-weight: 750;
}

.cabinet-nav a {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.cabinet-back {
  display: none;
}

.cabinet-main {
  width: 100%;
  max-width: 920px;
  display: grid;
  gap: 16px;
  margin: 0 auto;
  padding: 20px 16px 32px;
}

.cabinet-main-narrow {
  max-width: 560px;
}

.welcome-card,
.profile-card {
  max-width: none;
  box-shadow: 0 10px 30px rgba(25, 45, 75, .06);
}

.profile-card h2 {
  margin: 4px 0 18px;
  font-size: 1.35rem;
}

.profile-list {
  margin: 0 0 22px;
}

.profile-list div {
  display: grid;
  gap: 3px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}

.profile-list dt {
  color: var(--muted);
  font-size: .8rem;
}

.profile-list dd {
  margin: 0;
  font-weight: 700;
}

.owner-identifier {
  max-width: 100%;
  font: 700 .82rem/1.45 ui-monospace, SFMono-Regular, Consolas, monospace;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.owner-overview-grid,
.owner-overview-nav {
  display: grid;
  gap: 12px;
}

.owner-overview-grid {
  margin: 22px 0 14px;
}

.owner-metric-card,
.owner-overview-nav a {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}

.owner-metric-card {
  display: grid;
  gap: 8px;
  padding: 18px;
}

.owner-metric-card span,
.owner-metric-card small,
.owner-overview-nav span {
  color: var(--muted);
}

.owner-metric-card strong {
  font-size: clamp(1.7rem, 9vw, 2.45rem);
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.owner-metric-card small {
  line-height: 1.45;
}

.owner-overview-note {
  margin: 0 0 18px;
  line-height: 1.5;
}

.owner-overview-nav {
  margin: 0 0 20px;
}

.owner-overview-nav a {
  display: grid;
  gap: 4px;
  padding: 15px 16px;
  color: var(--text);
  text-decoration: none;
  overflow-wrap: anywhere;
}

.owner-overview-nav a:hover {
  border-color: var(--primary);
}

.telegram-main {
  max-width: 1120px;
  display: block;
}

.section-heading {
  margin-bottom: 16px;
}

.telegram-grid {
  display: grid;
  gap: 16px;
}

.channel-list,
.publication-list,
.channel-choices {
  display: grid;
  gap: 10px;
}

.recipient-selection-count {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: .84rem;
}

.channel-choice.is-unavailable {
  opacity: .72;
}

.channel-choice-warning {
  color: #a65f00;
}

.channel-card,
.publication-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fbfdff;
}

.channel-card > div,
.publication-row > div {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.channel-handle,
.publication-row small {
  color: var(--muted);
  font-size: .8rem;
}

.publication-row p {
  margin: 5px 0;
  color: #34455d;
  font-size: .88rem;
  white-space: pre-wrap;
}

.status-pill {
  flex: 0 0 auto;
  padding: 5px 8px;
  border-radius: 999px;
  background: #e9eff8;
  color: #40526d;
  font-size: .72rem;
  font-weight: 800;
  white-space: nowrap;
}

.status-success {
  background: var(--success-bg);
  color: var(--success);
}

.status-pill.status-warning {
  background: var(--warning-bg);
  color: var(--warning);
}

.status-error {
  background: var(--danger-bg);
  color: var(--danger);
}

.status-waiting {
  background: #fff5d9;
  color: #765400;
}

.setup-panel {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.setup-panel summary {
  min-height: 48px;
  display: flex;
  align-items: center;
  color: var(--primary);
  font-weight: 800;
  cursor: pointer;
}

.setup-panel[open] summary {
  margin-bottom: 14px;
}

.empty-state {
  margin: 0;
  padding: 14px;
  border-radius: 12px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: .9rem;
}

.channel-fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.channel-fieldset legend {
  margin-bottom: 9px;
  font-size: .92rem;
  font-weight: 750;
}

.channel-choice {
  min-height: 58px;
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 11px;
  align-items: center;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fbfdff;
  cursor: pointer;
}

.channel-choice:has(input:checked) {
  border-color: var(--primary);
  background: #eef5ff;
}

.channel-choice input {
  width: 24px;
  height: 24px;
  margin: 0;
  accent-color: var(--primary);
}

.channel-choice span {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.channel-choice small {
  color: var(--muted);
}

.section-title-row {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.section-title-row h2 {
  margin: 0;
}

.publication-media {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
}

.publication-media-heading {
  display: grid;
  gap: 12px;
}

.publication-media-heading h3,
.publication-media-heading p {
  margin: 0;
}

.publication-media-heading h3 {
  font-size: 1rem;
}

.publication-media-heading p {
  margin-top: 4px;
  color: var(--muted);
  font-size: .82rem;
}

.publication-media-add {
  position: relative;
  justify-self: start;
  overflow: hidden;
}

.publication-media-add.is-disabled {
  opacity: .55;
  cursor: not-allowed;
}

.publication-media-add input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.publication-media-message,
.publication-submit-error {
  min-height: 1.2em;
  margin: 0;
  color: var(--danger);
  font-size: .84rem;
}

.publication-media-message:empty,
.publication-submit-error:empty,
.publication-media-list:empty {
  display: none;
}

.publication-media-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.publication-media-item {
  min-width: 0;
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 9px;
  border: 1px solid #cad5e3;
  border-radius: 12px;
  background: #fff;
}

.publication-media-item.is-ready {
  border-color: #8bc7a5;
}

.publication-media-item.is-error {
  border-color: #e2a0a0;
  background: #fffafa;
}

.publication-media-preview,
.publication-media-placeholder {
  width: 68px;
  height: 68px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: #e7edf5;
  color: #52647d;
  object-fit: cover;
}

.publication-media-info {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.publication-media-info strong,
.publication-media-info small,
.publication-media-status {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.publication-media-info small,
.publication-media-status {
  color: var(--muted);
  font-size: .78rem;
}

.publication-media-item.is-ready .publication-media-status {
  color: var(--success);
}

.publication-media-item.is-error .publication-media-status {
  color: var(--danger);
}

.publication-media-progress {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  margin-top: 4px;
  color: var(--muted);
  font-size: .75rem;
}

.publication-media-progress progress {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  accent-color: var(--primary);
}

.publication-media-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 7px;
  justify-content: flex-end;
}

.media-action {
  min-width: 44px;
  min-height: 44px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--primary);
  cursor: pointer;
  font: inherit;
  font-weight: 800;
}

.media-action:disabled {
  opacity: .35;
  cursor: default;
}

.media-remove {
  color: var(--danger);
  font-size: 1.15rem;
}

.dashboard-main {
  max-width: 1120px;
  display: block;
}

.dashboard-main > * + * {
  margin-top: 16px;
}

.dashboard-welcome {
  max-width: none;
}

.dashboard-health {
  display: grid;
  gap: 3px;
  margin-top: 18px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 13px;
}

.dashboard-health span {
  color: var(--muted);
  font-size: .84rem;
}

.dashboard-health-success {
  border-color: #bce3ca;
  background: var(--success-bg);
  color: var(--success);
}

.dashboard-health-neutral {
  background: var(--surface-soft);
}

.dashboard-actions,
.dashboard-section {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--surface);
  box-shadow: 0 10px 30px rgba(25, 45, 75, .06);
}

.dashboard-actions > h2 {
  margin: 0 0 13px;
  font-size: 1.35rem;
}

.dashboard-action-grid,
.dashboard-platform-grid,
.dashboard-rule-list,
.dashboard-history-list,
.dashboard-channel-list {
  display: grid;
  gap: 10px;
}

.dashboard-action-card,
.dashboard-platform-card,
.dashboard-rule,
.dashboard-history-item {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #fbfdff;
}

.dashboard-action-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.dashboard-action-primary {
  border-color: #bcd1f3;
  background: #f3f7ff;
}

.dashboard-action-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: #e8f0fd;
  color: var(--primary);
  font-size: 1.1rem;
  font-weight: 900;
}

.dashboard-action-card p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: .82rem;
}

.dashboard-action-button,
.dashboard-action-note {
  grid-column: 1 / -1;
}

.dashboard-action-note {
  color: var(--muted);
  font-size: .82rem;
  font-weight: 750;
}

.dashboard-platform-heading {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 13px;
}

.dashboard-platform-heading h3 {
  margin: 0;
}

.platform-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  color: #fff;
  font-size: .66rem;
  font-weight: 900;
}

.platform-max {
  background: linear-gradient(145deg, #4f80ff, #8656f3);
}

.platform-telegram {
  background: #2aabee;
  font-size: 1.1rem;
}

.dashboard-platform-disabled {
  background: #f8f9fb;
}

.dashboard-platform-disabled p {
  color: var(--muted);
  font-size: .84rem;
}

.dashboard-platform-disabled .button {
  width: 100%;
  margin-top: 12px;
}

.dashboard-channel {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding: 10px;
  border-radius: 12px;
  background: var(--surface-soft);
}

.dashboard-channel > div {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.dashboard-channel strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-channel small,
.dashboard-rule small,
.dashboard-history-item time {
  color: var(--muted);
  font-size: .75rem;
}

.dashboard-rule-heading,
.dashboard-history-heading {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
}

.dashboard-rule-heading > div,
.dashboard-history-heading > div {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.dashboard-route-arrow {
  margin: 8px 0 3px 10px;
  color: #7a879b;
}

.dashboard-destinations {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.dashboard-destinations li {
  display: grid;
  gap: 1px;
  padding: 9px 10px;
  border-radius: 11px;
  background: var(--surface-soft);
}

.dashboard-destinations span {
  color: var(--muted);
  font-size: .75rem;
}

.history-route {
  display: grid;
  gap: 7px;
  margin: 12px 0 0;
}

.history-route div {
  display: grid;
  gap: 1px;
}

.history-route dt {
  color: var(--muted);
  font-size: .7rem;
  font-weight: 750;
  text-transform: uppercase;
}

.history-route dd {
  margin: 0;
  font-size: .84rem;
  font-weight: 700;
}

.dashboard-history-item > p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: .82rem;
}

.history-action {
  padding: 9px 10px;
  border-radius: 10px;
  background: var(--surface-soft);
  color: #34455d !important;
}

.dashboard-limit-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: .8rem;
}

.history-pagination {
  display: flex;
  justify-content: center;
  margin-top: 18px;
}

/* Universal publication composer. Unsupported formatting and platforms stay visibly disabled. */
.publication-format-toolbar {
  display: flex;
  gap: 7px;
  align-items: center;
  overflow-x: auto;
  padding: 7px;
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 12px 12px 0 0;
  background: var(--surface-soft);
  scrollbar-width: thin;
}

.publication-format-toolbar button,
.publication-emoji-picker button,
.preview-platform-tabs button {
  min-width: 44px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-weight: 750;
  white-space: nowrap;
}

.publication-format-toolbar button span {
  display: none;
}

.publication-format-toolbar button:disabled,
.preview-platform-tabs button:disabled {
  opacity: .48;
  cursor: not-allowed;
}

.format-support {
  min-width: 180px;
  margin-left: auto;
  color: var(--muted);
  font-size: .72rem;
  line-height: 1.3;
}

.publication-format-toolbar + .publication-emoji-picker + textarea,
.publication-format-toolbar + textarea {
  border-radius: 0 0 12px 12px;
}

.publication-emoji-picker {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-bottom: 0;
  background: #fff;
}

.publication-emoji-picker[hidden] {
  display: none;
}

.publication-emoji-picker button {
  flex: 0 0 44px;
  padding: 0;
  font-size: 1.25rem;
}

.recipient-platforms,
.recipient-platform {
  display: grid;
  gap: 10px;
}

.recipient-platform {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.recipient-platform.is-active {
  border-color: #c4d7f7;
  background: #f8fbff;
}

.recipient-platform.is-disabled {
  background: #f7f8fa;
  color: #748095;
}

.recipient-platform-heading,
.publication-preview-account {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.recipient-platform-heading h3,
.recipient-platform-heading p {
  margin: 0;
}

.recipient-platform-heading p {
  margin-top: 2px;
  color: var(--muted);
  font-size: .75rem;
}

.recipient-platform .platform-mark,
.publication-preview-account .platform-mark {
  width: 36px;
  height: 36px;
  border-radius: 11px;
}

.platform-vk {
  background: #2787f5;
  font-size: .7rem;
}

.publication-preview {
  min-width: 0;
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-soft);
}

.publication-preview-heading h3,
.publication-preview-heading p {
  margin: 0;
}

.publication-preview-heading p {
  margin-top: 3px;
  color: var(--muted);
  font-size: .78rem;
}

.preview-platform-tabs {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.preview-platform-tabs button {
  padding: 8px 12px;
}

.preview-platform-tabs button.is-active {
  border-color: var(--primary);
  background: #eaf2ff;
  color: var(--primary);
}

.publication-preview-card {
  min-width: 0;
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid #d8e0eb;
  border-radius: 15px;
  background: #fff;
}

.publication-preview-account span {
  min-width: 0;
  display: grid;
}

.publication-preview-account small {
  color: var(--muted);
  font-size: .72rem;
}

.publication-preview-text {
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.publication-preview-text a {
  color: var(--primary);
}

.publication-preview-media {
  min-width: 0;
  display: grid;
  gap: 4px;
  overflow: hidden;
  border-radius: 12px;
}

.publication-preview-media.is-album {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.publication-preview-media-item {
  min-width: 0;
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #e8edf4;
  color: #5c6b81;
  font-size: 1.8rem;
}

.publication-preview-media-item img,
.publication-preview-media-item video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.publication-preview-empty {
  margin: 0;
  color: var(--muted);
  font-size: .82rem;
}

.publication-preview-empty[hidden],
.publication-preview-text[hidden] {
  display: none;
}

.app-recent-history .dashboard-history-list {
  max-height: 350px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 3px;
  scrollbar-gutter: stable;
}

.platform-mark {
  flex: 0 0 42px;
  line-height: 1;
  text-align: center;
}

.dashboard-route-arrow {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  margin: 10px auto;
  border-radius: 13px;
  background: #eaf2ff;
  color: var(--primary);
  font-size: 1.65rem;
  font-weight: 950;
  line-height: 1;
}

.dashboard-channel {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
}

.channel-rename {
  grid-column: 1 / -1;
  min-width: 0;
  border-top: 1px solid var(--line);
  padding-top: 4px;
}

.channel-rename summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  color: var(--primary);
  cursor: pointer;
  font-size: .8rem;
  font-weight: 800;
}

.channel-rename form,
.channel-rename label {
  min-width: 0;
  display: grid;
  gap: 8px;
}

.channel-rename form {
  padding: 4px 0 8px;
}

.channel-rename label span,
.channel-rename small {
  color: var(--muted);
  font-size: .74rem;
}

.channel-rename input {
  width: 100%;
  min-width: 0;
}

@media (max-width: 430px) {
  .cabinet-header {
    flex-wrap: wrap;
  }

  .cabinet-nav {
    order: 3;
    width: 100%;
    justify-content: space-between;
    margin-left: 0;
    border-top: 1px solid var(--line);
  }

  .cabinet-nav a {
    min-height: 48px;
  }

  .header-logout .button {
    min-width: 70px;
    padding-right: 12px;
    padding-left: 12px;
  }

  .telegram-main {
    padding-right: 12px;
    padding-left: 12px;
  }

  .channel-card,
  .publication-row {
    display: grid;
  }

  .status-pill {
    justify-self: start;
  }

  .dashboard-rule-heading,
  .dashboard-history-heading {
    display: grid;
  }
}

@media (min-width: 700px) {
  .page-shell {
    padding-right: 28px;
    padding-left: 28px;
  }

  .auth-card,
  .profile-card,
  .welcome-card {
    padding: 32px;
  }

  .auth-card-wide {
    max-width: 560px;
  }

  .auth-card-wide.owner-overview-card {
    max-width: 760px;
  }

  .owner-overview-grid,
  .owner-overview-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .owner-metric-card-wide {
    grid-column: 1 / -1;
  }

  .site-footer {
    flex-direction: row;
    gap: 24px;
  }

  .legal-header {
    padding-right: 28px;
    padding-left: 28px;
  }

  .legal-main {
    padding: 36px 28px 56px;
  }

  .legal-document {
    padding: 40px 48px;
  }

  .legal-meta {
    grid-template-columns: 1fr 2fr 1.2fr;
  }

  .cabinet-header {
    padding-right: 28px;
    padding-left: 28px;
  }

  .cabinet-main {
    grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
    padding: 32px 28px 48px;
  }

  .cabinet-main-narrow {
    grid-template-columns: 1fr;
  }

  .telegram-main {
    display: block;
  }

  .telegram-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .publication-grid {
    grid-template-columns: minmax(0, 1fr) minmax(340px, .85fr);
  }

  .publication-media-heading {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  .publication-media-add {
    justify-self: end;
  }

  .publication-media-item {
    grid-template-columns: 68px minmax(0, 1fr) auto;
  }

  .publication-media-actions {
    grid-column: auto;
  }

  .dashboard-action-grid,
  .dashboard-platform-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .dashboard-actions,
  .dashboard-section {
    padding: 24px;
  }

  .publication-format-toolbar button span {
    display: inline;
  }

  .app-recent-history .dashboard-history-list {
    max-height: 450px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }
}

/* Stage 3: mobile-first cabinet shell. */
.cabinet-page {
  overflow-x: clip;
  background: #f4f6fa;
}

.cabinet-page .page-shell {
  min-width: 0;
  min-height: 100dvh;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
  text-decoration: none;
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.app-sidebar {
  display: none;
}

.app-topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  min-height: 66px;
  display: flex;
  gap: 12px;
  align-items: center;
  padding: max(10px, env(safe-area-inset-top)) 14px 10px;
  border-bottom: 1px solid rgba(220, 228, 239, .9);
  background: rgba(255, 255, 255, .94);
  backdrop-filter: blur(16px);
}

.app-mobile-brand,
.app-brand {
  color: var(--ink);
  text-decoration: none;
}

.app-mobile-brand {
  display: flex;
  gap: 8px;
  align-items: center;
  font-weight: 900;
}

.app-mobile-brand > span,
.app-brand > span {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 11px;
  background: linear-gradient(145deg, #1d3158, #397ff5);
  color: #fff;
  font-size: .72rem;
  font-weight: 900;
  letter-spacing: -.03em;
}

.app-topbar-context {
  min-width: 0;
  display: none;
}

.app-topbar-context strong,
.app-topbar-context small {
  overflow: hidden;
  display: block;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-topbar-context small {
  color: var(--muted);
  font-size: .72rem;
}

.app-topbar-logout {
  margin-left: auto;
}

.app-topbar-logout .button {
  min-width: 64px;
  min-height: 44px;
  padding: 8px 10px;
}

.app-mobile-nav {
  position: fixed;
  z-index: 30;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  padding: 7px 7px max(8px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, .97);
  box-shadow: 0 -8px 28px rgba(25, 45, 75, .08);
  backdrop-filter: blur(16px);
}

.app-mobile-nav-item {
  min-width: 0;
  min-height: 54px;
  display: grid;
  gap: 2px;
  place-items: center;
  align-content: center;
  padding: 5px 3px;
  border-radius: 12px;
  color: #718097;
  font-size: .68rem;
  font-weight: 780;
  line-height: 1.15;
  text-align: center;
  text-decoration: none;
}

.app-mobile-nav-item i {
  font-size: 1.15rem;
  font-style: normal;
  line-height: 1;
}

.app-mobile-nav-item.is-current {
  background: #eaf2ff;
  color: var(--primary);
}

.app-mobile-nav-item.is-disabled {
  color: #a0a9b7;
  cursor: not-allowed;
}

.app-main {
  min-width: 0;
  max-width: 1180px;
  padding: 22px 14px calc(92px + env(safe-area-inset-bottom));
}

.app-page-heading {
  display: flex;
  gap: 18px;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 20px;
}

.app-page-heading > div {
  min-width: 0;
}

.app-page-heading h1 {
  margin: 3px 0 7px;
  font-size: clamp(1.65rem, 8vw, 2.45rem);
  line-height: 1.08;
  letter-spacing: -.035em;
}

.app-page-heading p {
  max-width: 660px;
  margin: 0;
  color: var(--muted);
  font-size: .9rem;
}

.app-desktop-action {
  display: none;
}

.app-health-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  margin-bottom: 24px;
  padding: 16px;
  border: 1px solid;
  border-radius: 18px;
}

.app-health-card strong {
  display: block;
  margin-bottom: 3px;
}

.app-health-card p {
  margin: 0;
  color: var(--muted);
  font-size: .82rem;
}

.app-health-success {
  border-color: #c8ecdd;
  background: linear-gradient(135deg, #f0fbf6, #e8f8f1);
}

.app-health-neutral {
  border-color: #d6e3fb;
  background: linear-gradient(135deg, #f7faff, #edf4ff);
}

.app-health-icon {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: #fff;
  color: var(--success);
  font-weight: 900;
  box-shadow: 0 7px 20px rgba(28, 83, 61, .08);
}

.app-health-neutral .app-health-icon {
  color: var(--primary);
}

.app-live-badge,
.app-status-chip {
  grid-column: 1 / -1;
  width: fit-content;
  display: inline-flex;
  gap: 6px;
  align-items: center;
  padding: 6px 9px;
  border-radius: 999px;
  background: #fff;
  color: var(--success);
  font-size: .72rem;
  font-weight: 850;
}

.app-status-chip {
  color: #6c5a17;
}

.app-live-badge i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #28a875;
}

.app-section {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 10px 30px rgba(25, 45, 75, .055);
}

.app-main > .app-section + .app-section {
  margin-top: 16px;
}

.app-actions-section {
  margin-bottom: 16px;
}

.app-section-heading {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 13px;
}

.app-section-heading h2,
.app-section-heading h3 {
  margin: 0;
}

.app-section-heading .eyebrow {
  margin-bottom: 3px;
}

.app-section-note,
.app-card-note {
  color: var(--muted);
  font-size: .75rem;
}

.app-section-note {
  display: none;
}

.app-action-grid,
.app-platform-grid {
  display: grid;
  gap: 10px;
}

.app-action-card {
  min-width: 0;
  min-height: 82px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 11px;
  align-items: center;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: #fff;
  color: var(--ink);
  text-decoration: none;
  box-shadow: 0 7px 22px rgba(35, 54, 90, .04);
}

.app-action-card > i {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: #eaf2ff;
  color: var(--primary);
  font-size: 1.18rem;
  font-style: normal;
  font-weight: 900;
}

.app-action-card > span {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.app-action-card strong {
  font-size: .9rem;
}

.app-action-card small {
  color: var(--muted);
  font-size: .72rem;
  line-height: 1.35;
}

.app-action-card > b {
  color: #8996a9;
  font-size: 1.45rem;
}

.app-action-primary {
  border-color: #cbdcfb;
  background: linear-gradient(135deg, #f9fbff, #eef4ff);
}

.app-action-primary > i {
  background: var(--primary);
  color: #fff;
}

.app-action-disabled {
  background: #f8f9fb;
  color: #66758b;
  cursor: not-allowed;
}

.app-action-disabled > i {
  background: #f2ead9;
  color: #85620f;
}

.app-platform-card {
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
}

.app-platform-heading {
  display: flex;
  gap: 11px;
  align-items: center;
  margin-bottom: 14px;
}

.app-platform-heading > div {
  min-width: 0;
}

.app-platform-heading > div > h3,
.app-platform-heading > div > span {
  display: block;
  margin: 0;
}

.app-platform-heading > div > span {
  color: var(--muted);
  font-size: .72rem;
}

.platform-telegram svg {
  width: 22px;
  fill: currentColor;
}

.app-platform-heading > .platform-mark {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  line-height: 1;
  text-align: center;
}

.app-platform-heading > .platform-mark svg {
  width: 22px;
  height: 22px;
  display: block;
  margin: 0;
}

.channel-remove {
  width: 100%;
  margin-top: 6px;
}

.channel-health-check {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
}

.channel-health-check p,
.channel-health-check small {
  margin: 0;
  color: var(--muted);
  font-size: .75rem;
}

.channel-health-check .button {
  width: 100%;
}

.channel-remove summary {
  color: #a33131;
  cursor: pointer;
  font-size: .75rem;
  font-weight: 700;
}

.channel-remove form {
  display: grid;
  gap: 9px;
  margin-top: 9px;
}

.channel-remove label {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: .78rem;
}

.button-danger {
  color: #fff;
  background: #a33131;
}

.app-platform-card .dashboard-channel-list {
  margin-bottom: 14px;
}

.app-platform-card .app-card-note,
.app-platform-card .app-card-link {
  margin-top: auto;
}

.app-card-link {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  border-top: 1px solid #edf0f4;
  font-size: .82rem;
  font-weight: 800;
  text-decoration: none;
}

.app-platform-disabled {
  background: #fafafd;
}

.app-platform-disabled p {
  color: var(--muted);
  font-size: .82rem;
}

.app-platform-disabled .button {
  width: 100%;
  margin-top: auto;
}

.app-anchor-section {
  scroll-margin-top: 82px;
}

.app-rule-card {
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: #fff;
}

.route-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 12px;
}

.route-stats span {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: .75rem;
}

.route-stats strong {
  color: var(--ink);
}

.route-workspace {
  min-width: 0;
  display: grid;
  gap: 12px;
}

.route-master-list {
  min-width: 0;
  display: grid;
  gap: 7px;
}

.route-master-item {
  min-width: 0;
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.route-master-item.is-selected {
  border-color: #8daaf0;
  background: #eef4ff;
  box-shadow: inset 3px 0 0 var(--primary);
}

.route-master-item > span:first-child {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.route-master-item strong,
.route-master-item small {
  min-width: 0;
  overflow-wrap: anywhere;
}

.route-master-item small {
  color: var(--muted);
  font-size: .7rem;
}

.route-detail-stack,
.route-detail {
  min-width: 0;
}

.route-detail[hidden] {
  display: none;
}

.app-rule-card[data-route-status="paused"] {
  background: #fcfcfd;
}

.app-rule-source,
.dashboard-destinations li {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.app-rule-source {
  margin-top: 13px;
  padding: 10px;
  border-radius: 13px;
  background: #f6f8fb;
}

.app-rule-source > span,
.dashboard-destinations li > span {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.app-rule-source small,
.dashboard-destinations small {
  color: var(--muted);
  font-size: .7rem;
}

.app-rule-source strong,
.dashboard-destinations strong {
  min-width: 0;
  overflow-wrap: anywhere;
  line-height: 1.3;
}

.app-rule-source .platform-mark,
.dashboard-destinations .platform-mark {
  width: 36px;
  height: 36px;
  border-radius: 11px;
}

.dashboard-destinations li {
  padding: 10px;
}

.dashboard-destinations li:has([data-route-destination-toggle]) {
  grid-template-columns: auto auto minmax(0, 1fr);
}

[data-route-destination-toggle] {
  margin: 0;
  line-height: 0;
}

[data-route-destination-toggle] input {
  width: 20px;
  height: 20px;
  margin: 0;
  cursor: pointer;
}

.app-rule-destinations {
  min-width: 0;
}

.app-rule-label {
  display: block;
  margin: 0 0 6px 2px;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 800;
}

.route-toggle {
  margin: 0;
}

.route-toggle .button {
  width: 100%;
  min-height: 46px;
}

.route-toggle-result {
  min-height: 1.2em;
  margin: 7px 2px 0;
  color: var(--muted);
  font-size: .75rem;
}

.app-rule-card[aria-busy="true"] {
  opacity: .78;
}

.route-card-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  margin-top: 14px;
}

.route-card-actions > :first-child,
.route-card-actions > :last-child {
  grid-column: 1 / -1;
}

.route-card-actions .button {
  width: 100%;
  min-height: 46px;
}

.route-create-button {
  min-height: 46px;
}

.route-builder {
  width: min(720px, calc(100% - 20px));
  max-height: calc(100dvh - 20px);
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: 20px;
  box-shadow: 0 24px 80px rgba(15, 23, 42, .28);
}

.route-builder::backdrop {
  background: rgba(15, 23, 42, .52);
}

.route-builder form {
  display: grid;
  gap: 16px;
  padding: 18px;
  overflow-x: hidden;
}

.route-builder-heading,
.route-builder-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.route-builder-heading h3,
.route-builder-step h4 {
  margin: 0;
}

.route-builder-step {
  min-width: 0;
  display: grid;
  gap: 10px;
}

.route-builder-step h4 {
  display: flex;
  align-items: center;
  gap: 8px;
}

.route-builder-step h4 span {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: #eaf2ff;
  color: var(--primary);
}

.route-search {
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  font: inherit;
}

.route-choice-groups,
.route-choice-groups fieldset {
  min-width: 0;
  display: grid;
  gap: 8px;
}

.route-choice-groups fieldset {
  margin: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.route-choice-groups legend {
  padding: 0 5px;
  font-size: .78rem;
  font-weight: 850;
}

.route-choice {
  min-width: 0;
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  min-height: 54px;
  padding: 8px;
  border-radius: 12px;
  background: var(--surface-soft);
  cursor: pointer;
}

.route-choice:has(input:checked) {
  outline: 2px solid var(--primary);
  background: #eef5ff;
}

.route-choice:has(input:disabled) {
  opacity: .58;
  cursor: not-allowed;
}

.route-choice > span:last-child {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.route-choice strong {
  overflow-wrap: anywhere;
}

.route-choice small,
.route-builder-note,
.route-builder-result {
  color: var(--muted);
  font-size: .76rem;
}

.route-builder-note,
.route-builder-result {
  margin: 0;
}

.route-builder-result {
  min-height: 1.2em;
}

.route-builder-actions {
  position: sticky;
  bottom: 0;
  padding-top: 10px;
  background: #fff;
}

.route-builder-actions .button {
  min-height: 46px;
}

@media (min-width: 680px) {
  .route-choice-groups {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 900px) {
  .route-workspace {
    grid-template-columns: minmax(210px, .72fr) minmax(0, 1.6fr);
    align-items: start;
  }

  .route-master-list {
    position: sticky;
    top: 82px;
  }

  .route-detail {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1.35fr);
    gap: 12px;
    align-items: center;
  }

  .route-detail .dashboard-rule-heading,
  .route-detail .route-card-actions,
  .route-detail .route-toggle-result {
    grid-column: 1 / -1;
  }

  .route-detail .dashboard-route-arrow {
    transform: rotate(-90deg);
    margin: 0;
  }

  .route-detail .app-rule-source {
    margin-top: 0;
  }
}

.app-history-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 11px;
  align-items: start;
  background: #fff;
}

.app-history-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: #eef2f7;
  color: #64748a;
  font-weight: 900;
}

.app-history-icon.status-success {
  background: var(--success-bg);
  color: var(--success);
}

.app-history-icon.status-error {
  background: #fff2dc;
  color: #8b5b00;
}

.app-history-icon.status-waiting {
  background: #eaf2ff;
  color: var(--primary);
}

.app-history-content {
  min-width: 0;
}

.app-history-content .history-route {
  grid-template-columns: 1fr;
}

.app-history-content > p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: .82rem;
}

.app-text-link {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  font-size: .82rem;
  font-weight: 800;
  white-space: nowrap;
}

.app-load-more {
  width: 100%;
  max-width: 320px;
}

.cabinet-page .site-footer {
  padding-bottom: calc(94px + env(safe-area-inset-bottom));
}

@media (max-width: 359px) {
  .app-main {
    padding-right: 10px;
    padding-left: 10px;
  }

  .app-section,
  .app-platform-card {
    padding: 13px;
  }

  .app-mobile-nav-item {
    font-size: .62rem;
  }
}

@media (min-width: 700px) {
  .app-main {
    padding: 30px 24px 110px;
  }

  .app-action-grid,
  .app-platform-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .app-action-card {
    grid-template-columns: auto minmax(0, 1fr);
    align-content: start;
  }

  .app-action-card > b {
    display: none;
  }

  .app-health-card {
    grid-template-columns: auto minmax(0, 1fr) auto;
    padding: 18px 20px;
  }

  .app-live-badge,
  .app-status-chip {
    grid-column: auto;
  }

  .app-section {
    padding: 22px;
  }

  .app-section-note,
  .app-desktop-action {
    display: inline-flex;
  }

  .app-history-content .history-route {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.max-connect-main {
  width: min(100%, 840px);
  margin-inline: auto;
}

.max-connect-page-heading {
  align-items: flex-start;
  flex-wrap: wrap;
}

.max-connect-page-heading > div {
  flex: 1 1 320px;
}

.max-connect-page-heading .app-desktop-action {
  flex: 0 0 auto;
  max-width: 100%;
  white-space: nowrap;
}

.max-connect-card,
.max-connect-scope {
  margin-top: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 10px 30px rgba(35, 55, 85, .06);
}

.max-connect-scope {
  background: #f4f7fb;
  box-shadow: none;
}

.max-connect-scope p,
.max-connect-step p,
.max-connect-status small {
  margin: 4px 0 0;
  color: var(--muted);
}

.max-connect-step,
.max-connect-status {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.max-connect-step > span {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
}

.max-connect-step h2 {
  margin: 0;
  font-size: 1.15rem;
}

.max-connect-list {
  margin: 18px 0;
  padding-left: 24px;
  color: var(--ink);
}

.max-connect-list li + li {
  margin-top: 8px;
}

.connect-permission-required {
  color: #9a4d00;
  font-weight: 850;
}

.max-bot-profile {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  margin: 18px 0 14px;
  padding: 14px;
  border-radius: 14px;
  background: #f4f7fb;
}

.max-bot-profile-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 14px;
  background: var(--primary);
  color: #fff;
  font-size: .72rem;
  font-weight: 900;
}

.max-bot-profile small,
.max-bot-profile strong {
  display: block;
}

.max-bot-profile small,
.max-bot-link-note,
.max-bot-fallback p {
  color: var(--muted);
}

.max-bot-profile strong {
  margin-top: 2px;
  overflow-wrap: anywhere;
}

.max-bot-open {
  width: 100%;
  min-height: 52px;
}

.max-bot-link-note {
  margin: 10px 0 0;
  font-size: .86rem;
  line-height: 1.45;
}

.max-bot-fallback {
  margin: 18px 0;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.max-bot-fallback summary {
  cursor: pointer;
  font-weight: 750;
}

.max-bot-fallback p {
  margin: 10px 0 6px;
}

.max-bot-username-row {
  display: grid;
  gap: 8px;
}

.max-bot-username {
  width: 100%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  font: 700 .9rem/1.4 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.max-code-row {
  display: grid;
  gap: 10px;
  margin-top: 8px;
}

.max-code {
  width: 100%;
  min-height: 92px;
  resize: none;
  overflow-wrap: anywhere;
  font: 700 .9rem/1.45 ui-monospace, SFMono-Regular, Consolas, monospace;
}

.max-connect-status {
  margin-top: 18px;
  padding: 14px;
  border-radius: 14px;
  background: #f4f7fb;
}

.max-status-dot {
  width: 12px;
  height: 12px;
  margin-top: 5px;
  border-radius: 50%;
  background: #e0a01a;
}

.max-connect-challenge.is-observed .max-status-dot {
  background: #21a366;
}

.max-connect-challenge.is-terminal .max-status-dot {
  background: #8a94a5;
}

.max-connect-actions {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.max-connect-actions form,
.max-connect-actions .button,
.max-connect-card > form .button {
  width: 100%;
}

form[data-messenger-status-form],
form[data-messenger-confirm-form] {
  display: none;
}

@media (min-width: 640px) {
  .max-code-row {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
  }

  .max-connect-actions {
    grid-template-columns: repeat(2, minmax(0, max-content));
  }

  .max-bot-username-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }
}

@media (min-width: 1024px) {
  .cabinet-page {
    padding-left: 238px;
  }

  .app-sidebar {
    position: fixed;
    z-index: 40;
    inset: 0 auto 0 0;
    width: 238px;
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    border-right: 1px solid var(--line);
    background: #fff;
  }

  .app-brand {
    display: flex;
    gap: 10px;
    align-items: center;
    margin: 0 8px 30px;
  }

  .app-brand strong,
  .app-brand small {
    display: block;
  }

  .app-brand small {
    color: var(--primary);
    font-size: .7rem;
    letter-spacing: .04em;
  }

  .app-sidebar-nav {
    display: grid;
    gap: 5px;
  }

  .app-nav-item {
    min-height: 46px;
    display: flex;
    gap: 11px;
    align-items: center;
    padding: 0 13px;
    border-radius: 12px;
    color: #59677e;
    font-size: .86rem;
    font-weight: 740;
    text-decoration: none;
  }

  .app-nav-item i {
    width: 20px;
    font-size: 1.1rem;
    font-style: normal;
    text-align: center;
  }

  .app-nav-item.is-current {
    background: #eaf2ff;
    color: var(--primary);
  }

  .app-nav-item.is-disabled {
    color: #a1aab7;
    cursor: not-allowed;
  }

  .app-sidebar-note {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 9px;
    align-items: center;
    margin-top: auto;
    padding: 11px;
    border-radius: 14px;
    background: #f3f6fb;
  }

  .app-sidebar-note > span {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: #fff;
    color: var(--primary);
    font-weight: 900;
  }

  .app-sidebar-note p,
  .app-sidebar-note small {
    min-width: 0;
    display: block;
    margin: 0;
  }

  .app-sidebar-note small {
    color: var(--muted);
    font-size: .68rem;
  }

  .app-sidebar-logout {
    margin-top: 10px;
  }

  .app-sidebar-logout .button {
    width: 100%;
  }

  .app-topbar {
    padding-right: 32px;
    padding-left: 32px;
  }

  .app-mobile-brand,
  .app-topbar-logout,
  .app-mobile-nav {
    display: none;
  }

  .app-topbar-context {
    display: block;
  }

  .app-main {
    padding: 34px 32px 64px;
  }

  .dashboard-rule-list { display: block; }

  .cabinet-page .site-footer {
    padding-bottom: 24px;
  }
}
