@font-face {
  font-family: Arabic;
  src: url('/assets/arabic.woff2') format('woff2');
  font-display: swap;
  font-weight: 100 900;
}
:root {
  font-family: Arabic, 'Segoe UI', Tahoma, sans-serif;
  color-scheme: light;
  --bg: #eef2f5;
  --surface: #fff;
  --surface-2: #f7f9fb;
  --ink: #172c3d;
  --muted: #536779;
  --line: #dce4eb;
  --accent: #126d63;
  --accent-hover: #0c564e;
  --accent-soft: #e2f2ed;
  --nav: #152d3b;
  --nav-ink: #dce8ee;
  --warning: #8f5710;
  --warning-bg: #fff3d9;
  --danger: #b33b49;
  --danger-bg: #fff0f1;
  --shadow: 0 2px 3px #15304708, 0 8px 22px #15304706;
  --radius: 10px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  font-size: 16px;
}
[data-theme='dark'] {
  color-scheme: dark;
  --bg: #111d27;
  --surface: #1a2a37;
  --surface-2: #203341;
  --ink: #e9f0f4;
  --muted: #adc0cd;
  --line: #344b5b;
  --accent: #65c8af;
  --accent-hover: #82dbc3;
  --accent-soft: #24473f;
  --nav: #0c1822;
  --nav-ink: #dae8ef;
  --warning: #ffcf85;
  --warning-bg: #4c3a20;
  --danger: #ffb5bf;
  --danger-bg: #4c2b34;
  --shadow: 0 2px 3px #0002, 0 8px 24px #0002;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.65;
}
button,
input,
select,
textarea {
  font: inherit;
}
button,
a,
input,
textarea,
select {
  -webkit-tap-highlight-color: transparent;
}
button,
.local-dashboard-link {
  cursor: pointer;
}
button:disabled {
  opacity: 0.5;
  cursor: wait;
}
button,
select,
input,
textarea {
  border: 1px solid var(--line);
  border-radius: 7px;
}
button,
.local-dashboard-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.875rem;
  font-weight: 600;
  transition:
    background 0.18s var(--ease),
    box-shadow 0.18s var(--ease),
    transform 0.18s var(--ease);
}
.local-dashboard-link {
  border: 1px solid var(--line);
  border-radius: 7px;
  text-decoration: none;
}
button:hover,
.local-dashboard-link:hover {
  background: var(--surface-2);
}
button:active {
  transform: translateY(1px);
}
button.primary,
.local-dashboard-link.primary {
  background: var(--accent);
  color: var(--surface);
  border-color: var(--accent);
  box-shadow:
    0 2px 3px #0b403320,
    inset 0 1px 0 #ffffff20;
}
button.primary:hover,
.local-dashboard-link.primary:hover {
  background: var(--accent-hover);
}
[data-theme='dark'] button.primary,
[data-theme='dark'] .local-dashboard-link.primary {
  color: #112b24;
}
.secondary {
  box-shadow: 0 1px 2px #102a3b08;
}
.text-button {
  border: 0;
  background: none;
  padding: 4px;
  color: inherit;
}
.danger-button {
  color: var(--danger);
}
svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
.icon-defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}
.icon-button {
  width: 38px;
  height: 38px;
  padding: 8px;
}
.muted {
  color: var(--muted);
}
.error-text {
  color: var(--danger);
  min-height: 1.5em;
}
.skip-link {
  position: fixed;
  top: -100px;
  inset-inline-start: 20px;
  z-index: 30;
  background: var(--surface);
  padding: 10px;
}
.skip-link:focus {
  top: 10px;
}
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}
::selection {
  background: var(--accent);
  color: var(--surface);
}
input,
textarea {
  caret-color: var(--accent);
}
* {
  scrollbar-width: thin;
  scrollbar-color: var(--muted) transparent;
}
a {
  color: var(--accent);
  text-underline-offset: 4px;
}
h1,
h2,
h3,
p {
  margin: 0;
}
h1 {
  font-size: 1.8rem;
  font-weight: 750;
  line-height: 1.5;
  text-wrap: balance;
}
h2 {
  font-size: 1.1rem;
  font-weight: 700;
}
h3 {
  font-size: 1rem;
}
p {
  max-width: 75ch;
}
.shell {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: 244px;
  flex-shrink: 0;
  background: var(--nav);
  color: var(--nav-ink);
  position: fixed;
  inset-block: 0;
  inset-inline-start: 0;
  display: flex;
  flex-direction: column;
  z-index: 15;
  border-inline-end: 1px solid #ffffff08;
  box-shadow: -3px 0 15px #0e243408;
}
.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 26px 22px 22px;
}
.brand-mark {
  width: 40px;
  height: 43px;
  display: grid;
  place-items: center;
  background: #d3ede4;
  color: #153b32;
  border-radius: 10px 10px 3px 10px;
  font-size: 1.7rem;
  font-weight: 800;
  box-shadow:
    0 3px 8px #0002,
    inset 0 1px 0 #fff9;
}
.wordmark {
  font-size: 1.7rem;
  font-weight: 750;
  line-height: 1.3;
}
.wordmark span {
  font-size: 0.75rem;
  font-weight: 400;
  display: block;
  opacity: 0.8;
  margin-block-start: 4px;
}
.workspace-label {
  margin: 0 18px 16px;
  padding: 10px 12px;
  background: #ffffff08;
  border: 1px solid #ffffff10;
  border-radius: 7px;
  font-size: 0.8rem;
}
.workspace-label span {
  display: block;
  color: #b3c5d0;
  font-size: 0.75rem;
  margin-block-start: 3px;
}
nav {
  overflow: auto;
  flex: 1;
  padding: 0 12px 15px;
}
.nav-group {
  padding: 16px 12px 7px;
  font-size: 0.75rem;
  color: #9fb7c5;
}
.nav-link {
  display: flex;
  width: 100%;
  justify-content: flex-start;
  gap: 12px;
  background: transparent;
  color: var(--nav-ink);
  border-color: transparent;
  box-shadow: none;
  padding: 9px 12px;
  margin-block: 2px;
  font-size: 0.875rem;
  font-weight: 450;
  text-align: start;
  border-radius: 6px;
}
.nav-link:hover {
  background: #ffffff08;
}
.nav-link.active {
  background: #d2eee515;
  color: #a4e7d2;
  border-color: #90d2bf26;
  font-weight: 700;
  box-shadow:
    inset 0 1px 0 #ffffff06,
    0 2px 5px #0001;
}
.nav-link svg {
  width: 17px;
  height: 17px;
}
.sidebar-footer {
  padding: 16px 20px;
  border-block-start: 1px solid #ffffff12;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
}
.version {
  color: #a9bdc9;
}
.workspace {
  margin-inline-start: 244px;
  min-width: 0;
  width: calc(100% - 244px);
}
.topbar {
  height: 72px;
  background: var(--surface);
  border-block-end: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-inline: 32px;
  gap: 18px;
}
.breadcrumb {
  display: flex;
  gap: 12px;
  align-items: center;
  font-size: 0.8rem;
}
.breadcrumb > span {
  color: var(--muted);
}
.divider {
  opacity: 0.6;
}
.top-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}
.top-actions time {
  font-size: 0.85rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.user-badge {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.8rem;
}
.mobile-menu {
  display: none;
}
main {
  padding: 28px 32px 16px;
  max-width: 1920px;
  margin: auto;
}
.page-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-block-end: 24px;
}
.page-heading p {
  font-size: 0.875rem;
  margin-block-start: 6px;
}
.heading-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}
.notice {
  border: 1px solid #d9b35c65;
  background: var(--warning-bg);
  color: var(--warning);
  padding: 13px 17px;
  border-radius: 8px;
  margin-block-end: 22px;
  font-size: 0.875rem;
}
.notice.danger {
  background: var(--danger-bg);
  color: var(--danger);
}
.status-strip {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 14px 18px;
  border-radius: var(--radius);
  margin-block-end: 22px;
  font-size: 0.85rem;
}
.status-strip > span {
  display: flex;
  align-items: center;
  gap: 8px;
}
.status-strip > span + span {
  border-inline-start: 1px solid var(--line);
  padding-inline-start: 18px;
}
.status {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 5px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}
.status.good {
  background: var(--accent-soft);
  color: var(--accent);
}
.status.warn {
  background: var(--warning-bg);
  color: var(--warning);
}
.status.bad {
  background: var(--danger-bg);
  color: var(--danger);
}
.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  margin-block-end: 26px;
}
.metric {
  padding: 22px 24px;
  min-width: 0;
}
.metric + .metric {
  border-inline-start: 1px solid var(--line);
}
.metric-label {
  font-size: 0.85rem;
  color: var(--muted);
}
.metric-value {
  font-size: 2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.5;
  margin-block: 6px;
}
.metric-note {
  font-size: 0.75rem;
  color: var(--muted);
}
.critical-text {
  color: var(--danger);
}
.section {
  margin-block-end: 24px;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel-heading {
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-block-end: 1px solid var(--line);
}
.panel-heading p {
  font-size: 0.8rem;
  color: var(--muted);
  margin-block-start: 3px;
}
.panel-body {
  padding: 20px;
}
.table-scroll {
  overflow: auto;
  width: 100%;
}
table {
  border-collapse: collapse;
  width: 100%;
  text-align: start;
  font-size: 0.85rem;
  white-space: nowrap;
}
th {
  padding: 12px 18px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--surface-2);
  text-align: start;
  border-block-end: 1px solid var(--line);
}
td {
  padding: 14px 18px;
  border-block-end: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
  max-width: 350px;
  overflow: hidden;
  text-overflow: ellipsis;
}
tr:last-child td {
  border-block-end: 0;
}
tbody tr:hover {
  background: var(--surface-2);
}
td small {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
}
.table-action {
  font-size: 0.75rem;
  padding: 4px 10px;
}
.empty {
  padding: 48px 24px;
  text-align: center;
  display: grid;
  justify-items: center;
  gap: 10px;
}
.empty svg {
  width: 32px;
  height: 32px;
  color: var(--muted);
  margin-block-end: 4px;
}
.empty p {
  color: var(--muted);
  font-size: 0.875rem;
  max-width: 50ch;
}
.empty button {
  margin-block-start: 8px;
}
.split {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(260px, 1fr);
  gap: 24px;
  align-items: start;
}
.steps {
  list-style: none;
  margin: 0;
  padding: 0;
}
.step {
  display: flex;
  gap: 14px;
  padding: 16px 0;
  border-block-end: 1px solid var(--line);
  align-items: flex-start;
}
.step:first-child {
  padding-block-start: 0;
}
.step:last-child {
  border: 0;
  padding-block-end: 0;
}
.step-count {
  font-size: 0.75rem;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 50%;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.step p {
  font-size: 0.8rem;
  color: var(--muted);
  margin-block-start: 3px;
}
.step button {
  font-size: 0.75rem;
  margin-block-start: 8px;
  padding: 4px 10px;
}
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-block-end: 18px;
}
.toolbar input {
  min-width: 220px;
}
.toolbar label {
  font-size: 0.8rem;
}
.toolbar select {
  max-width: 240px;
}
input,
select,
textarea {
  padding: 9px 11px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.875rem;
  max-width: 100%;
  min-width: 0;
}
input::placeholder,
textarea::placeholder {
  color: var(--muted);
  opacity: 1;
}
select {
  appearance: none;
  padding-inline-end: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath fill='none' stroke='%23536779' d='m1 1 5 5 5-5'/%3E%3C/svg%3E");
  background-position: left 10px center;
  background-repeat: no-repeat;
}
textarea {
  resize: vertical;
  min-height: 100px;
  line-height: 1.7;
}
label {
  display: grid;
  gap: 7px;
  font-size: 0.875rem;
}
input[type='checkbox'] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}
.check-label {
  display: flex;
  align-items: center;
  gap: 10px;
}
.page-footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 0 4px;
  color: var(--muted);
  font-size: 0.75rem;
}
.page-footer > span:first-child {
  max-width: 75ch;
}
.editor {
  position: fixed;
  inset-block: 0;
  inset-inline-end: 0;
  width: min(530px, 100%);
  background: var(--surface);
  z-index: 25;
  border-inline-start: 1px solid var(--line);
  box-shadow: 8px 0 60px #10222f33;
  overflow: auto;
}
.editor-header {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-block-end: 1px solid var(--line);
  background: var(--surface);
  z-index: 1;
}
#record-form {
  padding: 24px;
  display: grid;
  gap: 18px;
}
.help {
  font-size: 0.75rem;
  color: var(--muted);
}
.form-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  border-block-start: 1px solid var(--line);
  padding-block-start: 20px;
  margin-block-start: 8px;
}
.toast {
  position: fixed;
  bottom: 24px;
  inset-inline-start: 50%;
  transform: translateX(50%);
  z-index: 50;
  max-width: 90vw;
  padding: 12px 22px;
  background: var(--nav);
  color: var(--nav-ink);
  border: 1px solid #ffffff24;
  border-radius: 8px;
  box-shadow: 0 6px 28px #102a3b30;
  font-size: 0.875rem;
}
.login-layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.login-story {
  background: var(--nav);
  color: var(--nav-ink);
  padding: 10vh 8vw;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
}
.login-story h1 {
  font-size: clamp(2rem, 3.5vw, 3.8rem);
  line-height: 1.6;
  margin-block: 28px 22px;
  max-width: 12ch;
}
.login-story p {
  color: #b6cbd7;
  max-width: 34ch;
  font-size: 1rem;
}
.story-rule {
  display: flex;
  gap: 22px;
  margin-block-start: 50px;
  border-block-start: 1px solid #ffffff30;
  padding-block-start: 18px;
  color: #bbd6cf;
  font-size: 0.8rem;
}
.login-form {
  align-self: center;
  justify-self: center;
  width: min(360px, calc(100% - 48px));
  display: grid;
  gap: 20px;
  padding-block: 40px;
}
.login-form h2 {
  font-size: 1.5rem;
  margin-block-start: 20px;
}
.login-form .wordmark {
  color: var(--accent);
}
.login-form > p.muted {
  font-size: 0.875rem;
  margin-block-start: -12px;
}
.login-note {
  font-size: 0.75rem;
  color: var(--muted);
  border-block-start: 1px solid var(--line);
  padding-block-start: 18px;
}
.stat-list {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  font-size: 0.875rem;
}
.stat-list dt {
  color: var(--muted);
}
.stat-list dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
}
.bar-list {
  display: grid;
  gap: 20px;
}
meter {
  width: 100%;
  height: 12px;
  accent-color: var(--accent);
}
meter::-webkit-meter-bar {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 4px;
}
meter::-webkit-meter-optimum-value {
  background: var(--accent);
  border-radius: 4px;
}
meter::-moz-meter-bar {
  background: var(--accent);
}
.bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  margin-block-end: 7px;
}
.bar {
  height: 7px;
  border-radius: 4px;
  background: var(--surface-2);
  overflow: hidden;
}
.bar > span {
  display: block;
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
}
.code {
  direction: ltr;
  text-align: left;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 14px;
  font:
    13px/1.8 Consolas,
    monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.filter-form {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  margin-block-end: 20px;
}
.filter-form label {
  flex: 1;
  min-width: 150px;
}
.body-copy {
  display: grid;
  gap: 16px;
  font-size: 0.9rem;
}
.body-copy ul {
  padding-inline-start: 20px;
  margin: 0;
}
.body-copy li {
  margin-block: 8px;
}
details {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 16px;
}
summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.875rem;
}
details p {
  font-size: 0.85rem;
  color: var(--muted);
  margin-block-start: 12px;
}
[hidden] {
  display: none !important;
}
@media (min-width: 1600px) {
  main {
    padding: 36px 48px;
  }
  .topbar {
    padding-inline: 48px;
  }
}
@media (max-width: 1100px) {
  .sidebar {
    width: 215px;
  }
  .workspace {
    margin-inline-start: 215px;
    width: calc(100% - 215px);
  }
  main {
    padding: 24px;
  }
  .topbar {
    padding-inline: 24px;
  }
  .split {
    grid-template-columns: 1fr;
  }
  .metric {
    padding: 16px;
  }
  .metric-value {
    font-size: 1.7rem;
  }
  .top-actions time {
    display: none;
  }
}
@media (max-width: 760px) {
  .sidebar {
    visibility: hidden;
    transform: translateX(100%);
    transition: transform 0.25s var(--ease);
    width: 244px;
  }
  .sidebar.open {
    visibility: visible;
    transform: translateX(0);
  }
  .workspace {
    margin: 0;
    width: 100%;
  }
  .mobile-menu {
    display: inline-flex;
  }
  .topbar {
    height: 64px;
    padding-inline: 16px;
  }
  .top-actions {
    gap: 8px;
  }
  .user-badge {
    max-width: 100px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .breadcrumb > span {
    display: none;
  }
  .breadcrumb {
    gap: 8px;
  }
  .breadcrumb strong {
    font-size: 0.75rem;
  }
  main {
    padding: 22px 16px 14px;
  }
  .page-heading {
    align-items: flex-start;
    gap: 12px;
    flex-wrap: wrap;
  }
  .heading-actions {
    gap: 6px;
    flex-wrap: wrap;
  }
  .heading-actions button {
    padding: 8px 10px;
    font-size: 0.8rem;
  }
  h1 {
    font-size: 1.5rem;
  }
  .page-heading p {
    font-size: 0.8rem;
  }
  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .metric:nth-child(3) {
    border-inline-start: 0;
    border-block-start: 1px solid var(--line);
  }
  .metric:nth-child(4) {
    border-block-start: 1px solid var(--line);
  }
  .metric-label {
    font-size: 0.8rem;
  }
  .metric-value {
    font-size: 1.8rem;
  }
  .metric-note {
    font-size: 0.7rem;
  }
  .status-strip {
    padding: 12px;
    gap: 10px;
  }
  .status-strip > span + span {
    padding-inline-start: 10px;
  }
  .page-footer {
    display: block;
  }
  .page-footer > span {
    display: block;
    margin-block: 8px;
  }
  .panel-heading {
    padding: 14px 16px;
  }
  .panel-body {
    padding: 16px;
  }
  .toolbar input {
    width: 100%;
    min-width: 0;
  }
  .login-layout {
    grid-template-columns: 1fr;
  }
  .login-story {
    display: none;
  }
  .filter-form {
    gap: 10px;
  }
  .filter-form label {
    min-width: calc(50% - 10px);
  }
  .filter-form button {
    flex: 1;
  }
  .empty {
    padding: 36px 18px;
  }
  .story-rule {
    flex-wrap: wrap;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
.messenger-workbench {
  display: grid;
  gap: 24px;
  min-width: 0;
}
.template-workbench {
  display: grid;
  gap: 20px;
}
.template-instructions {
  padding: 16px 20px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.8rem;
}
.template-instructions strong {
  color: var(--ink);
}
@media (max-width: 760px) {
  .page-heading[data-screen='templates'] {
    flex-direction: column;
    align-items: stretch;
  }
  .page-heading[data-screen='templates'] .heading-actions {
    justify-content: flex-start;
  }
}
.template-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
.template-filter {
  padding: 16px 20px;
  background: var(--surface-2);
  border-block-end: 1px solid var(--line);
}
.template-filter select {
  width: 100%;
}
.template-list {
  max-height: 660px;
  overflow: auto;
}
.template-row {
  display: flex;
  align-items: start;
  gap: 16px;
  padding: 18px 20px;
  border-block-end: 1px solid var(--line);
}
.template-row:last-child {
  border-block-end: 0;
}
.template-row.selected {
  background: var(--accent-soft);
}
.template-row > div:first-child {
  flex: 1;
  min-width: 0;
}
.template-row strong {
  font-size: 0.9rem;
}
.template-row p {
  font-size: 0.8rem;
  color: var(--muted);
  margin-block: 8px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.template-row small {
  font-size: 0.75rem;
  color: var(--muted);
}
.template-row-actions {
  display: grid;
  gap: 8px;
  flex-shrink: 0;
}
.template-preview {
  position: sticky;
  top: 20px;
}
.template-preview-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 20px;
}
.template-preview-controls label {
  min-width: 0;
  font-size: 0.8rem;
}
.template-preview-controls select,
.template-preview-controls input {
  width: 100%;
}
#alert-template-preview {
  margin: 0 20px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--ink);
  font-family: inherit;
  font-size: 0.85rem;
  line-height: 1.9;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  box-shadow: inset 0 2px 4px #132f3b0a;
}
.template-preview-note {
  padding: 16px 20px 20px;
  color: var(--muted);
  font-size: 0.75rem;
}
@media (max-width: 1100px) {
  .template-layout {
    grid-template-columns: 1fr;
  }
  .template-preview {
    position: static;
  }
  .template-list {
    max-height: 440px;
  }
}
@media (max-width: 760px) {
  .template-preview-controls {
    grid-template-columns: 1fr;
  }
  .template-row {
    padding: 16px;
    gap: 12px;
  }
  #alert-template-preview {
    margin-inline: 16px;
    padding: 16px;
  }
}
.messenger-account {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px 32px;
  padding: 20px 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow:
    0 4px 6px #132f3b0c,
    0 12px 24px #132f3b08,
    inset 0 1px 1px #ffffff80;
}
.messenger-connection {
  margin-inline-start: auto;
  text-align: end;
}
.connection-state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--muted);
}
.connection-state::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warning);
}
.connection-state.connected::before {
  background: var(--accent);
}
.messenger-account-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-block-start: 8px;
}
.messenger-connection-note {
  flex-basis: 100%;
  border-block-start: 1px solid var(--line);
  padding-block-start: 12px;
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
}
.messenger-tabs {
  display: flex;
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  box-shadow: inset 0 2px 4px #132f3b0c;
}
.messenger-tabs [role='tab'] {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
}
.messenger-tabs [role='tab']:hover {
  background: var(--surface);
  color: var(--ink);
}
.messenger-tabs [role='tab'][aria-selected='true'] {
  color: var(--accent);
  background: var(--surface);
  border-color: var(--line);
  box-shadow:
    0 3px 5px #132f3b18,
    inset 0 1px 1px #ffffff80;
}
.messenger-tabs [role='tab'] span {
  padding: 1px 7px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  font-size: 0.75rem;
}
.messenger-tab-panel {
  display: grid;
  gap: 24px;
  min-width: 0;
}
.messenger-tab-panel[hidden] {
  display: none;
}
.group-add-surface {
  display: grid;
  grid-template-columns: minmax(180px, 0.65fr) minmax(0, 1.35fr);
  gap: 32px;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow:
    0 4px 7px #132f3b0b,
    0 12px 28px #132f3b08;
}
.group-add-intro p {
  color: var(--muted);
  font-size: 0.875rem;
  margin-block-start: 8px;
  max-width: 32ch;
}
.group-add-surface #messenger-manual-form {
  margin: 0;
  max-width: none;
  gap: 14px;
}
.group-add-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
}
.group-add-actions span {
  font-size: 0.75rem;
  color: var(--muted);
}
.group-extra {
  border: 0;
  padding: 0;
  box-shadow: none;
  background: transparent;
}
.group-extra summary {
  font-size: 0.8rem;
  color: var(--muted);
}
.group-extra label {
  margin-block-start: 12px;
}
.invite-history {
  display: grid;
  gap: 12px;
}
.invite-history > h2 {
  font-size: 1rem;
}
.invite-row {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 3px 6px #132f3b0b;
}
.invite-symbol {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.invite-info {
  flex: 1;
  min-width: 0;
}
.invite-info strong {
  display: block;
  font-size: 0.9rem;
}
.invite-info a {
  display: block;
  width: fit-content;
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: 0.8rem;
  margin-block-start: 4px;
}
.invite-info p {
  font-size: 0.8rem;
  color: var(--muted);
  margin-block-start: 8px;
}
.group-library {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  overflow: hidden;
  box-shadow: 0 4px 8px #132f3b0a;
}
.library-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-block-end: 1px solid var(--line);
}
.library-row:last-child {
  border-block-end: 0;
}
.library-row > div {
  min-width: 0;
  overflow-wrap: anywhere;
}
.library-row small {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  margin-block-start: 4px;
}
.messenger-empty {
  padding: 28px 20px;
  text-align: center;
  margin-block: auto;
}
.messenger-empty h3 {
  font-size: 0.95rem;
  margin-block-end: 10px;
}
.messenger-empty p {
  font-size: 0.8rem;
  color: var(--muted);
}
.messenger-tab-panel .choice-list {
  min-height: 180px;
}
@media (max-width: 1100px) {
  .group-add-surface {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  .group-add-intro p {
    max-width: none;
  }
}
@media (max-width: 760px) {
  .messenger-account {
    padding: 18px;
    gap: 16px;
  }
  .messenger-connection {
    width: 100%;
    text-align: start;
  }
  .messenger-account-actions {
    gap: 8px;
  }
  .messenger-tabs {
    gap: 4px;
    padding: 4px;
  }
  .messenger-tabs [role='tab'] {
    flex-direction: column;
    gap: 4px;
    padding: 8px 6px;
    font-size: 0.75rem;
  }
  .group-add-surface {
    padding: 20px;
  }
  .invite-row {
    flex-wrap: wrap;
    gap: 12px;
    padding: 16px;
  }
  .invite-info {
    flex-basis: calc(100% - 56px);
  }
  .invite-row > button {
    margin-inline-start: 52px;
  }
  .library-row {
    padding: 16px;
    flex-wrap: wrap;
  }
  .messenger-tab-panel .choice-list {
    min-height: 140px;
  }
}
.account-surface {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px;
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow:
    0 3px 5px #132f3b0a,
    0 12px 26px #132f3b09,
    inset 0 1px 0 #ffffff40;
}
.account-picker {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  min-width: 220px;
}
.account-picker label {
  flex: 1;
  max-width: 440px;
  font-weight: 600;
}
.account-picker select {
  width: 100%;
  box-shadow:
    inset 0 1px 3px #1126380a,
    0 2px 3px #11263805;
}
.account-seal {
  display: grid;
  place-items: center;
  width: 48px;
  height: 52px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow:
    0 3px 6px #153a3020,
    inset 0 1px 0 #ffffff50;
}
.account-seal svg {
  width: 24px;
  height: 24px;
}
.discovery-summary {
  flex-basis: 100%;
  font-size: 0.875rem;
  color: var(--muted);
  border-block-start: 1px solid var(--line);
  padding-block-start: 14px;
}
.discovery-summary span {
  display: block;
  margin-block-start: 5px;
  font-size: 0.8rem;
}
.messenger-selection {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
  align-items: stretch;
}
.selection-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow:
    0 2px 3px #132f3b09,
    0 12px 24px #132f3b08,
    inset 0 1px 0 #ffffff60;
}
.selection-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px;
  border-block-end: 1px solid var(--line);
}
.selection-heading p {
  color: var(--muted);
  font-size: 0.8rem;
  margin-block-start: 4px;
}
.selection-count {
  padding: 4px 9px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  white-space: nowrap;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}
.selection-tools {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  background: var(--surface-2);
}
.selection-tools input {
  width: 100%;
}
.page-catalog-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
  padding: 16px;
  border-block-end: 1px solid var(--line);
}
.page-catalog-controls label {
  flex: 1;
  min-width: 180px;
  font-size: 0.8rem;
}
.page-catalog-controls select {
  width: 100%;
}
.page-catalog-controls .help {
  flex-basis: 100%;
  margin: 0;
}
@media (max-width: 760px) {
  .page-catalog-controls label {
    min-width: 0;
    flex-basis: 100%;
  }
}
.selection-tools button {
  flex-shrink: 0;
  font-size: 0.8rem;
}
.choice-list {
  max-height: 400px;
  min-height: 240px;
  overflow: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.choice-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow:
    0 2px 3px #1029380b,
    inset 0 1px 0 #ffffff40;
  transition:
    transform 0.18s var(--ease),
    box-shadow 0.18s var(--ease),
    background 0.18s var(--ease);
}
.choice-row:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 7px #10293814;
}
.choice-row.selected {
  background: var(--accent-soft);
  border-color: var(--accent);
  box-shadow:
    inset 0 1px 3px #10293810,
    0 1px 2px #10293809;
}
.choice-row > span:not(.status),
.choice-main > span {
  flex: 1;
  min-width: 0;
}
.choice-row > .status {
  flex: 0 0 auto;
}
.choice-row strong {
  display: block;
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}
.choice-row small {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-block-start: 3px;
}
.choice-main {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 12px;
  min-width: 0;
  cursor: pointer;
}
.group-verify {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding-block-start: 10px;
  border-block-start: 1px solid var(--line);
  font-size: 0.75rem;
  color: var(--muted);
}
.routing-save {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(170px, 0.7fr) auto auto;
  align-items: center;
  gap: 20px;
  padding: 22px;
  margin-block-start: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.routing-save > .error-text {
  grid-column: 1/-1;
  margin: 0;
  min-height: 0;
}
.routing-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.manual-group {
  background: var(--surface);
}
#messenger-manual-form {
  display: grid;
  gap: 16px;
  margin-block-start: 20px;
  max-width: 700px;
}
.messenger-workbench .section {
  margin-block-end: 0;
}
@media (max-width: 1100px) {
  .routing-save {
    grid-template-columns: 1fr 1fr;
  }
  .messenger-selection {
    gap: 16px;
  }
  .selection-heading {
    padding: 16px;
  }
}
@media (max-width: 760px) {
  .messenger-selection {
    grid-template-columns: 1fr;
  }
  .routing-save {
    grid-template-columns: 1fr;
    padding: 18px;
    gap: 16px;
  }
  .account-surface {
    padding: 18px;
    gap: 14px;
  }
  .account-surface > button {
    width: 100%;
  }
  .account-picker {
    min-width: 0;
    width: 100%;
  }
  .account-seal {
    width: 40px;
    height: 46px;
  }
  .selection-heading h2 {
    font-size: 1rem;
  }
  .choice-list {
    min-height: 160px;
    max-height: 320px;
  }
  .routing-save > .error-text {
    grid-column: auto;
  }
}
@media (prefers-reduced-motion: reduce) {
  .choice-row {
    transition: none;
  }
  .choice-row:hover {
    transform: none;
  }
}
