@font-face {
  font-family: "Vazirmatn";
  src: url("./fonts/vazirmatn-arabic.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF;
}
@font-face {
  font-family: "Vazirmatn";
  src: url("./fonts/vazirmatn-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #f4f1e9;
  --bg-strong: #ebe4d6;
  --surface: #fffdf8;
  --surface-2: #f8f4eb;
  --surface-3: #eee7da;
  --ink: #1a2a25;
  --ink-soft: #344740;
  --muted: #6c7b75;
  --line: #ded6c7;
  --line-strong: #c9bfad;
  --brand: #1d5a49;
  --brand-strong: #123f33;
  --brand-soft: #e4f0ea;
  --gold: #b57d2d;
  --gold-soft: #f6ecd8;
  --danger: #b2453d;
  --danger-soft: #fae7e4;
  --info: #2f6f8f;
  --info-soft: #e6f1f6;
  --success: #2c7259;
  --success-soft: #e3f1ea;
  --warning: #a16a17;
  --warning-soft: #f8efd9;
  --shadow: 0 22px 55px -34px rgba(22, 45, 38, 0.45);
  --shadow-soft: 0 10px 30px -24px rgba(22, 45, 38, 0.4);
  --radius: 18px;
  --radius-sm: 12px;
  --font: "Vazirmatn", "Noto Sans Arabic", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 8% 0%, rgba(181, 125, 45, 0.07), transparent 28rem),
    radial-gradient(circle at 92% 4%, rgba(29, 90, 73, 0.08), transparent 30rem),
    var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
body.no-scroll { overflow: hidden; }
::selection { background: var(--brand); color: #fff; }
:focus-visible { outline: 3px solid rgba(29, 90, 73, 0.35); outline-offset: 2px; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
img { max-width: 100%; }
[hidden] { display: none !important; }
bdi, code, .ltr { direction: ltr; unicode-bidi: isolate; }
.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;
}

/* ---------- shell ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 12px clamp(16px, 4vw, 40px);
  background: rgba(244, 241, 233, 0.86);
  backdrop-filter: blur(14px);
  border-block-end: 1px solid rgba(201, 191, 173, 0.55);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  min-width: max-content;
}
.brand img { width: 38px; height: 38px; object-fit: contain; }
.brand-copy { display: grid; line-height: 1.25; }
.brand-copy strong { font-size: 14px; font-weight: 800; }
.brand-copy small { color: var(--muted); font-size: 10.5px; letter-spacing: 0.01em; }
.main-nav { display: flex; align-items: center; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.nav-link {
  border: 0; background: transparent; color: var(--muted);
  padding: 7px 16px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px;
}
.nav-link[aria-current="page"] { background: var(--brand); color: #fff; }
.nav-link:hover:not([aria-current="page"]) { color: var(--ink); background: var(--surface-2); }
.top-actions { margin-inline-start: auto; display: flex; align-items: center; gap: 8px; }
.sync-state { color: var(--muted); font-size: 10.5px; white-space: nowrap; }
.icon-button, .ghost-button, .primary-button, .soft-button {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-soft);
  min-height: 34px;
  padding: 6px 13px;
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  transition: background .18s, border-color .18s, color .18s, transform .18s;
}
.icon-button { width: 34px; padding: 0; }
.primary-button { background: var(--brand); border-color: var(--brand); color: #fff; }
.primary-button:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
.soft-button { background: var(--brand-soft); border-color: transparent; color: var(--brand-strong); }
.ghost-button:hover, .icon-button:hover { background: var(--surface-2); border-color: var(--line-strong); }
.soft-button:hover { background: #d9eae3; }
button:disabled { opacity: .5; cursor: not-allowed; }
.logout-form { display: inline-flex; margin: 0; }
.logout-button { background: transparent; border-color: transparent; color: var(--muted); }
.logout-button:hover { background: var(--surface-2); border-color: var(--line); }

.page { width: min(1440px, 100%); margin-inline: auto; padding: 22px clamp(14px, 3.4vw, 38px) 56px; }

/* ---------- hero ---------- */
.hero {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(300px, 0.85fr);
  gap: 28px;
  padding: clamp(22px, 3.2vw, 40px);
  border-radius: 28px;
  background:
    radial-gradient(circle at 90% 18%, rgba(197, 149, 77, 0.28), transparent 18rem),
    radial-gradient(circle at 8% 110%, rgba(255, 255, 255, 0.12), transparent 22rem),
    linear-gradient(135deg, #1c5848, #123f33 62%, #0e342a);
  color: #fdfaf2;
  box-shadow: 0 28px 70px -40px rgba(12, 44, 35, 0.75);
}
.hero::after {
  content: "";
  position: absolute;
  inset-inline-end: -70px;
  inset-block-start: -90px;
  width: 280px;
  height: 280px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 50%;
  box-shadow: 0 0 0 38px rgba(255, 255, 255, 0.035), 0 0 0 78px rgba(255, 255, 255, 0.025);
  pointer-events: none;
}
.hero-copy { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: flex-start; gap: 12px; }
.eyebrow { display: inline-flex; align-items: center; gap: 7px; padding: 4px 10px; border: 1px solid rgba(255, 255, 255, 0.18); border-radius: 999px; color: rgba(255, 250, 240, 0.8); font-size: 10.5px; }
.eyebrow .dot { width: 6px; height: 6px; border-radius: 50%; background: #e8b96a; box-shadow: 0 0 0 4px rgba(232, 185, 106, 0.15); }
.hero h1 { margin: 0; font-size: clamp(24px, 3.1vw, 38px); line-height: 1.35; letter-spacing: -0.01em; }
.hero p { margin: 0; max-width: 52ch; color: rgba(255, 250, 240, 0.72); font-size: 13.5px; line-height: 1.9; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-block-start: 4px; }
.hero .primary-button { background: #f2e6cf; border-color: #f2e6cf; color: #123f33; }
.hero .primary-button:hover { background: #fff8ea; border-color: #fff8ea; }
.hero .ghost-button { background: rgba(255, 255, 255, 0.07); border-color: rgba(255, 255, 255, 0.2); color: #fffaf0; }
.hero .ghost-button:hover { background: rgba(255, 255, 255, 0.13); border-color: rgba(255, 255, 255, 0.3); }
.hero-stats { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; align-content: center; }
.stat {
  appearance: none;
  display: grid;
  gap: 2px;
  text-align: start;
  padding: 14px;
  border-radius: 15px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  background: rgba(255, 255, 255, 0.075);
  color: #fffaf0;
  transition: background .18s, transform .18s, border-color .18s;
}
.stat:hover { background: rgba(255, 255, 255, 0.13); border-color: rgba(255, 255, 255, 0.22); transform: translateY(-2px); }
.stat b { font-size: 24px; line-height: 1.2; font-weight: 800; }
.stat span { font-size: 10.5px; color: rgba(255, 250, 240, 0.68); }
.stat small { font-size: 9.5px; color: rgba(255, 250, 240, 0.5); }

/* ---------- library layout ---------- */
.library-layout { display: grid; grid-template-columns: 238px minmax(0, 1fr); gap: 22px; margin-block-start: 24px; align-items: start; }
.filters-toggle { display: none; }
.filters {
  position: sticky;
  top: 78px;
  display: grid;
  gap: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, 0.88);
  box-shadow: var(--shadow-soft);
}
.filter-group { display: grid; gap: 7px; }
.filter-group h2, .filter-group h3 { margin: 0; font-size: 11px; color: var(--muted); font-weight: 700; letter-spacing: .01em; }
.kind-list { display: grid; gap: 3px; }
.kind-button {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border: 0; border-radius: 9px; padding: 7px 9px; background: transparent;
  color: var(--ink-soft); font-size: 12px; text-align: start;
}
.kind-button:hover { background: var(--surface-2); }
.kind-button[aria-pressed="true"] { background: var(--brand-soft); color: var(--brand-strong); font-weight: 700; }
.kind-button .count { color: var(--muted); font-size: 10.5px; font-variant-numeric: tabular-nums; }
.kind-button[aria-pressed="true"] .count { color: var(--brand); }
.filter-select, .search-input, .toolbar select, .flow-toolbar select, .flow-toolbar input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  padding: 6px 10px;
  font-size: 12px;
}
.filter-select:focus, .search-input:focus, .toolbar select:focus { border-color: var(--brand); }
.check-row { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--ink-soft); }
.check-row input { accent-color: var(--brand); width: 15px; height: 15px; }
.clear-filters { justify-self: start; border: 0; background: transparent; color: var(--brand); font-size: 11px; font-weight: 700; padding: 0; }
.clear-filters:hover { text-decoration: underline; }
.filter-note { margin: 0; color: var(--muted); font-size: 10px; line-height: 1.8; }

.library-main { min-width: 0; display: grid; gap: 14px; }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.search-box { position: relative; flex: 1 1 280px; min-width: 220px; }
.search-box svg { position: absolute; inset-inline-start: 12px; inset-block-start: 50%; translate: 0 -50%; width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.search-box .search-input { min-height: 42px; padding-inline-start: 38px; border-radius: 12px; background: var(--surface); }
.toolbar select { width: auto; min-width: 130px; min-height: 40px; }
.segmented { display: inline-flex; padding: 3px; gap: 2px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.segmented button { border: 0; border-radius: 7px; background: transparent; color: var(--muted); padding: 6px 9px; display: inline-flex; align-items: center; justify-content: center; gap: 5px; font-size: 11px; }
.segmented button[aria-pressed="true"] { background: var(--surface-3); color: var(--ink); }
.active-filters { display: flex; flex-wrap: wrap; gap: 6px; min-height: 0; }
.filter-chip { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 3px 9px; font-size: 10.5px; color: var(--muted); }
.filter-chip button { border: 0; background: transparent; color: inherit; padding: 0; line-height: 1; }
.context-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 13px; border: 1px solid #c8e2d6; border-radius: 11px; background: var(--success-soft); color: #1e5743; font-size: 11px; }
.context-banner strong { font-size: 12px; }
.context-banner .ghost-button { border-color: #b7d8c8; color: #1e5743; background: rgba(255, 255, 255, .5); }
.result-line { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 11px; }
.result-line strong { color: var(--ink); font-size: 13px; }

/* ---------- cards ---------- */
.object-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(238px, 1fr)); gap: 16px; }
.object-card {
  display: flex; flex-direction: column; min-width: 0;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow-soft);
  overflow: hidden;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}
.object-card:hover { transform: translateY(-3px); border-color: var(--line-strong); box-shadow: var(--shadow); }
.object-card:focus-within { outline: 3px solid rgba(29, 90, 73, 0.28); outline-offset: 2px; }
.card-media {
  position: relative; display: block; width: 100%; padding: 0; border: 0;
  aspect-ratio: 16 / 10; background: linear-gradient(135deg, var(--surface-2), var(--surface-3));
  overflow: hidden; text-align: start;
}
.card-media img { position: relative; z-index: 1; width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .35s ease; }
.object-card:hover .card-media img { transform: scale(1.025); }
.card-media .placeholder {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: var(--brand); background:
    radial-gradient(circle at 25% 20%, rgba(29, 90, 73, .14), transparent 45%),
    linear-gradient(140deg, var(--surface-2), var(--brand-soft));
  font-size: 28px; font-weight: 800;
}
.media-top { position: absolute; z-index: 2; inset-block-start: 10px; inset-inline: 10px; display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.media-top .badge { backdrop-filter: blur(6px); }
.code-badge { font-family: var(--font); font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.card-body { display: flex; flex-direction: column; gap: 8px; padding: 14px; flex: 1; }
.card-title-row { display: flex; align-items: start; justify-content: space-between; gap: 8px; }
.card-title { margin: 0; font-size: 14px; line-height: 1.55; font-weight: 750; }
.card-title button { border: 0; background: transparent; padding: 0; color: inherit; text-align: start; font: inherit; }
.card-title button:hover { color: var(--brand); }
.card-sub { display: flex; flex-wrap: wrap; gap: 5px 9px; color: var(--muted); font-size: 10.5px; }
.card-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; margin-block-start: auto; }
.tag-list { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); font-size: 9.5px; padding: 1px 7px; }
.card-actions { display: flex; align-items: center; gap: 5px; padding-block-start: 3px; }
.card-actions .icon-button { width: 30px; min-height: 30px; }
.text-action { border: 0; background: transparent; color: var(--brand); font-size: 11px; font-weight: 700; padding: 4px 2px; }
.text-action:hover { text-decoration: underline; }
.card-more { margin-inline-start: auto; }

/* list view */
.object-grid.list-view { grid-template-columns: 1fr; gap: 10px; }
.object-grid.list-view .object-card { display: grid; grid-template-columns: 168px minmax(0, 1fr); }
.object-grid.list-view .card-media { aspect-ratio: auto; min-height: 132px; height: 100%; }
.object-grid.list-view .card-body { padding: 14px 16px; }
.object-grid.list-view .tag-list { display: none; }
@media (max-width: 640px) {
  .object-grid.list-view .object-card { grid-template-columns: 104px minmax(0, 1fr); }
  .object-grid.list-view .card-media { min-height: 118px; }
}

/* ---------- badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  border-radius: 999px; padding: 2px 8px;
  font-size: 9.5px; line-height: 1.8; font-weight: 650;
  border: 1px solid transparent; white-space: nowrap;
}
.badge[data-tone="neutral"] { background: var(--surface-3); color: var(--ink-soft); }
.badge[data-tone="info"] { background: var(--info-soft); color: var(--info); }
.badge[data-tone="success"] { background: var(--success-soft); color: var(--success); }
.badge[data-tone="warning"] { background: var(--warning-soft); color: var(--warning); }
.badge[data-tone="error"] { background: var(--danger-soft); color: var(--danger); }
.badge.glass { background: rgba(20, 42, 35, .72); color: #fffaf0; border-color: rgba(255, 255, 255, .14); }
.badge.glass-light { background: rgba(255, 253, 248, .9); color: var(--ink); border-color: rgba(222, 214, 199, .8); }
.status-icon { width: 14px; height: 14px; flex: 0 0 auto; }
.status-icon.designed { color: var(--success); }
.status-icon.inDesign { color: var(--warning); }
.status-icon.notDesigned { color: var(--muted); }

/* ---------- empty / error ---------- */
.empty-state {
  grid-column: 1 / -1;
  display: grid; place-items: center; gap: 8px; text-align: center;
  padding: 54px 20px; border: 1px dashed var(--line-strong); border-radius: var(--radius);
  background: rgba(255, 253, 248, .55); color: var(--muted);
}
.empty-state .empty-mark { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 16px; background: var(--surface-2); color: var(--brand); }
.empty-state strong { color: var(--ink); font-size: 14px; }
.empty-state p { margin: 0; max-width: 42ch; font-size: 12px; }
.error-box { padding: 18px; border: 1px solid #e5b9b4; border-radius: var(--radius); background: var(--danger-soft); color: #7c2a24; font-size: 12px; }
.error-box button { margin-block-start: 8px; }

/* ---------- flow ---------- */
.flow-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; flex-wrap: wrap; margin-block-start: 4px; }
.flow-head h1 { margin: 0 0 4px; font-size: clamp(21px, 2.4vw, 29px); }
.flow-head p { margin: 0; color: var(--muted); font-size: 12px; max-width: 62ch; }
.flow-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-block: 18px; }
.summary-card {
  display: grid; gap: 2px; padding: 13px 15px; border: 1px solid var(--line);
  border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-soft);
}
.summary-card b { font-size: 20px; line-height: 1.3; }
.summary-card span { color: var(--muted); font-size: 10.5px; }
.summary-card.designed b { color: var(--success); }
.summary-card.inDesign b { color: var(--warning); }
.summary-card.notDesigned b { color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; color: var(--muted); font-size: 10.5px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; border: 1.5px solid currentColor; }
.legend-swatch.designed { background: var(--success-soft); color: var(--success); }
.legend-swatch.inDesign { background: var(--warning-soft); color: var(--warning); }
.legend-swatch.notDesigned { background: var(--surface-2); color: var(--muted); border-style: dashed; }

.flow-toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface);
  margin-block-end: 12px;
}
.flow-toolbar .search-box { flex: 1 1 230px; }
.flow-toolbar select { width: auto; min-width: 128px; }
.section-tabs { display: inline-flex; flex-wrap: wrap; gap: 3px; padding: 3px; background: var(--surface-2); border-radius: 9px; }
.section-tabs button { border: 0; background: transparent; color: var(--muted); border-radius: 7px; padding: 5px 10px; font-size: 11px; }
.section-tabs button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 4px rgba(20, 40, 30, .08); font-weight: 700; }
.zoom-controls { display: inline-flex; align-items: center; gap: 3px; border: 1px solid var(--line); border-radius: 9px; padding: 2px; background: var(--surface); }
.zoom-controls button { width: 28px; height: 28px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); display: grid; place-items: center; font-size: 15px; }
.zoom-controls button:hover { background: var(--surface-2); color: var(--ink); }
.zoom-controls span { min-width: 40px; text-align: center; font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; }

.flow-stage {
  /* The flow board is a spatial diagram: physical coordinates are intentional. */
  direction: ltr;
  position: relative; overflow: auto; overscroll-behavior: contain;
  border: 1px solid var(--line); border-radius: var(--radius);
  background-color: var(--surface);
  background-image:
    linear-gradient(rgba(29, 90, 73, .045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(29, 90, 73, .045) 1px, transparent 1px);
  background-size: 26px 26px;
  min-height: 420px; max-height: min(86vh, 900px);
  scrollbar-width: thin;
}
.flow-sizer { position: relative; overflow: hidden; }
.flow-inner { position: absolute; top: 0; left: 0; direction: ltr; }
.flow-svg { position: absolute; inset: 0; overflow: visible; pointer-events: none; }
.flow-edge { fill: none; stroke: #a8b5ae; stroke-width: 1.4; opacity: .22; transition: opacity .15s, stroke .15s; }
.flow-edge.dim { opacity: .12; }
.flow-inner.has-focus .flow-edge { opacity: .07; }
.flow-inner.has-focus .flow-edge.is-active { opacity: .95; stroke: var(--brand); stroke-width: 1.8; }
.flow-edge-label {
  font-family: var(--font); font-size: 9px; fill: var(--brand-strong);
  paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round;
  direction: rtl; opacity: 0; transition: opacity .15s;
}
.flow-edge-label.is-active { opacity: 1; }
.flow-node {
  position: absolute; width: 224px; min-height: 104px;
  direction: rtl; text-align: start;
  display: grid; gap: 6px; align-content: start;
  padding: 11px 12px 10px;
  border: 1px solid var(--line); border-inline-start: 4px solid var(--muted);
  border-radius: 13px; background: var(--surface); color: var(--ink);
  box-shadow: 0 12px 28px -22px rgba(20, 45, 35, .45);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
}
.flow-node:hover { transform: translateY(-2px); box-shadow: 0 18px 34px -22px rgba(20, 45, 35, .5); }
.flow-node.designed { border-inline-start-color: var(--success); }
.flow-node.inDesign { border-inline-start-color: var(--warning); }
.flow-node.notDesigned { border-inline-start-color: var(--line-strong); border-style: dashed; border-inline-start-style: solid; background: rgba(255, 253, 248, .8); }
.flow-node-top { display: flex; align-items: center; gap: 6px; }
.flow-node-code { font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; }
.flow-node-status { margin-inline-start: auto; display: inline-flex; align-items: center; gap: 4px; font-size: 9px; color: var(--muted); }
.flow-node strong { font-size: 13px; line-height: 1.55; font-weight: 720; }
.flow-node .node-route { font-size: 10px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flow-node-foot { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-block-start: 2px; }
.flow-node-foot span { font-size: 9.5px; color: var(--muted); }
.flow-node .library-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.flow-list { display: grid; gap: 18px; }
.flow-section { display: grid; gap: 9px; }
.flow-section h2 { margin: 0; font-size: 13px; color: var(--ink); display: flex; align-items: center; gap: 8px; }
.flow-section h2 span { color: var(--muted); font-size: 10px; font-weight: 500; }
.flow-category { display: grid; gap: 6px; }
.flow-category h3 { margin: 0; color: var(--muted); font-size: 10.5px; font-weight: 600; }
.flow-list-row {
  display: grid; grid-template-columns: 42px minmax(0, 1.3fr) minmax(0, 1fr) auto auto;
  align-items: center; gap: 10px;
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface);
}
.flow-list-row:hover { border-color: var(--line-strong); background: #fffefa; }
.flow-list-row .row-code { font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; }
.flow-list-row .row-title { font-size: 12px; font-weight: 650; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flow-list-row .row-route { font-size: 10px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-actions { display: flex; align-items: center; gap: 5px; }
.row-actions .icon-button { width: 28px; min-height: 28px; }
.designed-text { color: var(--success); }
.inDesign-text { color: var(--warning); }
.notDesigned-text { color: var(--muted); }

/* ---------- dialogs / drawer ---------- */
dialog {
  border: 0; padding: 0; background: transparent; color: var(--ink);
  max-width: none; max-height: none;
}
dialog::backdrop { background: rgba(15, 31, 25, 0.45); backdrop-filter: blur(2px); }
.drawer {
  position: fixed;
  inset-block: 0;
  inset-inline-start: 0;
  margin-block: 0;
  margin-inline-start: 0;
  margin-inline-end: auto;
  width: min(560px, 100%);
  height: 100dvh;
  max-height: 100dvh;
  background: var(--surface);
  box-shadow: -24px 0 60px -30px rgba(10, 30, 22, .45);
  overflow: hidden;
}
.drawer[open] { display: flex; flex-direction: column; animation: drawer-in .22s ease both; }
@keyframes drawer-in { from { transform: translateX(18px); opacity: .4; } to { transform: translateX(0); opacity: 1; } }
.drawer-head {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 16px 18px; border-block-end: 1px solid var(--line);
  background: var(--surface); position: sticky; top: 0; z-index: 2;
}
.drawer-head-copy { display: grid; gap: 3px; min-width: 0; }
.drawer-head h2 { margin: 0; font-size: 16px; line-height: 1.5; overflow-wrap: anywhere; }
.drawer-head .sub { color: var(--muted); font-size: 10.5px; }
.drawer-head .icon-button { margin-inline-start: auto; flex: 0 0 auto; }
.drawer-body { padding: 16px 18px 24px; overflow: auto; display: grid; gap: 16px; }
.drawer-foot { position: sticky; bottom: 0; display: flex; flex-wrap: wrap; gap: 7px; padding: 12px 18px; background: rgba(255, 253, 248, 0.92); backdrop-filter: blur(8px); border-block-start: 1px solid var(--line); }
.detail-preview { width: 100%; height: 260px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.detail-preview.is-page { height: min(60vh, 560px); }
.detail-section { display: grid; gap: 8px; }
.detail-section h3 { margin: 0; font-size: 11px; color: var(--muted); font-weight: 700; }
.meta-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px 12px; }
.meta-item { display: grid; gap: 1px; min-width: 0; }
.meta-item dt { color: var(--muted); font-size: 9.5px; }
.meta-item dd { margin: 0; font-size: 11px; overflow-wrap: anywhere; }
.callout { display: grid; gap: 5px; padding: 11px 13px; border-radius: 11px; border: 1px solid var(--line); background: var(--surface-2); font-size: 11px; color: var(--ink-soft); }
.callout[data-tone="warning"] { background: var(--warning-soft); border-color: #ecd9b0; color: #6d4b13; }
.callout[data-tone="success"] { background: var(--success-soft); border-color: #c8e2d6; color: #1e5743; }
.callout[data-tone="info"] { background: var(--info-soft); border-color: #c8e0ea; color: #21546b; }
.callout strong { font-size: 12px; }
.state-row { display: flex; flex-wrap: wrap; gap: 5px; }
.state-chip { border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink-soft); padding: 3px 10px; font-size: 10px; }
.state-chip:hover { border-color: var(--brand); color: var(--brand); }
.state-chip[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.block-links { display: flex; flex-wrap: wrap; gap: 5px; }
.block-link { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 4px 8px; font-size: 10px; color: var(--ink-soft); display: inline-flex; align-items: center; gap: 5px; }
.block-link:hover { border-color: var(--brand); color: var(--brand); }
.drift-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--warning); box-shadow: 0 0 0 3px var(--warning-soft); }
.block-link bdi { color: var(--muted); font-size: 9px; }
.report-fields { display: grid; grid-template-columns: minmax(80px, 140px) minmax(0, 1fr); gap: 7px 12px; margin: 0; font-size: 10.5px; }
.report-fields dt { color: var(--muted); }
.report-fields dd { margin: 0; overflow-wrap: anywhere; }
.report-fields dd p { margin: 0 0 4px; }
.report-fields dd p:last-child { margin-bottom: 0; }
.report-code { display: block; font-size: 10px; color: var(--ink-soft); overflow-wrap: anywhere; }
pre.code-block { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--surface-3); color: var(--ink-soft); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; white-space: pre-wrap; overflow-wrap: anywhere; direction: ltr; text-align: left; }
.confirm-dialog {
  width: min(440px, calc(100% - 28px));
  margin: auto; padding: 20px; border-radius: 18px; background: var(--surface);
  box-shadow: 0 30px 80px -30px rgba(10, 30, 22, .55);
}
.confirm-dialog[open] { display: grid; gap: 12px; }
.confirm-dialog h2 { margin: 0; font-size: 16px; }
.confirm-dialog p { margin: 0; color: var(--muted); font-size: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 7px; flex-wrap: wrap; }
.delete-action { margin-inline-start: auto; color: var(--danger); }
.danger-button { background: var(--danger); border-color: var(--danger); color: #fff; }
.danger-button:hover { background: #93372f; border-color: #93372f; }
.toast {
  position: fixed; inset-block-end: 20px; inset-inline: 0; margin-inline: auto;
  z-index: 80; width: max-content; max-width: calc(100% - 28px);
  padding: 9px 16px; border-radius: 999px; background: #1b332b; color: #fffaf0;
  font-size: 11.5px; box-shadow: 0 18px 45px -20px rgba(10, 30, 22, .6);
  opacity: 0; translate: 0 8px; pointer-events: none; transition: opacity .2s, translate .2s;
}
.toast.show { opacity: 1; translate: 0 0; }

/* ---------- login ---------- */
.login-body { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.login-card {
  width: min(420px, 100%); display: grid; gap: 18px; padding: 28px;
  border: 1px solid var(--line); border-radius: 22px; background: var(--surface);
  box-shadow: 0 30px 80px -40px rgba(18, 55, 43, .55);
}
.login-brand { display: flex; align-items: center; gap: 11px; }
.login-brand img { width: 44px; height: 44px; }
.login-brand div { display: grid; gap: 1px; }
.login-brand strong { font-size: 16px; }
.login-brand small { color: var(--muted); font-size: 10.5px; }
.login-card h1 { margin: 0; font-size: 22px; }
.login-card .lead { margin: -8px 0 0; color: var(--muted); font-size: 12px; line-height: 1.9; }
.field { display: grid; gap: 5px; }
.field label { font-size: 11px; color: var(--ink-soft); font-weight: 600; }
.field input { min-height: 42px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-2); padding: 7px 11px; color: var(--ink); }
.field input:focus { border-color: var(--brand); background: var(--surface); }
.field input:focus-visible { outline: 2px solid rgba(29, 90, 73, .18); outline-offset: 1px; }
.login-card .primary-button { width: 100%; min-height: 44px; border-radius: 12px; font-size: 13px; }
.login-error { padding: 9px 12px; border-radius: 10px; background: var(--danger-soft); color: #7c2a24; font-size: 11.5px; }
.login-foot { color: var(--muted); font-size: 10px; line-height: 1.9; text-align: center; }

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  .hero { grid-template-columns: 1fr; }
  .hero-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .library-layout { grid-template-columns: 210px minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .library-layout { grid-template-columns: 1fr; }
  .filters-toggle { display: inline-flex; }
  .filters { display: none; position: static; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .filters.open { display: grid; }
  .filter-group:first-child { grid-column: 1 / -1; }
  .kind-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .filter-note { grid-column: 1 / -1; }
  .flow-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; gap: 8px; padding: 10px 14px; }
  .brand-copy small, .sync-state { display: none; }
  .main-nav { margin-inline-start: auto; }
  .top-actions { margin-inline-start: 0; }
  .nav-link { padding: 6px 11px; font-size: 11px; }
  .page { padding: 14px 12px 40px; }
  .hero { padding: 20px; border-radius: 22px; gap: 18px; }
  .hero-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { padding: 11px; }
  .stat b { font-size: 21px; }
  .filters { grid-template-columns: 1fr; }
  .kind-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toolbar select { flex: 1 1 120px; }
  .object-grid { grid-template-columns: 1fr; }
  .flow-list-row { grid-template-columns: 34px minmax(0, 1fr) auto; }
  .flow-list-row .row-route { display: none; }
  .flow-list-row .row-status { grid-column: 2 / 3; }
  .drawer { width: 100%; }
  .meta-grid { grid-template-columns: 1fr; }
  .report-fields { grid-template-columns: 1fr; gap: 2px 0; }
  .report-fields dt { margin-block-start: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
