/* ==========================================================================
   Takh — Trello-like kanban, Persian-first UI
   ========================================================================== */

@font-face {
  font-family: "Vazirmatn";
  src: url("/static/fonts/Vazirmatn-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Vazirmatn";
  src: url("/static/fonts/Vazirmatn-Medium.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Vazirmatn";
  src: url("/static/fonts/Vazirmatn-SemiBold.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Vazirmatn";
  src: url("/static/fonts/Vazirmatn-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --font: "Vazirmatn", "Segoe UI", Tahoma, system-ui, sans-serif;
  --bg: #f3f5fb;
  --bg-accent: #e9edfb;
  --surface: #ffffff;
  --surface-2: #f6f8fc;
  --text: #101828;
  --muted: #667085;
  --border: #e5e9f2;
  --hover: #eef2f9;
  --card-bg: #ffffff;
  --list-bg: rgba(255, 255, 255, 0.74);
  --topbar: rgba(13, 19, 38, 0.88);
  --primary: #6366f1;
  --primary-2: #8b5cf6;
  --primary-soft: #eef0ff;
  --ring: rgba(99, 102, 241, 0.22);
  --danger: #e5484d;
  --danger-soft: #feecec;
  --success: #10b981;
  --success-soft: #e7f8f1;
  --warning: #f59e0b;
  --warning-soft: #fff5e5;
  --info: #0ea5e9;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow: 0 18px 40px -20px rgba(16, 24, 40, 0.35);
  --shadow-lg: 0 40px 90px -30px rgba(8, 15, 35, 0.5);
  --radius: 16px;
  --radius-sm: 10px;
  --topbar-h: 64px;
}

[data-theme="dark"] {
  --bg: #080d1a;
  --bg-accent: #0c1426;
  --surface: #0f172a;
  --surface-2: #131f36;
  --text: #e6edf8;
  --muted: #8ea0bd;
  --border: rgba(148, 163, 184, 0.16);
  --hover: rgba(148, 163, 184, 0.1);
  --card-bg: #162138;
  --list-bg: rgba(13, 20, 38, 0.8);
  --topbar: rgba(6, 10, 22, 0.9);
  --primary: #818cf8;
  --primary-2: #a78bfa;
  --primary-soft: rgba(99, 102, 241, 0.16);
  --ring: rgba(129, 140, 248, 0.28);
  --danger: #fb7185;
  --danger-soft: rgba(251, 113, 133, 0.14);
  --success: #34d399;
  --success-soft: rgba(52, 211, 153, 0.12);
  --warning: #fbbf24;
  --warning-soft: rgba(251, 191, 36, 0.12);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow: 0 18px 40px -20px rgba(0, 0, 0, 0.7);
  --shadow-lg: 0 40px 90px -30px rgba(0, 0, 0, 0.85);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  height: 100%;
  scroll-behavior: smooth;
}

html.modal-open {
  overflow: hidden;
}

body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.65;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, p, figure {
  margin: 0;
}

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

button {
  border: 0;
  background: none;
  cursor: pointer;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img {
  max-width: 100%;
}

.hidden {
  display: none !important;
}

.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;
}

.icon {
  flex: none;
  vertical-align: middle;
}

.muted {
  color: var(--muted);
}

.spinner {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2.5px solid var(--border);
  border-top-color: var(--primary);
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

.spinner-sm {
  width: 15px;
  height: 15px;
  border-width: 2px;
}

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 42px;
  padding: 0 18px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  transition: transform 0.16s ease, background 0.16s ease, box-shadow 0.16s ease,
    border-color 0.16s ease, opacity 0.16s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  box-shadow: 0 12px 24px -12px rgba(99, 102, 241, 0.75);
}

.btn-primary:hover:not(:disabled) {
  box-shadow: 0 16px 30px -12px rgba(99, 102, 241, 0.85);
  filter: brightness(1.04);
}

.btn-ghost {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--hover);
}

.btn-soft {
  background: var(--primary-soft);
  color: var(--primary);
}

.btn-soft:hover:not(:disabled) {
  background: var(--ring);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  filter: brightness(1.05);
}

.btn-glass {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.24);
  color: #fff;
  backdrop-filter: blur(10px);
}

.btn-glass:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.26);
}

.btn-sm {
  height: 34px;
  padding: 0 13px;
  font-size: 0.8rem;
  border-radius: 8px;
}

.btn-lg {
  height: 48px;
  padding: 0 24px;
  font-size: 0.98rem;
}

.btn-block {
  width: 100%;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: background 0.15s ease, color 0.15s ease;
  flex: none;
}

.icon-btn:hover {
  background: var(--hover);
  color: var(--text);
}

.icon-btn.is-starred {
  color: var(--warning);
}

.icon-btn.is-starred .icon {
  fill: currentColor;
}

.text-btn {
  color: var(--muted);
  font-size: 0.82rem;
  padding: 4px 6px;
  border-radius: 6px;
}

.text-btn:hover {
  color: var(--text);
  background: var(--hover);
}

.link-btn {
  color: var(--primary);
  font-weight: 600;
  font-size: 0.86rem;
  padding: 0;
}

.link-btn:hover {
  text-decoration: underline;
}

/* ------------------------------------------------------------------ forms */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field > label,
.field-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
}

.input,
.textarea,
.select,
input[type="date"] {
  width: 100%;
  min-height: 42px;
  padding: 9px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease,
    background 0.15s ease;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--muted);
  opacity: 0.8;
}

.input:focus,
.textarea:focus,
.select:focus,
input[type="date"]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--ring);
}

.textarea {
  min-height: 104px;
  resize: vertical;
  line-height: 1.75;
}

.input-sm {
  min-height: 36px;
  padding: 6px 10px;
  font-size: 0.85rem;
}

.input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

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

.field-error {
  font-size: 0.75rem;
  color: var(--danger);
  min-height: 1em;
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.84rem;
  color: var(--text);
  cursor: pointer;
}

.checkbox input {
  width: 17px;
  height: 17px;
  accent-color: var(--primary);
  margin: 0;
}

.input-wrap {
  position: relative;
}

.input-wrap .icon-btn {
  position: absolute;
  inset-inline-end: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
}

/* --------------------------------------------------------------- avatars */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--avatar, #6366f1);
  color: #fff;
  font-weight: 600;
  letter-spacing: 0.01em;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
  flex: none;
  user-select: none;
}

.avatar-more {
  background: var(--surface-2);
  color: var(--muted);
  box-shadow: inset 0 0 0 1px var(--border);
}

.avatar-stack {
  display: inline-flex;
  align-items: center;
  direction: ltr;
}

.avatar-stack .avatar {
  margin-inline-start: -7px;
  border: 2px solid var(--card-bg);
}

.avatar-stack .avatar:first-child {
  margin-inline-start: 0;
}

/* ------------------------------------------------------------------ boot */
.boot {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 18px;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 30% 20%, var(--bg-accent), var(--bg) 60%);
  color: var(--muted);
  font-size: 0.85rem;
}

.boot-logo {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  display: grid;
  place-items: center;
  box-shadow: 0 20px 40px -18px rgba(99, 102, 241, 0.8);
  animation: pulse 1.8s ease-in-out infinite;
}

.boot-logo i {
  display: block;
  width: 24px;
  height: 22px;
  position: relative;
}

.boot-logo i::before,
.boot-logo i::after {
  content: "";
  position: absolute;
  background: #fff;
  border-radius: 3px;
}

.boot-logo i::before {
  inset: 0 15px 0 0;
}

.boot-logo i::after {
  inset: 6px 0 0 12px;
  opacity: 0.7;
}

/* ------------------------------------------------------------------ auth */
.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.02fr 0.98fr;
  background: var(--bg);
}

.auth-brand {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 40px;
  padding: clamp(28px, 4.5vw, 64px);
  color: #fff;
  background: radial-gradient(120% 100% at 10% 0%, #4338ca 0%, #5b21b6 42%, #9d174d 100%);
  isolation: isolate;
}

.auth-brand::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image: radial-gradient(rgba(255, 255, 255, 0.22) 1px, transparent 1px);
  background-size: 24px 24px;
  opacity: 0.35;
  mask-image: linear-gradient(to bottom, #000, transparent 85%);
}

.auth-brand::after {
  content: "";
  position: absolute;
  width: 480px;
  height: 480px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.22), transparent 65%);
  inset-block-start: -180px;
  inset-inline-start: -120px;
  z-index: -1;
}

.auth-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(135deg, #a78bfa, #f472b6);
  display: inline-grid;
  place-items: center;
  box-shadow: 0 10px 20px -10px rgba(0, 0, 0, 0.6);
  flex: none;
}

.brand-mark span {
  display: flex;
  gap: 3px;
  align-items: flex-end;
  height: 16px;
}

.brand-mark span i {
  display: block;
  width: 4px;
  border-radius: 2px;
  background: #fff;
}

.brand-mark span i:nth-child(1) { height: 16px; }
.brand-mark span i:nth-child(2) { height: 11px; opacity: 0.85; }
.brand-mark span i:nth-child(3) { height: 7px; opacity: 0.7; }

.brand-name {
  font-size: 1.15rem;
}

.auth-brand h1 {
  font-size: clamp(1.9rem, 3.4vw, 2.9rem);
  line-height: 1.35;
  font-weight: 700;
  letter-spacing: -0.02em;
  max-width: 16ch;
  margin-bottom: 14px;
}

.auth-brand .lead {
  color: rgba(255, 255, 255, 0.78);
  max-width: 38ch;
  font-size: 0.98rem;
}

.auth-features {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 30px;
}

.auth-feature {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.auth-feature .feature-icon {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.18);
  display: grid;
  place-items: center;
  flex: none;
  backdrop-filter: blur(8px);
}

.auth-feature strong {
  display: block;
  font-size: 0.92rem;
  margin-bottom: 2px;
}

.auth-feature p {
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.82rem;
  line-height: 1.6;
}

.brand-preview {
  display: flex;
  gap: 12px;
  padding: 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(14px);
  transform: rotate(-1.5deg);
  box-shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.6);
  max-width: 460px;
}

[dir="rtl"] .brand-preview {
  transform: rotate(1.5deg);
}

.preview-col {
  flex: 1;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.preview-col span {
  height: 26px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.9);
}

.preview-col span:nth-child(2) {
  height: 20px;
  opacity: 0.75;
}

.preview-col span:nth-child(3) {
  height: 20px;
  opacity: 0.55;
}

.preview-col:nth-child(2) span:first-child {
  background: #fbbf24;
}

.preview-col:nth-child(3) span:first-child {
  background: #34d399;
}

.auth-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(20px, 4vw, 56px);
  position: relative;
}

.auth-card {
  width: 100%;
  max-width: 470px;
  padding: 30px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.auth-switch {
  position: absolute;
  inset-block-start: 22px;
  inset-inline-end: 24px;
  display: flex;
  gap: 6px;
}

.auth-heading {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.auth-sub {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 24px;
}

.auth-tabs {
  display: inline-flex;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 11px;
  margin-bottom: 22px;
}

.auth-tabs button {
  padding: 7px 18px;
  border-radius: 8px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--muted);
  transition: all 0.15s ease;
}

.auth-tabs button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.auth-form .btn-lg {
  margin-top: 4px;
}

.auth-foot {
  text-align: center;
  font-size: 0.84rem;
  color: var(--muted);
  margin-top: 20px;
}

.auth-foot button {
  color: var(--primary);
  font-weight: 600;
}

.demo-card {
  margin-top: 24px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px dashed var(--border);
  background: var(--surface-2);
}

.demo-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.84rem;
  margin-bottom: 3px;
}

.demo-card p {
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 10px;
}

.demo-card code {
  font-family: ui-monospace, "SF Mono", monospace;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 5px;
  font-size: 0.76rem;
  direction: ltr;
  display: inline-block;
}

.demo-cred {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.73rem;
  color: var(--muted);
  margin-top: 4px;
}

.form-alert {
  display: none;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 9px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 0.8rem;
  line-height: 1.5;
}

.form-alert.show {
  display: flex;
}

.form-alert.is-info {
  background: var(--primary-soft);
  color: var(--primary);
  margin-bottom: 16px;
}

/* ---------------------------------------------------------------- topbar */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  min-height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px clamp(14px, 3vw, 28px);
  background: var(--topbar);
  color: #f8fafc;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(18px) saturate(140%);
}

.topbar .brand-name {
  color: #fff;
  font-size: 1.02rem;
}

.topbar .brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
}

.topbar .brand-mark span {
  height: 14px;
}

.topbar .brand-mark span i:nth-child(1) { height: 14px; }
.topbar .brand-mark span i:nth-child(2) { height: 9px; }
.topbar .brand-mark span i:nth-child(3) { height: 6px; }

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
  cursor: pointer;
}

.topbar-divider {
  width: 1px;
  height: 26px;
  background: rgba(255, 255, 255, 0.14);
  margin-inline: 2px;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 7px;
  color: rgba(255, 255, 255, 0.62);
  font-size: 0.82rem;
  min-width: 0;
}

.breadcrumb .current {
  color: #fff;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 26ch;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 1;
  max-width: 440px;
  min-width: 150px;
  margin-inline: auto;
  height: 38px;
  padding: 0 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.8);
  transition: background 0.16s ease, border-color 0.16s ease;
}

.search-box:focus-within {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.3);
}

.search-box input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: #fff;
  font-size: 0.84rem;
}

.search-box input::placeholder {
  color: rgba(255, 255, 255, 0.55);
}

.search-box.light {
  width: 100%;
  margin-inline: 0;
  background: var(--surface);
  border-color: var(--border);
  color: var(--muted);
}

.search-box.light input {
  color: var(--text);
}

.search-box.light input::placeholder {
  color: var(--muted);
}

.search-box.light kbd {
  display: none;
}

.search-box kbd {
  font-family: inherit;
  font-size: 0.68rem;
  padding: 1px 6px;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  color: rgba(255, 255, 255, 0.65);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: none;
}

.topbar .icon-btn {
  color: rgba(255, 255, 255, 0.78);
}

.topbar .icon-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.lang-toggle {
  display: inline-flex;
  padding: 3px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.12);
  margin-inline-end: 4px;
}

.lang-toggle button {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 5px;
  color: rgba(255, 255, 255, 0.65);
}

.lang-toggle button.active {
  background: rgba(255, 255, 255, 0.9);
  color: #1e1b4b;
}

.topbar-menu-wrap {
  position: relative;
}

.user-button {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 3px;
  border-radius: 50px;
  transition: background 0.15s ease;
}

.user-button:hover {
  background: rgba(255, 255, 255, 0.12);
}

.user-button .icon {
  color: rgba(255, 255, 255, 0.7);
}

/* ------------------------------------------------------------------ menu */
.menu {
  position: absolute;
  inset-block-start: calc(100% + 8px);
  inset-inline-end: 0;
  min-width: 210px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 80;
  animation: pop 0.14s ease;
}

.menu-head {
  padding: 8px 10px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.menu-head strong {
  display: block;
  font-size: 0.86rem;
}

.menu-head span {
  font-size: 0.72rem;
  color: var(--muted);
  direction: ltr;
  display: block;
  text-align: start;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.84rem;
  color: var(--text);
  text-align: start;
}

.menu-item:hover {
  background: var(--hover);
}

.menu-item.danger {
  color: var(--danger);
}

.menu-item .icon {
  color: var(--muted);
}

.menu-item.danger .icon {
  color: currentColor;
}

.menu-sep {
  height: 1px;
  background: var(--border);
  margin: 5px 4px;
}

.menu-label {
  padding: 7px 10px 4px;
  font-size: 0.67rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ------------------------------------------------------------------ view */
.view {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 30px clamp(16px, 4vw, 48px) 70px;
  flex: 1;
}

.view-board {
  max-width: none;
  padding: 0;
  position: relative;
}

/* Notebooks use the whole window width, like boards. */
.view-nb {
  max-width: none;
  padding: 16px clamp(12px, 2vw, 28px) 28px;
}

.view-nb .onenote-workspace {
  height: calc(100vh - var(--topbar-h) - 56px);
}

.db-banner {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 9px clamp(16px, 4vw, 48px);
  background: var(--warning-soft);
  color: #92400e;
  font-size: 0.8rem;
  border-bottom: 1px solid rgba(245, 158, 11, 0.28);
}

[data-theme="dark"] .db-banner {
  color: #fbbf24;
}

.db-banner.show {
  display: flex;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 26px;
}

.page-eyebrow {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 5px;
}

.page-title {
  font-size: clamp(1.55rem, 2.5vw, 2.05rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.3;
}

.page-sub {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 4px;
}

.page-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 30px 0 14px;
}

.section-head:first-of-type {
  margin-top: 0;
}

.section-title {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.count-pill {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 1px 8px;
}

.section-line {
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ---------------------------------------------------------------- boards */
.board-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
}

.board-tile {
  position: relative;
  min-height: 156px;
  border-radius: var(--radius);
  padding: 16px 18px;
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 22px;
  overflow: hidden;
  isolation: isolate;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.board-tile::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: radial-gradient(130% 130% at 0% 0%, rgba(255, 255, 255, 0.28), transparent 50%);
  opacity: 0.9;
}

.board-tile::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image: radial-gradient(rgba(255, 255, 255, 0.18) 1px, transparent 1px);
  background-size: 18px 18px;
  opacity: 0.25;
}

.board-tile:hover {
  transform: translateY(-3px);
  box-shadow: 0 22px 40px -22px rgba(8, 15, 35, 0.65);
}

.board-tile:focus-visible {
  outline: 3px solid rgba(255, 255, 255, 0.65);
  outline-offset: 2px;
}

.tile-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.tile-role {
  font-size: 0.63rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.22);
  backdrop-filter: blur(6px);
}

.tile-star {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.7);
  transition: background 0.15s ease, color 0.15s ease;
}

.tile-star:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.tile-star.is-starred {
  color: #fde68a;
}

.tile-star.is-starred .icon {
  fill: currentColor;
}

.tile-title {
  font-size: 1.12rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.45;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.15);
}

.tile-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.tile-stats {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.68rem;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(6px);
}

.board-tile .avatar-stack .avatar {
  border-color: rgba(255, 255, 255, 0.45);
}

.new-board-tile {
  min-height: 156px;
  border-radius: var(--radius);
  border: 1.5px dashed var(--border);
  background: var(--surface);
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-weight: 600;
  font-size: 0.88rem;
  transition: all 0.16s ease;
}

.new-board-tile:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
  transform: translateY(-2px);
}

.new-board-tile .plus-circle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.new-board-tile:hover .plus-circle {
  background: var(--surface);
  border-color: var(--primary);
}

.archive-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.archive-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.archive-row .grow {
  flex: 1;
  min-width: 0;
}

.archive-row strong {
  display: block;
  font-size: 0.86rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.archive-row span {
  font-size: 0.72rem;
  color: var(--muted);
}

/* ---------------------------------------------------------------- board */
.board-page {
  position: relative;
  min-height: calc(100vh - var(--topbar-h));
  display: flex;
  flex-direction: column;
  isolation: isolate;
  color: #fff;
  transition: background 0.3s ease;
}

.board-page::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image: radial-gradient(rgba(255, 255, 255, 0.17) 1px, transparent 1px);
  background-size: 22px 22px;
  opacity: 0.3;
  mask-image: linear-gradient(to bottom, #000 0%, rgba(0, 0, 0, 0.6) 60%, transparent 100%);
}

.board-page::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.06) 0%, rgba(0, 0, 0, 0.16) 100%);
  pointer-events: none;
}

.board-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 18px clamp(16px, 3vw, 30px) 6px;
}

.board-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.board-title {
  font-size: clamp(1.2rem, 2vw, 1.55rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.18);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 46vw;
}

.board-title-input {
  font-size: clamp(1.15rem, 2vw, 1.45rem);
  font-weight: 700;
  color: #fff;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 8px;
  padding: 3px 10px;
  outline: none;
  min-width: 200px;
  max-width: 46vw;
}

.board-title-input:focus {
  background: rgba(255, 255, 255, 0.24);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.18);
}

.board-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.head-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.88);
  font-size: 0.72rem;
  backdrop-filter: blur(8px);
}

.board-head .avatar-stack .avatar {
  border-color: rgba(255, 255, 255, 0.55);
}

.board-star {
  color: rgba(255, 255, 255, 0.78);
}

.board-star:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.board-star.is-starred {
  color: #fde68a;
}

.board-star.is-starred .icon {
  fill: currentColor;
}

.board-head-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-inline-start: auto;
}

.lists-scroll {
  flex: 1;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 12px clamp(16px, 3vw, 30px) 34px;
  overflow-x: auto;
  overflow-y: hidden;
  min-height: 320px;
}

.list-column {
  width: 302px;
  flex: 0 0 302px;
  border-radius: 14px;
  background: var(--list-bg);
  border: 1px solid rgba(255, 255, 255, 0.32);
  box-shadow: 0 16px 40px -24px rgba(8, 15, 35, 0.6);
  backdrop-filter: blur(16px) saturate(120%);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 196px);
  min-height: 220px;
  color: var(--text);
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

[data-theme="dark"] .list-column {
  border-color: rgba(255, 255, 255, 0.12);
}

.list-column.is-dragging {
  opacity: 0.55;
}

.list-column.drop-target {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
}

.list-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 10px 6px 12px;
  padding-inline-start: 12px;
}

.list-head-handle {
  cursor: grab;
  color: var(--muted);
  display: inline-flex;
  padding: 2px;
  border-radius: 5px;
}

.list-head-handle:hover {
  background: var(--hover);
}

.list-head-handle:active {
  cursor: grabbing;
}

.list-title {
  flex: 1;
  min-width: 0;
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.5;
  cursor: pointer;
  border-radius: 6px;
  padding: 1px 4px;
  margin-inline-start: -4px;
  word-break: break-word;
}

.list-title:hover {
  background: var(--hover);
}

.list-title-input {
  flex: 1;
  min-width: 0;
  font-size: 0.88rem;
  font-weight: 700;
  border: 1px solid var(--primary);
  border-radius: 6px;
  background: var(--surface);
  padding: 2px 6px;
  outline: none;
}

.list-count {
  font-size: 0.68rem;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 0 7px;
  flex: none;
}

.list-menu-wrap {
  position: relative;
  flex: none;
}

.list-menu-wrap .icon-btn {
  width: 28px;
  height: 28px;
}

.list-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 8px 6px;
  padding-inline: 8px;
  overflow-y: auto;
  min-height: 6px;
  flex: 1;
  scrollbar-width: thin;
}

.list-cards::-webkit-scrollbar {
  width: 6px;
}

.list-cards::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 99px;
}

.list-foot {
  padding: 0 8px 8px;
}

.list-empty {
  font-size: 0.76rem;
  color: var(--muted);
  text-align: center;
  padding: 12px 8px 14px;
}

.list-drop-marker {
  height: 3px;
  border-radius: 99px;
  background: var(--primary);
  margin: 1px 3px;
  box-shadow: 0 0 0 3px var(--ring);
}

/* ------------------------------------------------------------------ card */
.card {
  position: relative;
  background: var(--card-bg);
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 10px 8px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.1);
  cursor: grab;
  transition: border-color 0.14s ease, box-shadow 0.14s ease,
    transform 0.14s ease;
  user-select: none;
}

.card:hover {
  border-color: rgba(99, 102, 241, 0.45);
  box-shadow: 0 8px 18px -10px rgba(16, 24, 40, 0.4);
  transform: translateY(-1px);
}

.card:active {
  cursor: grabbing;
}

.card.is-dragging {
  opacity: 0.4;
}

.card-cover {
  height: 32px;
  border-radius: 7px;
  margin: -2px -2px 8px;
  background: var(--cover, #6366f1);
  background-image: linear-gradient(135deg, rgba(255, 255, 255, 0.22), transparent 60%);
}

.card-labels {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 6px;
}

.card-label {
  height: 8px;
  min-width: 36px;
  max-width: 100%;
  border-radius: 99px;
  background: var(--label, #6366f1);
}

.card-label.named {
  height: auto;
  padding: 1px 8px;
  font-size: 0.64rem;
  font-weight: 600;
  line-height: 1.6;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.card-title {
  font-size: 0.87rem;
  font-weight: 500;
  line-height: 1.55;
  word-break: break-word;
}

.card-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 7px;
  font-size: 0.68rem;
  color: var(--muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  line-height: 1;
}

.badge .icon {
  width: 13px;
  height: 13px;
}

.badge.complete {
  color: var(--success);
}

.due-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 0.67rem;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
}

.due-badge.is-overdue {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: transparent;
}

.due-badge.is-done {
  background: var(--success-soft);
  color: var(--success);
  border-color: transparent;
}

.due-badge .icon {
  width: 12px;
  height: 12px;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  min-height: 24px;
}

.card-footer-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-footer .avatar {
  border: 1.5px solid var(--card-bg);
}

.card-desc-icon {
  color: var(--muted);
}

.add-card-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 7px 10px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 500;
  text-align: start;
  transition: background 0.14s ease, color 0.14s ease;
}

.add-card-btn:hover {
  background: var(--hover);
  color: var(--text);
}

.composer {
  padding: 4px 8px 10px;
}

.composer textarea {
  width: 100%;
  min-height: 64px;
  resize: none;
  border: 1px solid var(--primary);
  border-radius: 8px;
  background: var(--surface);
  padding: 8px 10px;
  font-size: 0.84rem;
  outline: none;
  box-shadow: 0 0 0 3px var(--ring);
}

.composer-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 7px;
}

.composer-hint {
  font-size: 0.66rem;
  color: var(--muted);
  margin-inline-start: auto;
}

.add-list-column {
  width: 290px;
  flex: 0 0 290px;
}

.add-list-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 0.84rem;
  font-weight: 600;
  backdrop-filter: blur(12px);
  transition: background 0.15s ease;
  text-align: start;
}

.add-list-btn:hover {
  background: rgba(255, 255, 255, 0.26);
}

.add-list-form {
  background: var(--surface);
  border-radius: 12px;
  padding: 10px;
  box-shadow: var(--shadow);
  color: var(--text);
}

.add-list-form .input {
  margin-bottom: 8px;
}

/* ------------------------------------------------------------- board menu */
.drawer-section {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}

.drawer-section:last-child {
  border-bottom: 0;
}

.drawer-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
}

.bg-swatches {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.swatch {
  aspect-ratio: 1.15;
  border-radius: 8px;
  border: 2px solid transparent;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
  transition: transform 0.14s ease, border-color 0.14s ease;
}

.swatch:hover {
  transform: scale(1.05);
}

.swatch.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
}

.member-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
}

.member-row .grow {
  flex: 1;
  min-width: 0;
}

.member-row strong {
  font-size: 0.84rem;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.member-row .grow span {
  font-size: 0.7rem;
  color: var(--muted);
  display: block;
  text-align: start;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.role-tag {
  font-size: 0.62rem;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 99px;
  background: var(--primary-soft);
  color: var(--primary);
  flex: none;
}

.role-tag.muted {
  background: var(--surface-2);
  color: var(--muted);
}

.member-role-select {
  width: auto;
  min-width: 138px;
  flex: none;
  font-size: 0.74rem;
  min-height: 30px;
  height: 30px;
  padding: 0 8px;
}

.label-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 0;
}

.label-chip {
  height: 28px;
  min-width: 56px;
  border-radius: 6px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  font-weight: 600;
  color: #fff;
  padding: 0 9px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.22);
}

.label-editor {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-top: 10px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}

.label-editor .field {
  flex: 1;
}

.color-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  max-width: 118px;
}

.color-dot {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid transparent;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}

.color-dot.active {
  border-color: var(--text);
  box-shadow: 0 0 0 2px var(--surface);
}

.activity-feed {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 360px;
  overflow-y: auto;
}

.activity-item {
  display: flex;
  gap: 9px;
  align-items: flex-start;
}

.activity-copy {
  font-size: 0.78rem;
  line-height: 1.55;
  min-width: 0;
}

.activity-user {
  font-weight: 600;
}

.activity-text {
  color: var(--muted);
  margin-inline-start: 2px;
}

.activity-copy time {
  display: block;
  font-size: 0.65rem;
  color: var(--muted);
  opacity: 0.8;
  margin-top: 1px;
}

.invite-form {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.invite-form .input {
  flex: 1;
  min-height: 38px;
}

.invite-form select.input {
  flex: 0 0 auto;
  min-width: 138px;
}

.invite-form .btn {
  height: 38px;
}

.pending-invite {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 0.76rem;
  color: var(--muted);
}

.pending-invite .grow {
  flex: 1;
  direction: ltr;
  text-align: start;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ----------------------------------------------------------------- modal */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(4, 9, 24, 0.58);
  backdrop-filter: blur(5px);
  opacity: 0;
  transition: opacity 0.18s ease;
}

.overlay.is-visible {
  opacity: 1;
}

.modal-panel {
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  transform: translateY(14px) scale(0.985);
  transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.3, 1);
  overflow: hidden;
}

.overlay.is-visible .modal-panel {
  transform: none;
}

.modal-sm { max-width: 440px; }
.modal-md { max-width: 620px; }
.modal-lg { max-width: 780px; }
.modal-xl { max-width: 960px; }

.modal-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex: none;
}

.modal-title {
  font-size: 1rem;
  font-weight: 700;
  flex: 1;
  min-width: 0;
}

.modal-head-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 18px;
  margin-top: 18px;
  border-top: 1px solid var(--border);
}

.confirm-message {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.7;
}

.confirm-modal .modal-body {
  padding-top: 8px;
}

.overlay-drawer {
  justify-content: flex-start;
  align-items: stretch;
  padding: 0;
}

[dir="rtl"] .overlay-drawer {
  justify-content: flex-end;
}

.drawer-panel {
  max-width: 440px;
  height: 100%;
  max-height: 100vh;
  border-radius: 0;
  border-block: 0;
  border-inline-start: 1px solid var(--border);
  transform: translateX(-26px);
}

[dir="rtl"] .drawer-panel {
  transform: translateX(26px);
  border-inline-start: 0;
  border-inline-end: 1px solid var(--border);
}

.overlay.is-visible .drawer-panel {
  transform: none;
}

.drawer-panel .modal-body {
  padding: 0;
}

/* ------------------------------------------------------------- card modal */
.modal-card {
  max-width: 940px;
}

.modal-card .modal-body {
  padding: 0;
}

.card-modal-shell {
  position: relative;
  display: flex;
  flex-direction: column;
  max-height: 90vh;
}

.card-modal-cover {
  height: 112px;
  background: var(--cover, #6366f1);
  background-image: linear-gradient(135deg, rgba(255, 255, 255, 0.28), transparent 60%);
  position: relative;
  flex: none;
}

.card-modal-shell.no-cover .card-modal-cover {
  display: none;
}

.card-modal-shell.no-cover .card-main,
.card-modal-shell.no-cover .card-side {
  max-height: calc(90vh - 8px);
}

.card-modal-shell.no-cover .card-modal-close {
  color: var(--text);
  background: var(--surface-2);
}

.card-modal-shell.no-cover .card-modal-close:hover {
  background: var(--hover);
}

.card-modal-close {
  position: absolute;
  inset-block-start: 12px;
  inset-inline-end: 14px;
  z-index: 4;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  color: #fff;
  background: rgba(8, 15, 35, 0.35);
  backdrop-filter: blur(8px);
}

.card-modal-close:hover {
  background: rgba(8, 15, 35, 0.55);
}

.card-modal {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 286px;
  overflow: hidden;
  flex: 1;
  min-height: 0;
}

.card-main {
  padding: 20px 26px 30px;
  overflow-y: auto;
  max-height: calc(90vh - 112px);
}

.card-side {
  background: var(--surface-2);
  border-inline-start: 1px solid var(--border);
  padding: 18px 16px 28px;
  overflow-y: auto;
  max-height: calc(90vh - 112px);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card-title-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding-inline-end: 26px;
}

.card-title-input {
  width: 100%;
  font-size: 1.28rem;
  font-weight: 700;
  line-height: 1.5;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  padding: 4px 8px;
  margin-inline-start: -8px;
  outline: none;
  resize: none;
  overflow: hidden;
}

.card-title-input:hover {
  background: var(--hover);
}

.card-title-input:focus {
  background: var(--surface);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 6px 0 18px;
  font-size: 0.76rem;
  color: var(--muted);
}

.card-meta .meta-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.card-meta .meta-item strong {
  color: var(--text);
  font-weight: 600;
}

.card-section {
  margin-top: 22px;
}

.card-section-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.card-section-head .icon {
  color: var(--muted);
}

.card-section-title {
  font-size: 0.88rem;
  font-weight: 700;
  flex: 1;
}

.card-labels-big {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.label-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border-radius: 7px;
  font-size: 0.7rem;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.22);
  background: var(--label);
}

.label-pill.empty {
  color: var(--muted);
  background: var(--surface-2);
  border: 1px dashed var(--border);
  text-shadow: none;
}

.chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
}

.chip-btn:hover {
  background: var(--hover);
  color: var(--text);
}

.chip-btn.done {
  background: var(--success-soft);
  color: var(--success);
  border-color: transparent;
}

.chip-btn.overdue {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: transparent;
}

.desc-box {
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid transparent;
  font-size: 0.86rem;
  line-height: 1.8;
  color: var(--text);
  min-height: 46px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.desc-box:hover {
  border-color: var(--border);
  background: var(--surface);
}

.desc-box.empty {
  color: var(--muted);
}

.desc-box p {
  margin: 0 0 6px;
}

.desc-box p:last-child {
  margin-bottom: 0;
}

.desc-box ul,
.desc-box ol {
  margin: 4px 0;
  padding-inline-start: 20px;
}

.desc-box code {
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: 0.8em;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 4px;
  direction: ltr;
  display: inline-block;
}

.desc-editor textarea {
  min-height: 130px;
}

.desc-editor-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}

/* ---------------------------------------------------------------- checklists */
.checklist {
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 12px;
  padding: 13px 14px;
  margin-bottom: 12px;
}

.checklist-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.checklist-title {
  font-size: 0.84rem;
  font-weight: 700;
  flex: 1;
  min-width: 0;
}

.checklist-progress-label {
  font-size: 0.68rem;
  color: var(--muted);
  flex: none;
}

.progress {
  height: 6px;
  border-radius: 99px;
  background: var(--border);
  overflow: hidden;
  margin-bottom: 9px;
}

.progress > span {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--success), #34d399);
  transition: width 0.25s ease;
}

.check-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 3px 0;
  font-size: 0.8rem;
  border-radius: 6px;
}

.check-item:hover {
  background: var(--surface);
}

.check-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin-top: 3px;
  accent-color: var(--primary);
  flex: none;
}

.check-item .check-text {
  flex: 1;
  min-width: 0;
  line-height: 1.55;
  word-break: break-word;
}

.check-item.done .check-text {
  text-decoration: line-through;
  color: var(--muted);
}

.check-item .icon-btn {
  width: 24px;
  height: 24px;
  opacity: 0;
}

.check-item:hover .icon-btn {
  opacity: 1;
}

.check-add {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.check-add .input {
  min-height: 34px;
  font-size: 0.8rem;
}

.check-add .btn {
  height: 34px;
}

.add-checklist-form {
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 12px;
  margin-top: 6px;
}

/* -------------------------------------------------------------- attachments */
.attachment-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.attachment-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
}

.attachment-thumb {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--surface-2);
  flex: none;
  display: grid;
  place-items: center;
  color: var(--muted);
  overflow: hidden;
}

.attachment-info {
  flex: 1;
  min-width: 0;
}

.attachment-info strong {
  display: block;
  font-size: 0.78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.attachment-info span {
  font-size: 0.66rem;
  color: var(--muted);
}

.upload-drop {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px dashed var(--border);
  border-radius: 9px;
  padding: 9px 12px;
  margin-top: 8px;
  font-size: 0.76rem;
  color: var(--muted);
}

.upload-drop:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* ---------------------------------------------------------------- comments */
.comment {
  display: flex;
  gap: 9px;
  padding: 4px 0;
}

.comment-bubble {
  flex: 1;
  min-width: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 11px;
}

.comment-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 2px;
}

.comment-head strong {
  font-size: 0.76rem;
}

.comment-head time {
  font-size: 0.64rem;
  color: var(--muted);
}

.comment-body {
  font-size: 0.8rem;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

.comment-form {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  margin-top: 10px;
}

.comment-form .grow {
  flex: 1;
}

.comment-form textarea {
  min-height: 62px;
  font-size: 0.82rem;
}

/* --------------------------------------------------------------- card side */
.side-title {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 7px;
}

.side-block {
  border-bottom: 1px solid var(--border);
  padding-bottom: 14px;
}

.side-block:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.side-members {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.member-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 5px 7px;
  border-radius: 7px;
  font-size: 0.78rem;
  color: var(--text);
}

.member-toggle:hover {
  background: var(--hover);
}

.member-toggle .grow {
  flex: 1;
  text-align: start;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.member-toggle .icon {
  color: var(--primary);
}

.side-action-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.side-action {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 7px 9px;
  border-radius: 7px;
  font-size: 0.79rem;
  color: var(--text);
  text-align: start;
}

.side-action:hover {
  background: var(--hover);
}

.side-action .icon {
  color: var(--muted);
}

.side-action.danger {
  color: var(--danger);
}

.side-action.danger .icon {
  color: currentColor;
}

.side-label-picker {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 6px;
}

.side-label-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 5px;
  border-radius: 6px;
  font-size: 0.74rem;
  text-align: start;
}

.side-label-option:hover {
  background: var(--hover);
}

.side-label-option .label-chip {
  height: 22px;
  flex: 1;
}

.side-label-option .icon {
  color: var(--primary);
}

.cover-swatches {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.cover-swatches .swatch {
  aspect-ratio: 1.4;
}

.side-form {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 7px;
}

.side-form .input,
.side-form .select {
  min-height: 36px;
  font-size: 0.8rem;
}

.side-form .btn {
  height: 36px;
}

/* ---------------------------------------------------------------- settings */
.settings-page {
  max-width: 1080px;
  margin: 0 auto;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 18px;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}

.panel-wide {
  grid-column: 1 / -1;
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.panel-head .panel-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--primary-soft);
  color: var(--primary);
  flex: none;
}

.panel-title {
  font-size: 0.95rem;
  font-weight: 700;
  flex: 1;
}

.panel-sub {
  font-size: 0.76rem;
  color: var(--muted);
  margin-top: 1px;
}

.settings-form {
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.profile-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 2px 0 4px;
}

.profile-row .avatar {
  width: 56px !important;
  height: 56px !important;
  font-size: 20px !important;
}

.profile-row .grow {
  flex: 1;
}

.profile-row strong {
  display: block;
  font-size: 0.94rem;
}

.profile-row .grow span {
  font-size: 0.76rem;
  color: var(--muted);
  display: block;
  text-align: start;
}

[dir="rtl"] .profile-row .grow span,
[dir="rtl"] .member-row .grow span,
[dir="rtl"] .menu-head span {
  text-align: right;
}

[dir="ltr"] .profile-row .grow span,
[dir="ltr"] .member-row .grow span,
[dir="ltr"] .menu-head span {
  text-align: left;
}

.seg-toggle {
  display: flex;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  gap: 3px;
}

.seg-toggle button {
  flex: 1;
  padding: 7px 10px;
  border-radius: 7px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  transition: all 0.15s ease;
}

.seg-toggle button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.db-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.db-option {
  position: relative;
  display: flex;
  gap: 10px;
  padding: 14px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease,
    box-shadow 0.15s ease;
}

.db-option:hover {
  border-color: var(--primary);
}

.db-option:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 3px var(--ring);
}

.db-option input {
  margin-top: 4px;
  accent-color: var(--primary);
  flex: none;
}

.db-option strong {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.86rem;
}

.db-option span {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.55;
  margin-top: 2px;
}

.db-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.db-fields .span-2 {
  grid-column: span 2;
}

.db-status {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border-radius: 9px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.76rem;
  color: var(--muted);
  margin-bottom: 14px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px var(--success-soft);
  flex: none;
}

.status-dot.warn {
  background: var(--warning);
  box-shadow: 0 0 0 3px var(--warning-soft);
}

.badge-soft {
  font-size: 0.66rem;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 99px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}

.db-status code {
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: 0.7rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 1px 5px;
  direction: ltr;
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.settings-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.warning-box {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: 9px;
  background: var(--warning-soft);
  color: #92400e;
  font-size: 0.75rem;
  line-height: 1.6;
  margin-top: 14px;
}

[data-theme="dark"] .warning-box {
  color: #fbbf24;
}

.test-result {
  display: none;
  align-items: flex-start;
  gap: 8px;
  padding: 9px 11px;
  border-radius: 8px;
  font-size: 0.76rem;
  margin-top: 12px;
  line-height: 1.55;
}

.test-result.show {
  display: flex;
}

.test-result.ok {
  background: var(--success-soft);
  color: var(--success);
}

.test-result.fail {
  background: var(--danger-soft);
  color: var(--danger);
}

.about-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.about-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.78rem;
  padding: 7px 0;
  border-bottom: 1px dashed var(--border);
}

.about-row:last-child {
  border-bottom: 0;
}

.about-row span {
  color: var(--muted);
}

.about-row strong {
  font-weight: 600;
}

/* ----------------------------------------------------------------- search */
.search-page {
  max-width: 980px;
  margin: 0 auto;
}

.search-group {
  margin-top: 26px;
}

.search-group-title {
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 9px;
}

.search-board-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  margin-bottom: 7px;
  transition: border-color 0.14s ease, transform 0.14s ease;
}

.search-board-row:hover {
  border-color: var(--primary);
  transform: translateX(-2px);
}

[dir="ltr"] .search-board-row:hover {
  transform: translateX(2px);
}

.search-board-swatch {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  flex: none;
  background: linear-gradient(135deg, var(--board-a), var(--board-b));
}

.search-result {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  margin-bottom: 7px;
  transition: border-color 0.14s ease;
}

.search-result:hover {
  border-color: var(--primary);
}

.search-result > .icon {
  color: var(--muted);
  margin-top: 10px;
}

.search-result .grow {
  flex: 1;
  min-width: 0;
}

.search-result strong {
  display: block;
  font-size: 0.86rem;
  margin-bottom: 1px;
}

.search-result p {
  font-size: 0.76rem;
  color: var(--muted);
  line-height: 1.55;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.search-result-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 5px;
  font-size: 0.66rem;
  color: var(--muted);
}

.search-result-meta .chip {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 1px 7px;
}

/* ------------------------------------------------------------------ misc */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
}

.empty-icon {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  margin-bottom: 14px;
}

.empty-state h3 {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.empty-state p {
  font-size: 0.82rem;
  max-width: 38ch;
  line-height: 1.7;
}

.empty-action {
  margin-top: 14px;
}

.skeleton {
  background: linear-gradient(
    90deg,
    var(--surface-2) 25%,
    var(--hover) 37%,
    var(--surface-2) 63%
  );
  background-size: 400% 100%;
  animation: shimmer 1.4s ease infinite;
  border-radius: 10px;
}

.skeleton-tile {
  height: 156px;
  border-radius: var(--radius);
}

.skeleton-row {
  height: 56px;
  border-radius: 10px;
  margin-bottom: 8px;
}

.toast-root {
  position: fixed;
  inset-block-end: 22px;
  inset-inline: 0;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  padding: 0 16px;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  min-width: 240px;
  max-width: min(460px, 92vw);
  padding: 11px 13px;
  border-radius: 11px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  font-size: 0.82rem;
  line-height: 1.55;
  pointer-events: auto;
  animation: toastIn 0.2s cubic-bezier(0.2, 0.8, 0.3, 1);
}

.toast-out {
  animation: toastOut 0.22s ease forwards;
}

.toast .icon {
  color: var(--muted);
  margin-top: 1px;
}

.toast-success {
  border-inline-start: 3px solid var(--success);
}

.toast-success .icon {
  color: var(--success);
}

.toast-error {
  border-inline-start: 3px solid var(--danger);
}

.toast-error .icon {
  color: var(--danger);
}

.toast-warning {
  border-inline-start: 3px solid var(--warning);
}

.toast-warning .icon {
  color: var(--warning);
}

.toast-info {
  border-inline-start: 3px solid var(--info);
}

.toast-info .icon {
  color: var(--info);
}

.toast-text {
  flex: 1;
}

.toast-close {
  color: var(--muted);
  padding: 1px;
  border-radius: 4px;
  display: inline-flex;
}

.toast-close:hover {
  color: var(--text);
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 14px 0;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.grow {
  flex: 1;
  min-width: 0;
}

.nowrap {
  white-space: nowrap;
}

.small {
  font-size: 0.76rem;
}

.tiny {
  font-size: 0.68rem;
}

.text-danger {
  color: var(--danger);
}

.text-success {
  color: var(--success);
}

.text-warning {
  color: var(--warning);
}

/* ---------------------------------------------------------- board colors */
.bg-aurora { --board-a: #6366f1; --board-b: #a855f7; }
.bg-ocean { --board-a: #0284c7; --board-b: #06b6d4; }
.bg-sunset { --board-a: #f97316; --board-b: #ec4899; }
.bg-candy { --board-a: #ec4899; --board-b: #8b5cf6; }
.bg-forest { --board-a: #059669; --board-b: #84cc16; }
.bg-midnight { --board-a: #1e293b; --board-b: #475569; }
.bg-peach { --board-a: #fb7185; --board-b: #fbbf24; }
.bg-sky { --board-a: #38bdf8; --board-b: #6366f1; }
.bg-graphite { --board-a: #374151; --board-b: #111827; }
.bg-sand { --board-a: #d97706; --board-b: #a16207; }

.board-tile,
.board-page,
.search-board-swatch {
  background-image: linear-gradient(135deg, var(--board-a, #6366f1), var(--board-b, #a855f7));
}

/* ------------------------------------------------------------- animations */
@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

@keyframes pop {
  from { opacity: 0; transform: translateY(-4px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

@keyframes toastOut {
  to { opacity: 0; transform: translateY(8px); }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(0.94); }
}

.fade-in {
  animation: fadeIn 0.22s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ------------------------------------------------------------- responsive */
@media (max-width: 1024px) {
  .auth {
    grid-template-columns: 1fr;
  }

  .auth-brand {
    display: none;
  }

  .auth-panel {
    min-height: 100vh;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .panel-wide {
    grid-column: auto;
  }
}

@media (max-width: 900px) {
  .card-modal {
    grid-template-columns: 1fr;
  }

  .card-side {
    border-inline-start: 0;
    border-top: 1px solid var(--border);
    max-height: none;
  }

  .card-main {
    max-height: none;
  }

  .modal-card {
    max-height: 94vh;
  }

  .card-modal-shell {
    max-height: 94vh;
    overflow-y: auto;
  }
}

@media (max-width: 760px) {
  :root {
    --topbar-h: 106px;
  }

  .topbar {
    flex-wrap: wrap;
    row-gap: 8px;
    padding: 9px 14px;
  }

  .topbar-brand {
    order: 1;
  }

  .topbar-actions {
    order: 2;
    margin-inline-start: auto;
  }

  .topbar-divider,
  .breadcrumb {
    display: none;
  }

  .search-box {
    order: 3;
    flex: 1 0 100%;
    max-width: none;
    margin: 0;
    height: 36px;
  }

  .view {
    padding-top: 22px;
  }

  .board-grid {
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 12px;
  }

  .board-tile {
    min-height: 138px;
  }

  .board-head {
    padding-top: 14px;
  }

  .board-title {
    max-width: 60vw;
  }

  .list-column {
    width: 86vw;
    flex-basis: 86vw;
    max-height: calc(100vh - 250px);
  }

  .lists-scroll {
    scroll-snap-type: x mandatory;
    gap: 10px;
  }

  .overlay {
    padding: 0;
  }

  .modal-panel {
    max-height: 100vh;
    height: 100%;
    border-radius: 0;
    max-width: none !important;
  }

  .modal-card {
    height: 100vh;
  }

  .card-modal-shell {
    max-height: 100vh;
    height: 100%;
  }

  .card-main {
    padding: 18px 16px 28px;
  }

  .card-side {
    padding: 16px 16px 30px;
  }

  .drawer-panel {
    max-width: 92vw;
  }

  .modal-body {
    padding: 16px;
  }

  .db-options,
  .db-fields {
    grid-template-columns: 1fr;
  }

  .db-fields .span-2 {
    grid-column: auto;
  }

  .auth-switch {
    inset-block-start: 14px;
    inset-inline-end: 16px;
  }

  .auth-card {
    padding: 22px;
    border-radius: 18px;
  }

  .settings-page .panel {
    padding: 16px;
  }

  .page-head {
    align-items: flex-start;
  }

  .page-actions {
    width: 100%;
  }

  .page-actions .btn {
    flex: 1;
  }
}

@media (max-width: 480px) {
  .board-grid {
    grid-template-columns: 1fr;
  }

  .bg-swatches {
    grid-template-columns: repeat(5, 1fr);
  }

  .avatar-stack .avatar:nth-child(n + 4) {
    display: none;
  }

  .tile-bottom {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
}

/* --------------------------------------------------------- reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* --------------------------------------------------------------- scrollbar */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--muted) 35%, transparent);
  border-radius: 99px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

::-webkit-scrollbar-thumb:hover {
  background: color-mix(in srgb, var(--muted) 55%, transparent);
  background-clip: padding-box;
  border: 2px solid transparent;
}

/* ==========================================================================
   Notebook space
   ========================================================================== */
.topbar-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
}

.topbar-nav-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 34px;
  padding: 0 12px;
  border-radius: 9px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}

.topbar-nav-item:hover {
  color: #fff;
  text-decoration: none;
}

.topbar-nav-item.active {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

/* ------------------------------------------------------- notebook tiles */
.notebook-tile {
  position: relative;
  min-height: 132px;
  padding: 18px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.notebook-tile:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--ring);
}

.notebook-tile .tile-title {
  font-size: 1.05rem;
  font-weight: 700;
}

/* ---------------------------------------------------------- shared pages */
.shared-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.shared-page-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 0.14s ease, box-shadow 0.14s ease;
}

.shared-page-row:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.shared-page-row .grow {
  flex: 1;
  min-width: 0;
}

.shared-page-row strong {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.shared-page-row span {
  font-size: 0.76rem;
  opacity: 0.8;
}

.shared-page-icon {
  display: inline-flex;
  opacity: 0.7;
}

/* ---------------------------------------------------- notebook tree view */
.notebook-page-view {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.notebook-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.notebook-title {
  font-size: 1.5rem;
  font-weight: 800;
  margin: 0;
}

.notebook-title.editable {
  cursor: text;
  border-radius: 8px;
  padding: 2px 6px;
}

.notebook-title.editable:hover {
  background: var(--hover);
}

.notebook-categories {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.notebook-category {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.notebook-cat-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.notebook-cat-name {
  font-weight: 700;
  font-size: 0.98rem;
}

.notebook-cat-name.editable {
  cursor: text;
  border-radius: 6px;
  padding: 1px 4px;
}

.notebook-cat-name.editable:hover {
  background: var(--hover);
}

.notebook-subcats {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
}

.notebook-subcat {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.notebook-subcat-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--surface);
}

.notebook-subcat-name {
  font-weight: 600;
  font-size: 0.88rem;
}

.notebook-subcat-name.editable {
  cursor: text;
  border-radius: 6px;
  padding: 1px 4px;
}

.notebook-subcat-name.editable:hover {
  background: var(--hover);
}

.notebook-pages {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 12px 12px;
}

.notebook-page-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
}

.notebook-page-row:hover {
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}

.notebook-page-title {
  font-weight: 600;
  flex: 0 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.notebook-page-row .note-tag-list {
  margin-inline-start: auto;
}

.add-category-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 46px;
  border-radius: var(--radius-sm);
  border: 1.5px dashed var(--border);
  color: var(--muted);
  font-weight: 600;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.add-category-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.member-row-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

/* ------------------------------------------------------- note tags */
.note-tag-list {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 5px;
}

.note-tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--tag, #6366f1);
  background: color-mix(in srgb, var(--tag, #6366f1) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--tag, #6366f1) 30%, transparent);
  white-space: nowrap;
}

.note-tag-chip.removable button {
  display: inline-flex;
  color: inherit;
  opacity: 0.7;
  padding: 0;
}

.note-tag-chip.removable button:hover {
  opacity: 1;
}

.note-tag-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.note-tag-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border-radius: 8px;
  border: 1px solid var(--border);
  transition: border-color 0.14s ease;
}

.note-tag-toggle.active {
  border-color: var(--primary);
}

.note-tag-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.note-tag-form .input {
  flex: 1 1 120px;
}

/* ------------------------------------------------------- note editor */
.note-editor-page {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.note-editor-head {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.note-editor-title-wrap {
  min-width: 0;
  flex: 1;
}

.note-title-input {
  width: 100%;
  border: 0;
  background: transparent;
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text);
  outline: none;
  padding: 2px 4px;
  border-radius: 8px;
}

.note-title-input:focus {
  background: var(--surface);
  box-shadow: 0 0 0 4px var(--ring);
}

.note-editor-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.76rem;
  color: var(--muted);
  padding-inline-start: 4px;
}

.save-status {
  font-size: 0.74rem;
  color: var(--muted);
  white-space: nowrap;
}

.save-status.ok {
  color: var(--success);
}

.save-status.warn {
  color: var(--warning);
}

/* ------------------------------------------------------ read/edit modes */
.mode-toggle {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 10px;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  transition: background 0.14s ease, color 0.14s ease;
}

.mode-btn:hover {
  color: var(--text);
  background: var(--hover);
}

.mode-btn.active {
  color: var(--primary);
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.08);
}

.note-title-read {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 800;
  line-height: 1.3;
  color: var(--text);
}

.note-desc-read {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.note-surface.reading {
  cursor: default;
}

.note-editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 18px;
  align-items: start;
}

.note-editor-main {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
}

.toolbar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 7px;
  color: var(--muted);
  transition: background 0.14s ease, color 0.14s ease;
}

.toolbar-btn:hover {
  background: var(--hover);
  color: var(--text);
}

.toolbar-btn.active {
  background: var(--primary-soft);
  color: var(--primary);
}

.toolbar-dir {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.toolbar-btn.dir-label {
  width: auto;
  padding: 0 8px;
  gap: 5px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.toolbar-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 4px;
}

.toolbar-color {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 7px;
  color: var(--muted);
  cursor: pointer;
  position: relative;
}

.toolbar-color:hover {
  background: var(--hover);
  color: var(--text);
}

.toolbar-color input {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.note-surface {
  min-height: 420px;
  padding: 34px 40px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  line-height: 1.85;
  outline: none;
  font-size: 1rem;
}

.note-surface:focus {
  box-shadow: var(--shadow), 0 0 0 4px var(--ring);
}

.note-surface p {
  margin: 0 0 0.7em;
}

.note-surface h1,
.note-surface h2,
.note-surface h3 {
  margin: 0.9em 0 0.45em;
  line-height: 1.35;
}

.note-surface ul,
.note-surface ol {
  margin: 0 0 0.7em;
  padding-inline-start: 1.5em;
}

.note-surface blockquote {
  margin: 0 0 0.7em;
  padding-inline-start: 14px;
  border-inline-start: 3px solid var(--primary);
  color: inherit;
  opacity: 0.85;
}

.note-surface a {
  color: var(--primary);
}

.note-surface pre {
  background: rgba(0, 0, 0, 0.06);
  padding: 10px 12px;
  border-radius: 8px;
  overflow-x: auto;
}

.note-editor-side {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.note-meta-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.8rem;
}

.note-meta-rows > div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.note-meta-rows span {
  color: var(--muted);
}

/* ------------------------------------------------- page background colors */
.note-bg-paper { background: #ffffff; --note-text: #1f2937; }
.note-bg-cream { background: #fdf6e3; --note-text: #1f2937; }
.note-bg-mint { background: #e7f6ee; --note-text: #123b2a; }
.note-bg-sky { background: #e8f4fd; --note-text: #123a52; }
.note-bg-lavender { background: #f0ecfb; --note-text: #2b2350; }
.note-bg-rose { background: #fdeef0; --note-text: #5a1f28; }
.note-bg-sand { background: #fbf1e2; --note-text: #4a3418; }
.note-bg-graphite { background: #26303f; --note-text: #e6edf8; }

.note-surface,
.notebook-page-row,
.shared-page-row {
  color: var(--note-text, var(--text));
}

.swatch.note-bg-paper,
.swatch.note-bg-cream,
.swatch.note-bg-mint,
.swatch.note-bg-sky,
.swatch.note-bg-lavender,
.swatch.note-bg-rose,
.swatch.note-bg-sand,
.swatch.note-bg-graphite {
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}

/* ------------------------------------------------------------- responsive */
@media (max-width: 900px) {
  .note-editor-layout {
    grid-template-columns: 1fr;
  }

  .topbar-nav-item {
    padding: 0 9px;
  }

  .note-surface {
    padding: 24px 22px;
  }
}

/* ==========================================================================
   OneNote-style notebook workspace
   ========================================================================== */
.onenote-workspace {
  display: flex;
  flex-direction: column;
  gap: 0;
  height: calc(100vh - var(--topbar-h) - 40px);
  min-height: 480px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.nb-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-wrap: wrap;
}

.nb-title {
  font-size: 1.25rem;
  font-weight: 800;
  margin: 0;
}

.nb-title.editable {
  cursor: text;
  border-radius: 8px;
  padding: 2px 6px;
}

.nb-title.editable:hover {
  background: var(--hover);
}

.nb-sections {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px 0;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  flex-wrap: wrap;
}

.section-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 0 14px;
  border-radius: 8px 8px 0 0;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.86rem;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: color 0.14s ease, background 0.14s ease;
}

.section-tab:hover {
  color: var(--text);
  background: var(--hover);
}

.section-tab.active {
  color: var(--primary);
  background: var(--surface);
  border-bottom-color: var(--primary);
}

.section-tab.add {
  padding: 0 10px;
  color: var(--muted);
}

.section-tab.add:hover {
  color: var(--primary);
}

.section-tab-name.editable {
  cursor: text;
  border-radius: 6px;
  padding: 1px 4px;
}

.section-tab-name.editable:hover {
  background: var(--hover);
}

.nb-tag-filter {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  padding-bottom: 8px;
  margin-inline-start: auto;
}

.filter-label {
  font-size: 0.72rem;
  color: var(--muted);
}

.note-tag-chip.filterable {
  cursor: pointer;
  border: 1px solid color-mix(in srgb, var(--tag, #6366f1) 30%, transparent);
}

.note-tag-chip.filterable.active {
  color: #fff;
  background: var(--tag, #6366f1);
}

.chip-clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  color: var(--muted);
}

.chip-clear:hover {
  color: var(--danger);
}

.nb-body {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  flex: 1;
  min-height: 0;
}

.nb-pages {
  border-inline-end: 1px solid var(--border);
  background: var(--surface-2);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.nb-pages-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface-2);
  z-index: 1;
}

.pages-head-title {
  font-weight: 700;
  font-size: 0.9rem;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nb-page-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px;
}

.page-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 6px;
}

.page-group-title {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px 2px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.page-group-title .editable {
  cursor: text;
  border-radius: 6px;
  padding: 1px 3px;
}

.page-group-title .editable:hover {
  background: var(--hover);
}

.page-group-title .icon-btn {
  margin-inline-start: auto;
  width: 24px;
  height: 24px;
}

.page-list-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.page-list-item:hover {
  background: var(--hover);
}

.page-list-item.active {
  background: var(--primary-soft);
  border-color: var(--ring);
}

.page-item-title {
  font-weight: 600;
  font-size: 0.9rem;
  line-height: 1.4;
}

.page-item-desc {
  font-size: 0.76rem;
  color: var(--muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.page-item-meta {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}

.page-item-meta .note-tag-chip {
  width: 8px;
  height: 8px;
  padding: 0;
  border-radius: 50%;
  border: 0;
  background: var(--tag, #6366f1);
}

.add-subcategory-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 8px 12px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1.5px dashed var(--border);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
}

.add-subcategory-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.nb-canvas {
  overflow: auto;
  padding: 18px clamp(14px, 2vw, 26px) 24px;
  background: var(--bg);
}

/* --------------------------------------------------- editor description */
.note-desc-input {
  width: 100%;
  border: 0;
  background: transparent;
  font-size: 0.95rem;
  color: var(--muted);
  outline: none;
  padding: 2px 4px;
  border-radius: 8px;
}

.note-desc-input:focus {
  background: var(--surface);
  box-shadow: 0 0 0 4px var(--ring);
}

/* ------------------------------------------------- editor tables + images */
.note-surface table {
  border-collapse: collapse;
  width: auto;
  max-width: 100%;
  margin: 0.6em 0;
}

.note-surface td,
.note-surface th {
  border: 1px solid color-mix(in srgb, var(--note-text, #1f2937) 35%, transparent);
  padding: 6px 10px;
  min-width: 48px;
  vertical-align: top;
}

.note-surface th {
  font-weight: 700;
  background: color-mix(in srgb, var(--note-text, #1f2937) 8%, transparent);
}

.note-surface img {
  display: inline-block;
  max-width: 100%;
  resize: both;
  overflow: auto;
  border-radius: 6px;
  vertical-align: middle;
}

.note-surface img:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ------------------------------------------------------------- responsive */
@media (max-width: 900px) {
  .nb-body {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .nb-pages {
    max-height: 240px;
    border-inline-end: 0;
    border-bottom: 1px solid var(--border);
  }
}

.shared-page-desc {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 2px 0;
}

/* --------------------------------------------------------------- calendar */
.calendar-head {
  margin-bottom: 14px;
}

.cal-invite-banner {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  margin: 0 0 12px;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--warning) 35%, var(--border));
  background: color-mix(in srgb, var(--warning) 12%, var(--surface));
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
  text-align: start;
}

.cal-invite-banner .cal-invite-goto {
  margin-inline-start: auto;
  color: var(--primary);
  font-weight: 700;
}

.calendar-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 16px;
  align-items: start;
}

.cal-main,
.cal-side {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.cal-main {
  padding: 14px 14px 10px;
}

.cal-side {
  padding: 14px;
  position: sticky;
  top: 12px;
}

.cal-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.cal-title {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 800;
}

.cal-sub {
  margin: 2px 0 0;
  font-size: 0.74rem;
  color: var(--muted);
}

.cal-steps {
  display: flex;
  gap: 2px;
}

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 6px;
}

.cal-weekdays span {
  text-align: center;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted);
  padding: 4px 0;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.cal-cell {
  min-height: 94px;
  padding: 5px 6px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: var(--surface-2);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow: hidden;
  transition: border-color 0.14s ease, background 0.14s ease;
}

.cal-cell:hover {
  border-color: var(--border);
  background: var(--hover);
}

.cal-cell.out {
  opacity: 0.42;
}

.cal-cell.selected {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.cal-cell-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}

.cal-daynum {
  font-size: 1rem;
  font-weight: 800;
  min-width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
}

.cal-cell.today .cal-daynum {
  background: var(--primary);
  color: #fff;
}

.cal-gdate {
  font-size: 0.6rem;
  color: var(--muted);
  white-space: nowrap;
}

.cal-events {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.cal-event {
  display: block;
  font-size: 0.62rem;
  font-weight: 600;
  padding: 2px 5px;
  border-radius: 5px;
  background: var(--primary-soft);
  color: var(--primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cal-event.accepted {
  background: color-mix(in srgb, var(--success) 16%, transparent);
  color: var(--success);
}

.cal-event.pending {
  background: color-mix(in srgb, var(--warning) 20%, transparent);
  color: var(--warning);
}

.cal-event.declined {
  background: var(--surface-2);
  color: var(--muted);
  text-decoration: line-through;
}

.cal-more {
  font-size: 0.6rem;
  color: var(--muted);
  padding-inline-start: 2px;
}

.cal-side-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}

.cal-side-head strong {
  display: block;
  font-size: 0.95rem;
}

.cal-agenda {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.agenda-item {
  display: flex;
  gap: 9px;
  padding: 9px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  cursor: pointer;
}

.agenda-item:hover {
  border-color: var(--primary);
}

.agenda-item.declined {
  opacity: 0.65;
}

.agenda-time {
  flex: none;
  font-size: 0.66rem;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
  padding-top: 1px;
}

.agenda-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.agenda-title {
  font-size: 0.84rem;
}

.agenda-loc {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  font-size: 0.7rem;
  color: var(--muted);
}

.agenda-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.agenda-people {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  font-size: 0.68rem;
  color: var(--muted);
}

.agenda-actions {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 2px;
}

.agenda-actions .btn {
  height: 26px;
  padding: 0 8px;
  font-size: 0.7rem;
}

.agenda-actions .btn.is-active,
.agenda-item .btn.is-active {
  color: var(--primary);
  background: var(--primary-soft);
}

.agenda-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 18px 6px;
  text-align: center;
}

.calendar-page .badge {
  padding: 2px 7px;
  border-radius: 99px;
  font-size: 0.66rem;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}

.calendar-page .badge.owner {
  background: var(--primary-soft);
  color: var(--primary);
}

.calendar-page .badge.accepted {
  background: color-mix(in srgb, var(--success) 15%, transparent);
  color: var(--success);
}

.calendar-page .badge.declined {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  color: var(--danger);
}

.calendar-page .badge.pending {
  background: color-mix(in srgb, var(--warning) 18%, transparent);
  color: var(--warning);
}

.event-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.event-form-row {
  display: grid;
  grid-template-columns: 1.25fr 0.75fr;
  gap: 12px;
}

.jdate-row {
  display: flex;
  gap: 6px;
}

.jdate-row .input {
  flex: 1;
  min-width: 0;
}

.time-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.time-row .input {
  flex: 1;
  min-width: 0;
}

.time-sep {
  color: var(--muted);
}

.invite-add {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.invite-add .input {
  flex: 1;
}

.invitee-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.invitee-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 99px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.72rem;
}

.invitee-chip button {
  display: inline-flex;
  color: var(--muted);
}

.attendee-list {
  display: flex;
  flex-direction: column;
  margin-bottom: 6px;
}

.calendar-page .attendee-row,
.event-view .attendee-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 0;
}

.calendar-page .attendee-row .grow,
.event-view .attendee-row .grow {
  min-width: 0;
}

.calendar-page .attendee-row strong,
.event-view .attendee-row strong {
  display: block;
  font-size: 0.8rem;
}

.calendar-page .attendee-row span,
.event-view .attendee-row span {
  display: block;
  font-size: 0.7rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.event-view {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.event-view-when,
.event-view-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 0.84rem;
}

.event-view-meta {
  color: var(--muted);
  font-size: 0.78rem;
}

.event-view-desc {
  margin: 8px 0;
  padding: 9px 10px;
  border-radius: 9px;
  background: var(--surface-2);
  font-size: 0.82rem;
  white-space: pre-wrap;
}

.event-view .side-title {
  margin-top: 10px;
}

@media (max-width: 1000px) {
  .calendar-layout {
    grid-template-columns: 1fr;
  }

  .cal-side {
    position: static;
  }
}

@media (max-width: 700px) {
  .cal-cell {
    min-height: 74px;
    padding: 4px;
  }

  .cal-gdate {
    display: none;
  }

  .cal-event {
    font-size: 0.58rem;
  }

  .cal-weekdays span {
    font-size: 0.62rem;
  }

  .event-form-row {
    grid-template-columns: 1fr;
  }

  .jdate-row {
    flex-wrap: wrap;
  }
}

/* ----------------------------------------------------------------- paths */
.paths-head {
  margin-bottom: 14px;
}

.path-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.path-stat {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.path-stat-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--primary-soft);
  color: var(--primary);
  flex: none;
}

.path-stat strong {
  display: block;
  font-size: 1.1rem;
  font-weight: 800;
  line-height: 1.2;
}

.path-stat small {
  color: var(--muted);
  font-size: 0.7rem;
}

.path-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 14px;
}

.path-card {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 18px 16px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

.path-card:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--path-color) 45%, var(--border));
  box-shadow: 0 12px 26px rgba(16, 24, 40, 0.08);
}

.path-card-stripe {
  position: absolute;
  inset-block-start: 0;
  inset-inline: 0;
  height: 4px;
  background: linear-gradient(
    90deg,
    var(--path-color),
    color-mix(in srgb, var(--path-color) 35%, transparent)
  );
}

.path-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}

.path-card-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: var(--path-color);
  background: color-mix(in srgb, var(--path-color) 14%, transparent);
  flex: none;
}

.path-card-meta {
  margin-inline-start: auto;
  font-size: 0.68rem;
  color: var(--muted);
  white-space: nowrap;
}

.path-card-title {
  margin: 2px 0 0;
  font-size: 1.05rem;
  font-weight: 800;
}

.path-card-goal {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.4em;
}

.path-card-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}

.path-card-progress {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.path-card-progress span {
  font-size: 0.76rem;
  font-weight: 700;
}

.path-card-progress small {
  font-size: 0.64rem;
  color: var(--muted);
}

.path-card-open {
  margin-inline-start: auto;
  color: var(--muted);
  display: inline-flex;
}

.path-new-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 180px;
  border: 1.5px dashed var(--border);
  border-radius: 16px;
  color: var(--muted);
  font-weight: 600;
  background: transparent;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.path-new-tile:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}

/* progress ring ------------------------------------------------------- */
.progress-ring {
  --p: 0;
  --ring: var(--primary);
  position: relative;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--ring) calc(var(--p) * 1%), var(--surface-2) 0);
  flex: none;
}

.progress-ring::before {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background: var(--surface);
}

.progress-ring > span {
  position: relative;
  font-size: 0.66rem;
  font-weight: 800;
}

.progress-ring.ring-sm {
  width: 44px;
  height: 44px;
}

.progress-ring.ring-sm::before {
  inset: 5px;
}

.progress-ring.ring-sm > span {
  font-size: 0.6rem;
}

.progress-ring.ring-lg {
  width: 84px;
  height: 84px;
}

.progress-ring.ring-lg::before {
  inset: 8px;
}

.progress-ring.ring-lg > span {
  font-size: 0.85rem;
}

/* path detail --------------------------------------------------------- */
.path-detail-page {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.path-hero {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px;
  border-radius: 18px;
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--path-color) 15%, var(--surface)),
    var(--surface)
  );
  border: 1px solid color-mix(in srgb, var(--path-color) 28%, var(--border));
}

.path-hero-main {
  min-width: 0;
}

.path-hero-kicker {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--path-color);
}

.path-hero .page-title {
  margin: 2px 0;
}

.path-hero-goal {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.6;
  max-width: 76ch;
}

.path-hero-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.path-meta-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: -2px;
}

.path-date {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.76rem;
  color: var(--muted);
}

.path-tabs {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  align-self: flex-start;
}

.path-tab {
  height: 32px;
  padding: 0 16px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}

.path-tab.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.08);
}

.today-summary {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.today-summary-top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.today-summary-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.today-summary-label strong {
  font-size: 0.9rem;
}

.all-done {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--success);
  background: color-mix(in srgb, var(--success) 13%, transparent);
}

.path-progress {
  height: 7px;
  border-radius: 99px;
  background: var(--surface-2);
  overflow: hidden;
  margin: 4px 0 10px;
}

.path-progress.big {
  height: 9px;
  margin: 0;
}

.path-progress > span {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: var(--path-color, var(--primary));
  transition: width 0.3s ease;
}

.line-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.today-habits {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.today-line {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.today-line-name {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.habit-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.line-card {
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-inline-start: 4px solid var(--path-color, var(--primary));
}

.line-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.line-title-wrap {
  min-width: 0;
}

.line-name {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 800;
}

.line-goal {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.6;
}

.line-actions {
  display: flex;
  gap: 2px;
  margin-inline-start: auto;
}

.line-progress {
  margin-inline-start: auto;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
  padding-top: 2px;
}

.line-actions + .line-progress {
  margin-inline-start: 0;
}

.line-habits {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.habit-block {
  padding: 10px 12px;
  border-radius: 11px;
  background: var(--surface-2);
  border: 1px solid transparent;
}

.habit-block.is-due {
  border-color: color-mix(in srgb, var(--path-color) 22%, var(--border));
}

.habit-block.not-due {
  opacity: 0.72;
}

.habit-head {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.habit-icon {
  color: var(--path-color);
  display: inline-flex;
}

.habit-name {
  font-size: 0.84rem;
}

.cadence-chip {
  padding: 1px 7px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 600;
}

.habit-block.is-due .cadence-chip {
  color: var(--path-color);
  border-color: color-mix(in srgb, var(--path-color) 30%, var(--border));
  background: color-mix(in srgb, var(--path-color) 10%, var(--surface));
}

.habit-actions {
  display: flex;
  gap: 2px;
  margin-inline-start: auto;
}

.task-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 6px;
}

.path-task {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 2px;
  border-radius: 7px;
}

.path-task:hover {
  background: color-mix(in srgb, var(--path-color) 6%, transparent);
}

.task-check {
  width: 21px;
  height: 21px;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--path-color) 45%, var(--border));
  background: var(--surface);
  display: grid;
  place-items: center;
  color: transparent;
  flex: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.task-check:hover {
  border-color: var(--path-color);
}

.path-task.done .task-check {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

.task-check.static {
  opacity: 0.55;
  cursor: default;
}

.task-title {
  font-size: 0.82rem;
  line-height: 1.5;
}

.path-task.done .task-title {
  color: var(--muted);
  text-decoration: line-through;
}

.task-actions {
  display: flex;
  gap: 2px;
  margin-inline-start: auto;
}

.habit-empty {
  margin: 6px 0 0;
}

.task-add {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.task-add .input {
  flex: 1;
  min-height: 32px;
  height: 32px;
  font-size: 0.78rem;
}

.add-habit-btn {
  margin-top: 10px;
}

.line-empty {
  margin: 4px 0;
}

/* path forms ---------------------------------------------------------- */
.path-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.path-swatches {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.path-swatch {
  position: relative;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--c);
  border: 2px solid transparent;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
  cursor: pointer;
}

.path-swatch.active::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 12px;
  border: 2px solid var(--c);
}

.cadence-picker {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border-radius: 9px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  align-self: flex-start;
}

.cadence-option {
  height: 30px;
  padding: 0 14px;
  border-radius: 7px;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--muted);
}

.cadence-option.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.08);
}

.weekday-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.wd-chip {
  padding: 5px 10px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.72rem;
}

.wd-chip.active {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 700;
}

@media (max-width: 800px) {
  .path-hero {
    flex-wrap: wrap;
  }

  .path-hero .ring-lg {
    width: 64px;
    height: 64px;
  }

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

  .topbar-nav {
    overflow-x: auto;
    scrollbar-width: none;
  }

  .topbar-nav::-webkit-scrollbar {
    display: none;
  }
}

@media (max-width: 560px) {
  .path-stats {
    grid-template-columns: 1fr;
  }

  .path-hero-actions {
    width: 100%;
  }
}

/* ----------------------------------------------------------- templates */
.tpl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.tpl-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.tpl-card:hover {
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.tpl-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tpl-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary);
  display: grid;
  place-items: center;
  flex: none;
}

.tpl-name {
  font-size: 15px;
  font-weight: 700;
  margin: 0;
}

.tpl-code {
  color: var(--muted);
  font-size: 12px;
}

.tpl-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 12px;
  color: var(--muted);
}

.tpl-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.tpl-assign-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 2px 8px;
  border-radius: 999px;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tpl-assign-chip.muted {
  color: var(--muted);
  background: var(--hover);
}

/* ------------------------------------------------------------ builder */
.view-builder {
  height: calc(100vh - var(--topbar-h));
  overflow: hidden;
}

.builder {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.builder-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex: none;
}

.builder-title {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  min-width: 0;
}

.builder-title strong {
  font-size: 14px;
}

.builder-title .tpl-code {
  font-size: 11px;
}

.zoom-ctrl {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px 6px;
}

.zoom-value {
  font-size: 12px;
  color: var(--muted);
  min-width: 40px;
  text-align: center;
}

.builder-body {
  display: grid;
  grid-template-columns: 220px 1fr 280px;
  min-height: 0;
  flex: 1;
}

.builder-palette,
.builder-props {
  background: var(--surface);
  overflow-y: auto;
  padding: 12px;
}

.builder-palette {
  border-inline-end: 1px solid var(--border);
}

.builder-props {
  border-inline-start: 1px solid var(--border);
}

.palette-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 4px 0 8px;
}

.palette-group {
  margin-bottom: 14px;
}

.palette-group h5 {
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 6px;
}

.palette-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 6px;
  cursor: grab;
  font-size: 13px;
  background: var(--surface-2);
  user-select: none;
}

.palette-item:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.palette-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--primary);
  flex: none;
}

.builder-stage {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg);
}

.builder-pages {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex: none;
}

.builder-pages .sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 4px;
}

.page-indicator {
  font-size: 12px;
  color: var(--muted);
  min-width: 90px;
  text-align: center;
}

.builder-canvas-wrap {
  flex: 1;
  overflow: auto;
  padding: 24px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.builder-canvas {
  position: relative;
  background: #fff;
  box-shadow: var(--shadow);
  flex: none;
  overflow: hidden;
}

/* -------------------------------------------------------- form elements */
.fb-element {
  position: absolute;
  overflow: hidden;
  cursor: move;
  border: 1px dashed transparent;
  border-radius: 4px;
  padding: 2px;
}

.fb-element:hover {
  border-color: var(--primary);
}

.fb-element.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--ring);
}

.fb-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
  height: 100%;
}

.fb-field-label {
  font-size: 12px;
  color: var(--text);
  font-weight: 600;
}

.fb-required {
  color: var(--danger);
  font-style: normal;
}

.fb-input {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  color: #101828;
  box-sizing: border-box;
}

.fb-textarea {
  resize: none;
  flex: 1;
}

.fb-check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

.fb-options {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.fb-static-label {
  font-size: 13px;
  color: var(--text);
  white-space: pre-wrap;
}

.fb-static-heading {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.fb-static-para {
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  white-space: pre-wrap;
}

.fb-line {
  border: 0;
  border-top: 1px solid #94a3b8;
  margin: 0;
}

.fb-image {
  height: 100%;
  display: grid;
  place-items: center;
  border: 1px dashed #cbd5e1;
  border-radius: 6px;
  color: #94a3b8;
  font-size: 12px;
  background: #f8fafc;
}

.fb-shape {
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  border: 2px solid #64748b;
  background: transparent;
}

.fb-shape.fb-rounded {
  border-radius: 50%;
}

.fb-signature {
  height: 100%;
  border: 1px dashed #cbd5e1;
  border-radius: 6px;
  display: grid;
  place-items: center;
  color: #94a3b8;
  font-size: 12px;
}

.fb-table {
  height: 100%;
  overflow: hidden;
}

.fb-table table {
  width: 100%;
  height: 100%;
  border-collapse: collapse;
}

.fb-table td {
  border: 1px solid #cbd5e1;
  padding: 0;
}

.fb-table input {
  width: 100%;
  border: 0;
  padding: 4px;
  font-size: 12px;
  box-sizing: border-box;
}

/* palette dot colors */
.fb-type-line,
.fb-type-rect,
.fb-type-square,
.fb-type-circle,
.fb-type-ellipse {
  background: var(--warning);
}

.fb-type-image {
  background: var(--info);
}

.fb-type-textbox {
  background: var(--primary);
}

.prop-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.check-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

/* -------------------------------------------------------------- preview */
.preview-stack {
  display: flex;
  flex-direction: column;
  gap: 18px;
  align-items: center;
  padding: 8px;
}

.preview-page {
  position: relative;
  background: #fff;
  box-shadow: var(--shadow-sm);
  flex: none;
}

.preview-page .fb-element {
  cursor: default;
  border-color: transparent;
}

/* -------------------------------------------------------------- records */
.view-record {
  background: var(--bg);
  min-height: 100vh;
}

.record-head {
  margin: 8px 0 12px;
}

.record-title-input {
  font-size: 18px;
  font-weight: 700;
}

.record-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.record-pages-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.record-page {
  position: relative;
  background: #fff;
  box-shadow: var(--shadow);
  flex: none;
  padding: 16px;
  box-sizing: border-box;
}

.record-page .fb-element {
  cursor: default;
  border-color: transparent;
}

.record-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.record-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  text-decoration: none;
  color: var(--text);
}

.record-row:hover {
  border-color: var(--primary);
}

/* ------------------------------------------- templates/records responsive */
@media (max-width: 960px) {
  .builder-body {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr) auto;
    overflow: auto;
  }

  .builder-palette {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    border-inline-end: 0;
    border-bottom: 1px solid var(--border);
    padding: 8px 12px;
  }

  .builder-palette .palette-title {
    display: none;
  }

  .builder-palette .palette-group {
    display: flex;
    gap: 6px;
    margin: 0;
    flex: none;
  }

  .builder-palette .palette-group h5 {
    align-self: center;
    margin: 0 6px 0 0;
  }

  .builder-palette .palette-item {
    margin: 0;
    flex: none;
  }

  .builder-props {
    border-inline-start: 0;
    border-top: 1px solid var(--border);
    max-height: 220px;
  }

  .builder-stage {
    min-height: 50vh;
  }
}

@media (max-width: 640px) {
  .builder-toolbar {
    flex-wrap: wrap;
    gap: 6px;
  }

  .builder-title {
    flex: 1 1 auto;
  }

  .record-pages-wrap,
  .preview-stack {
    align-items: flex-start;
    overflow-x: auto;
    padding-bottom: 12px;
  }
}

/* ------------------------------------------------- form builder extras */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.color-input {
  padding: 2px;
  height: 36px;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
}

/* ------------------------------------------------------- advanced editor */
.view-templates {
  max-width: none;
}

.view-editor {
  max-width: none;
  padding: 0;
  height: calc(100vh - var(--topbar-h));
  overflow: hidden;
}

.editor {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex: none;
  flex-wrap: wrap;
}

.tb-sep {
  width: 1px;
  height: 22px;
  background: var(--border);
  margin: 0 2px;
}

.editor-body {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) 300px;
  min-height: 0;
  flex: 1;
}

.editor-left {
  border-inline-end: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.editor-right {
  border-inline-start: 1px solid var(--border);
  background: var(--surface);
  overflow-y: auto;
  padding: 12px;
}

.panel-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
}

.panel-tab {
  flex: 1;
  padding: 9px;
  background: none;
  border: 0;
  font: inherit;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}

.panel-tab.active {
  color: var(--primary);
  box-shadow: inset 0 -2px 0 var(--primary);
}

.panel-search {
  padding: 8px;
}

.panel-scroll {
  overflow-y: auto;
  padding: 8px 12px;
  flex: 1;
}

.palette-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 6px;
  cursor: grab;
  font-size: 13px;
  background: var(--surface-2);
  user-select: none;
}

.palette-item:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.palette-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--primary);
  flex: none;
}

.palette-group {
  margin-bottom: 12px;
}

.palette-group h5 {
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 6px;
}

.component-item {
  padding: 8px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  margin-bottom: 6px;
  cursor: grab;
  font-size: 13px;
}

.editor-stage {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg);
}

.editor-rulers {
  display: flex;
  height: 22px;
  flex: none;
}

.ruler-corner {
  width: 22px;
  height: 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex: none;
}

.ruler-h {
  flex: 1;
  height: 22px;
  background-color: var(--surface);
  background-image: repeating-linear-gradient(to right, var(--border) 0 1px, transparent 1px 50px);
  border-bottom: 1px solid var(--border);
}

.ruler-v {
  display: none;
}

.editor-canvas-wrap {
  position: relative;
  flex: 1;
  overflow: auto;
  padding: 20px;
}

.editor-canvas {
  position: relative;
  background: #fff;
  box-shadow: var(--shadow);
  transform-origin: top left;
  flex: none;
  margin: 0 auto;
}

.canvas-elements {
  position: absolute;
  inset: 0;
}

.editor-el {
  position: absolute;
}

.el-inner {
  width: 100%;
  height: 100%;
  transform-origin: center center;
  overflow: visible;
  box-sizing: border-box;
}

.editor-el.is-locked .el-inner {
  cursor: not-allowed;
}

.selection-box {
  position: absolute;
  border: 1px solid var(--primary);
  pointer-events: none;
  z-index: 9999;
}

.handle {
  position: absolute;
  width: 10px;
  height: 10px;
  background: #fff;
  border: 1px solid var(--primary);
  border-radius: 2px;
  pointer-events: auto;
  z-index: 1;
}

.h-nw { left: -5px; top: -5px; cursor: nwse-resize; }
.h-n { left: 50%; top: -5px; transform: translateX(-50%); cursor: ns-resize; }
.h-ne { right: -5px; top: -5px; cursor: nesw-resize; }
.h-e { right: -5px; top: 50%; transform: translateY(-50%); cursor: ew-resize; }
.h-se { right: -5px; bottom: -5px; cursor: nwse-resize; }
.h-s { left: 50%; bottom: -5px; transform: translateX(-50%); cursor: ns-resize; }
.h-sw { left: -5px; bottom: -5px; cursor: nesw-resize; }
.h-w { left: -5px; top: 50%; transform: translateY(-50%); cursor: ew-resize; }

.rotate-handle {
  position: absolute;
  top: -30px;
  left: 50%;
  transform: translateX(-50%);
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #fff;
  border: 1px solid var(--primary);
  color: var(--primary);
  pointer-events: auto;
  cursor: grab;
  z-index: 1;
}

.marquee {
  position: absolute;
  border: 1px dashed var(--primary);
  background: rgba(99, 102, 241, 0.08);
  display: none;
  pointer-events: none;
  z-index: 9998;
}

.editor-guides {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 9997;
}

.guide {
  position: absolute;
  pointer-events: auto;
}

.guide.h {
  left: 0;
  right: 0;
  height: 1px;
  background: #ef4444;
  cursor: ns-resize;
}

.guide.v {
  top: 0;
  bottom: 0;
  width: 1px;
  background: #ef4444;
  cursor: ew-resize;
}

.editor-pages {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex: none;
}

.editor-pages .sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 4px;
}

.page-indicator {
  font-size: 12px;
  color: var(--muted);
  min-width: 90px;
  text-align: center;
}

.prop-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.prop-section summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  padding: 4px 0;
  color: var(--text);
}

.prop-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 6px 0 6px 4px;
}

.align-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}

/* form element internals */
.fb-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.fb-text {
  width: 100%;
  height: 100%;
  overflow: hidden;
  white-space: pre-wrap;
  box-sizing: border-box;
}

.fb-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
  height: 100%;
  box-sizing: border-box;
}

.fb-field-label {
  font-size: 12px;
  font-weight: 600;
}

.fb-required {
  color: var(--danger);
  font-style: normal;
}

.fb-input {
  width: 100%;
  box-sizing: border-box;
  border-radius: 4px;
  padding: 5px 8px;
  font-family: inherit;
  background: #fff;
  color: #101828;
}

.fb-textarea {
  resize: none;
  flex: 1;
}

.fb-check {
  display: flex;
  align-items: center;
  gap: 6px;
}

.fb-options {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.fb-image,
.fb-qr {
  height: 100%;
  display: grid;
  place-items: center;
  border: 1px dashed #cbd5e1;
  border-radius: 6px;
  color: #94a3b8;
  background: #f8fafc;
  box-sizing: border-box;
}

.fb-image-fill {
  width: 100%;
  height: 100%;
  display: block;
}

.fb-barcode {
  height: 100%;
  display: flex;
  align-items: stretch;
  gap: 3px;
}

.fb-barcode i {
  flex: 1;
  background: #111827;
}

.fb-barcode i:nth-child(3n) {
  flex: 0.4;
}

.fb-icon {
  height: 100%;
  display: grid;
  place-items: center;
}

.fb-signature {
  border-bottom: 2px solid #94a3b8 !important;
  font-style: italic;
}

.fb-initial {
  text-align: center;
  font-size: 24px;
}

.fb-table {
  width: 100%;
  height: 100%;
  border-collapse: collapse;
}

.fb-table td {
  border: 1px solid #cbd5e1;
  padding: 0;
}

.fb-table input {
  width: 100%;
  border: 0;
  padding: 4px;
  font-size: 12px;
  box-sizing: border-box;
}

/* palette dot colors for the new element set */
.fb-type-rect,
.fb-type-roundedrect,
.fb-type-square,
.fb-type-circle,
.fb-type-ellipse,
.fb-type-triangle,
.fb-type-polygon,
.fb-type-line,
.fb-type-arrow,
.fb-type-curve,
.fb-type-freehand {
  background: var(--warning);
}

.fb-type-text,
.fb-type-heading,
.fb-type-paragraph,
.fb-type-input,
.fb-type-textarea,
.fb-type-number,
.fb-type-date,
.fb-type-checkbox,
.fb-type-radio,
.fb-type-select,
.fb-type-signature,
.fb-type-initial {
  background: var(--info);
}

.fb-type-image,
.fb-type-logo,
.fb-type-qr,
.fb-type-barcode,
.fb-type-icon,
.fb-type-watermark {
  background: var(--primary);
}

.fb-type-table,
.fb-type-divider,
.fb-type-vdivider,
.fb-type-pagenumber,
.fb-type-header,
.fb-type-footer {
  background: var(--success);
}

/* record page rendering */
.record-el {
  position: absolute;
}

/* responsive editor */
@media (max-width: 1100px) {
  .editor-body {
    grid-template-columns: 200px minmax(0, 1fr) 260px;
  }
}

@media (max-width: 900px) {
  .editor-body {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr) auto;
    overflow: auto;
  }

  .editor-left {
    flex-direction: row;
    overflow-x: auto;
  }

  .editor-left .panel-tabs,
  .editor-left .panel-search {
    display: none;
  }

  .editor-left .panel-scroll {
    display: flex;
    gap: 6px;
    overflow-x: auto;
  }

  .editor-left .palette-group {
    display: flex;
    gap: 6px;
    margin: 0;
    flex: none;
  }

  .editor-left .palette-group h5 {
    align-self: center;
    margin: 0 6px 0 0;
  }

  .editor-left .palette-item {
    margin: 0;
    flex: none;
    white-space: nowrap;
  }

  .editor-right {
    max-height: 260px;
  }

  .editor-stage {
    min-height: 50vh;
  }
}
