@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@400;500;600;700;800&display=swap');

:root {
  --primary: #4f46e5;
  --bg: #f5f7fb;
  --card: #fff;
  --text: #18202f;
  --muted: #748094;
  --border: #e7eaf0;
  --danger: #d64545;
  --ok: #22a06b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Vazirmatn, Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 260px;
  background: #fff;
  border-left: 1px solid var(--border);
  padding: calc(20px + env(safe-area-inset-top)) calc(14px + env(safe-area-inset-right)) calc(20px + env(safe-area-inset-bottom)) 14px;
  position: fixed;
  inset: 0 0 0 auto;
  display: flex;
  flex-direction: column;
  z-index: 10;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 8px; }
.brand-icon {
  width: 38px; height: 38px; border-radius: 11px;
  background: var(--primary); color: #fff;
  display: grid; place-items: center; font-weight: 800; font-size: 21px;
}
.brand strong { display: block; font-size: 18px; }
.brand small { display: block; color: var(--muted); font-size: 11px; }
.cafe-home { display: inline-block; margin-top: 2px; color: var(--primary); font-size: 11px; font-weight: 700; text-decoration: none; }
.cafe-home:hover { text-decoration: underline; }

.projects-label {
  margin: 18px 8px 8px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.project-list {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.project-item {
  border: 0;
  background: transparent;
  color: #596477;
  text-align: right;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}
.project-item:hover { background: #f1f2f7; color: var(--primary); }
.project-item.active { background: #eef0ff; color: var(--primary); font-weight: 700; }
.project-item .dot {
  width: 10px; height: 10px; border-radius: 50%; flex: none;
}
.project-item .name {
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.project-item .count {
  font-size: 11px; color: var(--muted); background: #f0f2f6;
  border-radius: 999px; padding: 2px 7px;
}

.sidebar-bottom { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); }
.nav-link {
  border: 0; background: transparent; color: #596477; text-align: right;
  padding: 10px 12px; border-radius: 10px; font-size: 13px; width: 100%;
  display: block;
}
.nav-link i { margin-left: 8px; }
.nav-link:hover { background: #f1f2f7; color: var(--primary); }
.file-label { cursor: pointer; }

.main { margin-right: 260px; width: calc(100% - 260px); min-height: 100vh; padding-top: env(safe-area-inset-top); }

.empty-state {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--muted);
  padding: 40px 20px;
}
.empty-state i { font-size: 48px; margin-bottom: 12px; color: var(--primary); }
.empty-state h2 { color: var(--text); margin: 0 0 8px; font-size: 24px; }
.empty-state p { margin: 0 0 20px; }

.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 5;
}

.project-heading { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.project-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.project-title-wrap { flex: 1; min-width: 0; }
.project-title-input {
  border: 0; background: transparent; font-size: 22px; font-weight: 800;
  width: 100%; outline: 0; color: var(--text); min-width: 0;
}
.project-title-input:focus { background: #f8f9fb; border-radius: 8px; padding: 4px 8px; }
.project-sub { color: var(--muted); font-size: 12px; margin-top: 2px; min-height: 16px; }

.top-actions { display: flex; gap: 8px; flex: none; }

.content { max-width: 980px; margin: 0 auto; padding: 24px 28px; }

.view-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.view-tab {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 10px;
  padding: 8px 14px;
  color: #667085;
  font-size: 13px;
  font-weight: 600;
}
.view-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.tab-count {
  display: inline-block;
  min-width: 18px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(255,255,255,.2);
  font-size: 11px;
}
.view-tab:not(.active) .tab-count { background: #eef0f5; color: var(--muted); }

.quick {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  box-shadow: 0 5px 20px #1d293908;
}
.quick .form-control { border: 0; box-shadow: none !important; }

.toolbar {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-top: 8px;
}
.toolbar-side { min-width: 220px; }

.filter {
  display: flex;
  gap: 8px;
  overflow: auto;
  padding: 8px 0;
  flex: 1;
}
.filter button {
  white-space: nowrap;
  border: 1px solid #e0e4ea;
  background: #fff;
  border-radius: 9px;
  padding: 8px 14px;
  color: #667085;
  font-size: 13px;
}
.filter button b { margin-right: 4px; }
.filter button.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.tag-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-bottom: 12px;
  min-height: 0;
}
.tag-filter:empty { display: none; }
.tag-filter-label { font-size: 12px; color: var(--muted); margin-left: 4px; }
.tag-chip {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  color: #596477;
}
.tag-chip.active {
  background: #eef0ff;
  border-color: #c7c9f5;
  color: var(--primary);
  font-weight: 600;
}

.item-block { margin-bottom: 8px; }
.item {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 13px 15px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.item.done { opacity: 0.72; }
.item.done .item-title { text-decoration: line-through; }
.item.tested { opacity: 0.58; }
.item.tested .item-title { text-decoration: line-through; }
.item.doing {
  border-color: #f0c36a;
  background: #fffdf8;
}
.item.subtask {
  padding: 10px 12px;
  background: #fbfcfe;
}
.item.doing.subtask { background: #fffaf0; }
.subtasks {
  margin: 4px 28px 0 0;
  padding-right: 12px;
  border-right: 2px solid #e4e7ef;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.item-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex: none;
}
.item-add-sub {
  border: 0;
  background: transparent;
  color: #8b94a3;
  padding: 4px 6px;
  margin-top: 2px;
}
.item-add-sub:hover { color: var(--primary); }

.check {
  width: 22px; height: 22px;
  border: 2px solid #c8ced8;
  border-radius: 7px;
  display: grid; place-items: center;
  cursor: pointer; flex: none;
  background: #fff; color: #fff;
  padding: 0;
  margin-top: 2px;
}
.check.ok { background: var(--ok); border-color: var(--ok); }
.check.doing {
  background: #f59e0b;
  border-color: #f59e0b;
  color: #fff;
  font-size: 11px;
}
.check.tested {
  background: #0f766e;
  border-color: #0f766e;
  color: #fff;
  font-size: 12px;
  cursor: default;
  opacity: 1;
}
.check.tested:disabled { opacity: 1; }

.status-pill {
  font-size: 11px;
  border-radius: 6px;
  padding: 2px 7px;
  font-weight: 600;
  background: #f3f4f8;
  color: #64748b;
}
.status-pill.doing { background: #fff7e8; color: #b45309; }
.status-pill.done,
.status-pill.fixed,
.status-pill.closed { background: #eaf8f1; color: #16734a; }
.status-pill.tested { background: #e6f5f3; color: #0f766e; }

.item-body { flex: 1; min-width: 0; }
.item-title {
  width: 100%; border: 0; background: transparent; outline: 0;
  font-weight: 600; font-size: 14px; color: var(--text); padding: 0;
}
.item-title:focus { background: #f8f9fb; border-radius: 6px; padding: 4px 6px; }

.meta { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 5px; align-items: center; }
.badge2 {
  font-size: 11px; border-radius: 6px; padding: 3px 7px; font-weight: 600;
}
.badge2.task { background: #eef2ff; color: #5148d8; }
.badge2.task.subtask { background: #f3f0ff; color: #6d28d9; }
.badge2.bug { background: #fff0f0; color: var(--danger); }

.tags-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: 8px;
}
.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #f3f4f8;
  color: #4b5568;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
}
.tag-pill button {
  border: 0;
  background: transparent;
  color: #9aa3b2;
  padding: 0;
  line-height: 1;
  font-size: 14px;
}
.tag-pill button:hover { color: var(--danger); }
.tag-input {
  border: 1px dashed #d5dae3;
  background: transparent;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 11px;
  width: 88px;
  outline: 0;
}
.tag-input:focus {
  border-color: var(--primary);
  width: 120px;
}

.done-btn {
  border: 1px solid #d7f0e4;
  background: #eaf8f1;
  color: #16734a;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  margin-top: 2px;
}
.done-btn:hover { background: #d8f3e6; }
.item-del {
  border: 0; background: transparent; color: #8b94a3; padding: 4px 6px; margin-top: 2px;
}
.item-del:hover { color: var(--danger); }

.date-group { margin-bottom: 18px; }
.date-group-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 700;
  color: #4b5568;
  margin: 8px 2px 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.list-empty {
  text-align: center;
  padding: 48px 16px;
  color: var(--muted);
  background: #fff;
  border: 1px dashed var(--border);
  border-radius: 13px;
}
.list-empty i { font-size: 32px; display: block; margin-bottom: 10px; }

.notes-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.notes-head strong { display: block; font-size: 16px; }
.muted { color: var(--muted); }
.note-quick-types {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.note-quick-btn {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 11px;
  padding: 10px 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #4b5568;
  font-weight: 600;
}
.note-quick-btn i { color: var(--primary); font-size: 16px; }
.note-quick-btn:hover {
  border-color: #c7c9f5;
  background: #f7f8ff;
  color: var(--primary);
}
.note-type-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.note-type-filter:empty { display: none; }
.notes-list { display: flex; flex-direction: column; gap: 10px; }
.note-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 16px;
}
.note-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.note-card-head h6 { margin: 6px 0 0; font-size: 15px; font-weight: 700; }
.note-type-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  background: #eef0ff;
  border-radius: 999px;
  padding: 3px 9px;
}
.note-type-deploy .note-type-badge { background: #fff1e8; color: #c2410c; }
.note-type-command .note-type-badge { background: #ecfdf5; color: #047857; }
.note-type-guide .note-type-badge { background: #eff6ff; color: #1d4ed8; }
.note-type-tip .note-type-badge { background: #fffbeb; color: #b45309; }
.note-type-meeting .note-type-badge { background: #f5f3ff; color: #6d28d9; }
.note-type-link .note-type-badge { background: #ecfeff; color: #0e7490; }
.note-actions { display: flex; gap: 6px; flex: none; }
.note-body {
  margin: 0 0 10px;
  font-size: 13px;
  line-height: 1.8;
  white-space: pre-wrap;
  color: #374151;
  word-break: break-word;
}
.note-body.is-code,
.note-body-input.is-code {
  font-family: Consolas, "Courier New", monospace;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 10px;
  padding: 12px 14px;
  line-height: 1.65;
  direction: ltr;
  text-align: left;
}
.note-body-input {
  font-family: Vazirmatn, Tahoma, sans-serif;
}
.note-body-input.is-code {
  border: 0;
  min-height: 220px;
}
.note-meta { border-top: 1px solid #f0f2f5; padding-top: 8px; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}
.modal-card {
  width: min(560px, 100%);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.2);
  max-height: 90vh;
  overflow: auto;
}
.modal-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 0;
}
.modal-card-head h5 { margin: 0; font-weight: 800; }
.modal-close {
  border: 0;
  background: transparent;
  font-size: 24px;
  line-height: 1;
  color: #9aa3b2;
}
.modal-card-body { padding: 16px 18px 18px; }
.modal-card-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

@media (max-width: 850px) {
  .sidebar {
    width: 72px;
    padding: calc(16px + env(safe-area-inset-top)) calc(8px + env(safe-area-inset-right)) calc(16px + env(safe-area-inset-bottom)) 8px;
  }
  .brand div, .projects-label, .sidebar-bottom, .project-item .name, .project-item .count,
  .new-project-btn span { display: none; }
  .new-project-btn { padding: 10px; }
  .project-item { justify-content: center; padding: 12px; }
  .main { margin-right: 72px; width: calc(100% - 72px); }
  .content { padding: 16px 12px; }
  .topbar { padding: 14px 12px; flex-wrap: wrap; }
  .toolbar-side { width: 100%; min-width: 0; }
}

@media (max-width: 500px) {
  .top-actions .btn { font-size: 0; padding: 8px 10px; }
  .top-actions .btn i { font-size: 16px; margin: 0; }
  .done-btn { display: none; }
  .project-sub { display: none; }
  .subtasks { margin-right: 12px; }
}

.pwa-install {
  position: fixed;
  z-index: 40;
  left: 16px;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  max-width: 420px;
  margin-inline: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 12px 12px 14px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.16);
}
.pwa-install-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 800;
  flex: none;
}
.pwa-install-copy { flex: 1; min-width: 0; }
.pwa-install-copy strong { display: block; font-size: 14px; }
.pwa-install-copy small { display: block; color: var(--muted); font-size: 12px; }
.pwa-install-close {
  border: 0;
  background: transparent;
  color: #9aa3b2;
  font-size: 22px;
  line-height: 1;
  padding: 0 4px;
}
@media (min-width: 851px) {
  .pwa-install {
    right: 280px;
    left: auto;
    margin-inline: 0;
    width: 380px;
  }
}
