/* =====================================================
   XT2 DailyLog - Complete CSS
   Dark theme with orange (#f5a623) accent
   Mobile-first, responsive, production-ready
   ===================================================== */

/* ── CSS Custom Properties ── */
:root {
  --bg-primary: #0d0d0d;
  --bg-secondary: #1a1a1a;
  --bg-card: #1e1e1e;
  --bg-card-hover: #252525;
  --bg-input: #1e1e1e;
  --bg-elevated: #2a2a2a;

  --text-primary: #ffffff;
  --text-secondary: #e0e0e0;
  --text-muted: #888888;
  --text-disabled: #555555;

  --accent: #f5a623;
  --accent-hover: #e6981a;
  --accent-light: rgba(245, 166, 35, 0.15);
  --accent-glow: rgba(245, 166, 35, 0.3);

  --border-color: #2d2d2d;
  --border-light: #3a3a3a;
  --divider: #222222;

  --success: #4caf50;
  --warning: #ff9800;
  --danger: #f44336;
  --info: #2196f3;

  --priority-urgent: #f44336;
  --priority-high: #ff9800;
  --priority-medium: #f5a623;
  --priority-low: #4caf50;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.6);
  --shadow-xl: 0 16px 48px rgba(0, 0, 0, 0.7);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 50%;

  --nav-height: 60px;
  --topbar-height: 56px;
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 400ms ease;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);

  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

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

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

body {
  font-family: var(--font-family);
  background: linear-gradient(180deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
  background-attachment: fixed;
  color: var(--text-secondary);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
}

/* Scrollbar styling */
::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

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

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Selection */
::selection {
  background: var(--accent);
  color: var(--bg-primary);
}

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

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

img {
  max-width: 100%;
  height: auto;
  display: block;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  font-size: inherit;
}

input,
textarea,
select {
  font-family: inherit;
  font-size: inherit;
}

/* ── Loading Screen ── */
.loading-screen {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

.loading-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-logo {
  width: 80px;
  height: 80px;
  margin-bottom: 24px;
  animation: loadingPulse 2s ease-in-out infinite;
}

.loading-logo svg {
  width: 100%;
  height: 100%;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 16px;
}

.loading-text {
  color: var(--text-muted);
  font-size: 14px;
  letter-spacing: 0.5px;
}

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

@keyframes loadingPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(0.95); }
}

/* ── Auth Screen ── */
.auth-screen {
  position: fixed;
  inset: 0;
  background: linear-gradient(180deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 8000;
}

.auth-screen.active {
  display: flex;
}

.auth-container {
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.auth-logo {
  width: 72px;
  height: 72px;
  margin: 0 auto 12px;
}

.auth-logo svg {
  width: 100%;
  height: 100%;
}

.auth-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.auth-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 32px;
}

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

.auth-form .form-group {
  text-align: left;
}

.auth-form .form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.auth-form .form-input {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 15px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

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

.auth-form .form-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.auth-btn {
  width: 100%;
  padding: 14px;
  background: var(--accent);
  color: var(--bg-primary);
  font-size: 16px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast), transform var(--transition-fast);
  margin-top: 8px;
}

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

.auth-btn:active {
  transform: scale(0.98);
}

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

.auth-error {
  display: none;
  padding: 12px;
  background: rgba(244, 67, 54, 0.1);
  border: 1px solid rgba(244, 67, 54, 0.3);
  border-radius: var(--radius-sm);
  color: var(--danger);
  font-size: 13px;
  text-align: center;
}

.auth-error.visible {
  display: block;
}

/* ── App Shell ── */
.app-shell {
  display: none;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.app-shell.active {
  display: flex;
}

/* ── Top Bar ── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  height: var(--topbar-height);
  padding: 0 16px;
  background: rgba(13, 13, 13, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-color);
}

.topbar-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}

.topbar-title span {
  color: var(--accent);
}

.topbar-project-select {
  margin-left: 12px;
  padding: 6px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  max-width: 160px;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 28px;
  cursor: pointer;
}

.topbar-project-select:focus {
  outline: none;
  border-color: var(--accent);
}

.topbar-spacer {
  flex: 1;
}

.topbar-avatar {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--bg-primary);
  cursor: pointer;
  transition: transform var(--transition-fast);
}

.topbar-avatar:hover {
  transform: scale(1.08);
}

/* ── Main Content Area ── */
.main-content {
  flex: 1;
  padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 16px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── Views ── */
.view {
  display: none;
  padding: 16px;
  animation: viewFadeIn 0.3s ease;
}

.view.active {
  display: block;
}

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

/* ── Dashboard View ── */

/* Stats Row */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 12px;
  text-align: center;
  transition: transform var(--transition-fast), border-color var(--transition-fast);
}

.stat-card:active {
  transform: scale(0.97);
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.1;
}

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.3;
}

/* Quick Actions Grid */
.section-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 14px;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 28px;
}

.quick-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 1;
  max-height: 100px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 12px 4px;
  cursor: pointer;
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
}

.quick-action-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, var(--accent-light) 0%, transparent 70%);
  opacity: 0;
  transition: opacity var(--transition-normal);
}

.quick-action-btn:hover::before,
.quick-action-btn:focus-visible::before {
  opacity: 1;
}

.quick-action-btn:active {
  transform: scale(0.93);
  border-color: var(--accent);
}

.quick-action-btn .icon {
  width: 32px;
  height: 32px;
  margin-bottom: 6px;
  color: var(--accent);
  position: relative;
  z-index: 1;
  flex-shrink: 0;
}

.quick-action-btn .icon svg {
  width: 100%;
  height: 100%;
}

.quick-action-btn .label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.2;
  position: relative;
  z-index: 1;
}

/* Audio button special styling */
.quick-action-btn.action-audio {
  border-color: var(--accent);
  background: linear-gradient(135deg, rgba(245, 166, 35, 0.08) 0%, var(--bg-card) 100%);
}

.quick-action-btn.action-audio .icon {
  color: var(--accent);
}

/* Recent Activity */
.recent-activity {
  margin-top: 4px;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--divider);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.activity-item:last-child {
  border-bottom: none;
}

.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--accent);
  margin-top: 7px;
  flex-shrink: 0;
}

.activity-content {
  flex: 1;
  min-width: 0;
}

.activity-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.activity-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.activity-time {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  margin-top: 2px;
}

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

.activity-dot.dot-diary { background: var(--success); }
.activity-dot.dot-task { background: var(--info); }

/* ── Diary View ── */
.diary-date-group {
  margin-bottom: 24px;
}

.diary-date-header {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-color);
}

.diary-entry-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.diary-entry-card:hover {
  border-color: var(--border-light);
  background: var(--bg-card-hover);
}

.diary-entry-card:active {
  transform: scale(0.99);
}

.diary-entry-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.diary-entry-date {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.diary-entry-weather {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--text-muted);
}

.diary-entry-weather svg {
  width: 16px;
  height: 16px;
}

.diary-entry-summary {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 10px;
}

.diary-entry-meta {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text-muted);
}

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

.diary-entry-meta-item svg {
  width: 14px;
  height: 14px;
  opacity: 0.7;
}

/* Diary expanded details */
.diary-entry-details {
  display: none;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border-color);
}

.diary-entry-card.expanded .diary-entry-details {
  display: block;
}

.diary-detail-section {
  margin-bottom: 12px;
}

.diary-detail-section:last-child {
  margin-bottom: 0;
}

.diary-detail-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.diary-detail-value {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.diary-photos-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-top: 6px;
}

.diary-photo-thumb {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  overflow: hidden;
}

.diary-photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ── Diary cards (JS-generated) ── */
.diary-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.diary-card:hover {
  border-color: var(--border-light);
  background: var(--bg-card-hover);
}

.diary-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.diary-card-weather {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.diary-card-crew {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-elevated);
  padding: 2px 8px;
  border-radius: 10px;
}

.diary-card-body {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 10px;
}

.diary-card-body p {
  margin: 0;
}

.diary-card-photos {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
  overflow: hidden;
}

.diary-card-photo {
  width: 60px;
  height: 60px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  cursor: pointer;
}

.diary-card-photo-more {
  width: 60px;
  height: 60px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.diary-card-actions {
  display: flex;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
}

.diary-action-btn {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.diary-action-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.diary-action-btn.diary-delete-btn {
  color: var(--danger);
}

.diary-action-btn.diary-delete-btn:hover {
  background: rgba(244, 67, 54, 0.1);
}

/* ── Activity empty state ── */
.activity-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 14px;
}

.activity-empty p {
  margin: 0;
}

/* Filter Tabs */
.filter-tabs {
  display: flex;
  gap: 0;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 4px;
  margin-bottom: 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.filter-tabs::-webkit-scrollbar {
  display: none;
}

.filter-tab {
  flex: 1;
  min-width: fit-content;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  text-align: center;
  white-space: nowrap;
  transition: all var(--transition-fast);
  cursor: pointer;
}

.filter-tab.active {
  background: var(--accent);
  color: var(--bg-primary);
  font-weight: 600;
}

.filter-tab:not(.active):hover {
  color: var(--text-secondary);
  background: var(--bg-elevated);
}

/* ── Tasks View ── */
.task-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}

.task-card:hover {
  border-color: var(--border-light);
  background: var(--bg-card-hover);
}

.task-card:active {
  transform: scale(0.99);
}

.task-card-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 6px;
}

.task-checkbox {
  width: 22px;
  height: 22px;
  border: 2px solid var(--border-light);
  border-radius: 6px;
  flex-shrink: 0;
  margin-top: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.task-checkbox.checked {
  background: var(--success);
  border-color: var(--success);
}

.task-checkbox.checked svg {
  display: block;
}

.task-checkbox svg {
  width: 14px;
  height: 14px;
  color: #fff;
  display: none;
}

.task-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  flex: 1;
  line-height: 1.4;
}

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

.task-priority-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  flex-shrink: 0;
}

.task-priority-badge.urgent {
  background: rgba(244, 67, 54, 0.15);
  color: var(--priority-urgent);
}

.task-priority-badge.high {
  background: rgba(255, 152, 0, 0.15);
  color: var(--priority-high);
}

.task-priority-badge.medium {
  background: rgba(245, 166, 35, 0.15);
  color: var(--priority-medium);
}

.task-priority-badge.low {
  background: rgba(76, 175, 80, 0.15);
  color: var(--priority-low);
}

.task-card-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  padding-left: 32px;
}

.task-due-date {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.task-due-date svg {
  width: 13px;
  height: 13px;
}

.task-due-date.overdue {
  color: var(--danger);
}

.task-project-tag {
  font-size: 11px;
  padding: 2px 8px;
  background: var(--bg-elevated);
  border-radius: 10px;
  color: var(--text-muted);
}

.task-status-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
}

.task-status-badge.pending {
  background: rgba(255, 152, 0, 0.12);
  color: var(--warning);
}

.task-status-badge.in-progress {
  background: rgba(33, 150, 243, 0.12);
  color: var(--info);
}

.task-status-badge.completed {
  background: rgba(76, 175, 80, 0.12);
  color: var(--success);
}

/* ── Task card JS-generated class aliases ── */
.task-card-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  flex: 1;
  line-height: 1.4;
}

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

.task-card-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-top: 4px;
  padding-left: 0;
}

.task-status-btn {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 10px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all var(--transition-fast);
}

.task-status-btn.pending {
  background: rgba(255, 152, 0, 0.12);
  color: var(--warning);
}

.task-status-btn.in-progress {
  background: rgba(33, 150, 243, 0.12);
  color: var(--info);
}

.task-status-btn.completed {
  background: rgba(76, 175, 80, 0.12);
  color: var(--success);
}

.task-status-btn:hover {
  filter: brightness(1.15);
}

.task-category {
  font-size: 11px;
  padding: 2px 8px;
  background: var(--bg-elevated);
  border-radius: 10px;
  color: var(--text-muted);
}

.task-delete-btn {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  margin-left: auto;
  transition: all var(--transition-fast);
}

.task-delete-btn:hover {
  color: var(--danger);
  border-color: var(--danger);
  background: rgba(244, 67, 54, 0.08);
}

/* ── AI Chat View ── */
.chat-view {
  display: none;
  flex-direction: column;
  height: calc(100vh - var(--topbar-height) - var(--nav-height) - var(--safe-top) - var(--safe-bottom));
  height: calc(100dvh - var(--topbar-height) - var(--nav-height) - var(--safe-top) - var(--safe-bottom));
  padding: 0 !important;
}

.chat-view.active {
  display: flex;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-message {
  display: flex;
  flex-direction: column;
  max-width: 80%;
  animation: messageIn 0.3s ease;
}

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

.chat-message.user {
  align-self: flex-end;
}

.chat-message.ai {
  align-self: flex-start;
}

.chat-bubble {
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.chat-message.user .chat-bubble {
  background: var(--accent);
  color: var(--bg-primary);
  border-bottom-right-radius: 6px;
}

.chat-message.ai .chat-bubble {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border-bottom-left-radius: 6px;
}

.chat-bubble p {
  margin-bottom: 8px;
}

.chat-bubble p:last-child {
  margin-bottom: 0;
}

.chat-bubble strong {
  color: var(--text-primary);
}

.chat-bubble code {
  background: rgba(255, 255, 255, 0.1);
  padding: 1px 4px;
  border-radius: 4px;
  font-size: 13px;
}

.chat-bubble ul,
.chat-bubble ol {
  padding-left: 18px;
  margin: 4px 0;
}

.chat-time {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  padding: 0 4px;
}

.chat-message.user .chat-time {
  text-align: right;
}

/* Typing Indicator */
.typing-indicator {
  display: none;
  align-self: flex-start;
  padding: 12px 16px;
  background: var(--bg-elevated);
  border-radius: 18px;
  border-bottom-left-radius: 6px;
}

.typing-indicator.visible {
  display: flex;
}

.typing-dots {
  display: flex;
  gap: 4px;
  align-items: center;
}

.typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typingBounce 1.4s ease-in-out infinite;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.16s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.32s;
}

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* Chat Input Area */
.chat-input-area {
  padding: 10px 12px;
  background: rgba(13, 13, 13, 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.chat-input-wrapper {
  flex: 1;
  display: flex;
  align-items: flex-end;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 22px;
  padding: 4px 4px 4px 14px;
  transition: border-color var(--transition-fast);
}

.chat-input-wrapper:focus-within {
  border-color: var(--accent);
}

.chat-text-input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 15px;
  padding: 8px 0;
  resize: none;
  max-height: 120px;
  overflow-y: auto;
  line-height: 1.4;
}

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

.chat-text-input:focus {
  outline: none;
}

.chat-attach-btn,
.chat-mic-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.chat-attach-btn:hover,
.chat-mic-btn:hover {
  color: var(--text-secondary);
  background: var(--bg-elevated);
}

.chat-attach-btn svg,
.chat-mic-btn svg {
  width: 20px;
  height: 20px;
}

.chat-send-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition-fast);
  opacity: 0.5;
}

.chat-send-btn.active {
  opacity: 1;
}

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

.chat-send-btn:active {
  transform: scale(0.9);
}

.chat-send-btn svg {
  width: 20px;
  height: 20px;
}

.chat-mic-btn.recording {
  color: var(--danger);
  animation: micPulse 1s ease infinite;
}

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

/* ── More Menu View ── */
.more-menu-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.more-menu-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  margin-bottom: 6px;
}

.more-menu-item:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-light);
}

.more-menu-item:active {
  transform: scale(0.99);
}

.more-menu-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.more-menu-icon svg {
  width: 22px;
  height: 22px;
  color: var(--accent);
}

.more-menu-text {
  flex: 1;
}

.more-menu-text .title {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
}

.more-menu-text .desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 1px;
}

.more-menu-arrow {
  color: var(--text-disabled);
}

.more-menu-arrow svg {
  width: 18px;
  height: 18px;
}

/* ── Bottom Navigation ── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: rgba(13, 13, 13, 0.8);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-top: 1px solid rgba(45, 45, 45, 0.6);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 200;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 0;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
  position: relative;
}

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

.nav-item:active {
  transform: scale(0.92);
}

.nav-item .nav-icon {
  width: 24px;
  height: 24px;
  position: relative;
}

.nav-item .nav-icon svg {
  width: 100%;
  height: 100%;
}

.nav-item .nav-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.2px;
}

.nav-badge {
  position: absolute;
  top: -2px;
  right: -6px;
  width: 16px;
  height: 16px;
  border-radius: var(--radius-full);
  background: var(--danger);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg-primary);
}

/* ── FAB (Floating Action Button) ── */
.fab {
  position: fixed;
  bottom: calc(var(--nav-height) + var(--safe-bottom) + 16px);
  right: 16px;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg), 0 0 20px var(--accent-glow);
  z-index: 150;
  transition: all var(--transition-fast);
  cursor: pointer;
}

.fab:hover {
  transform: scale(1.08);
  box-shadow: var(--shadow-xl), 0 0 30px var(--accent-glow);
}

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

.fab svg {
  width: 26px;
  height: 26px;
}

.fab.hidden {
  transform: scale(0);
  opacity: 0;
  pointer-events: none;
}

/* ── Modals ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 500;
  display: none;
  align-items: flex-end;
  justify-content: center;
  animation: overlayIn 0.2s ease;
}

.modal-overlay.active {
  display: flex;
}

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

.modal {
  width: 100%;
  max-height: 92vh;
  max-height: 92dvh;
  background: var(--bg-secondary);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: modalSlideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalSlideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-handle {
  width: 36px;
  height: 4px;
  background: var(--border-light);
  border-radius: 2px;
  margin: 10px auto 0;
  flex-shrink: 0;
}

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

.modal-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-close-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all var(--transition-fast);
}

.modal-close-btn:hover {
  background: var(--bg-elevated);
  color: var(--text-secondary);
}

.modal-close-btn svg {
  width: 20px;
  height: 20px;
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
}

.modal-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 10px;
  flex-shrink: 0;
  padding-bottom: calc(12px + var(--safe-bottom));
}

/* ── Forms ── */
.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-input,
.form-textarea,
.form-select {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 15px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-disabled);
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.form-textarea {
  resize: vertical;
  min-height: 100px;
  line-height: 1.5;
}

.form-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
  cursor: pointer;
}

.form-select option {
  background: var(--bg-card);
  color: var(--text-primary);
}

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

.form-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Dynamic add rows */
.dynamic-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.dynamic-row .form-input {
  flex: 1;
}

.dynamic-row-remove {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--danger);
  flex-shrink: 0;
  transition: background var(--transition-fast);
}

.dynamic-row-remove:hover {
  background: rgba(244, 67, 54, 0.1);
}

.dynamic-row-remove svg {
  width: 18px;
  height: 18px;
}

.add-row-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px;
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--accent);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.add-row-btn:hover {
  border-color: var(--accent);
  background: var(--accent-light);
}

.add-row-btn svg {
  width: 16px;
  height: 16px;
}

/* Photo upload area */
.photo-upload-area {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.photo-upload-area:hover {
  border-color: var(--accent);
  background: var(--accent-light);
}

.photo-upload-area svg {
  width: 36px;
  height: 36px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.photo-upload-area .upload-text {
  font-size: 13px;
  color: var(--text-muted);
}

.photo-upload-preview {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.photo-preview-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-elevated);
}

.photo-preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-preview-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-full);
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.photo-preview-remove svg {
  width: 14px;
  height: 14px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  border: none;
  white-space: nowrap;
}

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

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

.btn-primary {
  background: var(--accent);
  color: var(--bg-primary);
  flex: 1;
}

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

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-light);
}

.btn-danger {
  background: rgba(244, 67, 54, 0.12);
  color: var(--danger);
}

.btn-danger:hover {
  background: rgba(244, 67, 54, 0.2);
}

.btn-ghost {
  background: transparent;
  color: var(--accent);
  padding: 8px 12px;
}

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

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 8px 14px;
  font-size: 13px;
}

/* ── Audio Recorder Overlay ── */
.audio-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 600;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.audio-overlay.active {
  display: flex;
}

.audio-overlay-close {
  position: absolute;
  top: calc(16px + var(--safe-top));
  right: 16px;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.audio-overlay-close svg {
  width: 22px;
  height: 22px;
}

.audio-status {
  font-size: 14px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 24px;
}

.audio-timer {
  font-size: 56px;
  font-weight: 300;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  margin-bottom: 32px;
}

.audio-waveform {
  width: 100%;
  max-width: 300px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  margin-bottom: 48px;
}

.audio-waveform-bar {
  width: 4px;
  border-radius: 2px;
  background: var(--accent);
  transition: height 0.1s ease;
  animation: waveformPulse 1.2s ease-in-out infinite;
}

.audio-waveform-bar:nth-child(odd) {
  animation-delay: 0.1s;
}

.audio-waveform-bar:nth-child(3n) {
  animation-delay: 0.2s;
}

.audio-waveform-bar:nth-child(5n) {
  animation-delay: 0.3s;
}

@keyframes waveformPulse {
  0%, 100% { height: 8px; opacity: 0.4; }
  50% { height: 40px; opacity: 1; }
}

.audio-controls {
  display: flex;
  align-items: center;
  gap: 24px;
}

.audio-record-btn {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-full);
  background: var(--danger);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  position: relative;
}

.audio-record-btn::before {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: var(--radius-full);
  border: 2px solid var(--danger);
  opacity: 0.3;
  animation: recordPulse 1.5s ease infinite;
}

.audio-record-btn.recording::before {
  animation: recordPulse 1.5s ease infinite;
}

.audio-record-btn:not(.recording)::before {
  animation: none;
  opacity: 0;
}

@keyframes recordPulse {
  0% { transform: scale(1); opacity: 0.3; }
  50% { transform: scale(1.15); opacity: 0.1; }
  100% { transform: scale(1); opacity: 0.3; }
}

.audio-record-btn svg {
  width: 32px;
  height: 32px;
  color: #fff;
}

.audio-record-btn.recording .record-icon {
  display: none;
}

.audio-record-btn.recording .stop-icon {
  display: block;
}

.audio-record-btn:not(.recording) .record-icon {
  display: block;
}

.audio-record-btn:not(.recording) .stop-icon {
  display: none;
}

.audio-cancel-btn,
.audio-send-btn {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.audio-cancel-btn {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
}

.audio-send-btn {
  background: var(--accent);
  color: var(--bg-primary);
  opacity: 0.5;
  pointer-events: none;
}

.audio-send-btn.active {
  opacity: 1;
  pointer-events: auto;
}

.audio-cancel-btn svg,
.audio-send-btn svg {
  width: 22px;
  height: 22px;
}

/* ── Photo Preview Overlay ── */
.photo-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.95);
  z-index: 600;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.photo-overlay.active {
  display: flex;
}

.photo-overlay-close {
  position: absolute;
  top: calc(16px + var(--safe-top));
  right: 16px;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 1;
}

.photo-overlay-close svg {
  width: 22px;
  height: 22px;
}

.photo-overlay img {
  max-width: 100%;
  max-height: 80vh;
  max-height: 80dvh;
  object-fit: contain;
}

.photo-overlay-actions {
  position: absolute;
  bottom: calc(24px + var(--safe-bottom));
  display: flex;
  gap: 16px;
}

/* ── Search Overlay ── */
.search-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  z-index: 550;
  display: none;
  flex-direction: column;
}

.search-overlay.active {
  display: flex;
  animation: viewFadeIn 0.2s ease;
}

.search-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-color);
  padding-top: calc(10px + var(--safe-top));
}

.search-back-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  flex-shrink: 0;
  cursor: pointer;
}

.search-back-btn svg {
  width: 22px;
  height: 22px;
}

.search-input-wrapper {
  flex: 1;
}

.search-input {
  width: 100%;
  padding: 10px 0;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 16px;
}

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

.search-input:focus {
  outline: none;
}

.search-results {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 16px;
}

.search-results-group,
.search-group {
  margin-bottom: 20px;
}

.search-results-group-title,
.search-group-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--divider);
  cursor: pointer;
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.search-result-icon svg {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
}

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

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

.search-result-meta,
.search-result-date {
  font-size: 12px;
  color: var(--text-muted);
}

.search-loading {
  text-align: center;
  padding: 32px;
  color: var(--text-muted);
  font-size: 14px;
}

.search-empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.search-empty svg {
  width: 48px;
  height: 48px;
  margin-bottom: 12px;
  opacity: 0.3;
}

.search-empty p {
  font-size: 14px;
}

/* ── AI Chat Overlay ── */
.ai-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ai-chat-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px 24px 20px;
  color: var(--text-muted);
}

.ai-chat-welcome p {
  font-size: 15px;
  margin-top: 12px;
  color: var(--text-secondary);
}

.ai-chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 20px;
  justify-content: center;
}

.ai-suggestion-btn {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.ai-suggestion-btn:active {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
}

.ai-chat-bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}

.ai-chat-bubble.user {
  align-self: flex-end;
  background: var(--accent);
  color: #000;
  border-bottom-right-radius: 4px;
}

.ai-chat-bubble.ai {
  align-self: flex-start;
  background: var(--surface-elevated);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

.ai-chat-bubble.ai p { margin: 0 0 8px; }
.ai-chat-bubble.ai p:last-child { margin-bottom: 0; }
.ai-chat-bubble.ai ul, .ai-chat-bubble.ai ol { margin: 4px 0; padding-left: 20px; }
.ai-chat-bubble.ai strong { color: var(--accent); }

.ai-chat-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  background: var(--surface-elevated);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
}

.ai-chat-typing span {
  width: 8px;
  height: 8px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: aiTypingDot 1.2s infinite ease-in-out;
}

.ai-chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.ai-chat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes aiTypingDot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

.ai-chat-input-area {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  padding-bottom: calc(12px + var(--safe-bottom));
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.ai-chat-input {
  flex: 1;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 10px 16px;
  font-size: 14px;
  color: var(--text-primary);
  outline: none;
}

.ai-chat-input:focus {
  border-color: var(--accent);
}

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

.ai-chat-send-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ai-chat-send-btn svg {
  width: 18px;
  height: 18px;
  stroke: #000;
}

.ai-chat-send-btn:disabled {
  opacity: 0.5;
}

/* ── Toast Notifications ── */
.toast-container {
  position: fixed;
  top: calc(16px + var(--safe-top));
  right: 16px;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: calc(100vw - 32px);
  width: 360px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
}

.toast.removing {
  animation: toastOut 0.3s ease forwards;
}

@keyframes toastIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes toastOut {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(100%); opacity: 0; }
}

.toast-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

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

.toast-message {
  flex: 1;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.toast-close {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-disabled);
  flex-shrink: 0;
  cursor: pointer;
  transition: color var(--transition-fast);
}

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

.toast-close svg {
  width: 14px;
  height: 14px;
}

/* Colored left border for toasts */
.toast.success { border-left: 3px solid var(--success); }
.toast.warning { border-left: 3px solid var(--warning); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--info); }

/* ── Skeleton Loading ── */
.skeleton {
  background: linear-gradient(90deg, var(--bg-card) 25%, var(--bg-card-hover) 50%, var(--bg-card) 75%);
  background-size: 200% 100%;
  animation: skeletonShimmer 1.5s ease infinite;
  border-radius: var(--radius-sm);
}

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

.skeleton-line {
  height: 14px;
  margin-bottom: 8px;
  border-radius: 4px;
}

.skeleton-line.short {
  width: 60%;
}

.skeleton-line.medium {
  width: 80%;
}

.skeleton-card {
  height: 80px;
  margin-bottom: 10px;
  border-radius: var(--radius-md);
}

.skeleton-circle {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
}

/* ── Pull to Refresh ── */
.pull-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 0;
  overflow: hidden;
  transition: height 0.3s ease;
}

.pull-indicator.visible {
  height: 50px;
}

.pull-indicator-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border-color);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.empty-state svg {
  width: 64px;
  height: 64px;
  color: var(--text-disabled);
  margin-bottom: 16px;
}

.empty-state h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.empty-state p {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 260px;
  line-height: 1.5;
}

/* ── Date Range Picker ── */
.date-range-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ── Report Type Selector ── */
.report-type-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}

.report-type-card {
  background: var(--bg-card);
  border: 2px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.report-type-card:hover {
  border-color: var(--border-light);
}

.report-type-card.selected {
  border-color: var(--accent);
  background: var(--accent-light);
}

.report-type-card svg {
  width: 28px;
  height: 28px;
  color: var(--accent);
  margin-bottom: 8px;
}

.report-type-card .title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

/* ── Settings List ── */
.settings-section {
  margin-bottom: 24px;
}

.settings-section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  padding: 0 4px;
}

.settings-list {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--divider);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.settings-item:last-child {
  border-bottom: none;
}

.settings-item:hover {
  background: var(--bg-card-hover);
}

.settings-item-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.settings-item-icon {
  width: 20px;
  height: 20px;
  color: var(--text-muted);
}

.settings-item-label {
  font-size: 14px;
  color: var(--text-primary);
}

.settings-item-value {
  font-size: 13px;
  color: var(--text-muted);
}

/* Toggle Switch */
.toggle-switch {
  width: 44px;
  height: 24px;
  background: var(--bg-elevated);
  border-radius: 12px;
  position: relative;
  cursor: pointer;
  transition: background var(--transition-fast);
  border: 1px solid var(--border-color);
}

.toggle-switch.active {
  background: var(--accent);
  border-color: var(--accent);
}

.toggle-switch::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: var(--radius-full);
  background: #fff;
  top: 2px;
  left: 2px;
  transition: transform var(--transition-fast);
}

.toggle-switch.active::after {
  transform: translateX(20px);
}

/* ── Responsive ── */

/* Tablet and up */
@media (min-width: 768px) {
  .main-content {
    max-width: 680px;
    margin: 0 auto;
  }

  .quick-actions {
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
  }

  .quick-action-btn {
    max-height: 110px;
  }

  .quick-action-btn .icon {
    width: 36px;
    height: 36px;
  }

  .quick-action-btn .label {
    font-size: 12px;
  }

  .modal {
    max-width: 540px;
    max-height: 85vh;
    max-height: 85dvh;
    border-radius: var(--radius-xl);
    margin: auto;
  }

  .modal-overlay {
    align-items: center;
  }

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

  .modal-handle {
    display: none;
  }

  .toast-container {
    width: 400px;
  }
}

/* Desktop */
@media (min-width: 1024px) {
  .main-content {
    max-width: 720px;
  }

  .stats-row {
    gap: 14px;
  }

  .stat-card {
    padding: 18px 16px;
  }

  .stat-value {
    font-size: 32px;
  }

  .stat-label {
    font-size: 12px;
  }
}

/* Small phones */
@media (max-width: 374px) {
  .quick-actions {
    grid-template-columns: repeat(3, 1fr);
  }

  .stats-row {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }

  .stat-card {
    padding: 10px 8px;
  }

  .stat-value {
    font-size: 22px;
  }

  .stat-label {
    font-size: 10px;
  }

  .topbar-project-select {
    max-width: 100px;
    font-size: 12px;
  }
}

/* Landscape mode */
@media (max-height: 500px) and (orientation: landscape) {
  .audio-timer {
    font-size: 36px;
    margin-bottom: 16px;
  }

  .audio-waveform {
    height: 30px;
    margin-bottom: 16px;
  }

  .audio-record-btn {
    width: 60px;
    height: 60px;
  }
}

/* ── Utility Classes ── */
.text-center { text-align: center; }
.text-accent { color: var(--accent); }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }

.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }

.flex { display: flex; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }

.hidden { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* ── Dark input autofill fix ── */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
textarea:-webkit-autofill {
  -webkit-text-fill-color: var(--text-primary);
  -webkit-box-shadow: 0 0 0 1000px var(--bg-input) inset;
  transition: background-color 5000s ease-in-out 0s;
  caret-color: var(--text-primary);
}

/* ── Print ── */
@media print {
  .bottom-nav,
  .fab,
  .topbar {
    display: none !important;
  }

  .main-content {
    padding-bottom: 0 !important;
  }

  body {
    background: #fff;
    color: #000;
  }
}

/* ── Phase 1: New Components ── */

/* Search Bar */
.search-bar-container {
  position: relative;
  margin-bottom: 16px;
}

.search-bar {
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0 12px;
  height: 44px;
  transition: border-color var(--transition-fast);
}

.search-bar:focus-within {
  border-color: var(--accent);
}

.search-bar-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--text-muted);
}

.search-bar-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  padding: 8px 10px;
  font-size: 14px;
}

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

.search-bar-clear {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  color: var(--text-muted);
  transition: background var(--transition-fast);
}

.search-bar-clear:hover {
  background: var(--bg-elevated);
}

.search-bar-clear svg {
  width: 16px;
  height: 16px;
}

.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-top: 4px;
  max-height: 320px;
  overflow-y: auto;
  z-index: 100;
  box-shadow: var(--shadow-lg);
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--divider);
  transition: background var(--transition-fast);
}

.search-result-item:last-child {
  border-bottom: none;
}

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

.search-result-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.search-result-icon.diary { background: rgba(245, 166, 35, 0.15); }
.search-result-icon.task { background: rgba(76, 175, 80, 0.15); }
.search-result-icon.note { background: rgba(33, 150, 243, 0.15); }

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

.search-result-title {
  font-size: 13px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-result-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.search-no-results {
  padding: 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* Coach Card */
.coach-card {
  background: var(--bg-card);
  border: 1px solid var(--accent);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 16px;
}

.coach-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.coach-card-icon {
  font-size: 18px;
}

.coach-card-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.5px;
}

.coach-card-messages {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.coach-msg {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

.coach-msg::before {
  content: "\2022";
  color: var(--accent);
  font-weight: bold;
  flex-shrink: 0;
}

.coach-msg.high { color: var(--danger); }
.coach-msg.high::before { color: var(--danger); }
.coach-msg.low { color: var(--success); }
.coach-msg.low::before { color: var(--success); }

.coach-loading {
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
}

/* Active Projects List */
.active-projects-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.project-card-home {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.project-card-home:hover {
  border-color: var(--accent);
  background: var(--bg-card-hover);
}

.project-card-home-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.project-card-home-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.project-card-home-name .emoji {
  font-size: 16px;
}

.project-card-home-client {
  font-size: 12px;
  color: var(--text-muted);
}

.project-card-home-stats {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 8px;
}

.project-card-home-stat {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

.project-card-home-stat .val {
  color: var(--text-primary);
  font-weight: 600;
}

/* Diary progress bar */
.diary-progress-bar {
  flex: 1;
  height: 6px;
  background: var(--bg-elevated);
  border-radius: 3px;
  overflow: hidden;
  max-width: 100px;
}

.diary-progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease;
}

.diary-progress-fill.complete { background: var(--success); }
.diary-progress-fill.partial { background: var(--warning); }
.diary-progress-fill.empty { background: var(--danger); }

.project-card-home-last {
  font-size: 11px;
  color: var(--text-disabled);
  margin-top: 6px;
}

/* ── Project list items (modals) ── */
.project-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.project-item:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-light);
}

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

.project-item-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.project-item-address,
.project-item-client {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Voice Button (floating) */
.voice-fab {
  position: fixed;
  bottom: calc(var(--nav-height) + 80px + var(--safe-bottom));
  right: 16px;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background: var(--accent);
  color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  z-index: 90;
  transition: transform var(--transition-fast), background var(--transition-fast);
}

.voice-fab:hover {
  transform: scale(1.05);
}

.voice-fab:active {
  transform: scale(0.95);
}

.voice-fab svg {
  width: 24px;
  height: 24px;
}

.voice-fab.recording {
  background: var(--danger);
  animation: voicePulse 1.5s ease-in-out infinite;
}

.voice-fab.processing {
  background: var(--info);
}

@keyframes voicePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(244, 67, 54, 0.4); }
  50% { box-shadow: 0 0 0 12px rgba(244, 67, 54, 0); }
}

/* ── Budget / Document / API Key items ── */
.budget-item, .document-item, .apikey-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.budget-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 4px;
  flex-wrap: wrap;
}
.budget-value {
  color: var(--accent);
  font-weight: 600;
  font-size: 14px;
}
.budget-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 12px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
}
.budget-status-draft { background: rgba(158,158,158,0.2); color: #9e9e9e; }
.budget-status-sent { background: rgba(33,150,243,0.2); color: #42a5f5; }
.budget-status-negotiating { background: rgba(255,152,0,0.2); color: #ffa726; }
.budget-status-won { background: rgba(76,175,80,0.2); color: #66bb6a; }
.budget-status-lost { background: rgba(244,67,54,0.2); color: #ef5350; }
.budget-status-expired { background: rgba(158,158,158,0.15); color: #757575; }
.btn-icon {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  transition: background 0.2s, color 0.2s;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-icon:hover { background: var(--bg-secondary); color: var(--text-primary); }
.btn-icon svg { width: 16px; height: 16px; }
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }
.mb-16 { margin-bottom: 16px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.btn-block { width: 100%; }
