:root {
  --bg: #eef1f8;
  --panel: #ffffff;
  --border: #e5e9f2;
  --text: #1c2333;
  --muted: #707b91;
  --primary: #4f46e5;
  --primary-2: #2563eb;
  --primary-dark: #4338ca;
  --danger: #dc2626;
  --radius: 12px;

  /* Layered shadows for real elevation/3D feel — each combines a tight
     "contact" shadow with a soft ambient one, the way real light behaves. */
  --shadow-sm: 0 1px 2px rgba(30, 41, 59, .06), 0 1px 1px rgba(30, 41, 59, .04);
  --shadow-md: 0 4px 10px rgba(30, 41, 59, .08), 0 2px 4px rgba(30, 41, 59, .06);
  --shadow-lg: 0 12px 28px rgba(30, 41, 59, .14), 0 4px 10px rgba(30, 41, 59, .08);
  --shadow-glow: 0 8px 20px rgba(79, 70, 229, .25);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background:
    radial-gradient(circle at 8% 0%, rgba(129, 140, 248, .10) 0, transparent 45%),
    radial-gradient(circle at 96% 12%, rgba(56, 189, 248, .10) 0, transparent 40%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-size: 14px;
}

.container { max-width: 1320px; margin: 0 auto; padding: 24px 20px 60px; }

.topbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  background: rgba(255, 255, 255, .85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 12px rgba(30, 41, 59, .05);
  padding: 12px 20px;
  position: sticky; top: 0; z-index: 20;
}
.topbar > * { margin-bottom: 6px; }
.topbar .brand {
  font-weight: 800; font-size: 19px; text-decoration: none;
  background: linear-gradient(120deg, var(--primary) 0%, #ec4899 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  letter-spacing: -.02em;
  margin-right: 24px;
}
.topbar nav { display: flex; flex: 1; align-items: center; justify-content: center; flex-wrap: wrap; }
.nav-link {
  display: inline-flex; align-items: center;
  color: var(--muted); text-decoration: none; font-weight: 600; font-size: 13px;
  margin: 0 5px 6px; padding: 7px 14px; border-radius: 999px;
  background: #fff; border: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(30, 41, 59, .05), 0 1px 1px rgba(30, 41, 59, .04);
  transition: transform .12s ease, box-shadow .12s ease, color .12s ease, background .12s ease, border-color .12s ease;
}
.nav-link:hover {
  color: var(--primary); border-color: #c7d2fe; transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.nav-link:active { transform: translateY(0); }
.nav-link.active {
  color: #fff; border-color: transparent;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-2) 100%);
  box-shadow: 0 4px 10px rgba(79, 70, 229, .32), 0 1px 2px rgba(79, 70, 229, .2);
}
.nav-link.active:hover { color: #fff; transform: translateY(-1px); box-shadow: 0 6px 14px rgba(79, 70, 229, .38); }
.user-menu { display: flex; align-items: center; color: var(--muted); font-size: 13px; margin-left: 24px; }
.user-menu > * + * { margin-left: 10px; }

.page-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; gap: 16px; }
.page-header h1 { margin: 4px 0 0; font-size: 22px; letter-spacing: -.01em; }
.header-actions { display: flex; flex-wrap: wrap; }
.header-actions > * { margin-left: 8px; margin-bottom: 4px; }
.header-actions > *:first-child { margin-left: 0; }

.back-link { color: var(--muted); text-decoration: none; font-size: 13px; font-weight: 600; }
.back-link:hover { color: var(--primary); }
.muted { color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--panel);
  color: var(--text); font-size: 13px; font-weight: 600; cursor: pointer;
  text-decoration: none; box-shadow: var(--shadow-sm);
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.btn:hover { background: #f7f8fc; transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(0); box-shadow: var(--shadow-sm); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-2) 100%);
  border-color: transparent; color: #fff; box-shadow: var(--shadow-glow);
}
.btn-primary:hover { background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%); box-shadow: 0 10px 24px rgba(79, 70, 229, .32); }
.btn-danger { color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: #fef2f2; }
.file-upload-btn { position: relative; }

.grid { display: flex; flex-wrap: wrap; gap: 18px; }
.grid > .project-card { flex: 1 1 260px; min-width: 260px; }

.project-card {
  position: relative;
  background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
  padding: 20px 20px 16px; box-shadow: var(--shadow-sm); overflow: hidden;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.project-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: linear-gradient(90deg, var(--primary) 0%, #06b6d4 50%, #ec4899 100%);
  opacity: 0; transition: opacity .18s ease;
}
.project-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: transparent; }
.project-card:hover::before { opacity: 1; }
.project-card.is-featured { border-color: #fde68a; background: linear-gradient(180deg, #fffbeb 0%, var(--panel) 70px); }
.project-card.is-featured::before { opacity: 1; background: linear-gradient(90deg, #f59e0b 0%, #fbbf24 100%); }

.project-card-link { text-decoration: none; color: var(--text); display: block; }
.project-card h3 {
  margin: 0 0 4px; padding-right: 30px; font-size: 17px; font-weight: 800;
  line-height: 1.3; letter-spacing: -.01em;
}
.project-card p { margin: 10px 0; font-size: 12.5px; color: var(--muted); line-height: 1.5; min-height: 19px; }
.project-card .meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); font-weight: 600; }
.project-card-dates { margin: 8px 0 0; font-size: 11px; color: var(--muted); }

/* Domain + last-activity get their own row, full card width — no more
   truncating a domain name down to a few illegible characters just to
   squeeze past a star button. */
.project-card-badges { display: flex; flex-wrap: wrap; align-items: center; margin: 2px 0 4px; }
.project-card-badges > * { margin: 0 6px 6px 0; }

.domain-badge {
  display: inline-flex; align-items: center; font-size: 11px; font-weight: 700;
  color: #075985; background: linear-gradient(135deg, #e0f2fe, #bae6fd); padding: 4px 10px; border-radius: 999px;
  text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
  box-shadow: var(--shadow-sm); transition: transform .12s ease;
}
.domain-badge:hover { transform: translateY(-1px); }

.activity-badge {
  display: inline-block; font-size: 10.5px; font-weight: 700; padding: 3px 9px; border-radius: 999px;
}
.activity-badge.activity-green { background: #dcfce7; color: #166534; }
.activity-badge.activity-yellow { background: #fef9c3; color: #854d0e; }
.activity-badge.activity-orange { background: #ffedd5; color: #9a3412; }

.project-card > .note-indicator { margin-top: 10px; }

.file-table-scroll { overflow-x: auto; border-radius: 14px; }
.file-table { width: 100%; min-width: 800px; table-layout: fixed; border-collapse: separate; border-spacing: 0; background: var(--panel); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow-sm); }
.file-table th, .file-table td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: top; }
.file-table td { padding-top: 14px; }
.file-table th {
  background: linear-gradient(180deg, #f8f9ff 0%, #f1f3fb 100%);
  color: var(--muted); font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
}
.file-table tr:last-child td { border-bottom: none; }
.file-table tbody tr.file-row-main { transition: background .12s ease; }
.file-table tbody tr.file-row-main td { border-bottom: none; padding-bottom: 6px; }
.file-table tbody tr.file-row-main:hover,
.file-table tbody tr.file-row-main:hover + tr.file-row-actions { filter: brightness(0.97); }
.file-table tbody tr.file-row-actions { background: #fbfcfe; }
.file-table tbody tr.file-row-actions:hover { filter: brightness(0.97); }
.file-table tbody tr.file-row-actions td { padding-top: 2px; padding-bottom: 12px; }
.file-table tbody tr:last-child td { border-bottom: none; }
.file-name-link { color: var(--primary); text-decoration: none; font-weight: 700; overflow-wrap: anywhere; }
.file-name-link:hover { text-decoration: underline; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }

.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .55); backdrop-filter: blur(2px); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal-backdrop.hidden { display: none; }
.modal { background: var(--panel); border-radius: 16px; padding: 24px; width: 380px; max-width: 92vw; box-shadow: var(--shadow-lg); }
.modal h2 { margin: 0 0 14px; font-size: 17px; font-weight: 800; }
.modal label { display: block; margin-bottom: 12px; font-size: 13px; font-weight: 600; color: var(--text); }
.modal input, .modal textarea, .modal select {
  display: block; width: 100%; margin-top: 5px; padding: 9px 11px;
  border: 1px solid var(--border); border-radius: 8px; font-size: 13px; font-family: inherit;
  transition: border-color .12s, box-shadow .12s;
}
.modal input:focus, .modal textarea:focus, .modal select:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, .12);
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

.data-tools-modal { width: 440px; max-height: 85vh; overflow-y: auto; }
.data-tools-section { border-top: 1px solid var(--border); padding-top: 16px; margin-top: 16px; }
.data-tools-section:first-of-type { border-top: none; padding-top: 0; margin-top: 0; }
.data-tools-section h3 { margin: 0 0 6px; font-size: 14px; font-weight: 800; }
.data-tools-section .small-note { font-size: 12px; line-height: 1.5; margin: 0 0 12px; font-weight: 400; }
.data-tools-section label.hidden { display: none; }
.checkbox-label { display: flex; align-items: center; font-weight: 500; }
.checkbox-label input { display: inline-block; width: auto; margin: 0 8px 0 0; }

.goto-row-group { display: inline-flex; align-items: center; }
.goto-row-group input {
  width: 72px; padding: 7px 9px; border: 1px solid var(--border); border-radius: 8px 0 0 8px;
  border-right: none; font-size: 13px; font-family: inherit; height: 34px; box-sizing: border-box;
}
.goto-row-group input:focus { outline: none; border-color: var(--primary); z-index: 1; position: relative; }
.goto-row-group .btn { border-radius: 0 8px 8px 0; }

.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.auth-box { background: var(--panel); border: 1px solid var(--border); border-radius: 16px; padding: 32px; width: 340px; box-shadow: var(--shadow-lg); }
.auth-box h1 {
  font-size: 19px; margin: 0 0 18px; font-weight: 800;
  background: linear-gradient(120deg, var(--primary) 0%, #ec4899 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent; display: inline-block;
}
.auth-box label { display: block; margin-bottom: 12px; font-size: 13px; font-weight: 600; }
.auth-box input { display: block; width: 100%; margin-top: 5px; padding: 10px 11px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; }
.auth-box input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, .12); }
.auth-box button { width: 100%; margin-top: 6px; padding: 11px; }
.error { color: var(--danger); font-size: 13px; }

.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 380px; max-width: 90vw; background: var(--panel); border-left: 1px solid var(--border); box-shadow: -8px 0 28px rgba(15, 23, 42, .12); z-index: 40; display: flex; flex-direction: column; }
.drawer.hidden { display: none; }
.drawer-header { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.drawer-header h2 { font-size: 15px; margin: 0; font-weight: 800; }
.log-list { overflow-y: auto; padding: 10px 18px; flex: 1; }
.log-item { padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 12.5px; }
.log-item .action { font-weight: 700; text-transform: capitalize; }
.log-item .meta { color: var(--muted); margin-top: 2px; }

.folder-bar { display: flex; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.folder-pill-list { display: flex; flex-wrap: wrap; align-items: center; }
.folder-pill-list > * { margin: 0 8px 6px 0; }

.folder-pill {
  display: inline-flex; align-items: center; background: var(--panel); border: 1px solid var(--border);
  border-radius: 999px; padding: 6px 12px; font-size: 12.5px; font-weight: 600; color: var(--text);
  cursor: pointer; margin: 0 8px 6px 0; box-shadow: var(--shadow-sm); transition: all .12s ease;
}
.folder-pill:hover { border-color: var(--primary); color: var(--primary); transform: translateY(-1px); }
.folder-pill.active {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-2) 100%); color: #fff; border-color: transparent;
  box-shadow: 0 4px 10px rgba(79, 70, 229, .32);
}
.folder-pill-count {
  display: inline-block; margin-left: 6px; font-size: 10.5px; font-weight: 700; opacity: .75;
}
.folder-pill-delete {
  display: inline-block; margin-left: 8px; font-size: 13px; line-height: 1; opacity: .5;
  border-radius: 50%; width: 16px; height: 16px; text-align: center;
}
.folder-pill-delete:hover { opacity: 1; background: rgba(220, 38, 38, .15); color: var(--danger); }
.folder-pill-new { background: transparent; border: 1.5px dashed var(--border); color: var(--muted); }
.folder-pill-new:hover { border-color: var(--primary); color: var(--primary); background: #f5f6ff; }

.file-folder-badge {
  display: inline-flex; align-items: center; font-size: 10.5px; font-weight: 700; color: #6d28d9;
  background: #f3e8ff; padding: 2px 8px; border-radius: 999px; margin-left: 6px; white-space: nowrap;
}

.file-drop-zone { position: relative; border-radius: 14px; transition: background .15s, box-shadow .15s; }
.file-drop-zone.drag-over {
  background: #eef2ff; box-shadow: inset 0 0 0 2px var(--primary), var(--shadow-md);
}
.file-drop-zone .drop-hint {
  font-size: 12px; color: var(--muted); padding: 8px 2px 12px; text-align: center;
  border: 1.5px dashed #c7d2fe; border-radius: 10px; margin-bottom: 10px; font-weight: 600;
}
.file-drop-zone.drag-over .drop-hint { color: var(--primary); border-color: var(--primary); }
.upload-progress { background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; margin-bottom: 14px; font-size: 13px; box-shadow: var(--shadow-sm); }
.upload-progress.hidden { display: none; }
.upload-progress-label { margin-bottom: 8px; color: var(--text); font-weight: 600; }
.upload-progress-track { background: #eef1f5; border-radius: 999px; height: 8px; overflow: hidden; }
.upload-progress-fill { background: linear-gradient(90deg, var(--primary) 0%, #06b6d4 100%); height: 100%; width: 0%; transition: width .15s ease; border-radius: 999px; }

.editor-page {
  margin: 0; display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden;
}
.editor-topbar {
  box-shadow: 0 2px 12px rgba(15, 23, 42, .08);
  position: static; z-index: 10; flex-shrink: 0;
  padding: 10px 20px;
}
.editor-title { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.editor-title > * + * { margin-top: 2px; }
.editor-title strong { font-size: 14px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.editor-status-line { display: flex; align-items: center; }
.editor-status-line > * + * { margin-left: 6px; }
.editor-status-line .muted { font-size: 12px; }

.status-dot {
  width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
  background: #94a3b8; transition: background .2s; box-shadow: 0 0 0 3px rgba(0,0,0,.04);
}
.status-dot-saved { background: #22c55e; box-shadow: 0 0 0 3px rgba(34, 197, 94, .18); }
.status-dot-dirty { background: #f59e0b; box-shadow: 0 0 0 3px rgba(245, 158, 11, .18); }
.status-dot-saving { background: #f59e0b; box-shadow: 0 0 0 3px rgba(245, 158, 11, .18); animation: pulse-dot 1s ease-in-out infinite; }
.status-dot-error { background: var(--danger); box-shadow: 0 0 0 3px rgba(220, 38, 38, .18); }
@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

.btn-close {
  color: var(--muted); border-color: var(--border);
}
.btn-close:hover { background: #fee2e2; color: var(--danger); border-color: #fecaca; }

a.disabled-link { pointer-events: none; opacity: .6; }

/* flex:1 fills whatever vertical space is left below the topbar — this
   works correctly no matter how tall the topbar actually renders (one
   line on desktop, several wrapped lines on a narrow phone), unlike a
   fixed pixel offset which would either leave a gap or overlap the
   topbar the moment its real height differs from the assumed value. */
.sheet-container { position: relative; flex: 1; min-height: 0; overflow: auto; background: #eef1f8; }
.sheet-container.read-only::before {
  content: 'View only — you do not have edit access to this project';
  display: block; background: #fef3c7; color: #92400e; font-size: 12.5px;
  padding: 6px 14px; text-align: center;
}

.text-editor-area {
  position: relative; flex: 1; min-height: 0;
  width: 100%; border: none; outline: none; resize: none;
  padding: 20px 24px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px; line-height: 1.6; color: var(--text); background: #fff;
  box-sizing: border-box;
}
.text-editor-area[readonly] { background: #f8f9fb; color: var(--muted); }

/* ---------------- Dashboard ---------------- */

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

.hero {
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 45%, #db2777 100%);
  border-radius: 20px;
  padding: 30px 32px;
  color: #fff;
  margin-bottom: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  box-shadow: 0 16px 36px rgba(79, 70, 229, .28);
  animation: fadeInUp .4s ease both;
}
.hero::before {
  content: ''; position: absolute; top: -60px; right: -40px; width: 220px; height: 220px;
  background: radial-gradient(circle, rgba(255,255,255,.18) 0%, transparent 70%);
  border-radius: 50%;
}
.hero::after {
  content: ''; position: absolute; bottom: -80px; left: 15%; width: 180px; height: 180px;
  background: radial-gradient(circle, rgba(255,255,255,.10) 0%, transparent 70%);
  border-radius: 50%;
}
.hero > * { position: relative; z-index: 1; }
.hero h1 { margin: 0 0 4px; font-size: 23px; font-weight: 800; letter-spacing: -.01em; }
.hero p { margin: 0; opacity: .9; font-size: 13px; }
.hero .hero-actions { display: flex; flex-wrap: wrap; }
.hero .hero-actions > * { margin-left: 8px; }
.hero .hero-actions > *:first-child { margin-left: 0; }
.hero .btn-primary { background: #fff; color: var(--primary); border-color: #fff; box-shadow: 0 6px 16px rgba(0,0,0,.18); }
.hero .btn-primary:hover { background: #f8f8ff; box-shadow: 0 8px 20px rgba(0,0,0,.22); }
.hero .btn-ghost { background: rgba(255,255,255,.14); color: #fff; border-color: rgba(255,255,255,.4); backdrop-filter: blur(4px); box-shadow: none; }
.hero .btn-ghost:hover { background: rgba(255,255,255,.24); }

.stats-row { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 26px; }
.stats-row > .stat-card { flex: 1 1 170px; min-width: 170px; }
.stat-card {
  position: relative; overflow: hidden;
  background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
  padding: 18px 20px; display: flex; align-items: center;
  animation: fadeInUp .4s ease both;
  box-shadow: var(--shadow-sm);
  transition: transform .18s ease, box-shadow .18s ease;
}
.stat-card > * + * { margin-left: 14px; }
.stat-card:hover { transform: translateY(-4px) scale(1.01); box-shadow: var(--shadow-lg); }
.stat-icon {
  width: 44px; height: 44px; border-radius: 13px; display: flex; align-items: center; justify-content: center;
  font-size: 19px; flex-shrink: 0; box-shadow: var(--shadow-sm);
}
.stat-icon.blue { background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%); box-shadow: 0 6px 14px rgba(59, 130, 246, .35); }
.stat-icon.violet { background: linear-gradient(135deg, #a78bfa 0%, #7c3aed 100%); box-shadow: 0 6px 14px rgba(124, 58, 237, .35); }
.stat-icon.green { background: linear-gradient(135deg, #4ade80 0%, #16a34a 100%); box-shadow: 0 6px 14px rgba(22, 163, 74, .35); }
.stat-icon.amber { background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%); box-shadow: 0 6px 14px rgba(245, 158, 11, .35); }
.stat-value { font-size: 21px; font-weight: 800; line-height: 1.1; letter-spacing: -.01em; }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 2px; font-weight: 600; }

.dashboard-layout { display: flex; gap: 22px; align-items: flex-start; }
.dashboard-layout > div:first-child, .dashboard-layout > .file-drop-zone { flex: 1 1 0; min-width: 0; }
.dashboard-layout > aside { flex: 0 0 260px; width: 260px; }
@media (max-width: 880px) {
  .dashboard-layout { flex-direction: column; }
  .dashboard-layout > aside { width: 100%; flex-basis: auto; }
}

.side-panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
  padding: 18px; animation: fadeInUp .45s ease both; box-shadow: var(--shadow-sm);
}
.side-panel + .side-panel { margin-top: 18px; }
.side-panel h2 { font-size: 14px; margin: 0 0 14px; display: flex; align-items: center; justify-content: space-between; font-weight: 800; }
.side-panel h2 .btn-sm { font-weight: 600; }

.activity-feed { display: flex; flex-direction: column; gap: 0; max-height: 360px; overflow-y: auto; }
.activity-item { position: relative; padding: 0 0 14px 20px; border-left: 2px solid var(--border); }
.activity-item:last-child { border-color: transparent; padding-bottom: 0; }
.activity-item::before {
  content: ''; position: absolute; left: -5px; top: 2px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--primary); box-shadow: 0 0 0 3px rgba(79, 70, 229, .15);
}
.activity-item.action-delete::before { background: var(--danger); box-shadow: 0 0 0 3px rgba(220, 38, 38, .15); }
.activity-item.action-upload::before, .activity-item.action-create::before { background: #16a34a; box-shadow: 0 0 0 3px rgba(22, 163, 74, .15); }
.activity-item.action-edit_save::before { background: #d97706; box-shadow: 0 0 0 3px rgba(217, 119, 6, .15); }
.activity-item.action-rename::before { background: #64748b; box-shadow: 0 0 0 3px rgba(100, 116, 139, .15); }
.activity-item.action-download::before { background: #94a3b8; box-shadow: 0 0 0 3px rgba(148, 163, 184, .15); }
.activity-text { font-size: 12.5px; }
.activity-text b { font-weight: 700; }
.activity-time { font-size: 11px; color: var(--muted); margin-top: 2px; }

.reminder-item { padding: 10px 0; border-bottom: 1px solid var(--border); }
.reminder-item:last-child { border-bottom: none; }
.reminder-title { font-size: 13px; font-weight: 700; display: flex; justify-content: space-between; gap: 8px; }
.reminder-meta { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.reminder-error { font-size: 11px; color: var(--danger); margin-top: 3px; background: #fef2f2; padding: 4px 7px; border-radius: 6px; }
.reminder-due { font-size: 11px; padding: 3px 8px; border-radius: 999px; background: linear-gradient(135deg, #fde68a, #fbbf24); color: #78350f; white-space: nowrap; font-weight: 700; box-shadow: var(--shadow-sm); }
.reminder-due.overdue { background: linear-gradient(135deg, #fecaca, #f87171); color: #7f1d1d; }
.reminder-cancel { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 11px; padding: 0; font-weight: 600; }
.reminder-cancel:hover { color: var(--danger); }

.empty-hint { font-size: 12.5px; color: var(--muted); padding: 8px 0; }

/* ---------------- Featured, notes, stars ---------------- */

.star-btn {
  background: none; border: none; cursor: pointer; font-size: 16px; line-height: 1;
  color: #d1d5db; padding: 2px; vertical-align: middle; transition: color .15s, transform .15s;
}
.star-btn:hover { color: #fbbf24; transform: scale(1.25) rotate(-8deg); }
.star-btn.featured { color: #f59e0b; filter: drop-shadow(0 1px 3px rgba(245, 158, 11, .5)); }

/* Star lives in its own corner, out of the title's way entirely — no
   more squeezing the title against badges on the same line. Subtle
   until hovered or already featured, so it doesn't compete for
   attention with the title itself. */
.corner-star {
  position: absolute; top: 14px; right: 14px; z-index: 1;
  font-size: 18px; color: #e2e5eb; padding: 4px;
}
.corner-star:hover { color: #fbbf24; transform: scale(1.2) rotate(-8deg); }
.corner-star.featured { color: #f59e0b; filter: drop-shadow(0 1px 3px rgba(245, 158, 11, .5)); }

.note-indicator {
  background: none; border: none; cursor: pointer; font-size: 13px; line-height: 1;
  padding: 2px 4px; vertical-align: middle; opacity: .85; border-radius: 6px;
  transition: background .12s;
}
.note-indicator:hover { background: #eef1ff; }
.note-indicator.empty { opacity: .3; }

.page-header h1 .star-btn, .page-header h1 .note-indicator { font-size: 15px; }

.featured-list { display: flex; flex-direction: column; gap: 2px; max-height: 260px; overflow-y: auto; }
.featured-item {
  display: flex; align-items: center; padding: 8px 8px; border-radius: 8px;
  text-decoration: none; color: var(--text); font-size: 12.5px; font-weight: 600;
  transition: background .12s, transform .12s;
}
.featured-item > * + * { margin-left: 8px; }
.featured-item:hover { background: linear-gradient(90deg, #fef9e7, transparent); transform: translateX(2px); }
.featured-icon { font-size: 13px; flex-shrink: 0; }

.file-name-cell { display: flex; flex-direction: column; gap: 4px; min-width: 280px; }
.file-name-row { display: flex; align-items: center; }
.file-name-row > * + * { margin-left: 6px; }
.file-name-row .file-name-link { flex: 1; }

/* File color tags — a light/pastel palette so text stays readable
   regardless of which one is picked, applied to both rows of a file
   (main + actions) so the whole block is tinted, not just one line. */
.file-row-main.file-color-red, .file-row-actions.file-color-red { background: #fef2f2; }
.file-row-main.file-color-orange, .file-row-actions.file-color-orange { background: #fff7ed; }
.file-row-main.file-color-yellow, .file-row-actions.file-color-yellow { background: #fefce8; }
.file-row-main.file-color-green, .file-row-actions.file-color-green { background: #f0fdf4; }
.file-row-main.file-color-blue, .file-row-actions.file-color-blue { background: #eff6ff; }
.file-row-main.file-color-purple, .file-row-actions.file-color-purple { background: #faf5ff; }
.file-row-main.file-color-gray, .file-row-actions.file-color-gray { background: #f8fafc; }

/* Shared by both the small trigger button (in the file row) and each
   option inside the popover — same color-<name> modifier classes. */
.color-swatch-btn, .color-picker-popover .color-option {
  width: 16px; height: 16px; border-radius: 50%; border: 1.5px solid #d8dce3;
  background: #fff; cursor: pointer; padding: 0; flex-shrink: 0;
}
.color-swatch-btn:hover, .color-picker-popover .color-option:hover { border-color: #94a3b8; transform: scale(1.1); }
.color-swatch-btn.has-color { border-color: transparent; }
.color-swatch-btn.color-red, .color-option.color-red { background: #ef4444; border-color: transparent; }
.color-swatch-btn.color-orange, .color-option.color-orange { background: #f97316; border-color: transparent; }
.color-swatch-btn.color-yellow, .color-option.color-yellow { background: #eab308; border-color: transparent; }
.color-swatch-btn.color-green, .color-option.color-green { background: #22c55e; border-color: transparent; }
.color-swatch-btn.color-blue, .color-option.color-blue { background: #3b82f6; border-color: transparent; }
.color-swatch-btn.color-purple, .color-option.color-purple { background: #a855f7; border-color: transparent; }
.color-swatch-btn.color-gray, .color-option.color-gray { background: #64748b; border-color: transparent; }
.color-option.color-clear { position: relative; }
.color-option.color-clear::before, .color-option.color-clear::after {
  content: ''; position: absolute; top: 50%; left: 10%; width: 80%; height: 1.5px; background: #cbd5e1;
}
.color-option.color-clear::before { transform: translateY(-50%) rotate(45deg); }
.color-option.color-clear::after { transform: translateY(-50%) rotate(-45deg); }

.color-picker-popover {
  position: absolute; z-index: 30; background: #fff; border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow-lg); padding: 8px; display: flex; gap: 6px;
}
.color-picker-popover.hidden { display: none; }

.note-inline-input {
  border: 1px solid transparent; background: transparent; font-size: 12px;
  color: var(--muted); padding: 3px 6px; border-radius: 6px; width: 100%;
  font-style: italic; transition: background .15s, border-color .15s;
}
.note-inline-input::placeholder { color: #c7ccd3; }
.note-inline-input:hover { background: #f8f9fb; }
.note-inline-input:focus {
  outline: none; background: #fff; border-color: var(--border); color: var(--text);
  font-style: normal; box-shadow: 0 0 0 3px rgba(79, 70, 229, .08);
}
.note-inline-input.saving { background: #fef9c3; }
.note-inline-input.saved { background: #dcfce7; }
.file-location { cursor: help; }
.location-badge {
  display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 700;
  color: #075985; background: linear-gradient(135deg, #e0f2fe, #bae6fd); padding: 4px 10px; border-radius: 999px;
  box-shadow: var(--shadow-sm);
}

.project-header-dates { font-size: 12px; color: var(--muted); margin: 4px 0 0; }


.modal textarea#reminderMessage { resize: vertical; }

/* ==================================================================
   Responsive / mobile — phones and small tablets. Desktop layout is
   untouched above this point; everything below only takes effect at
   or under these widths.
   ================================================================== */

@media (max-width: 640px) {
  .container { padding: 16px 12px 40px; }

  /* Buttons and nav pills need real touch targets on a phone — the
     desktop sizing (~34px tall) is too small to reliably tap. */
  .btn { padding: 10px 14px; min-height: 40px; }
  .btn-sm { padding: 8px 12px; min-height: 34px; }
  .nav-link { padding: 9px 14px; min-height: 38px; }
  .color-swatch-btn, .star-btn, .note-indicator { min-width: 28px; min-height: 28px; }

  .topbar { padding: 10px 14px; }
  .topbar .brand { font-size: 17px; order: 1; margin-right: auto; }
  .topbar nav { order: 3; flex-basis: 100%; justify-content: flex-start; margin-top: 4px; }
  .user-menu { order: 2; margin-left: 0; }
  .user-menu span { font-size: 12px; }

  .page-header { flex-direction: column; align-items: stretch; }
  .page-header h1 { font-size: 19px; }
  .header-actions { justify-content: flex-start; }
  .header-actions > * { flex: 1 1 auto; text-align: center; justify-content: center; }

  .hero { padding: 22px 18px; flex-direction: column; align-items: flex-start; }
  .hero h1 { font-size: 19px; }
  .hero .hero-actions { width: 100%; }
  .hero .hero-actions > * { flex: 1 1 auto; text-align: center; justify-content: center; }

  .stats-row > .stat-card { flex-basis: calc(50% - 8px); }
  .grid > .project-card { flex-basis: 100%; min-width: 0; }

  .modal { padding: 18px; width: 100%; max-width: 94vw; }
  .data-tools-modal { width: 100%; }

  /* File table reflows into a stack of cards instead of scrolling
     horizontally — each file's details become label:value rows using
     the data-label attributes on each <td> (added in app.js), with the
     file name staying prominent at the top the way it already is. */
  .file-table-scroll { overflow-x: visible; }
  .file-table { display: block; width: 100%; min-width: 0; }
  .file-table tbody { display: block; width: 100%; }
  .file-table thead { display: none; }
  .file-table tbody tr.file-row-main { display: block; padding: 14px 14px 4px; }
  .file-table tbody tr.file-row-actions { display: block; }
  .file-table tbody tr.file-row-actions td { display: block; padding: 0 14px 14px; }
  .file-table td { display: block; width: 100%; box-sizing: border-box; }
  .file-table td.file-name-cell { display: flex; padding: 0 0 6px; min-width: 0; }
  .file-table td[data-label] {
    display: flex; justify-content: space-between; align-items: baseline;
    padding: 7px 0; border-top: 1px dashed var(--border); font-size: 13px;
    white-space: nowrap;
  }
  .file-table td[data-label]::before {
    content: attr(data-label); font-weight: 700; color: var(--muted);
    font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em;
    margin-right: 10px;
  }

  .row-actions { display: flex; flex-wrap: wrap; }
  .row-actions > * { flex: 1 1 calc(50% - 3px); margin: 0 6px 6px 0; justify-content: center; }
  .row-actions > *:nth-child(2n) { margin-right: 0; }

  .drawer { width: 100%; max-width: 100%; }

  .editor-topbar { padding: 8px 12px; }
  .editor-title strong { font-size: 13px; }
  .goto-row-group input { width: 56px; }
}

@media (max-width: 420px) {
  .stats-row > .stat-card { flex-basis: 100%; }
  .folder-pill, .domain-badge { max-width: 100%; }
}
