/* Mavynzo (ماوینزو) panel, "Lajvard" world: Isfahan's lapis and turquoise glaze on a
   cool porcelain ground. Lapis owns the shell (the rail), turquoise means sent / on,
   saffron means attention, red means failed. Glazed tiles appear only in the week row
   and the mark. Direction contract: .impeccable/surfaces/web-app-css.md */

@font-face { font-family: 'Vazirmatn'; src: url(/fonts/Vazirmatn-Regular.woff2) format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Vazirmatn'; src: url(/fonts/Vazirmatn-Medium.woff2) format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Vazirmatn'; src: url(/fonts/Vazirmatn-Bold.woff2) format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Vazirmatn'; src: url(/fonts/Vazirmatn-ExtraBold.woff2) format('woff2'); font-weight: 800; font-display: swap; }
@font-face { font-family: 'Sora'; src: url(/fonts/sora-latin-600-normal.woff2) format('woff2'); font-weight: 600; font-display: swap; unicode-range: U+0000-00FF, U+2000-206F; }
@font-face { font-family: 'Sora'; src: url(/fonts/sora-latin-700-normal.woff2) format('woff2'); font-weight: 700; font-display: swap; unicode-range: U+0000-00FF, U+2000-206F; }

:root {
  color-scheme: light;
  /* lapis: the shell */
  --lapis-900: #0f1f4d;
  --lapis-800: #16295e;
  --lapis-700: #1f3a80;
  --lapis-500: #3457b4;
  --lapis-100: #e6ecf7;
  --on-lapis: #e7ecf8;
  --on-lapis-2: #a9b7dd;
  /* turquoise glaze: sent, on, positive */
  --turq-500: #13a5a6;
  --turq-700: #0b6f71;
  --turq-100: #dcf4f2;
  /* saffron: attention, waiting */
  --saffron-500: #d99a12;
  --saffron-800: #6b4a05;
  --saffron-100: #fbf0d6;
  /* red: failed, destructive */
  --red-600: #b8382f;
  --red-100: #f8e4e2;
  /* porcelain ground and ink */
  --porcelain: #f3f6fa;
  --surface: #fbfcfe;
  --sunken: #eef2f8;
  --line: #dde4ef;
  --line-strong: #c9d4e6;
  --ink: #0f1a33;
  --ink-2: #44526e;
  --ink-3: #62708a;
  --backdrop: rgba(15, 31, 77, .42);
  /* type: one family, a short scale; rank by weight and colour */
  --font-fa: 'Vazirmatn', Tahoma, sans-serif;
  --font-latin: 'Sora', 'Vazirmatn', sans-serif;
  --fs-display: clamp(40px, 5.2vw, 64px);
  --fs-title: 26px;
  --fs-head: 16px;
  --fs-body: 15px;
  --fs-small: 13.5px;
  --fs-micro: 12.5px;
  /* shape and depth: controls 10, cards 14, tiles 6 */
  --r-tile: 6px; --r-ctl: 10px; --r-card: 14px; --r-sheet: 20px; --r-chip: 999px;
  --shadow-card: 0 6px 18px -12px rgba(15, 31, 77, .28);
  --shadow-lift: 0 24px 60px -20px rgba(15, 31, 77, .45);
  --ring: 0 0 0 3px rgba(19, 165, 166, .28);
  --ease: cubic-bezier(.23, 1, .32, 1);
  --dur: .28s;
  --dur-fast: .16s;
  --rail-w: 256px;
}

/* ---------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scrollbar-color: var(--line-strong) transparent; }
body {
  margin: 0; min-height: 100dvh; background: var(--porcelain); color: var(--ink);
  font-family: var(--font-fa); font-size: var(--fs-body); line-height: 1.75;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; caret-color: var(--turq-500);
}
::selection { background: var(--turq-100); color: var(--ink); }
body:has(dialog[open]) { overflow: hidden; }
[hidden] { display: none !important; }
h1, h2, h3, p, dl, dd, ul { margin: 0; }
ul { padding: 0; list-style: none; }
h1, h2, h3 { line-height: 1.3; letter-spacing: -.012em; text-wrap: balance; }
a { color: var(--lapis-500); text-decoration: none; text-underline-offset: 3px; }
a:hover { text-decoration: underline; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
img, svg { display: block; max-width: 100%; }
:focus-visible { outline: 2px solid var(--turq-500); outline-offset: 2px; }
.latin { font-family: var(--font-latin); direction: ltr; unicode-bidi: isolate; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.boot { min-height: 100dvh; display: grid; place-content: center; justify-items: center; gap: 14px; color: var(--ink-3); font-size: var(--fs-small); }
.boot-mark { width: 56px; height: 56px; animation: breathe 1.4s var(--ease) infinite alternate; }
@keyframes breathe { from { opacity: .45; } to { opacity: 1; } }

/* ---------------------------------------------------------------- shell: lapis rail + work area */
.shell { display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr); min-height: max(100vh, 100dvh); }
.rail {
  position: sticky; top: 0; height: 100dvh; max-height: 100vh; min-height: 100%; overflow-y: auto; scrollbar-color: var(--lapis-700) transparent;
  display: flex; flex-direction: column; gap: 22px; padding: 24px 16px; background: var(--lapis-800); color: var(--on-lapis);
}
.brand { display: flex; align-items: center; gap: 11px; padding-inline: 6px; color: inherit; border-radius: var(--r-ctl); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 38px; height: 38px; flex: none; }
.brand-text { display: grid; line-height: 1.2; }
.brand-text b { font-size: 21px; font-weight: 800; letter-spacing: -.01em; }
.brand-text small { font-family: var(--font-latin); font-size: 10.5px; font-weight: 600; letter-spacing: .12em; color: var(--on-lapis-2); }

.rail-page { display: grid; gap: 8px; padding: 12px; border-radius: var(--r-card); background: var(--lapis-900); }
.page-switch {
  width: 100%; min-height: 40px; padding: 6px 12px; padding-inline-end: 34px; border-radius: var(--r-ctl);
  border: 1px solid #2b4382; background-color: var(--lapis-800); color: white; font-family: var(--font-latin); font-size: 13.5px; font-weight: 600; direction: ltr; text-align: right;
  appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a9b7dd' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-size: 16px; background-position: left 10px center;
}
.page-switch option { color: var(--ink); background: white; }
.page-switch:focus-visible { outline-color: var(--turq-500); }

.live { display: inline-flex; align-items: center; gap: 8px; font-size: var(--fs-micro); font-weight: 700; color: var(--on-lapis-2); }
.live .dot { width: 8px; height: 8px; border-radius: 2px; transform: rotate(45deg); background: currentColor; flex: none; }
.live.is-on { color: #7fe0db; }
.live.is-warn { color: #f4c95a; }
.live.is-bad { color: #ff9c92; }

.rail-nav { display: grid; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: var(--r-ctl);
  color: #c9d3ee; font-weight: 500; transition: background var(--dur-fast), color var(--dur-fast);
}
.nav-item:hover { background: rgba(255, 255, 255, .06); color: white; text-decoration: none; }
.nav-item[aria-current="page"] { background: rgba(255, 255, 255, .1); color: white; font-weight: 700; }
.nav-item[aria-current="page"] svg { color: #7fe0db; }
.rail-soon { display: grid; gap: 2px; }
.rail-soon p { font-size: 12px; color: #8a9bcb; padding-inline: 12px; margin-bottom: 2px; }
.rail-soon .nav-item { color: #7d8fc1; cursor: default; }
.rail-soon .nav-item:hover { background: none; color: #7d8fc1; }
.soon-tag { margin-inline-start: auto; font-size: 10.5px; border: 1px solid #3a4f8c; border-radius: var(--r-chip); padding: 0 8px; line-height: 1.7; }
.rail-foot { margin-top: auto; padding-inline: 12px; font-size: 12px; color: #8a9bcb; overflow-wrap: anywhere; }

.work { min-width: 0; }
.main { width: min(100% - 48px, 1160px); margin-inline: auto; padding-block: 28px 56px; }
.main:focus { outline: none; }
.wrap { width: min(100% - 32px, 1120px); margin-inline: auto; }
.bottomnav, .mobilebar { display: none; }

@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail { display: none; }
  .mobilebar {
    display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 40;
    padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px; background: var(--lapis-800); color: var(--on-lapis);
  }
  .mobilebar .brand-text small { display: none; }
  .mobilebar .brand-mark { width: 32px; height: 32px; }
  .mobilebar .page-switch { width: auto; max-width: 46vw; margin-inline-start: auto; min-height: 36px; }
  .main { width: min(100% - 32px, 1160px); padding-block: 20px calc(100px + env(safe-area-inset-bottom, 0px)); }
  .bottomnav {
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px;
    position: fixed; inset: auto 0 0 0; z-index: 40; padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));
    background: var(--lapis-800);
  }
  .bn { display: grid; justify-items: center; gap: 2px; padding: 6px 4px 4px; border-radius: var(--r-ctl); color: #9fb0da; font-size: 11.5px; font-weight: 700; line-height: 1.5; }
  .bn:hover { text-decoration: none; }
  .bn svg { width: 40px; height: 28px; padding: 3px 9px; border-radius: var(--r-chip); transition: background var(--dur-fast); }
  .bn[aria-current="page"] { color: white; }
  .bn[aria-current="page"] svg { background: rgba(127, 224, 219, .2); color: #7fe0db; }
}

/* ---------------------------------------------------------------- page structure */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px 20px; margin-bottom: 22px; }
.page-head h1 { font-size: var(--fs-title); font-weight: 800; color: var(--lapis-800); }
.page-head p { color: var(--ink-2); font-size: 14.5px; margin-top: 4px; max-width: 62ch; }
.head-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.stack { display: grid; gap: 18px; }
.split { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 900px) { .split { grid-template-columns: minmax(0, 1fr); } }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 20px; min-width: 0; box-shadow: var(--shadow-card); }
.card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; margin-bottom: 14px; }
.card-head h2 { font-size: var(--fs-head); font-weight: 800; }
.card-head .link { font-size: var(--fs-small); font-weight: 700; }
.hint { font-size: var(--fs-micro); color: var(--ink-3); line-height: 1.75; }
.hint code, .code {
  font-family: var(--font-latin); font-size: 12px; direction: ltr; unicode-bidi: isolate; color: var(--lapis-700);
  background: var(--lapis-100); border-radius: 5px; padding: 1px 6px;
}
.code-block {
  display: block; overflow-x: auto; white-space: pre; font-family: var(--font-latin); font-size: 12px; direction: ltr; text-align: left;
  background: var(--lapis-900); color: #dbe3f6; border-radius: var(--r-ctl); padding: 10px 12px; margin-top: 10px;
}

/* ---------------------------------------------------------------- controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 9px 18px;
  border-radius: var(--r-ctl); border: 1px solid transparent; font-size: 14.5px; font-weight: 700; line-height: 1; white-space: nowrap;
  transition: transform var(--dur-fast) var(--ease), background var(--dur-fast), border-color var(--dur-fast), opacity var(--dur-fast);
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--lapis-800); color: white; }
.btn-primary:hover { background: var(--lapis-700); }
.btn-ghost { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.btn-ghost:hover { background: var(--lapis-100); border-color: #b7c5df; }
.btn-danger { background: var(--red-100); border-color: #efc5c0; color: var(--red-600); }
.btn-danger.is-armed, .btn-danger:hover { background: var(--red-600); border-color: var(--red-600); color: white; }
.btn-sm { min-height: 36px; padding: 7px 14px; font-size: var(--fs-small); }
.btn-lg { min-height: 50px; padding: 13px 26px; font-size: 16px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-icon {
  display: inline-grid; place-items: center; width: 36px; height: 36px; flex: none; padding: 0;
  border-radius: var(--r-ctl); border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  transition: background var(--dur-fast), border-color var(--dur-fast), color var(--dur-fast), transform var(--dur-fast) var(--ease);
}
.btn-icon:hover { background: var(--lapis-100); color: var(--lapis-800); }
.btn-icon:active { transform: scale(.94); }
.btn-icon:disabled { opacity: .35; cursor: default; background: transparent; }
.btn-icon.is-armed { background: var(--red-600); border-color: var(--red-600); color: white; }

.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: var(--r-chip); white-space: nowrap;
  background: var(--sunken); color: var(--ink-2); font-size: 12px; font-weight: 700; line-height: 1.7;
}
.badge svg { width: 12px; height: 12px; stroke-width: 3; }
.t-green { background: var(--turq-100); color: var(--turq-700); }
.t-gold { background: var(--saffron-100); color: var(--saffron-800); }
.t-red { background: var(--red-100); color: var(--red-600); }

/* rule code: a small glazed tile with the rule's catalog number, same colour everywhere */
.rcode {
  display: inline-grid; place-items: center; flex: none; width: 24px; height: 24px; border-radius: 5px;
  color: white; font-size: 11.5px; font-weight: 800; position: relative; overflow: hidden;
}
.rcode::before { content: ""; position: absolute; inset: 0; background: radial-gradient(120% 90% at 25% 15%, rgba(255, 255, 255, .35), transparent 55%); }
.rcode span { position: relative; }
.rcode.lg { width: 32px; height: 32px; font-size: 13px; border-radius: 7px; }
.rc0 { background: var(--turq-500); } .rc1 { background: var(--lapis-500); } .rc2 { background: #c98a0c; }
.rc3 { background: #7b5ea7; } .rc4 { background: #2f86b9; }
.rcode.off { background: #9aa4b8; }

.switch {
  position: relative; flex: none; width: 46px; height: 26px; padding: 0; border-radius: var(--r-chip);
  border: 0; background: #c3cddd; transition: background var(--dur-fast);
}
.switch::after {
  content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: white; box-shadow: 0 1px 3px rgba(15, 31, 77, .3); transition: inset-inline-start var(--dur) var(--ease);
}
.switch[aria-checked="true"] { background: var(--turq-500); }
.switch[aria-checked="true"]::after { inset-inline-start: 23px; }
.switch:disabled { opacity: .55; cursor: wait; }
.switch-lg { width: 58px; height: 32px; }
.switch-lg::after { width: 26px; height: 26px; }
.switch-lg[aria-checked="true"]::after { inset-inline-start: 29px; }

.field { display: grid; gap: 7px; min-width: 0; }
.label { font-weight: 700; font-size: 14px; }
.label small { font-weight: 400; color: var(--ink-3); font-size: var(--fs-micro); }
/* Each line takes its direction from its own first letter (a URL line stays LTR inside
   Persian text), while alignment follows the page. Covers placeholders too. */
.input, .chips-input input, .ev-text, .dmtext, .bubble, .cap, .target-cap, .ev-error, .proof-dm { unicode-bidi: plaintext; }
.input {
  width: 100%; min-height: 46px; padding: 10px 13px; font-size: 16px; line-height: 1.6;
  background: white; border: 1px solid var(--line-strong); border-radius: var(--r-ctl); color: var(--ink); outline: none;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.input:focus { border-color: var(--turq-500); box-shadow: var(--ring); }
.input::placeholder { color: var(--ink-3); opacity: .8; }
.input[aria-invalid="true"] { border-color: var(--red-600); }
textarea.input { resize: vertical; min-height: 104px; line-height: 1.8; }
.input.mono { font-family: var(--font-latin); font-size: 13px; direction: ltr; text-align: left; word-break: break-all; }
select.input {
  appearance: none; padding-inline-end: 38px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2362708a' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-size: 18px; background-position: left 13px center;
}
.form-error { color: var(--red-600); font-size: var(--fs-small); font-weight: 500; }

.seg { display: flex; flex-wrap: wrap; gap: 4px; width: fit-content; max-width: 100%; padding: 4px; border-radius: var(--r-ctl); background: var(--sunken); }
.seg button { border: 0; background: transparent; color: var(--ink-2); padding: 7px 14px; border-radius: 7px; font-size: var(--fs-small); font-weight: 700; transition: background var(--dur-fast), color var(--dur-fast); }
.seg button:hover { color: var(--ink); }
.seg button[aria-checked="true"] { background: white; color: var(--lapis-800); box-shadow: 0 1px 3px rgba(15, 31, 77, .15); }

.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { padding: 6px 14px; border-radius: var(--r-chip); border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); font-size: var(--fs-small); font-weight: 700; transition: background var(--dur-fast), color var(--dur-fast), border-color var(--dur-fast); }
.pill:hover { color: var(--ink); border-color: var(--line-strong); }
.pill[aria-pressed="true"] { background: var(--lapis-800); border-color: var(--lapis-800); color: white; }

.kw { display: inline-flex; align-items: center; gap: 4px; padding: 2px 11px; border-radius: var(--r-chip); background: var(--lapis-100); color: var(--lapis-800); font-size: var(--fs-small); font-weight: 500; max-width: 100%; overflow-wrap: anywhere; }
.kw-any { background: var(--saffron-100); color: var(--saffron-800); font-weight: 700; }
.kw button { display: grid; place-items: center; width: 20px; height: 20px; margin-inline-end: -6px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--ink-3); }
.kw button:hover { color: var(--ink); background: rgba(15, 31, 77, .08); }

/* ---------------------------------------------------------------- banners and empty states */
.banner { display: flex; align-items: flex-start; gap: 12px; padding: 13px 16px; border-radius: var(--r-card); background: var(--saffron-100); color: var(--saffron-800); }
.banner > svg { color: var(--saffron-500); margin-top: 3px; flex: none; }
.banner-red { background: var(--red-100); color: #7a2620; }
.banner-red > svg { color: var(--red-600); }
.banner-body { flex: 1; min-width: 0; }
.banner-body b { display: block; font-size: 14.5px; color: inherit; }
.banner-body p { font-size: var(--fs-small); overflow-wrap: anywhere; }
.banner-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

.empty { display: grid; justify-items: center; gap: 10px; padding: 32px 16px; text-align: center; color: var(--ink-3); }
.empty b { color: var(--ink); font-size: 16px; }
.empty p { max-width: 46ch; font-size: 14px; }
.ico-box { display: grid; place-items: center; width: 50px; height: 50px; border-radius: var(--r-ctl); background: var(--turq-100); color: var(--turq-700); }
.ico-box.is-red { background: var(--red-100); color: var(--red-600); }

.sk { display: block; border-radius: var(--r-card); background: linear-gradient(90deg, #e7ecf4, #f1f4f9, #e7ecf4); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
.sk-card { height: 132px; }
.sk-kpi { height: 104px; }
.sk-chart { height: 300px; }
.sk-hero { height: 150px; }
.sk-tiles { height: 120px; }
.sk-line { height: 72px; border-radius: var(--r-ctl); margin-block: 8px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------------------------------------------------------------- dashboard */
.today { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 28px; align-items: end; }
@media (max-width: 1000px) { .today { grid-template-columns: minmax(0, 1fr); gap: 18px; } }
.lead h2 { font-size: var(--fs-display); font-weight: 800; line-height: 1.08; letter-spacing: -.02em; color: var(--lapis-800); }
.lead h2 em { font-style: normal; color: var(--turq-500); }
.lead .facts { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 12px; color: var(--ink-2); font-size: 15px; }
.lead .facts b { color: var(--ink); font-weight: 700; }
.lead .facts .bad b { color: var(--red-600); }

.proof { display: grid; gap: 8px; padding: 16px 18px; border-radius: var(--r-card); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-card); min-width: 0; }
.proof-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; font-size: var(--fs-micro); color: var(--ink-3); }
.proof-c { font-size: 15px; overflow-wrap: anywhere; }
.proof-c bdi { font-weight: 700; }
.proof-dm {
  justify-self: start; max-width: 100%; padding: 9px 13px; border-radius: 14px 14px 14px 4px; background: var(--turq-100); color: #0a4f50;
  font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.proof.is-empty { color: var(--ink-3); font-size: 14px; }

.week-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.week-head h2 { font-size: var(--fs-head); font-weight: 800; }
.week-head span { font-size: var(--fs-small); color: var(--ink-3); }
.tiles { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; padding: 4px; border-radius: var(--r-ctl); background: var(--line-strong); }
.tile {
  position: relative; display: grid; align-content: end; height: 112px; padding: 10px 12px; border-radius: var(--r-tile);
  color: white; overflow: hidden; background: var(--lapis-500);
}
.tile::before { content: ""; position: absolute; inset: 0; background: radial-gradient(120% 90% at 25% 15%, rgba(255, 255, 255, .36), transparent 55%); pointer-events: none; }
.tile b { position: relative; font-size: 32px; font-weight: 800; line-height: 1; }
.tile span { position: relative; font-size: 12px; opacity: .88; }
.tile.zero { background: #aab6cd; }
.tile.today { outline: 3px solid var(--saffron-500); outline-offset: -3px; }
@media (max-width: 600px) {
  .tile { height: 84px; padding: 8px 7px; }
  .tile b { font-size: 22px; }
  .tile span { font-size: 10.5px; }
}

.dash-cols { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 22px; align-items: start; }
@media (max-width: 1000px) { .dash-cols { grid-template-columns: minmax(0, 1fr); } }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 10px; }
.section-head h2 { font-size: var(--fs-head); font-weight: 800; }
.section-head a { font-size: var(--fs-small); font-weight: 700; }

.master { display: inline-flex; align-items: center; gap: 12px; padding: 7px 8px 7px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); font-weight: 700; font-size: 14px; }
.master.is-off { color: var(--ink-2); }
.checked-at { font-size: var(--fs-small); color: var(--ink-3); }

.top-rules { display: grid; gap: 8px; }
.top-rule { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 14px; border-radius: var(--r-card); background: var(--surface); border: 1px solid var(--line); }
.top-rule.is-off { opacity: .6; }
.top-name { font-weight: 700; font-size: 14.5px; line-height: 1.4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-sub { font-size: 12.5px; color: var(--ink-3); }
.top-count { text-align: left; line-height: 1.15; }
.top-count b { display: block; font-size: 22px; font-weight: 800; color: var(--lapis-800); }
.top-count span { font-size: 11.5px; color: var(--ink-3); }

/* ---------------------------------------------------------------- activity feed */
.feed { display: grid; }
.card .feed, .rows .feed { margin: 0; }
.rows { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 4px 16px; box-shadow: var(--shadow-card); }
.ev { display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 12px; padding-block: 13px; border-top: 1px solid var(--line); }
.ev:first-child { border-top: 0; }
.feed.compact .ev { padding-block: 11px; }
.avatar { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 9px; font-weight: 800; font-size: 14px; font-family: var(--font-latin); }
.av0 { background: var(--turq-100); color: var(--turq-700); }
.av1 { background: var(--saffron-100); color: var(--saffron-800); }
.av2 { background: var(--lapis-100); color: var(--lapis-700); }
.av3 { background: #efe7f7; color: #5d4386; }
.av4 { background: var(--sunken); color: var(--ink-2); }
.ev-top { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.ev-user { font-weight: 700; font-size: 14px; overflow-wrap: anywhere; }
.ev-time { font-size: var(--fs-micro); color: var(--ink-3); }
.ev-status { margin-inline-start: auto; }
.ev-text { margin-top: 2px; font-size: 14.5px; line-height: 1.75; text-align: right; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.feed.compact .ev-text { -webkit-line-clamp: 2; font-size: 14px; color: var(--ink-2); }
.ev-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin-top: 6px; font-size: var(--fs-micro); color: var(--ink-3); }
.ev-meta b { color: var(--ink); font-weight: 700; }
.ev-rule { display: inline-flex; align-items: center; gap: 6px; }
.ev-rule .rcode { width: 20px; height: 20px; font-size: 10.5px; border-radius: 4px; }
.ev-error { margin-top: 6px; font-size: var(--fs-micro); color: var(--red-600); overflow-wrap: anywhere; }
.ev-actions { margin-top: 10px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 16px; }
.search { position: relative; flex: 1 1 220px; max-width: 360px; }
.search .input { min-height: 40px; padding-inline-start: 40px; font-size: 15px; }
.search svg { position: absolute; inset-inline-start: 13px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.more { display: flex; justify-content: center; margin-top: 14px; }

/* ---------------------------------------------------------------- rules */
.rules { display: grid; gap: 14px; }
.rule { display: grid; gap: 14px; transition: border-color var(--dur-fast); }
.rule:hover { border-color: var(--line-strong); }
.rule-head { display: flex; align-items: center; gap: 12px; }
.rule-head h3 { flex: 1; min-width: 0; font-size: 16.5px; font-weight: 800; overflow-wrap: anywhere; }
.rule-actions { display: flex; gap: 6px; }
.rule.is-off .rule-body { opacity: .6; }
.rule-body { display: grid; gap: 12px; transition: opacity var(--dur-fast); }
.rule-row { display: grid; grid-template-columns: 64px minmax(0, 1fr); align-items: center; gap: 12px; font-size: var(--fs-small); }
.rule-row.top { align-items: start; }
.rule-row > .k { color: var(--ink-3); }
.kws { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.target { display: flex; align-items: center; gap: 10px; min-width: 0; }
.target-cap { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thumb { width: 42px; height: 42px; flex: none; border-radius: var(--r-ctl); object-fit: cover; background: var(--sunken); }
.thumb.ph, .target-all { display: grid; place-items: center; width: 42px; height: 42px; flex: none; border-radius: var(--r-ctl); background: var(--sunken); color: var(--ink-3); }
.dmtext {
  padding: 9px 13px; border-radius: 14px 14px 14px 4px; background: var(--turq-100); color: #0a4f50; justify-self: start;
  font-size: 14px; line-height: 1.75; white-space: pre-wrap; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.stats { display: flex; flex-wrap: wrap; gap: 4px 16px; padding-top: 12px; border-top: 1px solid var(--line); font-size: var(--fs-micro); color: var(--ink-3); }
.stats b { color: var(--ink); font-weight: 700; }
@media (max-width: 520px) {
  .rule-row { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .rule-head { flex-wrap: wrap; }
  .rule-head h3 { flex-basis: calc(100% - 100px); }
  .rule-actions { width: 100%; justify-content: flex-end; }
}

.tester form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 220px) auto; gap: 10px; }
@media (max-width: 700px) { .tester form { grid-template-columns: minmax(0, 1fr); } }
.test-out { display: grid; gap: 4px; margin-top: 14px; }
.test-out:empty { display: none; }
.test-hit, .test-miss { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14.5px; }
.test-hit { color: var(--turq-700); }
.test-miss { color: var(--ink-3); }

/* ---------------------------------------------------------------- rule editor */
dialog.sheet {
  width: min(100% - 24px, 760px); max-width: 100%; max-height: min(92dvh, 960px); padding: 0;
  border: 0; border-radius: var(--r-sheet); background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-lift); overflow: hidden;
}
dialog.sheet[open] { display: flex; flex-direction: column; animation: sheetIn var(--dur) var(--ease); }
dialog.sheet::backdrop { background: var(--backdrop); }
@keyframes sheetIn { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
.sheet form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 22px; border-bottom: 1px solid var(--line); }
.sheet-head h2 { font-size: 18px; font-weight: 800; color: var(--lapis-800); }
.sheet-body { display: grid; gap: 22px; padding: 22px; overflow-y: auto; overscroll-behavior: contain; }
.sheet-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--line); background: var(--porcelain); }
.sheet-foot .form-error { flex: 1 1 200px; }
.sheet-foot .spacer { flex: 1; }
@media (max-width: 600px) {
  dialog.sheet { width: 100%; margin: auto 0 0; border-radius: var(--r-sheet) var(--r-sheet) 0 0; max-height: 94dvh; padding-bottom: env(safe-area-inset-bottom, 0px); }
  .sheet-body { padding: 18px 16px; }
  .sheet-head, .sheet-foot { padding-inline: 16px; }
}
.two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
@media (max-width: 600px) { .two { grid-template-columns: minmax(0, 1fr); } }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.toggle-row { display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; border-radius: var(--r-ctl); background: var(--porcelain); border: 1px solid var(--line); }
.toggle-row .switch { margin-top: 2px; }
.toggle-row b { display: block; font-size: 14px; }

.chips-input {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 46px; padding: 6px 8px; cursor: text;
  background: white; border: 1px solid var(--line-strong); border-radius: var(--r-ctl);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.chips-input:focus-within { border-color: var(--turq-500); box-shadow: var(--ring); }
.chips-input input { flex: 1 1 140px; min-width: 0; border: 0; outline: 0; background: transparent; padding: 6px 4px; font-size: 16px; }

.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; max-height: 330px; overflow-y: auto; padding: 3px; }
.media {
  position: relative; display: grid; align-content: start; gap: 6px; padding: 6px; text-align: start;
  border-radius: var(--r-ctl); border: 1.5px solid var(--line); background: white; color: var(--ink);
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}
.media:hover { border-color: var(--line-strong); }
.media[aria-checked="true"] { border-color: var(--turq-500); box-shadow: var(--ring); }
.media-img { width: 100%; aspect-ratio: 1; max-width: 100%; object-fit: cover; border-radius: 7px; background: var(--sunken); }
.media-img.ph { display: grid; place-items: center; color: var(--ink-3); }
.media .cap { font-size: 12px; line-height: 1.6; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.media .when { font-size: 11.5px; color: var(--ink-3); }
.media .media-type { position: absolute; top: 11px; inset-inline-end: 11px; background: rgba(255, 255, 255, .92); }
.media .tick { position: absolute; top: 11px; inset-inline-start: 11px; display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--turq-500); color: white; opacity: 0; transform: scale(.6); transition: opacity var(--dur-fast), transform var(--dur) var(--ease); }
.media .tick svg { stroke-width: 3; }
.media[aria-checked="true"] .tick { opacity: 1; transform: none; }

.counter { font-size: var(--fs-micro); color: var(--ink-3); }
.counter.warn { color: var(--saffron-800); }
.counter.over { color: var(--red-600); font-weight: 700; }
.preview { display: grid; gap: 10px; padding: 14px; border-radius: var(--r-card); background: var(--porcelain); border: 1px solid var(--line); }
.preview-head { display: flex; align-items: center; gap: 8px; font-size: var(--fs-micro); color: var(--ink-3); }
.preview-head .mini { width: 26px; height: 26px; display: grid; place-items: center; }
.preview-head .mini svg { width: 24px; height: 24px; }
.bubble {
  width: fit-content; max-width: min(92%, 420px); padding: 10px 14px; border-radius: 18px; border-end-start-radius: 6px;
  background: white; border: 1px solid var(--line); font-size: 14px; line-height: 1.75; white-space: pre-wrap; overflow-wrap: anywhere;
}
.bubble.is-empty { color: var(--ink-3); }
.replies { display: grid; gap: 8px; }
.reply-row { display: flex; align-items: center; gap: 8px; }
.reply-row .input { min-height: 44px; }

/* ---------------------------------------------------------------- settings */
.settings { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.settings .wide { grid-column: 1 / -1; }
@media (max-width: 900px) { .settings { grid-template-columns: minmax(0, 1fr); } }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 10px 18px; font-size: 14px; }
.kv dt { color: var(--ink-3); }
.kv dd { font-weight: 500; overflow-wrap: anywhere; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.card-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.limits { display: grid; gap: 11px; }
.limits li { display: flex; gap: 10px; font-size: 14px; color: var(--ink-2); }
.limits li svg { color: var(--turq-500); margin-top: 5px; flex: none; }
.limits b { color: var(--ink); }
form.stack-form { display: grid; gap: 12px; }
.connect { display: grid; gap: 10px; justify-items: start; min-width: 0; }
.connect .code-block { margin-top: 0; width: 100%; }
.manual { border-top: 1px solid var(--line); padding-top: 14px; }
.manual summary { cursor: pointer; font-size: var(--fs-small); font-weight: 700; color: var(--ink-2); width: fit-content; border-radius: 5px; }
.manual summary:hover { color: var(--ink); }
.manual[open] summary { margin-bottom: 12px; }

/* ---------------------------------------------------------------- login: the lapis field with a porcelain card */
.login {
  min-height: max(100vh, 100dvh); display: grid; place-items: center; background: var(--lapis-800);
  padding: calc(28px + env(safe-area-inset-top, 0px)) 16px calc(28px + env(safe-area-inset-bottom, 0px));
}
.login > div { width: min(100%, 420px); }
.login-card { width: 100%; display: grid; gap: 18px; padding: 32px 28px; border-radius: var(--r-sheet); background: var(--surface); box-shadow: 0 30px 80px -30px rgba(0, 0, 0, .6); }
.login-card .brand-mark { width: 48px; height: 48px; }
.login-card h1 { font-size: 26px; font-weight: 800; color: var(--lapis-800); }
.login-card .sub { color: var(--ink-2); font-size: 14px; margin-top: 2px; }
.login-tiles { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; margin-top: 18px; }
.login-tiles i { height: 10px; border-radius: 2px; background: var(--lapis-700); }
.login-tiles i:nth-child(3n) { background: var(--turq-500); }
.login-tiles i:nth-child(7) { background: var(--saffron-500); }
.pw { position: relative; }
.pw .input { padding-inline-end: 52px; }
.pw .btn-icon { position: absolute; inset-inline-end: 5px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--ink-3); }
.pw .btn-icon:hover { color: var(--ink); background: var(--sunken); }

/* connect screen (a user without pages) */
.bare { min-height: 100dvh; }
.bare .mobilebar { display: flex; position: static; }

/* ---------------------------------------------------------------- toasts */
.toasts { position: fixed; inset-inline: 0; bottom: calc(22px + env(safe-area-inset-bottom, 0px)); z-index: 100; display: grid; justify-items: center; gap: 8px; padding-inline: 16px; pointer-events: none; }
@media (max-width: 900px) { .toasts { bottom: calc(88px + env(safe-area-inset-bottom, 0px)); } }
.toast {
  display: flex; align-items: center; gap: 10px; max-width: min(540px, 100%); padding: 10px 16px; pointer-events: auto;
  border-radius: 12px; background: var(--lapis-900); color: white; box-shadow: var(--shadow-lift);
  font-size: 14px; font-weight: 500; animation: toastIn .3s var(--ease);
}
.toast svg { color: #7fe0db; flex: none; }
.toast.is-error { background: #5c1d18; }
.toast.is-error svg { color: #ff9c92; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
