/* iNotion v0.9 — RTL, Dark Mode, Glass Morphism, Micro-animations */
/* Inspired by Linear 2026 "calmer interface" refresh */

@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@100..900&display=swap');

/* ── CSS Custom Properties ─────────────────────────────────────────────── */
:root {
  /* Light palette */
  --bg:          #f4f4f8;
  --bg-2:        #eeeef4;
  --surface:     #ffffff;
  --surface-2:   #f8f8fc;
  --surface-3:   #f0f0f6;
  --border:      #e2e2ec;
  --border-2:    #d0d0de;
  --text:        #18181e;
  --text-2:      #3c3c50;
  --text-muted:  #7a7a96;
  --primary:     #5b51e8;
  --primary-2:   #4a42d6;
  --primary-bg:  #eeedfb;
  --danger:      #e03e3e;
  --danger-bg:   #fff1f1;
  --success:     #2da44e;
  --success-bg:  #edfcf2;
  --warning:     #c47d0e;
  --warning-bg:  #fff8e6;
  --shadow-sm:   0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md:   0 4px 16px rgba(0,0,0,.10), 0 2px 6px rgba(0,0,0,.06);
  --shadow-lg:   0 12px 40px rgba(0,0,0,.14), 0 4px 12px rgba(0,0,0,.08);
  --radius-sm:   6px;
  --radius:      10px;
  --radius-lg:   16px;
  --radius-xl:   22px;
  --transition:  .18s cubic-bezier(.4,0,.2,1);
  --font:        'Vazirmatn', 'Segoe UI', Tahoma, sans-serif;
}

[data-theme="dark"] {
  --bg:          #0f0f12;
  --bg-2:        #14141a;
  --surface:     #1a1a22;
  --surface-2:   #202028;
  --surface-3:   #26262e;
  --border:      #2c2c3a;
  --border-2:    #38384a;
  --text:        #eaeaf4;
  --text-2:      #b8b8d0;
  --text-muted:  #606078;
  --primary:     #7c70f5;
  --primary-2:   #9188f7;
  --primary-bg:  #1e1c3a;
  --danger:      #f87171;
  --danger-bg:   #2a1a1a;
  --success:     #4ade80;
  --success-bg:  #0f2a1a;
  --warning:     #fbbf24;
  --warning-bg:  #2a2000;
  --shadow-sm:   0 1px 3px rgba(0,0,0,.3);
  --shadow-md:   0 4px 16px rgba(0,0,0,.4);
  --shadow-lg:   0 12px 40px rgba(0,0,0,.5);
}

/* ── Reset & Base ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { color-scheme: light; scroll-behavior: smooth; }
[data-theme="dark"] { color-scheme: dark; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  direction: rtl;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  overflow-x: clip;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
#app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  min-height: 100svh;
}
.mobile-only { display: none !important; }
.inbox-wrap { position: relative; }
.settings-mobile-actions.mobile-only { display: none !important; }
.icon-btn {
  width: 40px; height: 40px; min-width: 40px;
  border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 16px; color: var(--text-muted);
  background: transparent; border: none; flex-shrink: 0;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.mobile-kanban-tabs { display: none; }
.bottom-nav { display: none; }
.mobile-board-btn { display: none; }
.filter-bar-head { display: contents; }
#filter-bar .filter-toggle { display: none; }

/* Mobile board picker sheet */
.mobile-sheet {
  position: fixed; inset: 0; z-index: 220;
  background: rgba(0,0,0,.4);
  backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 0;
}
.mobile-sheet-box {
  width: 100%; max-height: min(78dvh, 560px);
  background: var(--surface);
  border-radius: 18px 18px 0 0;
  padding: 10px 16px calc(16px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  animation: slideUp .2s ease;
}
.mobile-sheet-handle {
  width: 40px; height: 4px; border-radius: 99px;
  background: var(--border-2); margin: 4px auto 10px;
}
.mobile-sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.mobile-sheet-head h3 { font-size: 16px; font-weight: 700; }
.mobile-board-list {
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  display: flex; flex-direction: column; gap: 8px;
  min-height: 0; flex: 1;
}
.mobile-board-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  text-align: right; width: 100%;
  padding: 14px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
}
.mobile-board-item.active {
  border-color: var(--primary);
  background: var(--primary-bg);
  color: var(--primary);
}
.mobile-board-item strong { font-size: 14px; display: block; }
.mobile-board-meta { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.mobile-board-empty { color: var(--text-muted); padding: 20px; text-align: center; }
.btn-full { width: 100%; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; border: none; background: none; font-family: var(--font); font-size: inherit; color: inherit; }
input, select, textarea { font-family: var(--font); font-size: inherit; direction: rtl; color: var(--text); background: var(--surface); }
::selection { background: var(--primary-bg); color: var(--primary); }

/* ── Utilities ──────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.input-full {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.input-full:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-bg);
}
.error { color: var(--danger); font-size: 13px; }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--radius-sm);
  font-weight: 500; font-size: 13.5px;
  transition: background var(--transition), color var(--transition), box-shadow var(--transition), transform var(--transition);
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 1px 4px rgba(91,81,232,.3); }
.btn-primary:hover { background: var(--primary-2); box-shadow: 0 2px 8px rgba(91,81,232,.4); }
.btn-outline { border: 1px solid var(--border); color: var(--text-2); background: var(--surface); }
.btn-outline:hover { background: var(--surface-2); border-color: var(--border-2); }
.btn-ghost { color: var(--text-muted); background: transparent; }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(1.1); }
.btn-danger-outline {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 35%, var(--border));
  background: transparent;
}
.btn-danger-outline:hover {
  background: var(--danger-bg);
  color: var(--danger);
}
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-full { width: 100%; }
.btn-icon {
  background: none; border: none; cursor: pointer; color: var(--text-muted);
  padding: 3px 5px; border-radius: 4px; font-size: 14px;
  transition: color var(--transition), background var(--transition);
}
.btn-icon:hover { color: var(--text); background: var(--surface-2); }
.btn-google {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); display: flex; align-items: center;
  gap: 8px; padding: 10px 20px; border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}
.btn-google:hover { background: var(--surface-2); }

/* ── Auth ───────────────────────────────────────────────────────────────── */
.auth-box {
  max-width: 400px; margin: 100px auto;
  background: var(--surface); border-radius: var(--radius-lg);
  padding: 40px; box-shadow: var(--shadow-lg);
  text-align: center; border: 1px solid var(--border);
  animation: fadeUp .3s ease;
}
.auth-box h1 { font-size: 28px; color: var(--primary); margin-bottom: 8px; font-weight: 700; }
.auth-box p { color: var(--text-muted); margin-bottom: 20px; }
.auth-box input { width: 100%; padding: 10px 12px; margin: 8px 0; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.auth-box input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-bg); }

/* ── Header ─────────────────────────────────────────────────────────────── */
#app-header {
  display: flex; flex-direction: column; gap: 6px;
  padding: 8px 16px;
  background: rgba(var(--surface-rgb, 255,255,255), .85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow-sm);
  transition: background var(--transition);
  flex-shrink: 0;
}
.header-top {
  display: flex; align-items: center; gap: 10px;
  min-height: 40px;
}
[data-theme="dark"] #app-header { background: rgba(26,26,34,.88); }
.logo { font-size: 18px; font-weight: 700; color: var(--primary); letter-spacing: -.5px; flex-shrink: 0; }
.board-select {
  padding: 5px 10px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface);
  font-size: 13px; color: var(--text-2); max-width: 220px;
  min-width: 0; flex: 1 1 auto;
}
.main-nav {
  display: flex; gap: 2px; flex-wrap: nowrap;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 2px;
}
.main-nav::-webkit-scrollbar { display: none; }
.nav-btn {
  padding: 6px 11px; border-radius: var(--radius-sm);
  color: var(--text-muted); font-size: 13px;
  transition: background var(--transition), color var(--transition);
  flex: 0 0 auto; white-space: nowrap;
}
.nav-btn:hover { background: var(--surface-2); color: var(--text); }
.nav-btn.active { background: var(--primary-bg); color: var(--primary); font-weight: 600; }
.header-actions { display: flex; align-items: center; gap: 6px; margin-right: auto; flex-shrink: 0; }
.header-brand { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.user-badge {
  background: var(--primary-bg); color: var(--primary);
  border-radius: 20px; padding: 3px 10px; font-size: 12px; font-weight: 500;
}
.dark-toggle {
  width: 32px; height: 32px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; color: var(--text-muted);
  background: none; transition: background var(--transition);
}
.dark-toggle:hover { background: var(--surface-2); }

/* Inbox bell */
.inbox-badge {
  position: absolute; top: 2px; left: 2px;
  background: var(--danger); color: #fff;
  border-radius: 50%; width: 16px; height: 16px;
  font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  animation: pop .2s ease;
  pointer-events: none;
}

/* ── Filter Bar ─────────────────────────────────────────────────────────── */
#filter-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 8px 16px;
  transition: background var(--transition);
  flex-shrink: 0;
}
.filter-toggle {
  display: none;
  width: 100%;
  text-align: right;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 500;
}
.filter-controls { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filter-controls input,
.filter-controls select {
  padding: 5px 9px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 13px;
  background: var(--surface-2); color: var(--text);
  transition: border-color var(--transition);
}
.filter-controls input:focus, .filter-controls select:focus {
  outline: none; border-color: var(--primary);
}
.filter-chips { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 6px; }
.chip {
  background: var(--primary-bg); color: var(--primary);
  border-radius: 20px; padding: 3px 10px; font-size: 12px;
  cursor: pointer; border: 1px solid transparent;
  transition: background var(--transition), filter var(--transition);
  animation: popIn .15s ease;
}
.chip:hover { filter: brightness(.95); }
.chip-high { background: var(--danger-bg); color: var(--danger); }
.chip-medium { background: var(--warning-bg); color: var(--warning); }
.chip-low { background: var(--success-bg); color: var(--success); }

/* ── Stats Widget ───────────────────────────────────────────────────────── */
#stats-widget {
  display: flex; align-items: center; gap: 16px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 16px;
  margin-bottom: 16px; box-shadow: var(--shadow-sm);
  animation: fadeUp .25s ease;
}
.stats-item { display: flex; flex-direction: column; gap: 2px; }
.stats-label { font-size: 11px; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: .5px; }
.stats-value { font-size: 20px; font-weight: 700; color: var(--text); }
.stats-progress { flex: 1; }
.progress-bar-wrap {
  background: var(--border); border-radius: 99px; height: 6px; overflow: hidden;
}
.progress-bar-fill {
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  height: 100%; border-radius: 99px;
  transition: width .6s cubic-bezier(.4,0,.2,1);
}
.streak-badge {
  background: var(--warning-bg); color: var(--warning);
  border-radius: var(--radius-sm); padding: 4px 10px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}

/* ── Layout ─────────────────────────────────────────────────────────────── */
#main-layout {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
#content-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  -webkit-overflow-scrolling: touch;
}
.view-section { min-height: 100%; }
#view-board.view-section { height: 100%; display: flex; flex-direction: column; }

/* ── Kanban ─────────────────────────────────────────────────────────────── */
.kanban-board {
  display: flex; gap: 14px; height: 100%; min-height: 0;
  overflow-x: auto; overflow-y: hidden;
  padding-bottom: 16px;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
}
.kanban-col {
  flex: 0 0 290px; display: flex; flex-direction: column;
  background: var(--surface-2); border-radius: var(--radius);
  border: 1px solid var(--border); overflow: hidden;
  transition: box-shadow var(--transition);
  scroll-snap-align: start;
  max-height: 100%;
}
.kanban-col-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 11px 14px; font-weight: 600; font-size: 13px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.col-count {
  background: var(--border); color: var(--text-muted);
  border-radius: 99px; padding: 1px 8px; font-size: 11px; font-weight: 600;
}
.kanban-cards {
  flex: 1; overflow-y: auto; padding: 10px;
  display: flex; flex-direction: column; gap: 7px; min-height: 60px;
}

/* ── Kanban card ────────────────────────────────────────────────────────── */
.kanban-card {
  background: var(--surface); border-radius: var(--radius-sm);
  padding: 11px 13px; cursor: pointer;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
  animation: cardIn .2s ease;
}
.kanban-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: var(--border-2);
}
.kanban-card:active { transform: translateY(0); }
.kanban-card.prio-high  { border-right: 3px solid var(--danger); }
.kanban-card.prio-medium { border-right: 3px solid var(--warning); }
.kanban-card.prio-low   { border-right: 3px solid var(--success); }
.card-title { font-weight: 500; margin-bottom: 7px; line-height: 1.4; font-size: 13.5px; color: var(--text); }
.card-meta { display: flex; gap: 5px; flex-wrap: wrap; align-items: center; }
.card-tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 7px; }
.tag-chip {
  font-size: 11px; border-radius: 4px; padding: 2px 6px;
  border: 1px solid; font-weight: 500;
}

/* ── Badges ─────────────────────────────────────────────────────────────── */
.badge { font-size: 11px; border-radius: var(--radius-sm); padding: 2px 7px; font-weight: 600; display: inline-flex; align-items: center; gap: 3px; }
.badge-high    { background: var(--danger-bg);  color: var(--danger);  }
.badge-medium  { background: var(--warning-bg); color: var(--warning); }
.badge-low     { background: var(--success-bg); color: var(--success); }
.status-badge  { font-size: 11px; border-radius: var(--radius-sm); padding: 2px 8px; font-weight: 500; }
.status-todo   { background: var(--surface-3); color: var(--text-muted); }
.status-doing  { background: var(--primary-bg); color: var(--primary); }
.status-done   { background: var(--success-bg); color: var(--success); }
.due-badge     { font-size: 11px; border-radius: var(--radius-sm); padding: 2px 6px; font-weight: 500; }
.overdue       { background: var(--danger-bg); color: var(--danger); font-weight: 700; }
.due-soon      { background: var(--warning-bg); color: var(--warning); font-weight: 600; }
.assignee-chip { font-size: 14px; }
.assignee-field { position: relative; display: block; width: 100%; }
.assignee-picker { position: relative; margin-top: 4px; }
.assignee-suggest {
  position: absolute; z-index: 40; inset-inline: 0; top: calc(100% + 4px);
  max-height: 220px; overflow: auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-md, 0 8px 24px rgba(0,0,0,.12));
}
.assignee-suggest-item {
  display: flex; flex-direction: column; gap: 2px;
  width: 100%; text-align: right; padding: 10px 12px;
  border: 0; background: transparent; cursor: pointer; color: inherit;
}
.assignee-suggest-item:hover,
.assignee-suggest-item.active { background: var(--surface-2); }
.assignee-suggest-name { font-weight: 600; font-size: 13px; color: var(--text); }
.assignee-suggest-meta { font-size: 11.5px; color: var(--text-muted); }
.assignee-suggest-empty {
  padding: 12px; font-size: 12px; color: var(--text-muted); text-align: center;
}
.share-members-list {
  display: flex; flex-direction: column; gap: 8px;
  max-height: 180px; overflow: auto;
  padding: 4px 0;
}
.share-member-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2);
}

/* ── List View ──────────────────────────────────────────────────────────── */
.task-table {
  width: 100%; border-collapse: collapse;
  background: var(--surface); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}
.task-table th {
  background: var(--surface-2); padding: 10px 14px;
  font-size: 11.5px; text-align: right; color: var(--text-muted);
  border-bottom: 1px solid var(--border); font-weight: 600;
  text-transform: uppercase; letter-spacing: .4px;
}
.task-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 13px; }
.task-row { cursor: pointer; transition: background var(--transition); }
.task-row:hover { background: var(--surface-2); }

/* ── Calendar ───────────────────────────────────────────────────────────── */
.calendar-nav { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; }
.calendar-nav span { font-weight: 600; font-size: 15px; min-width: 160px; text-align: center; }
.calendar-grid-header {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px;
  margin-bottom: 4px; text-align: center;
  font-size: 11.5px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .3px;
}
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-cell {
  min-height: 88px; background: var(--surface);
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  padding: 6px; transition: background var(--transition);
}
.cal-cell.empty { background: transparent; border-color: transparent; }
.cal-cell.cal-today { border-color: var(--primary); background: var(--primary-bg); }
.cal-day-num { font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 4px; }
.cal-task {
  font-size: 11px; border-radius: 4px; padding: 2px 5px; margin-bottom: 2px;
  cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: filter var(--transition);
}
.cal-task:hover { filter: brightness(.95); }
.cal-task.prio-high   { background: var(--danger-bg);  color: var(--danger); }
.cal-task.prio-medium { background: var(--warning-bg); color: var(--warning); }
.cal-task.prio-low    { background: var(--success-bg); color: var(--success); }

/* ── Agent sidebar ──────────────────────────────────────────────────────── */
.agent-sidebar {
  width: 360px; min-width: 320px; display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--border);
  height: 100%; overflow: hidden;
}
.agent-header {
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px; flex-shrink: 0;
}
.agent-title { font-weight: 700; color: var(--primary); font-size: 14px; }
.agent-subtitle { font-size: 11px; color: var(--text-muted); flex: 1; }
.agent-messages { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.agent-empty-hint { color: var(--text-muted); font-size: 13px; }
.agent-empty-hint ul { margin-top: 8px; padding-right: 16px; line-height: 1.8; }
.agent-bubble {
  border-radius: var(--radius); padding: 10px 12px;
  font-size: 13px; line-height: 1.5; white-space: pre-wrap; max-width: 92%;
  animation: fadeUp .2s ease;
}
.agent-user {
  background: var(--primary); color: #fff; align-self: flex-end;
  border-bottom-left-radius: 3px;
}
.agent-assistant {
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); align-self: flex-start;
  border-bottom-right-radius: 3px;
}
.agent-assistant.streaming::after { content: "▋"; animation: blink 1s infinite; color: var(--primary); }
.agent-input-area {
  padding: 12px; border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 8px; flex-shrink: 0;
}
.agent-input-row { display: flex; gap: 8px; }
.agent-input {
  flex: 1; resize: none; border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 9px 10px; font-size: 13px;
  background: var(--surface-2); color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.agent-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-bg); }

/* ── Mic button ─────────────────────────────────────────────────────────── */
.mic-btn {
  width: 40px; height: 40px; border-radius: 50%;
  border: 1.5px solid var(--border); background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; flex-shrink: 0; cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}
.mic-btn:hover { border-color: var(--primary); background: var(--primary-bg); }
.mic-btn.recording {
  background: var(--danger-bg); border-color: var(--danger);
  animation: pulse 1s infinite;
}

/* ── Task Modal (Glass Morphism) ────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.35);
  backdrop-filter: blur(6px);
  display: flex; align-items: flex-start; justify-content: center;
  z-index: 200; overflow-y: auto; padding: 40px 16px;
  animation: fadeIn .18s ease;
}
[data-theme="dark"] .modal { background: rgba(0,0,0,.55); }
.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 700px;
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  animation: slideUp .22s cubic-bezier(.34,1.4,.64,1);
}
.modal-sm { max-width: 380px; }
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 22px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-body { padding: 20px 22px; display: flex; flex-direction: column; gap: 14px; }
.modal-footer {
  padding: 14px 22px; border-top: 1px solid var(--border);
  display: flex; gap: 8px; justify-content: flex-end;
}
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row label {
  display: flex; flex-direction: column; gap: 4px;
  flex: 1; min-width: 140px; font-size: 12.5px;
  color: var(--text-muted); font-weight: 500;
}
.form-row label select,
.form-row label input {
  padding: 8px 10px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface-2);
  color: var(--text);
}

/* ── Subtasks / Comments / Activity ────────────────────────────────────── */
.subtask-list, .comment-list, .activity-list { display: flex; flex-direction: column; gap: 6px; }
.subtask-item {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px;
  border-radius: var(--radius-sm); background: var(--surface-2);
  border: 1px solid var(--border); transition: background var(--transition);
}
.subtask-item:hover { background: var(--surface-3); }
.subtask-add-row { display: flex; gap: 8px; align-items: center; }
.comment-item {
  background: var(--surface-2); border-radius: var(--radius-sm);
  padding: 9px 12px; display: flex; flex-direction: column; gap: 3px;
  border: 1px solid var(--border);
}
.comment-author { font-size: 11px; font-weight: 600; color: var(--primary); }
.comment-body { font-size: 13px; color: var(--text); }
.comment-date { font-size: 11px; color: var(--text-muted); }
.activity-item {
  border-right: 3px solid var(--border); padding: 3px 10px;
  font-size: 12px; display: flex; gap: 8px; flex-wrap: wrap;
  transition: border-color var(--transition);
}
.activity-item:hover { border-right-color: var(--primary); }
.activity-action { font-weight: 600; color: var(--primary); }
.activity-detail { color: var(--text-muted); flex: 1; }
.activity-date { color: var(--text-muted); font-size: 11px; }
.attachment-list { display: flex; flex-direction: column; gap: 4px; }
.attachment-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 10px; background: var(--surface-2);
  border-radius: var(--radius-sm); font-size: 13px;
  border: 1px solid var(--border);
}

/* ── Command Palette ────────────────────────────────────────────────────── */
#command-palette {
  position: fixed; inset: 0; z-index: 300;
  background: rgba(0,0,0,.4); backdrop-filter: blur(8px);
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 15vh;
  animation: fadeIn .15s ease;
}
.cp-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); width: 100%; max-width: 560px;
  box-shadow: var(--shadow-lg); overflow: hidden;
  animation: slideUp .2s cubic-bezier(.34,1.3,.64,1);
}
.cp-input {
  width: 100%; padding: 16px 18px; border: none; background: transparent;
  font-size: 16px; color: var(--text); outline: none; direction: rtl;
  border-bottom: 1px solid var(--border);
}
.cp-results { max-height: 360px; overflow-y: auto; padding: 8px; }
.cp-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: var(--radius-sm); cursor: pointer; font-size: 14px;
  transition: background var(--transition), color var(--transition);
}
.cp-item:hover, .cp-item.active { background: var(--primary-bg); color: var(--primary); }
.cp-item-icon { font-size: 16px; width: 24px; text-align: center; }
.cp-item-label { flex: 1; }
.cp-item-shortcut {
  font-size: 11px; color: var(--text-muted);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 4px; padding: 1px 6px; font-family: monospace;
}
.cp-empty { padding: 24px; text-align: center; color: var(--text-muted); font-size: 13px; }

/* ── Quick Add FAB ──────────────────────────────────────────────────────── */
#quick-add-fab {
  position: fixed; bottom: 24px; left: 24px; z-index: 150;
}
.fab-btn {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--primary); color: #fff;
  font-size: 24px; font-weight: 300; line-height: 1;
  box-shadow: 0 4px 16px rgba(91,81,232,.45);
  display: flex; align-items: center; justify-content: center;
  transition: transform var(--transition), box-shadow var(--transition);
}
.fab-btn:hover {
  transform: scale(1.1) rotate(45deg);
  box-shadow: 0 6px 24px rgba(91,81,232,.55);
}
.fab-input-wrap {
  position: absolute; bottom: 60px; left: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 12px; width: 280px; display: flex; gap: 8px;
  animation: slideUp .18s ease;
}
.fab-input {
  flex: 1; border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 10px; background: var(--surface-2); color: var(--text);
  font-size: 13px;
}
.fab-input:focus { outline: none; border-color: var(--primary); }
.nlp-preview {
  font-size: 11px; color: var(--text-muted); padding: 4px 2px;
  display: flex; gap: 6px; flex-wrap: wrap;
}
.nlp-tag {
  background: var(--primary-bg); color: var(--primary);
  border-radius: 4px; padding: 1px 6px; font-size: 11px; font-weight: 500;
}

/* ── Inbox Dropdown ─────────────────────────────────────────────────────── */
.inbox-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  width: 340px; max-height: 420px; overflow-y: auto; z-index: 200;
  animation: slideUp .18s ease;
}
.inbox-section-title {
  padding: 10px 14px 6px; font-size: 11px; font-weight: 700;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px;
}
.inbox-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  border-bottom: 1px solid var(--border); cursor: pointer;
  transition: background var(--transition);
}
.inbox-item:hover { background: var(--surface-2); }
.inbox-item-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.inbox-item-dot.overdue { background: var(--danger); }
.inbox-item-dot.today   { background: var(--warning); }
.inbox-item-dot.reminder { background: var(--primary); }
.inbox-item-text { flex: 1; min-width: 0; }
.inbox-item-title { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inbox-item-meta { font-size: 11px; color: var(--text-muted); }
.inbox-empty { padding: 24px; text-align: center; color: var(--text-muted); font-size: 13px; }

/* ── Board Templates Modal ──────────────────────────────────────────────── */
.template-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.template-card {
  padding: 14px; border: 1.5px solid var(--border);
  border-radius: var(--radius); cursor: pointer;
  transition: border-color var(--transition), background var(--transition), transform var(--transition);
  text-align: center;
}
.template-card:hover {
  border-color: var(--primary); background: var(--primary-bg);
  transform: translateY(-2px);
}
.template-card.selected { border-color: var(--primary); background: var(--primary-bg); }
.template-icon { font-size: 26px; margin-bottom: 6px; }
.template-name { font-size: 13px; font-weight: 600; color: var(--text); }
.template-desc { font-size: 11px; color: var(--text-muted); margin-top: 3px; }

/* ── Toast ──────────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 88px; left: 24px; z-index: 300;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 10px 16px; border-radius: var(--radius-sm);
  font-size: 13px; box-shadow: var(--shadow-md);
  animation: slideUp .2s ease; border: 1px solid;
  max-width: 300px; word-break: break-word;
}
.toast-success { background: var(--success-bg); color: var(--success); border-color: var(--success); }
.toast-error   { background: var(--danger-bg);  color: var(--danger);  border-color: var(--danger); }
.toast-info    { background: var(--primary-bg); color: var(--primary); border-color: var(--primary); }

/* ── Keyframes ──────────────────────────────────────────────────────────── */
@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeUp  { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideUp { from { opacity: 0; transform: translateY(18px) scale(.97); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes cardIn  { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes popIn   { from { opacity: 0; transform: scale(.8); } to { opacity: 1; transform: scale(1); } }
@keyframes pop     { from { transform: scale(.5); } to { transform: scale(1); } }
@keyframes pulse   { 0%,100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(224,62,62,.4); } 50% { transform: scale(1.08); box-shadow: 0 0 0 6px rgba(224,62,62,0); } }
@keyframes blink   { 0%,100% { opacity: 1; } 50% { opacity: 0; } }

/* ── Scrollbar ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Responsive / Mobile shell ──────────────────────────────────────────── */
@media (max-width: 900px), (pointer: coarse) and (max-width: 1100px) {
  .desktop-only,
  .desktop-nav { display: none !important; }
  .mobile-only { display: flex !important; }
  .settings-mobile-actions.mobile-only {
    display: flex !important;
    flex-direction: column;
    gap: 8px;
  }

  /* Compact top bar */
  #app-header {
    padding: 8px 12px;
    padding-top: max(8px, env(safe-area-inset-top));
    gap: 0;
  }
  .header-top { gap: 8px; min-height: 44px; }
  .header-brand { gap: 0; flex: 1; min-width: 0; }
  .header-actions { gap: 2px; margin-right: 0; }
  .board-select.desktop-only { display: none !important; }
  .mobile-board-btn {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    min-width: 0;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    text-align: right;
  }
  #mobile-board-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
    flex: 1;
  }
  .mobile-board-chevron {
    color: var(--text-muted);
    flex-shrink: 0;
  }
  .header-add-task {
    padding: 8px 12px;
    font-size: 13px;
  }

  /* Filters collapsed by default */
  .filter-bar-head { display: block; }
  #filter-bar { padding: 8px 12px; }
  #filter-bar .filter-toggle {
    display: block;
    width: 100%;
    text-align: right;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
    color: var(--text-2);
    font-size: 13px;
    font-weight: 500;
  }
  #filter-bar:not(.filters-open) .filter-controls { display: none !important; }
  #filter-bar.filters-open .filter-controls {
    display: flex !important;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    margin-top: 8px;
  }
  #filter-bar.filters-open .filter-controls > * { width: 100%; min-height: 44px; }

  /* Bottom nav */
  .bottom-nav {
    display: flex !important;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 120;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    justify-content: space-around;
    box-shadow: 0 -4px 20px rgba(0,0,0,.06);
  }
  .bnav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 4px;
    color: var(--text-muted);
    font-size: 11px;
    border-radius: var(--radius-sm);
    min-height: 48px;
  }
  .bnav-btn span { font-size: 18px; line-height: 1; }
  .bnav-btn em { font-style: normal; font-size: 11px; }
  .bnav-btn.active { color: var(--primary); background: var(--primary-bg); font-weight: 600; }

  /* Content above bottom nav */
  #content-area {
    padding: 10px 12px;
    padding-bottom: calc(88px + env(safe-area-inset-bottom));
  }
  #stats-widget { display: none !important; }

  /* One-column kanban with tabs */
  .mobile-kanban-tabs {
    display: flex !important;
    gap: 6px;
    margin-bottom: 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .mobile-kanban-tabs::-webkit-scrollbar { display: none; }
  .mktab {
    flex: 1 0 auto;
    padding: 10px 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-2);
    font-size: 12.5px;
    font-weight: 500;
    white-space: nowrap;
  }
  .mktab span {
    display: inline-block;
    margin-right: 4px;
    background: var(--surface-3);
    border-radius: 99px;
    padding: 0 7px;
    font-size: 11px;
    font-weight: 700;
  }
  .mktab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
  }
  .mktab.active span { background: rgba(255,255,255,.22); color: #fff; }

  #view-board.view-section { display: flex; flex-direction: column; min-height: 0; }
  .kanban-board {
    flex-direction: column;
    overflow: hidden;
    gap: 0;
    padding-bottom: 0;
    height: auto;
    flex: 1;
    min-height: 50vh;
  }
  .kanban-col {
    display: none !important;
    flex: 1 1 auto;
    width: 100%;
    max-height: none;
    min-height: 50vh;
  }
  .kanban-col.is-mobile-active {
    display: flex !important;
  }
  .kanban-col-header { display: none; }
  .kanban-cards {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 4px 2px 20px;
    gap: 8px;
  }
  .kanban-card {
    padding: 14px 14px;
  }
  .kanban-card:hover { transform: none; }

  /* Agent fullscreen */
  .agent-sidebar { display: none; }
  .agent-sidebar:not(.hidden) {
    display: flex !important;
    position: fixed;
    inset: 0;
    width: 100%;
    min-width: 0;
    height: 100dvh;
    height: 100svh;
    z-index: 180;
    box-shadow: none;
    border: none;
    padding-bottom: env(safe-area-inset-bottom);
  }

  /* FAB above bottom nav */
  #quick-add-fab {
    bottom: calc(72px + env(safe-area-inset-bottom));
    left: 14px;
  }
  .inbox-dropdown {
    right: 0;
    left: auto;
    width: min(92vw, 340px);
  }

  .auth-box {
    margin: 24px 16px;
    padding: 28px 20px;
    max-width: none;
  }
  .modal { padding: 0; align-items: stretch; }
  .modal-box {
    max-width: 100%;
    min-height: 100dvh;
    min-height: 100svh;
    border-radius: 0;
    border: none;
  }
  .modal-sm {
    min-height: auto;
    margin: auto 16px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    max-width: calc(100% - 32px);
  }
  .modal-header, .modal-body, .modal-footer { padding-left: 16px; padding-right: 16px; }
  .modal-footer {
    position: sticky;
    bottom: 0;
    background: var(--surface);
    padding-bottom: calc(14px + env(safe-area-inset-bottom));
    flex-wrap: wrap;
  }
  .form-row label { min-width: 100%; }
  #task-list-container { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .task-table { min-width: 560px; }
  .template-grid { grid-template-columns: 1fr; }
  .cp-box { margin: 0 12px; max-width: none; }
  #command-palette { padding-top: 10vh; }
}

/* ── Density toggle ─────────────────────────────────────────────────────── */
[data-density="compact"] .kanban-card { padding: 7px 10px; }
[data-density="compact"] .card-title { font-size: 12.5px; }
[data-density="compact"] .task-table td { padding: 7px 12px; }
