/* ============================================
   GREJER — A Things-inspired task manager
   Design system & complete styles
   ============================================ */

/* ---------- Design Tokens ---------- */
:root {
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'SF Pro Display',
    'Helvetica Neue', 'Segoe UI', Roboto, system-ui, sans-serif;

  /* Surfaces */
  --bg: #F2F2F7;
  --surface: #FFFFFF;
  --sidebar-bg: #FBFBFD;
  --sidebar-hover: #F0F0F5;
  --sidebar-active: #E8F0FE;

  /* Text */
  --text-primary: #1C1C1E;
  --text-secondary: #636366;
  --text-tertiary: #AEAEB2;
  --text-placeholder: #C7C7CC;

  /* Accent */
  --accent: #007AFF;
  --accent-hover: #0066D6;
  --accent-light: #E8F0FE;
  --accent-bg: rgba(0, 122, 255, 0.08);

  /* Semantic */
  --green: #34C759;
  --orange: #FF9500;
  --red: #FF3B30;
  --yellow: #FFCC00;
  --purple: #AF52DE;
  --teal: #5AC8FA;
  --pink: #FF2D55;

  /* Borders */
  --border: #E5E5EA;
  --border-light: #F0F0F5;
  --divider: rgba(0, 0, 0, 0.06);

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.16);

  /* Radii */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Layout */
  --sidebar-width: 260px;
  --detail-width: 400px;
  --header-height: 52px;

  /* Transitions */
  --ease-out: cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --duration-fast: 0.15s;
  --duration-normal: 0.25s;
  --duration-slow: 0.4s;
}

/* ---------- Reset ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--bg);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
  border: none;
  outline: none;
  background: none;
}

button {
  cursor: pointer;
  -webkit-appearance: none;
}

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

ul,
ol {
  list-style: none;
}

/* ---------- App Layout ---------- */
#app {
  display: flex;
  height: 100vh;
  height: 100dvh;
  position: relative;
  overflow: hidden;
}

/* ---------- Sidebar Overlay (mobile) ---------- */
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 90;
  opacity: 0;
  transition: opacity var(--duration-normal) var(--ease-out);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

#sidebar-overlay.visible {
  display: block;
  opacity: 1;
}

/* ---------- Sidebar ---------- */
#sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100%;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 100;
  transition: transform var(--duration-normal) var(--ease-out);
}

.sidebar-header {
  padding: 20px 20px 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.sidebar-logo {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text-primary);
}

.sidebar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 12px 4px;
  padding: 7px 10px;
  background: rgba(0, 0, 0, 0.04);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--duration-fast);
}

.sidebar-search:hover {
  background: rgba(0, 0, 0, 0.06);
}

.sidebar-search svg {
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.sidebar-search span {
  font-size: 13px;
  color: var(--text-tertiary);
}

.sidebar-search kbd {
  margin-left: auto;
  font-size: 11px;
  color: var(--text-tertiary);
  background: rgba(0, 0, 0, 0.05);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: var(--font);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px 0 16px;
  scrollbar-width: none;
}

.sidebar-nav::-webkit-scrollbar {
  display: none;
}

/* Nav items */
.nav-list {
  padding: 4px 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--duration-fast);
  user-select: none;
  position: relative;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-primary);
}

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

.nav-item.active {
  background: var(--sidebar-active);
  color: var(--accent);
}

.nav-item.active .nav-icon svg {
  color: var(--accent);
}

.nav-icon {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.nav-icon svg {
  width: 18px;
  height: 18px;
}

.nav-icon.inbox svg { color: #007AFF; }
.nav-icon.today svg { color: #FFB800; }
.nav-icon.upcoming svg { color: #FF3B30; }
.nav-icon.anytime svg { color: #5AC8FA; }
.nav-icon.someday svg { color: #FF9500; }
.nav-icon.logbook svg { color: #34C759; }
.nav-icon.trash svg { color: #8E8E93; }

.nav-badge {
  margin-left: auto;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  min-width: 18px;
  text-align: right;
}

.nav-item.active .nav-badge {
  color: var(--accent);
}

/* Sidebar sections */
.nav-section {
  margin-top: 8px;
  padding: 0 8px;
}

.nav-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 12px 4px;
  cursor: pointer;
  user-select: none;
}

.nav-section-title {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-tertiary);
}

.nav-section-btn {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xs);
  color: var(--text-tertiary);
  opacity: 0;
  transition: opacity var(--duration-fast), background var(--duration-fast);
}

.nav-section:hover .nav-section-btn {
  opacity: 1;
}

.nav-section-btn:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--text-secondary);
}

/* Project items in sidebar */
.project-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--duration-fast);
  font-size: 13.5px;
  font-weight: 400;
  color: var(--text-primary);
}

.project-nav-item:hover {
  background: var(--sidebar-hover);
}

.project-nav-item.active {
  background: var(--sidebar-active);
  color: var(--accent);
}

.project-nav-icon {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  position: relative;
  flex-shrink: 0;
  overflow: hidden;
}

.project-nav-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--accent);
  transition: height var(--duration-normal) var(--ease-out);
}

.project-nav-count {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-tertiary);
}

/* Area items */
.area-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--duration-fast);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-secondary);
  user-select: none;
}

.area-nav-item:hover {
  background: var(--sidebar-hover);
}

.area-nav-item.active {
  background: var(--sidebar-active);
  color: var(--accent);
}

.area-nav-item.dragging { opacity: 0.4; }
.area-nav-item.area-drag-over { background: var(--sidebar-active); outline: 2px solid var(--accent); }

.area-nav-label { flex: 1; }

.area-chevron {
  margin-left: auto;
  color: var(--text-tertiary);
  transition: transform 0.2s;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.area-chevron.collapsed { transform: rotate(-90deg); }

/* Tag items in sidebar */
.tag-nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--duration-fast);
  font-size: 13px;
  color: var(--text-primary);
}

.tag-nav-item:hover {
  background: var(--sidebar-hover);
}

.tag-nav-item.active {
  background: var(--sidebar-active);
  color: var(--accent);
}

.tag-edit-btn {
  flex-shrink: 0;
}
.tag-nav-item:hover .tag-edit-btn {
  opacity: 1;
}
/* Pekskärm har ingen hover — visa knappen direkt */
@media (hover: none) {
  .tag-edit-btn {
    opacity: 1;
  }
}

.tag-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ---------- Main Area ---------- */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
  background: var(--bg);
}

#main-header {
  flex-shrink: 0;
  padding: 24px 32px 0;
}

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.view-title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text-primary);
  line-height: 1.2;
}

.view-title.inbox { color: #007AFF; }
.view-title.today { color: #FFB800; }
.view-title.upcoming { color: #FF3B30; }
.view-title.anytime { color: #5AC8FA; }
.view-title.someday { color: #FF9500; }
.view-title.logbook { color: #34C759; }
.view-title.trash { color: #8E8E93; }

.view-subtitle {
  font-size: 13px;
  color: var(--text-tertiary);
  font-weight: 400;
  margin-top: 2px;
}

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

.view-action-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: background var(--duration-fast), color var(--duration-fast);
}

.view-action-btn:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--text-primary);
}

.menu-btn {
  display: none;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  margin-right: 8px;
  flex-shrink: 0;
}

.menu-btn:hover {
  background: rgba(0, 0, 0, 0.06);
}

/* ---------- Main Content ---------- */
#main-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 32px 100px;
  scroll-behavior: smooth;
}

#main-content::-webkit-scrollbar {
  width: 6px;
}

#main-content::-webkit-scrollbar-track {
  background: transparent;
}

#main-content::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 3px;
}

#main-content::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.2);
}

/* ---------- Task List ---------- */
.task-list {
  max-width: 720px;
}

.task-group {
  margin-bottom: 24px;
}

.task-group-header {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-tertiary);
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.task-group-header.overdue {
  color: var(--red);
}

.heading-row {
  display: flex;
  align-items: center;
  padding: 16px 0 4px;
  gap: 8px;
}

.heading-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.1px;
}

.heading-title-input {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  border: none;
  background: none;
  width: 100%;
  padding: 0;
}

.heading-title-input::placeholder {
  color: var(--text-placeholder);
}

/* ---------- Task Item ---------- */
.task-item {
  display: flex;
  align-items: flex-start;
  padding: 10px 4px;
  border-bottom: 1px solid var(--divider);
  cursor: pointer;
  position: relative;
  transition: background var(--duration-fast), opacity var(--duration-normal),
    max-height var(--duration-slow) var(--ease-out),
    padding var(--duration-slow) var(--ease-out),
    margin var(--duration-slow) var(--ease-out);
  border-radius: var(--radius-sm);
}

.task-item:hover {
  background: rgba(0, 0, 0, 0.02);
}

.task-item.selected {
  background: var(--accent-bg);
}

.task-item.completing {
  opacity: 0;
  max-height: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  margin: 0 !important;
  border-color: transparent !important;
  overflow: hidden;
  pointer-events: none;
}

.task-item.dragging {
  opacity: 0.5;
  background: var(--accent-bg);
}

.task-item.drag-over-top {
  box-shadow: 0 -2px 0 var(--accent);
}

.task-item.drag-over-bottom {
  box-shadow: 0 2px 0 var(--accent);
}

/* Checkbox */
.task-checkbox {
  width: 20px;
  height: 20px;
  min-width: 20px;
  border: 2px solid #C7C7CC;
  border-radius: 50%;
  margin-top: 1px;
  margin-right: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--duration-fast) var(--ease-out);
  cursor: pointer;
  position: relative;
  flex-shrink: 0;
}

.task-checkbox:hover {
  border-color: var(--accent);
  transform: scale(1.1);
}

.task-checkbox.checked {
  border-color: var(--accent);
  background: var(--accent);
  animation: checkboxPop 0.35s var(--ease-spring);
}

.task-checkbox.checked svg {
  opacity: 1;
  transform: scale(1);
}

.task-checkbox svg {
  width: 12px;
  height: 12px;
  color: white;
  opacity: 0;
  transform: scale(0.5);
  transition: all var(--duration-fast) var(--ease-spring);
}

@keyframes checkboxPop {
  0% { transform: scale(1); }
  40% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

/* Task content */
.task-content {
  flex: 1;
  min-width: 0;
}

.task-title {
  font-size: 14.5px;
  font-weight: 400;
  color: var(--text-primary);
  line-height: 1.4;
  word-wrap: break-word;
}

.task-item.completed .task-title {
  color: var(--text-tertiary);
  text-decoration: line-through;
}

.task-notes-preview {
  font-size: 12.5px;
  color: var(--text-tertiary);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 3px;
  flex-wrap: wrap;
}

.task-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11.5px;
  color: var(--text-tertiary);
}

.task-meta-item svg {
  width: 12px;
  height: 12px;
}

.task-meta-item.overdue {
  color: var(--red);
}

.task-meta-item.today-badge {
  color: var(--accent);
}

.task-project-badge {
  font-size: 11.5px;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.task-project-badge svg {
  width: 10px;
  height: 10px;
}

.task-tags {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}

.task-tag-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.task-checklist-count {
  font-size: 11px;
  color: var(--text-tertiary);
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.task-checklist-count svg {
  width: 12px;
  height: 12px;
}

/* ---------- New Task Inline ---------- */
.new-task-row {
  display: flex;
  align-items: flex-start;
  padding: 10px 4px;
  border-bottom: 1px solid var(--divider);
  animation: fadeIn 0.2s var(--ease-out);
}

.new-task-row .task-checkbox {
  opacity: 0.3;
  pointer-events: none;
}

.new-task-input {
  flex: 1;
  font-size: 14.5px;
  padding: 0;
  line-height: 1.4;
  min-height: 22px;
  resize: none;
  border: none;
  background: none;
}

.new-task-input::placeholder {
  color: var(--text-placeholder);
}

.new-task-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
}

/* ---------- Detail Panel ---------- */
#detail-panel {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  width: var(--detail-width);
  max-width: 100vw;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 80;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--duration-normal) var(--ease-out);
  overflow: hidden;
}

#detail-panel.open {
  transform: translateX(0);
}

#detail-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 75;
  background: rgba(0, 0, 0, 0.15);
  opacity: 0;
  transition: opacity var(--duration-normal);
}

#detail-overlay.visible {
  display: block;
  opacity: 1;
}

.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}

.detail-close-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
  transition: background var(--duration-fast), color var(--duration-fast);
}

.detail-close-btn:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--text-primary);
}

.detail-actions {
  display: flex;
  gap: 4px;
}

.detail-action-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
  transition: background var(--duration-fast), color var(--duration-fast);
}

.detail-action-btn:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--text-primary);
}

.detail-action-btn.danger:hover {
  background: rgba(255, 59, 48, 0.08);
  color: var(--red);
}

.detail-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.detail-title-input {
  width: 100%;
  font-size: 20px;
  font-weight: 600;
  line-height: 1.35;
  padding: 0;
  margin-bottom: 16px;
  border: none;
  background: none;
  resize: none;
  color: var(--text-primary);
  letter-spacing: -0.2px;
  /* Skyddsnät kring den JS-styrda höjden: titeln får aldrig kollapsa till
     osynlig (buggen i ISSUE-25) eller svälla och tränga undan fälten om
     scrollHeight mäts fel, t.ex. i en dold/strypt flik. */
  min-height: 28px;
  max-height: 40vh;
}

.detail-title-input::placeholder {
  color: var(--text-placeholder);
}

.detail-field {
  display: flex;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
  gap: 12px;
  min-height: 44px;
}

.detail-field-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  min-width: 80px;
  flex-shrink: 0;
}

.detail-field-value {
  flex: 1;
  font-size: 13.5px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.detail-field-value.placeholder {
  color: var(--text-placeholder);
}

.detail-field-btn {
  padding: 4px 10px;
  border-radius: var(--radius-xs);
  font-size: 13px;
  color: var(--accent);
  cursor: pointer;
  transition: background var(--duration-fast);
}

.detail-field-btn:hover {
  background: var(--accent-bg);
}

.detail-notes {
  width: 100%;
  min-height: 80px;
  padding: 12px 0;
  border: none;
  background: none;
  resize: none;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
}

.detail-notes::placeholder {
  color: var(--text-placeholder);
}

/* Checklist in detail */
.detail-checklist {
  padding: 8px 0;
}

/* ---------- Länkar i detaljpanelen ---------- */
.detail-links {
  padding: 8px 0;
  border-top: 1px solid var(--border-light);
}

.link-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  min-width: 0;
}

.link-item-icon {
  display: flex;
  align-items: center;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.link-item-text {
  flex: 1;
  min-width: 0;
  font-size: 13.5px;
  color: var(--accent);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-item-text:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.link-item-btn {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xs);
  color: var(--text-tertiary);
  opacity: 0;
  flex-shrink: 0;
  transition: opacity var(--duration-fast), background var(--duration-fast), color var(--duration-fast);
}

.link-item:hover .link-item-btn {
  opacity: 1;
}

.link-item-btn:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--text-primary);
}

/* Pekskärm har ingen hover — visa knapparna direkt */
@media (hover: none) {
  .link-item-btn {
    opacity: 1;
  }
}

.detail-checklist-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
}

.detail-checklist-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.checklist-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
}

.checklist-checkbox {
  width: 16px;
  height: 16px;
  min-width: 16px;
  border: 1.5px solid #C7C7CC;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--duration-fast);
}

.checklist-checkbox:hover {
  border-color: var(--accent);
}

.checklist-checkbox.checked {
  border-color: var(--accent);
  background: var(--accent);
}

.checklist-checkbox.checked svg {
  opacity: 1;
}

.checklist-checkbox svg {
  width: 10px;
  height: 10px;
  color: white;
  opacity: 0;
}

.checklist-text {
  flex: 1;
  font-size: 13.5px;
  border: none;
  background: none;
  padding: 2px 0;
}

.checklist-text.completed {
  color: var(--text-tertiary);
  text-decoration: line-through;
}

.checklist-delete {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
  opacity: 0;
  transition: opacity var(--duration-fast);
  cursor: pointer;
  border-radius: var(--radius-xs);
}

.checklist-item:hover .checklist-delete {
  opacity: 1;
}

.checklist-delete:hover {
  color: var(--red);
}

.checklist-add-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 0;
  font-size: 13px;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: color var(--duration-fast);
}

.checklist-add-btn:hover {
  color: var(--accent);
}

/* Detail move-to selector */
.detail-move-select {
  padding: 4px 8px;
  border-radius: var(--radius-xs);
  font-size: 13px;
  background: rgba(0, 0, 0, 0.04);
  border: none;
  cursor: pointer;
  color: var(--text-primary);
}

.detail-move-select:hover {
  background: rgba(0, 0, 0, 0.06);
}

/* ---------- FAB (Floating Action Button) ---------- */
#fab {
  position: absolute;
  bottom: 24px;
  right: 24px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0, 122, 255, 0.35);
  z-index: 50;
  transition: transform var(--duration-fast) var(--ease-spring),
    box-shadow var(--duration-fast);
}

#fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 24px rgba(0, 122, 255, 0.4);
}

#fab:active {
  transform: scale(0.95);
}

/* ---------- Dialogs ---------- */
.dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fadeIn 0.15s var(--ease-out);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.dialog {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  width: 440px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 64px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: dialogIn 0.25s var(--ease-spring);
}

@keyframes dialogIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border-light);
}

.dialog-title {
  font-size: 16px;
  font-weight: 600;
}

.dialog-close {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xs);
  color: var(--text-tertiary);
  transition: background var(--duration-fast);
}

.dialog-close:hover {
  background: rgba(0, 0, 0, 0.06);
}

.dialog-body {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
}

.dialog-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border-light);
}

/* Quick Add Dialog */
.quick-add-dialog {
  width: 520px;
}

.quick-add-title {
  width: 100%;
  font-size: 17px;
  font-weight: 500;
  padding: 0;
  margin-bottom: 12px;
  border: none;
  background: none;
  line-height: 1.4;
}

.quick-add-title::placeholder {
  color: var(--text-placeholder);
}

.quick-add-notes {
  width: 100%;
  font-size: 14px;
  padding: 0;
  min-height: 40px;
  border: none;
  background: none;
  resize: none;
  line-height: 1.5;
  color: var(--text-secondary);
}

.quick-add-notes::placeholder {
  color: var(--text-placeholder);
}

.quick-add-options {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.quick-add-option {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: var(--radius-full);
  font-size: 12.5px;
  color: var(--text-secondary);
  background: rgba(0, 0, 0, 0.04);
  cursor: pointer;
  transition: background var(--duration-fast), color var(--duration-fast);
}

.quick-add-option:hover {
  background: rgba(0, 0, 0, 0.08);
  color: var(--text-primary);
}

.quick-add-option.active {
  background: var(--accent-light);
  color: var(--accent);
}

.quick-add-option svg {
  width: 14px;
  height: 14px;
}

/* ---------- Date Picker Popover ---------- */
.date-picker-popover {
  position: fixed;
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  z-index: 250;
  width: 280px;
  animation: fadeIn 0.15s var(--ease-out);
  overflow: hidden;
}

.date-picker-shortcuts {
  display: flex;
  flex-direction: column;
  padding: 8px;
  border-bottom: 1px solid var(--border-light);
}

.date-picker-shortcut {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  transition: background var(--duration-fast);
  color: var(--text-primary);
}

.date-picker-shortcut:hover {
  background: var(--sidebar-hover);
}

.date-picker-shortcut svg {
  width: 16px;
  height: 16px;
}

.date-picker-shortcut .shortcut-label {
  flex: 1;
}

.date-picker-shortcut .shortcut-day {
  font-size: 11.5px;
  color: var(--text-tertiary);
}

.date-picker-calendar {
  padding: 12px;
}

.calendar-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.calendar-month-label {
  font-size: 13.5px;
  font-weight: 600;
}

.calendar-nav-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xs);
  color: var(--text-secondary);
  transition: background var(--duration-fast);
}

.calendar-nav-btn:hover {
  background: rgba(0, 0, 0, 0.06);
}

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

.calendar-day-header {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-tertiary);
  text-align: center;
  padding: 4px 0;
  letter-spacing: 0.3px;
}

.calendar-day {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 13px;
  cursor: pointer;
  transition: background var(--duration-fast), color var(--duration-fast);
  margin: 0 auto;
}

.calendar-day:hover {
  background: rgba(0, 0, 0, 0.06);
}

.calendar-day.other-month {
  color: var(--text-placeholder);
}

.calendar-day.today {
  font-weight: 700;
  color: var(--accent);
}

.calendar-day.selected {
  background: var(--accent);
  color: white;
  font-weight: 600;
}

.calendar-day.past {
  color: var(--text-tertiary);
}

.date-picker-footer {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  border-top: 1px solid var(--border-light);
}

.date-picker-clear {
  font-size: 13px;
  color: var(--red);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-xs);
  transition: background var(--duration-fast);
}

.date-picker-clear:hover {
  background: rgba(255, 59, 48, 0.06);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  transition: background var(--duration-fast), color var(--duration-fast),
    transform var(--duration-fast);
  cursor: pointer;
  user-select: none;
}

.btn:active {
  transform: scale(0.97);
}

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

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: rgba(0, 0, 0, 0.06);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: rgba(0, 0, 0, 0.1);
}

.btn-ghost {
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: rgba(0, 0, 0, 0.06);
}

.btn-danger {
  color: var(--red);
}

.btn-danger:hover {
  background: rgba(255, 59, 48, 0.08);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 12.5px;
}

/* ---------- Form Elements ---------- */
.input {
  width: 100%;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
  background: var(--surface);
}

.input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.12);
}

.input::placeholder {
  color: var(--text-placeholder);
}

.textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  resize: vertical;
  min-height: 60px;
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
  background: var(--surface);
}

.textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.12);
}

.select-wrapper {
  position: relative;
}

.select-wrapper select {
  width: 100%;
  padding: 8px 32px 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--surface);
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.select-wrapper::after {
  content: '';
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--text-tertiary);
  pointer-events: none;
}

/* Color swatches */
.color-picker {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.color-swatch {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  transition: transform var(--duration-fast);
  border: 2px solid transparent;
}

.color-swatch:hover {
  transform: scale(1.15);
}

.color-swatch.selected {
  border-color: var(--text-primary);
  box-shadow: 0 0 0 2px var(--surface);
}

/* ---------- Empty States ---------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 32px;
  text-align: center;
}

.empty-state-icon {
  width: 56px;
  height: 56px;
  color: var(--text-placeholder);
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.empty-state-text {
  font-size: 13.5px;
  color: var(--text-tertiary);
  max-width: 280px;
  line-height: 1.5;
}

/* ---------- Search ---------- */
.search-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 300;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
  animation: fadeIn 0.15s var(--ease-out);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.search-dialog {
  width: 520px;
  max-width: calc(100vw - 32px);
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  animation: dialogIn 0.2s var(--ease-spring);
}

.search-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-light);
}

.search-input-wrap svg {
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.search-input {
  flex: 1;
  font-size: 16px;
  border: none;
  background: none;
  padding: 0;
}

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

.search-results {
  max-height: 360px;
  overflow-y: auto;
  padding: 4px;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--duration-fast);
}

.search-result-item:hover {
  background: var(--sidebar-hover);
}

.search-result-icon {
  color: var(--text-tertiary);
  flex-shrink: 0;
}

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

.search-result-title {
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-sub {
  font-size: 12px;
  color: var(--text-tertiary);
}

.search-empty {
  padding: 24px;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 13.5px;
}

/* ---------- Upcoming view ---------- */
.upcoming-day {
  margin-bottom: 4px;
}

.upcoming-day-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 12px 0 6px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 5;
}

.upcoming-day-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.upcoming-day-date {
  font-size: 13px;
  color: var(--text-tertiary);
}

.upcoming-day-header.today .upcoming-day-name {
  color: var(--accent);
}

.upcoming-day-header.overdue .upcoming-day-name {
  color: var(--red);
}

/* ---------- Project View ---------- */
.project-header {
  margin-bottom: 8px;
}

.project-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.project-progress-bar {
  flex: 1;
  height: 4px;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 2px;
  overflow: hidden;
}

.project-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width var(--duration-normal) var(--ease-out);
}

.project-progress-text {
  font-size: 12px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.add-heading-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 0;
  font-size: 13px;
  color: var(--text-tertiary);
  cursor: pointer;
  margin-top: 8px;
  transition: color var(--duration-fast);
}

.add-heading-btn:hover {
  color: var(--accent);
}

/* ---------- Logbook ---------- */
.logbook-date-group {
  margin-bottom: 16px;
}

.logbook-date-header {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-tertiary);
  padding: 8px 0;
  border-bottom: 1px solid var(--border-light);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* ---------- Trash ---------- */
.trash-actions {
  margin-bottom: 16px;
}

/* ---------- Animations ---------- */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInRight {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.animate-in {
  animation: slideUp 0.3s var(--ease-out);
}

/* ---------- Tooltip ---------- */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 8px;
  background: var(--text-primary);
  color: var(--surface);
  font-size: 11px;
  border-radius: var(--radius-xs);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--duration-fast);
}

[data-tooltip]:hover::after {
  opacity: 1;
}

/* ---------- Dropdown / Context menu ---------- */
.dropdown-menu {
  position: fixed;
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  min-width: 180px;
  padding: 4px;
  z-index: 250;
  animation: fadeIn 0.1s var(--ease-out);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  transition: background var(--duration-fast);
  color: var(--text-primary);
}

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

.dropdown-item svg {
  width: 16px;
  height: 16px;
  color: var(--text-secondary);
}

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

.dropdown-item.danger svg {
  color: var(--red);
}

.dropdown-divider {
  height: 1px;
  background: var(--border-light);
  margin: 4px 8px;
}

/* ---------- Tag pills ---------- */
.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11.5px;
  font-weight: 500;
  background: rgba(0, 0, 0, 0.06);
  color: var(--text-secondary);
}

.tag-pill .tag-dot {
  width: 6px;
  height: 6px;
}

/* ---------- Taggar på projekt ---------- */

/* Väljaren i projektdialogen: piller som växlar av/på */
.project-tag-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.project-tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 12.5px;
  color: var(--text-secondary);
  background: rgba(0, 0, 0, 0.05);
  cursor: pointer;
  transition: background var(--duration-fast), color var(--duration-fast);
}

.project-tag-pill .tag-dot {
  width: 7px;
  height: 7px;
}

.project-tag-pill:hover {
  background: rgba(0, 0, 0, 0.09);
  color: var(--text-primary);
}

.project-tag-pill.active {
  background: var(--accent-light);
  color: var(--accent);
}

/* Taggraden överst i projektvyn */
.project-tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 4px;
}

.project-tag-row .tag-pill:hover {
  background: rgba(0, 0, 0, 0.1);
}

@media (prefers-color-scheme: dark) {
  .project-tag-pill {
    background: rgba(255, 255, 255, 0.08);
  }
  .project-tag-pill:hover {
    background: rgba(255, 255, 255, 0.14);
  }
  .project-tag-row .tag-pill:hover {
    background: rgba(255, 255, 255, 0.16);
  }
}

/* ============================================
   Hjälp & guide
   ============================================ */

/* Egen avdelare så länken inte ser ut att tillhöra sektionen ovanför */
.help-nav-item {
  color: var(--text-tertiary);
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
  border-radius: 0;
}

.help-nav-item.active {
  color: var(--accent);
  background: none;
}

.help-page {
  max-width: 680px;
  padding-bottom: 48px;
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.65;
}

.help-lead {
  font-size: 15.5px;
  line-height: 1.6;
  color: var(--text-secondary);
  margin: 4px 0 28px;
}

.help-section {
  margin-bottom: 32px;
}

.help-section h2 {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.2px;
  margin: 0 0 10px;
  color: var(--text-primary);
}

.help-page p {
  margin: 0 0 12px;
  color: var(--text-secondary);
}

.help-page strong {
  color: var(--text-primary);
  font-weight: 600;
}

.help-page em {
  font-style: italic;
}

.help-page code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px;
  padding: 1px 5px;
  border-radius: var(--radius-xs);
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-primary);
}

.help-page kbd {
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: var(--radius-xs);
  background: rgba(0, 0, 0, 0.06);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  white-space: nowrap;
}

/* Tabellerna: vy-/kortkommandoöversikt */
.help-table {
  width: 100%;
  border-collapse: collapse;
  margin: 4px 0 8px;
}

.help-table th {
  text-align: left;
  vertical-align: top;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text-primary);
  padding: 8px 16px 8px 0;
  white-space: nowrap;
  width: 1%;
}

.help-table td {
  vertical-align: top;
  padding: 8px 0;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-light);
}

.help-table th {
  border-bottom: 1px solid var(--border-light);
}

.help-table tr:last-child th,
.help-table tr:last-child td {
  border-bottom: none;
}

.help-keys th {
  padding-right: 20px;
}

.help-list {
  margin: 4px 0 12px;
  padding-left: 18px;
  color: var(--text-secondary);
}

.help-list li {
  margin-bottom: 7px;
}

/* Sidonotis — mindre viktigt förtydligande */
.help-note {
  font-size: 13px;
  color: var(--text-tertiary);
  border-left: 2px solid var(--border);
  padding-left: 12px;
  margin-top: 12px;
}

/* Utpekad ruta för den vanligaste förvirringen */
.help-callout {
  background: var(--accent-light);
  border-radius: var(--radius-md, 10px);
  padding: 18px 20px 6px;
}

.help-callout h2 {
  color: var(--accent);
}

.help-footer {
  margin-top: 40px;
  padding-top: 16px;
  border-top: 1px solid var(--border-light);
  font-size: 12.5px;
  color: var(--text-tertiary);
}

@media (prefers-color-scheme: dark) {
  .help-page code,
  .help-page kbd {
    background: rgba(255, 255, 255, 0.09);
  }
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  :root {
    --sidebar-width: 280px;
  }

  #sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
    z-index: 100;
  }

  #sidebar.open {
    transform: translateX(0);
  }

  .menu-btn {
    display: flex;
  }

  #main-header {
    padding: 16px 16px 0;
  }

  .view-header {
    flex-direction: row;
  }

  .view-title {
    font-size: 24px;
  }

  #main-content {
    padding: 8px 16px 100px;
  }

  #detail-panel {
    width: 100%;
    max-width: 100%;
  }

  #fab {
    bottom: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
  }

  .dialog {
    width: calc(100vw - 24px);
    max-height: calc(100vh - 48px);
  }

  .quick-add-dialog {
    width: calc(100vw - 24px);
  }

  .search-dialog {
    width: calc(100vw - 24px);
    margin-top: 0;
  }

  .date-picker-popover {
    position: fixed;
    left: 50% !important;
    top: 50% !important;
    transform: translate(-50%, -50%) !important;
  }

  .sidebar-search kbd {
    display: none;
  }
}

@media (max-width: 480px) {
  .view-title {
    font-size: 22px;
  }

  .task-item {
    padding: 8px 2px;
  }
}

/* Large screens - detail panel side by side */
@media (min-width: 1024px) {
  #detail-overlay {
    display: none !important;
  }

  #detail-panel.open ~ #main {
    margin-right: var(--detail-width);
  }
}

/* ---------- Dark mode ready (via prefers-color-scheme) ---------- */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1C1C1E;
    --surface: #2C2C2E;
    --sidebar-bg: #1C1C1E;
    --sidebar-hover: rgba(255, 255, 255, 0.06);
    --sidebar-active: rgba(0, 122, 255, 0.15);
    --text-primary: #F2F2F7;
    --text-secondary: #AEAEB2;
    --text-tertiary: #636366;
    --text-placeholder: #48484A;
    --accent-light: rgba(0, 122, 255, 0.2);
    --accent-bg: rgba(0, 122, 255, 0.12);
    --border: #38383A;
    --border-light: #2C2C2E;
    --divider: rgba(255, 255, 255, 0.06);
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.6);
  }

  body {
    color-scheme: dark;
  }

  .task-checkbox {
    border-color: #48484A;
  }

  .checklist-checkbox {
    border-color: #48484A;
  }
}

/* ---------- Print ---------- */
@media print {
  #sidebar,
  #fab,
  #detail-panel,
  #sidebar-overlay,
  #detail-overlay {
    display: none !important;
  }

  #main {
    width: 100%;
  }

  .task-item {
    break-inside: avoid;
  }
}

/* ---------- Safe area for notched devices ---------- */
@supports (padding: env(safe-area-inset-left)) {
  #sidebar {
    padding-left: env(safe-area-inset-left);
  }

  #main-header,
  #main-content {
    padding-left: calc(env(safe-area-inset-left) + 16px);
    padding-right: calc(env(safe-area-inset-right) + 16px);
  }

  #fab {
    right: calc(env(safe-area-inset-right) + 24px);
    bottom: calc(env(safe-area-inset-bottom) + 24px);
  }
}

/* ---------- Selection ---------- */
::selection {
  background: rgba(0, 122, 255, 0.2);
}

/* ---------- Focus visible ---------- */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button:focus-visible,
.nav-item:focus-visible,
.task-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  border-radius: var(--radius-sm);
}

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

/* ============================================
   LOGIN SCREEN
   ============================================ */

#login-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
  animation: fadeIn 0.3s var(--ease-out);
}

.login-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  max-width: 380px;
  width: 100%;
}

.login-icon {
  margin-bottom: 20px;
  filter: drop-shadow(0 8px 24px rgba(0, 122, 255, 0.3));
  animation: slideUp 0.5s var(--ease-out);
}

.login-icon svg {
  border-radius: 18px;
}

.login-title {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.8px;
  color: var(--text-primary);
  margin-bottom: 8px;
  animation: slideUp 0.5s 0.05s var(--ease-out) both;
}

.login-tagline {
  font-size: 16px;
  color: var(--text-secondary);
  margin-bottom: 40px;
  font-weight: 400;
  letter-spacing: -0.1px;
  animation: slideUp 0.5s 0.1s var(--ease-out) both;
}

.google-signin-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 14px 24px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  transition: background var(--duration-fast), box-shadow var(--duration-fast),
    transform var(--duration-fast) var(--ease-spring);
  box-shadow: var(--shadow-sm);
  animation: slideUp 0.5s 0.15s var(--ease-out) both;
  margin-bottom: 16px;
}

.google-signin-btn:hover {
  background: var(--surface);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.google-signin-btn:active {
  transform: translateY(0) scale(0.98);
}

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

.google-signin-btn svg {
  flex-shrink: 0;
}

.login-error {
  font-size: 13px;
  color: var(--red);
  margin-top: 8px;
  animation: fadeIn 0.2s;
}

.login-disclaimer {
  font-size: 12px;
  color: var(--text-tertiary);
  line-height: 1.5;
  max-width: 280px;
  animation: slideUp 0.5s 0.2s var(--ease-out) both;
}

/* Login loading spinner */
.login-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(0, 0, 0, 0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================
   SIDEBAR USER SECTION
   ============================================ */

.sidebar-user {
  padding: 12px 12px;
  border-top: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.user-avatar-placeholder {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}

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

.user-name {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-email {
  font-size: 11px;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sign-out-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xs);
  color: var(--text-tertiary);
  flex-shrink: 0;
  transition: background var(--duration-fast), color var(--duration-fast);
}

.sign-out-btn:hover {
  background: rgba(255, 59, 48, 0.08);
  color: var(--red);
}

/* .fab-dubblettreglerna borttagna (ISSUE-09) — det finns nu bara EN
   FAB: den statiska #fab i index.html, stylad av #fab-reglerna ovan. */

@media (max-width: 768px) {
  /* Push content up so FAB doesn't cover last task */
  #main-content {
    padding-bottom: 96px;
  }
}

/* Inline links in project notes */
.inline-link {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-all;
}
.inline-link:hover { opacity: 0.75; }

/* Link previews below task notes textarea */
.notes-links {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 0 4px;
}
.notes-link-item {
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
  word-break: break-all;
  padding: 4px 8px;
  background: rgba(0, 122, 255, 0.07);
  border-radius: 6px;
  display: block;
}
.notes-link-item:hover { background: rgba(0, 122, 255, 0.14); }

/* Dark mode adjustments for login */
@media (prefers-color-scheme: dark) {
  .google-signin-btn {
    background: #2C2C2E;
    border-color: #3A3A3C;
  }

  .google-signin-btn:hover {
    background: #3A3A3C;
  }

  .login-spinner {
    border-color: rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent);
  }
}
