/* سطوح و رنگ‌های معنایی سیستم، همراه با اکسن فرش‌آورد. */
@font-face { font-family: Peyda; font-weight: 400; font-display: swap; src: url('/static/peyda-regular.woff2') format('woff2'); }
@font-face { font-family: Peyda; font-weight: 500; font-display: swap; src: url('/static/peyda-medium.woff2') format('woff2'); }
@font-face { font-family: Peyda; font-weight: 600; font-display: swap; src: url('/static/peyda-semibold.woff2') format('woff2'); }
@font-face { font-family: Peyda; font-weight: 800; font-display: swap; src: url('/static/peyda-extrabold.woff2') format('woff2'); }

:root {
  color-scheme: light;
  --bg: #f2f2f7;
  --surface: #fff;
  --surface-2: #efeff4;
  --surface-3: #e5e5ea;
  --border: rgba(60, 60, 67, .14);
  --border-strong: rgba(60, 60, 67, .29);
  --text: #1c1c1e;
  --text-2: #48484a;
  --text-3: #636366;
  --primary: #5e4f47;
  --primary-hover: #4a3e38;
  --on-primary: #fff;
  --nav-active: #e5e5ea;
  --nav-active-text: var(--primary);
  --bad: #bd2520;
  --bad-bg: #ffebe9;
  --badge-text: #fff;
  --good: #216b35;
  --good-bg: #e3f6e8;
  --warn: #805000;
  --warn-bg: #fff2da;
  --info-bg: #e5e5ea;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .04);
  --shadow: 0 8px 32px rgba(0, 0, 0, .08);
  --shadow-lg: 0 24px 72px rgba(0, 0, 0, .20);
  --scrim: rgba(28, 28, 30, .40);
  --focus: var(--primary);
  --radius: 20px;
  --radius-sm: 12px;
  --lg-fallback: #fafafd;
  --lg-bg: linear-gradient(155deg, rgba(255, 255, 255, .91), rgba(242, 242, 247, .74));
  --lg-panel: linear-gradient(155deg, rgba(255, 255, 255, .97), rgba(242, 242, 247, .90));
  --lg-border: rgba(255, 255, 255, .85);
  --lg-shadow: 0 8px 32px rgba(0, 0, 0, .10), inset 0 1px 0 rgba(255, 255, 255, .8);
  --lg-control: rgba(60, 60, 67, .08);
  --lg-selected: var(--nav-active);
  --lg-selected-text: var(--nav-active-text);
  --lg-divider: var(--border);
  --lg-filter: blur(24px) saturate(132%);
  --motion-ease: cubic-bezier(.22, .75, .25, 1);
  --motion-fast: 150ms;
  --motion-panel: 300ms;
  font-family: Peyda, Tahoma, sans-serif;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000;
  --surface: #1c1c1e;
  --surface-2: #2c2c2e;
  --surface-3: #3a3a3c;
  --border: rgba(84, 84, 88, .65);
  --border-strong: rgba(142, 142, 147, .57);
  --text: #f2f2f7;
  --text-2: #c7c7cc;
  --text-3: #a1a1a6;
  --primary: #d9b99b;
  --primary-hover: #e8cfb5;
  --on-primary: #1c1c1e;
  --nav-active: #3a3a3c;
  --bad: #ff6961;
  --bad-bg: rgba(255, 105, 97, .14);
  --badge-text: #1c1c1e;
  --good: #64d980;
  --good-bg: rgba(48, 209, 88, .15);
  --warn: #ffbe55;
  --warn-bg: rgba(255, 159, 10, .15);
  --info-bg: #2c2c2e;
  --shadow-sm: none;
  --shadow: 0 14px 40px rgba(0, 0, 0, .42);
  --shadow-lg: 0 24px 80px rgba(0, 0, 0, .65);
  --scrim: rgba(0, 0, 0, .62);
  --lg-fallback: #242426;
  --lg-bg: linear-gradient(155deg, rgba(44, 44, 46, .84), rgba(28, 28, 30, .74));
  --lg-panel: linear-gradient(155deg, rgba(44, 44, 46, .96), rgba(28, 28, 30, .94));
  --lg-border: rgba(142, 142, 147, .32);
  --lg-shadow: 0 12px 36px rgba(0, 0, 0, .48), inset 0 1px 0 rgba(255, 255, 255, .08);
  --lg-control: rgba(235, 235, 245, .10);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 15px/1.7 Peyda, Tahoma, sans-serif; -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .6; }
a { color: var(--primary); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
bdi, .ltr { unicode-bidi: isolate; }
.ltr { direction: ltr; display: inline-block; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ico { width: 1.25em; height: 1.25em; flex: none; vertical-align: middle; }

/* ---------- دکمه‌ها ---------- */
.btn, button.primary, button.secondary, button.danger, .link-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 8px 18px; border-radius: 999px; border: 1px solid transparent;
  font-weight: 600; text-decoration: none; transition: background var(--motion-fast), border-color var(--motion-fast), transform var(--motion-fast) var(--motion-ease);
}
button.primary, .btn.primary { background: var(--primary); color: var(--on-primary); }
button.primary:hover:not(:disabled) { background: var(--primary-hover); }
button.secondary, .btn.secondary, .link-button { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
button.secondary:hover:not(:disabled), .link-button:hover { background: var(--surface-2); }
button.danger { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
button.danger:hover:not(:disabled) { filter: brightness(.96); }
button.ghost, .btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
button.ghost:hover { background: var(--surface-2); color: var(--text); }
button:active:not(:disabled) { transform: scale(.98); }
.btn.sm, button.sm { min-height: 34px; padding: 4px 14px; font-size: .9em; }
.iconbtn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; border: 0; background: transparent; color: var(--text-2); }
.iconbtn:hover { background: var(--surface-2); color: var(--text); }

/* ---------- فرم ---------- */
.field { display: grid; gap: 6px; margin-bottom: 14px; font-weight: 600; font-size: .93em; color: var(--text-2); }
.field input, .field select, .field textarea, input.input, .search input {
  width: 100%; min-height: 46px; padding: 10px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font-weight: 400; font-size: 1rem;
}
.field textarea { min-height: 110px; resize: vertical; line-height: 1.8; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: transparent; }
.field input[type=checkbox] { width: auto; min-height: 0; }
.formgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr)); gap: 0 14px; }
.check { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.actions, .row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.actions { margin: 14px 0; }
.spread { justify-content: space-between; }

/* ---------- ساختار برنامه ---------- */
:is(.side-rail, .drawer, .tabbar) {
  border: 1px solid var(--lg-border);
  box-shadow: var(--lg-shadow);
  background: var(--lg-fallback);
}
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  :is(.side-rail, .drawer, .tabbar) {
    background: var(--lg-bg);
    -webkit-backdrop-filter: var(--lg-filter);
    backdrop-filter: var(--lg-filter);
  }
  .drawer { background: var(--lg-panel); }
}
.logo-dark { display: none; }
:root[data-theme="dark"] .logo-light { display: none; }
:root[data-theme="dark"] .logo-dark { display: inline; }
.app { min-height: 100svh; }
.nav {
  position: relative; display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 6px 14px; border: 0; border-radius: 999px;
  background: transparent; color: var(--text); font-weight: 500; white-space: nowrap; transition: background var(--motion-fast), color var(--motion-fast), transform var(--motion-fast) var(--motion-ease);
}
.nav .ico { color: var(--text-2); width: 1.15em; height: 1.15em; }
.nav:hover { background: var(--lg-control); }
.nav.active { background: var(--nav-active); color: var(--nav-active-text); font-weight: 600; }
.nav.active .ico { color: inherit; }
.nav .badge { margin-inline-start: 2px; }
.iconbtn { position: relative; }
.iconbtn.active { background: var(--nav-active); color: var(--nav-active-text); }
.badge { min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--bad); color: var(--badge-text); font-size: .74rem; font-weight: 600; text-align: center; line-height: 20px; }
.badge:empty, .badge[data-zero] { display: none; }
.iconbtn .badge { position: absolute; top: 1px; inset-inline-end: 0; min-width: 18px; line-height: 18px; font-size: .68rem; }
.avatar { width: 38px; height: 38px; border: 0; border-radius: 50%; display: grid; place-items: center; background: var(--primary); color: var(--on-primary); font-weight: 800; }
#main { min-width: 0; width: 100%; max-width: 1240px; margin-inline: auto; padding: max(28px, env(safe-area-inset-top)) clamp(16px, 4vw, 46px) 64px; }
#main:focus { outline: none; }
.pagehead { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.pagehead h1 { font-size: clamp(1.7rem, 2.6vw, 2.3rem); font-weight: 800; line-height: 1.3; letter-spacing: -.01em; }
.lede, .muted { color: var(--text-2); }
.pagehead .lede:not(:empty) { margin-top: 5px; }
.pagehead .row:empty { display: none; }

/* ---------- کارت و پنل ---------- */
.card, .panel, .workspace-panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.panel, .workspace-panel { padding: 20px; margin-bottom: 18px; }
.panel h3, .workspace-panel h2, .section-title { font-size: 1.05rem; font-weight: 800; margin-bottom: 12px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr)); gap: 14px; margin-bottom: 22px; }
.stat {
  display: grid; gap: 4px; padding: 18px 20px; text-align: start; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm);
}
button.stat:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.stat .label { display: flex; gap: 8px; align-items: center; color: var(--text-2); font-weight: 500; }
.stat strong { font-size: 2.1rem; line-height: 1.2; font-weight: 800; }
.stat.bad strong { color: var(--bad); }
.stat.good strong { color: var(--good); }
.stat.warn strong { color: var(--warn); }

/* ---------- کارها ---------- */
.projectbar, .segmented { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; align-items: center; }
.pill-btn {
  min-height: 36px; padding: 4px 16px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text); font-weight: 500;
}
.pill-btn[aria-pressed="true"], .pill-btn.on { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.board { display: grid; grid-template-columns: repeat(4, minmax(240px, 1fr)); gap: 14px; overflow-x: auto; padding-bottom: 8px; }
.lane { background: var(--surface-2); border-radius: var(--radius); padding: 12px; min-height: 160px; }
:root[data-theme="dark"] .lane { background: var(--surface); }
.lane-head { display: flex; justify-content: space-between; align-items: center; padding: 4px 6px 10px; font-weight: 800; }
.lane-count { min-width: 26px; padding: 0 8px; border-radius: 999px; background: var(--surface); color: var(--text-2); font-size: .85rem; text-align: center; }
:root[data-theme="dark"] .lane-count { background: var(--surface-3); }
.task-card {
  display: grid; gap: 10px; padding: 14px; margin-bottom: 10px; border-radius: 12px; background: var(--surface);
  border: 1px solid var(--border); cursor: pointer; box-shadow: var(--shadow-sm); text-align: start;
}
:root[data-theme="dark"] .task-card { background: var(--surface-2); border-color: transparent; }
.task-card:hover { border-color: var(--border-strong); }
.task-title { font-weight: 600; line-height: 1.6; }
.task-foot { display: flex; justify-content: space-between; gap: 8px; color: var(--text-2); font-size: .88rem; }
.task-list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.task-list-head, .task-line { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 1.4fr) minmax(0, 1.2fr) minmax(0, 1.3fr); gap: 12px; align-items: center; padding: 12px 18px; }
.task-list-head { background: var(--surface-2); color: var(--text-2); font-size: .85rem; font-weight: 600; }
.task-line { border-top: 1px solid var(--border); cursor: pointer; }
.task-line:hover { background: var(--surface-2); }
.task-line small { display: block; color: var(--text-2); }
.task-line strong { font-weight: 600; }
.tag, .status-tag, .chip {
  display: inline-flex; align-items: center; gap: 6px; width: fit-content; padding: 2px 11px; border-radius: 999px;
  background: var(--info-bg); color: var(--text-2); font-size: .85rem; font-weight: 500; font-style: normal; white-space: nowrap;
}
.tag::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.tag.bad { background: var(--bad-bg); color: var(--bad); }
.tag.good { background: var(--good-bg); color: var(--good); }
.tag.warn { background: var(--warn-bg); color: var(--warn); }
.chip::before { display: none; }
.due.late { color: var(--bad); font-weight: 600; }
.due.soon { color: var(--warn); font-weight: 600; }
.empty { display: grid; justify-items: center; gap: 8px; padding: 36px 16px; color: var(--text-2); text-align: center; }
.empty .ico { width: 34px; height: 34px; color: var(--text-3); }
.lane .empty { padding: 20px 8px; font-size: .9rem; }
.item-row { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 14px 0; border-top: 1px solid var(--border); }
.item-row:first-child { border-top: 0; }
.item-row small { display: block; color: var(--text-2); }
.review-note { margin-top: 6px; padding: 8px 12px; border-radius: 10px; background: var(--info-bg); color: var(--text-2); }
.comment { padding: 12px 14px; margin-bottom: 10px; border-radius: 12px; background: var(--surface-2); }
.comment small { display: flex; gap: 10px; align-items: center; color: var(--text-2); margin-bottom: 4px; }
.output-text { white-space: pre-wrap; line-height: 1.9; }
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 14px; text-align: start; border-top: 1px solid var(--border); white-space: nowrap; }
th { color: var(--text-2); font-size: .85rem; font-weight: 600; border-top: 0; background: var(--surface-2); }
hr { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }

/* ---------- گفت‌وگو ---------- */
.chat-log { display: grid; gap: 10px; max-height: 58vh; overflow-y: auto; padding: 6px 2px 14px; }
.chat-message { padding: 12px 16px; border-radius: 18px; background: var(--surface-2); max-width: 760px; }
.chat-message.mine { background: var(--info-bg); margin-inline-start: auto; }
.chat-message.ai { border: 1px dashed var(--border-strong); background: transparent; }
.chat-message p { white-space: pre-wrap; margin: 4px 0; }
.chat-message img, .chat-message video { max-width: min(100%, 360px); border-radius: 12px; display: block; margin: 6px 0; }
.chat-message audio { width: min(100%, 320px); display: block; margin: 6px 0; }
.chat-message .meta { display: flex; gap: 10px; align-items: baseline; color: var(--text-2); font-size: .85rem; }
.chat-form { border-top: 1px solid var(--border); padding-top: 14px; margin-top: 8px; }

/* ---------- تقویم ---------- */
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; margin-top: 14px; }
.calendar-grid > b { text-align: center; color: var(--text-2); font-size: .85rem; font-weight: 600; padding: 4px 0; }
.cal-cell { min-height: 78px; padding: 4px; border-radius: 12px; display: grid; align-content: start; gap: 2px; }
.cal-cell button.day { width: 100%; min-height: 32px; border: 0; border-radius: 8px; background: transparent; font-weight: 600; text-align: start; padding: 2px 8px; }
.cal-cell button.day:hover { background: var(--surface-2); }
.cal-cell button.day[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); }
.cal-cell.today button.day { box-shadow: inset 0 0 0 2px var(--primary); }
.cal-cell small { display: block; padding: 1px 8px; border-radius: 6px; background: var(--info-bg); color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .75rem; }

/* ---------- نامه ---------- */
.letter-paper { margin: 14px 0; padding: 22px; border-radius: 12px; background: #fff; color: #1c1c1e; border: 1px solid var(--border); box-shadow: var(--shadow-sm); min-height: 180px; }
.letter-paper[data-paper="A5"] { max-width: 420px; }
.letter-paper img { width: 20px; vertical-align: middle; margin-inline-end: 6px; }
.letter-paper p { white-space: pre-wrap; line-height: 2; margin-top: 10px; }
.team-picker, .tool-list { display: grid; gap: 8px; margin-bottom: 14px; max-height: 260px; overflow-y: auto; }

/* ---------- دیالوگ ---------- */
.modal-bg { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 20px; background: var(--scrim); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
.modal {
  width: min(680px, 100%); max-height: 90svh; overflow-y: auto; border-radius: 22px; background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-lg); padding: 22px 24px 26px; animation: rise var(--motion-panel) var(--motion-ease);
}
.modal.small { width: min(420px, 100%); }
.modalhead { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.modalhead h2 { font-size: 1.2rem; font-weight: 800; }
@keyframes rise { from { opacity: 0; transform: translateY(12px) scale(.98); } }
@keyframes sheet-in { from { transform: translateY(32px); opacity: .65; } }
@keyframes shade-in { from { opacity: 0; } }
.modal-bg, .install-bg { animation: shade-in var(--motion-fast) ease-out; }
button.stat, .task-card, .task-line, .pill-btn {
  transition: background var(--motion-fast), border-color var(--motion-fast), transform var(--motion-fast) var(--motion-ease);
}
:is(.task-card, .task-line)[role="button"]:active { transform: scale(.989); }
.toast:not([hidden]), .datepop { animation: rise 220ms var(--motion-ease); }
.toast {
  position: fixed; z-index: 80; inset-inline: 0; bottom: 28px; margin-inline: auto; width: fit-content; max-width: min(92vw, 520px);
  padding: 12px 20px; border-radius: 999px; background: var(--text); color: var(--bg); box-shadow: var(--shadow-lg); font-weight: 500;
}
.toast.error { background: var(--bad); color: var(--badge-text); }
.skeleton { border-radius: 12px; background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.3s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.sk-row { height: 64px; margin-bottom: 10px; }
.sk-stat { height: 98px; }

/* ---------- انتخاب‌گر تاریخ ---------- */
.datepick { position: relative; }
.datepop {
  position: absolute; z-index: 70; inset-inline-start: 0; top: calc(100% + 6px); width: 300px; padding: 12px; border-radius: 16px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
}
.datepop header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-weight: 800; }
.datepop .calendar-grid { margin-top: 4px; gap: 2px; }
.datepop .d { min-height: 36px; border: 0; border-radius: 50%; background: transparent; }
.datepop .d:hover { background: var(--surface-2); }
.datepop .d.sel { background: var(--primary); color: var(--on-primary); }
.datepop .d.today { box-shadow: inset 0 0 0 1.5px var(--primary); }

/* ---------- ورود ---------- */
.login-page { min-height: 100svh; display: flex; flex-direction: column; }
.login-main { flex: 1; display: grid; place-items: center; padding: max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom)); }
.login-card { width: min(100%, 440px); background: var(--surface); border: 1px solid var(--border); border-radius: 30px; padding: clamp(20px, 6vw, 34px); box-shadow: var(--shadow); animation: rise var(--motion-panel) var(--motion-ease); }
.signin-mark { display: block; margin: 0 auto 16px; border-radius: 16px; }
.login-card form:not([hidden]) { animation: rise 220ms var(--motion-ease); }
.login-card h1 { font-size: clamp(1.7rem, 5vw, 2.2rem); font-weight: 800; line-height: 1.35; text-align: center; margin-bottom: 8px; letter-spacing: -.01em; }
.login-card p { color: var(--text-2); text-align: center; }
.login-card form, .login-stack { margin-top: 28px; display: grid; gap: 12px; }
.login-card label { font-weight: 600; font-size: .92rem; color: var(--text-2); }
.login-card input {
  display: block; width: 100%; height: 50px; margin-top: 6px; padding: 10px 16px; border: 1px solid var(--border-strong); border-radius: 12px;
  background: var(--surface); color: var(--text); font-size: 1.1rem; text-align: start;
}
.login-card input::placeholder { color: var(--text-3); }
.login-card input:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: transparent; }
.login-card #code { text-align: center; letter-spacing: .5em; font-size: 1.35rem; }
.captcha-box { display: flex; justify-content: center; min-height: 0; }
.sign-in {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 48px; margin-top: 4px;
  border: 0; border-radius: 12px; background: var(--primary); color: var(--on-primary); font-weight: 800; font-size: 1rem;
}
.sign-in svg { width: 20px; height: 20px; }
.sign-in:hover:not(:disabled) { background: var(--primary-hover); }
.plain-button { display: block; width: 100%; min-height: 48px; margin-top: 10px; border: 1px solid var(--border-strong); border-radius: 12px; background: transparent; color: var(--text); font-weight: 600; }
.plain-button:hover { background: var(--surface-2); }
.login-actions { display: flex; justify-content: space-between; gap: 8px; }
.login-actions button { border: 0; background: none; color: var(--primary); font-weight: 600; padding: 8px 2px; text-decoration: underline; text-underline-offset: 4px; }
.login-actions button:disabled { text-decoration: none; color: var(--text-3); }
.login-card .login-status { color: var(--bad); min-height: 2.6em; margin-top: 10px; font-size: .92em; text-align: center; }

/* ---------- مدال نصب وب‌اپ ---------- */
.install-bg { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 20px; background: var(--scrim); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.install-card { width: min(440px, 100%); max-height: calc(100dvh - 40px); overflow: auto; border-radius: 30px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-lg); animation: rise var(--motion-panel) var(--motion-ease); }
.install-art { display: grid; place-items: center; height: 126px; background: var(--surface-2); }
.install-art img { box-sizing: content-box; width: 38px; height: 38px; padding: 13px; background: #5e4f47; border-radius: 16px; box-shadow: var(--shadow); }
.install-body { padding: 24px 26px 26px; }
.install-body h2 { margin: 0 0 6px; font-size: 1.35rem; font-weight: 800; }
.install-body > p { color: var(--text-2); }
.install-body .sign-in { margin-top: 18px; }
.install-help { margin-top: 12px; padding: 10px 14px; border-radius: 12px; background: var(--info-bg); color: var(--text-2); font-size: .9rem; }

/* ---------- ناوبری کناری و موبایل ---------- */
.skip-link { position: fixed; z-index: 65; inset-block-start: 12px; inset-inline-start: 12px; padding: 10px 16px; background: var(--surface); border-radius: 12px; transform: translateY(-150%); }
.skip-link:focus { transform: none; }
.side-rail, .tabbar { display: none; }
body.drawer-active { overflow: hidden; }
@media (min-width: 1024px) {
  .app {
    --rail-width: 62px;
    display: grid; grid-template-columns: minmax(0, 1fr) calc(var(--rail-width) + 24px);
    transition: grid-template-columns var(--motion-panel) var(--motion-ease);
  }
  .app.rail-expanded { --rail-width: 230px; }
  #main { grid-column: 1; grid-row: 1; padding-top: max(36px, env(safe-area-inset-top)); }
  .side-rail {
    position: fixed; z-index: 35; inset-inline-end: max(12px, env(safe-area-inset-left));
    inset-block: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-bottom));
    width: var(--rail-width); display: flex; flex-direction: column; align-items: stretch; gap: 8px; padding: 8px;
    border-radius: 22px; overflow: hidden;
    transition: width var(--motion-panel) var(--motion-ease);
  }
  .rail-top { display: flex; align-items: center; justify-content: space-between; padding-inline-start: 8px; min-height: 46px; }
  .rail-brand { display: inline-flex; }
  .rail-brand img { width: 100px; height: auto; }
  .rail-toggle { flex: none; }
  .rail-bottom { padding-top: 7px; border-top: 1px solid var(--border); }
  #rail-items { flex: 1; min-height: 0; overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; padding: 2px; }
  .side-rail .nav { width: 100%; min-height: 42px; border-radius: 12px; padding-inline: 9px; }
  .side-rail .badge { margin-inline-start: auto; }
  .side-rail .avatar { width: 28px; height: 28px; flex: none; }
  .rail-account-name { overflow: hidden; text-overflow: ellipsis; }
  .app:not(.rail-expanded) .rail-top { justify-content: center; padding-inline-start: 0; }
  .app:not(.rail-expanded) .side-rail :is(.rail-brand, .drawer-label, .nav span:not(.badge):not(.avatar)) { display: none; }
  .app:not(.rail-expanded) .side-rail .nav { padding: 0; justify-content: center; }
  .app:not(.rail-expanded) .side-rail .badge { position: absolute; top: 0; inset-inline-end: 0; }
}
.panel, .workspace-panel, .task-title, .task-line strong, .chat-message, .drawer-user { overflow-wrap: anywhere; }
.task-line > *, .pagehead > *, .panel, .workspace-panel { min-width: 0; }

.drawer-scrim {
  position: fixed; inset: 0; z-index: 58; background: var(--scrim); opacity: 0; visibility: hidden;
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
  transition: opacity var(--motion-panel), visibility 0s var(--motion-panel);
}
.drawer {
  position: fixed; z-index: 59; inset-block: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-bottom));
  left: max(8px, env(safe-area-inset-left)); width: min(calc(100% - 24px), 360px);
  display: flex; flex-direction: column; gap: 12px; padding: 14px;
  border-radius: 25px; transform: translateX(calc(-100% - 24px)); visibility: hidden;
  transition: transform var(--motion-panel) var(--motion-ease), visibility 0s var(--motion-panel);
  overflow-y: auto; overscroll-behavior: contain; scroll-padding-block: 12px;
}
.drawer.open { transform: none; visibility: visible; transition-delay: 0s; }
.drawer-scrim.open { opacity: 1; visibility: visible; transition-delay: 0s; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding-inline: 6px; }
.drawer-head img { height: 27px; width: auto; }
.drawer-head .iconbtn { width: 44px; height: 44px; background: var(--lg-control); }
.drawer-group { display: grid; gap: 2px; }
.drawer-label { padding: 9px 9px 3px; font-size: .78rem; font-weight: 600; color: var(--text-3); }
.drawer .nav { width: 100%; justify-content: flex-start; min-height: 44px; border-radius: 13px; }
:is(.side-rail, .drawer) .js-search { background: var(--lg-control); }
:is(.side-rail, .drawer) .js-search:hover { background: var(--surface-3); }
.drawer .nav .badge { margin-inline-start: auto; }
.drawer-account { padding: 5px 4px; border-block: 1px solid var(--border); }
.drawer-user { display: flex; align-items: center; gap: 10px; padding: 4px 8px; min-width: 0; }
.drawer-user small { display: block; color: var(--text-2); }
.drawer-user .avatar { flex: none; }
.account-summary { margin-bottom: 12px; }
.account-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.drawer .account-actions .nav { flex: 1; width: auto; padding-inline: 8px; }
.account-actions .theme-icon { display: inline-flex; }
.search-actions { justify-content: flex-end; }

@media (max-width: 1023px) {
  #main { padding-bottom: calc(92px + env(safe-area-inset-bottom)); }
  .tabbar {
    position: fixed; z-index: 55; inset-inline: max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-left));
    bottom: max(8px, env(safe-area-inset-bottom)); margin-inline: auto; width: auto; max-width: 480px;
    display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 2px; padding: 5px; border-radius: 26px;
    animation: rise var(--motion-panel) var(--motion-ease);
  }
  .tabbar button {
    position: relative; display: grid; place-items: center; align-content: center; gap: 2px; min-height: 48px; padding: 3px 0;
    border: 0; border-radius: 20px; background: transparent; color: var(--text-2); font-size: .72rem; font-weight: 600;
    transition: background var(--motion-fast), color var(--motion-fast), transform var(--motion-fast) var(--motion-ease);
  }
  .tabbar button .ico { width: 22px; height: 22px; }
  .tabbar button:is(.active, [aria-expanded="true"]) { background: var(--lg-selected); color: var(--lg-selected-text); }
  .tabbar .badge { position: absolute; top: 2px; inset-inline-start: 54%; margin: 0; font-size: .67rem; min-width: 18px; padding: 0 4px; line-height: 18px; }
  .task-list-head { display: none; }
  .task-line { grid-template-columns: minmax(0, 1fr) auto; row-gap: 6px; padding-inline: 12px; }
  .task-line > :nth-child(2) { grid-column: 1; color: var(--text-2); font-size: .88rem; }
  .task-line > :nth-child(3) { grid-column: 2; grid-row: 1; justify-self: end; }
  .task-line > :nth-child(4) { grid-column: 2; grid-row: 2; justify-self: end; }
  .board { grid-template-columns: repeat(4, 82vw); scroll-snap-type: x mandatory; }
  .lane { scroll-snap-align: start; }
  .modal-bg { align-items: end; padding: 0; }
  .modal { width: 100%; max-height: min(92svh, 100dvh); border-radius: 24px 24px 0 0; padding-bottom: max(24px, env(safe-area-inset-bottom)); animation-name: sheet-in; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stat strong { font-size: 1.8rem; }
  .cal-cell { min-height: 54px; }
  .cal-cell small { display: none; }
  .toast { bottom: calc(82px + env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
#confirmBox { z-index: 95; }
.dash-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 18px; }
.dash-grid .panel { margin-bottom: 0; }
.dash-grid + .panel { margin-top: 18px; }
input[type=file] { max-width: 100%; color: var(--text-2); }
input[type=file]::file-selector-button {
  margin-inline-end: 12px; padding: 7px 16px; border: 1px solid var(--border-strong); border-radius: 999px;
  background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
}
.field input[type=file] { min-height: 0; padding: 8px; }
.brand-tag { font-size: .7rem; font-weight: 600; padding: 1px 7px; border-radius: 6px; background: var(--info-bg); color: var(--text-2); vertical-align: middle; letter-spacing: .04em; }

/* ---------- مدیریت کار پیشرفته ---------- */
.filterbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.filterbar select { min-height: 38px; padding: 4px 12px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); }
.check.inline { margin: 0 6px; }
.view-chip { display: inline-flex; align-items: center; }
.lbl { display: inline-flex; align-items: center; gap: 4px; padding: 1px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; background: var(--info-bg); color: var(--text-2); }
.lbl-brown { background: rgba(162, 132, 94, .16); color: #72563a; }
.lbl-gold { background: var(--warn-bg); color: var(--warn); }
.lbl-slate { background: var(--surface-3); color: var(--text-2); }
.lbl-plum { background: rgba(175, 82, 222, .12); color: #7834a3; }
:root[data-theme="dark"] .lbl-brown { color: #d9c5a8; }
:root[data-theme="dark"] .lbl-plum { background: rgba(191, 90, 242, .16); color: #dda6f7; }
.lbl.pick { cursor: pointer; padding: 3px 12px; }
.lbl.pick input { accent-color: var(--primary); }
.lbl-x { border: 0; background: none; color: inherit; padding: 0 2px; font-size: 1rem; line-height: 1; }
.meta-row { gap: 10px; color: var(--text-2); font-size: .82rem; }
.meta { display: inline-flex; align-items: center; gap: 4px; }
.meta.done { color: var(--good); }
.meta.blocked { color: var(--bad); }
.meta .ico { width: 1em; height: 1em; }
.task-card.dragging { opacity: .45; }
.lane.over { outline: 2px dashed var(--primary); outline-offset: -4px; }
.progress { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; margin-bottom: 10px; }
.progress > span { display: block; height: 100%; width: var(--p, 0%); border-radius: inherit; background: var(--good); }
.subtask .struck { text-decoration: line-through; color: var(--text-3); }
.row input[type=text], .row input[type=number], #subtask-form input, #time-form input { flex: 1; min-width: 90px; min-height: 38px; padding: 4px 12px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); }
.activity { margin: 8px 0; color: var(--text-2); }
.activity summary { cursor: pointer; font-weight: 600; margin-bottom: 6px; }
.gantt { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.gantt-head, .gantt-row { display: grid; grid-template-columns: 200px minmax(520px, 1fr); gap: 12px; align-items: center; }
.gantt-scale { position: relative; height: 26px; color: var(--text-3); font-size: .78rem; }
.gantt-scale span { position: absolute; inset-inline-start: var(--s, 0); white-space: nowrap; }
.gantt-row { min-height: 40px; border-top: 1px solid var(--border); }
.gantt-name { border: 0; background: none; text-align: start; color: var(--text); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gantt-name:hover { text-decoration: underline; }
.gantt-track { position: relative; height: 22px; border-radius: 8px; background: var(--surface-2); }
.gantt-track::after { content: ''; position: absolute; top: -6px; bottom: -6px; inset-inline-start: var(--today, 0); width: 2px; background: var(--bad); opacity: .6; }
.gantt-bar { position: absolute; top: 3px; bottom: 3px; inset-inline-start: var(--s, 0); width: var(--w, 4%); min-width: 6px; border-radius: 999px; background: var(--primary); opacity: .85; }
.gantt-bar.good { background: var(--good); } .gantt-bar.bad { background: var(--bad); } .gantt-bar.warn { background: var(--warn); }
@media (max-width: 1023px) { .gantt-head, .gantt-row { grid-template-columns: 130px minmax(520px, 1fr); } }

@media (max-width: 380px) {
  .stats { gap: 8px; }
  .stat { padding: 12px; }
  .pagehead { gap: 12px; }
  .panel, .workspace-panel { padding: 14px; }
}

@media (prefers-reduced-transparency: reduce), (forced-colors: active) {
  :is(.side-rail, .drawer, .tabbar) {
    background: var(--lg-fallback);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .drawer-scrim {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}
@media (forced-colors: active) {
  :is(.side-rail .nav, .drawer .nav, .tabbar button)[aria-current="page"] { border: 1px solid Highlight; }
}

@media (min-width: 1024px) { .drawer, .drawer-scrim { display: none; } }

.module-split { display: grid; grid-template-columns: minmax(205px, 285px) minmax(0, 1fr); gap: 14px; align-items: start; }
.module-list { display: grid; gap: 5px; margin-block: 10px; }
.module-list .nav { width: 100%; justify-content: flex-start; white-space: normal; text-align: start; }
.module-list .nav small { color: var(--text-2); }
.module-list .nav[aria-pressed="true"] { background: var(--lg-selected); color: var(--lg-selected-text); }
.module-search .field { margin-bottom: 6px; }
@media (max-width: 760px) { .module-split { grid-template-columns: minmax(0, 1fr); } }

.board-scroll { overflow: auto; max-height: 540px; margin-block: 12px; border: 1px solid var(--border); border-radius: 14px; }
.sticky-board { position: relative; width: 1200px; height: 850px; background: radial-gradient(var(--lg-divider) 1px, transparent 1px) 0 0 / 18px 18px, var(--bg); }
.sticky-note { position: absolute; width: 175px; padding: 8px; border-radius: 12px; background: var(--warn-bg); border: 1px solid var(--border); box-shadow: var(--shadow-sm); }
.sticky-note textarea { width: 100%; height: 92px; resize: none; background: transparent; border: 0; padding: 6px; color: var(--text); }
.sticky-handle { touch-action: none; cursor: grab; }
.formatted-text { white-space: pre-wrap; overflow-wrap: anywhere; }
/* ناوبری راست‌چین و نمای پیام‌رسان */
@media(min-width:1024px){
 .app { grid-template-columns:calc(var(--rail-width) + 24px) minmax(0,1fr) }
 #main {grid-column:2}
 .side-rail {inset-inline-end:auto;inset-inline-start:max(12px,env(safe-area-inset-right))}
}
.drawer {left:auto;right:max(8px,env(safe-area-inset-right));transform:translateX(calc(100% + 24px))}
.drawer.open {transform:none}
.pagehead{text-align:start}
#more-tab {grid-column:1;grid-row:1}
.calendar-grid abbr,.thread-return {display:none}
.messenger summary {cursor:pointer;padding:8px}
.thread-panel {min-width:0}
.messenger .chat-log {max-height:54dvh;min-height:170px;align-content:start}
.messenger .chat-message {width:fit-content;max-width:88%}
.messenger .chat-message.mine {margin-inline-start:0;margin-inline-end:auto;border-inline-start:3px solid var(--primary)}
.messenger .chat-message:not(.mine) {margin-inline-start:auto}
.messenger audio,.messenger input[type=file] {max-width:100%}
#room-send textarea {min-height:52px}
.letter-paper textarea {width:100%;border:0;background:white;color:#1c1c1e;line-height:2;resize:vertical}
.modal:has(#letter-form){width:min(860px,100%)}
#letter-form .letter-paper{padding:clamp(18px,5vw,60px)}
@media(max-width:660px){
.calendar-grid .weekday-full {display:none}
.calendar-grid abbr {display:inline;text-decoration:none}
.messenger .thread-panel,.messenger.thread-open>section:first-child {display:none}
.messenger.thread-open .thread-panel,.thread-return {display:block}
.thread-return {margin-bottom:12px}
.messenger button {min-height:42px}
}
@media(prefers-reduced-motion:no-preference){
.messenger .thread-panel,.letter-paper {animation:rise 200ms var(--motion-ease)}
}
.letter-edit {min-height:16rem;line-height:2.15;color:#1c1c1e;background:white;white-space:pre-wrap;overflow-wrap:anywhere;padding:12px 2px}
.letter-edit:focus-visible {outline:0;box-shadow:inset 0 -2px var(--primary)}
.letter-paper[data-paper=A5]{margin-inline:auto;width:100%}
@media(max-width:660px){.calendar-grid{gap:2px}.cal-cell{min-width:0}.letter-edit{min-height:12rem}}
.conversation {gap:10px;min-height:58px}
.conversation-icon {display:grid;place-items:center;flex:none;width:36px;height:36px;border-radius:12px;background:var(--surface-2)}
.conversation-copy {display:grid;gap:2px;min-width:0;text-align:start}
.conversation-copy small,.conversation-copy strong {overflow:hidden;white-space:nowrap;text-overflow:ellipsis}
#room-send {border-top:1px solid var(--border);padding-block-start:12px}
#room-send input[type=file]{display:block;font-size:.82rem}
@media(prefers-reduced-motion:no-preference){
 .pill-btn,.nav,.secondary,.primary,.iconbtn,.tabbar button{transition:background-color 160ms ease,color 160ms ease,transform 150ms var(--motion-ease)}
 #content>section:first-child,.letter-library details[open] .actions,.chat-message:last-child{animation:shade-in 180ms ease-out}
}
