:root {
  --bg: #e8edf5;
  --surface: rgba(255, 255, 255, 0.82);
  --surface-solid: #ffffff;
  --surface-2: #f4f7fb;
  --border: rgba(148, 163, 184, 0.35);
  --text: #0b1220;
  --muted: #5b6b82;
  --accent: #0f2d4a;
  --accent-2: #1d6ef0;
  --accent-3: #3b82f6;
  --accent-soft: rgba(29, 110, 240, 0.1);
  --success: #059669;
  --danger: #dc2626;
  --warn: #d97706;
  --radius: 18px;
  --radius-sm: 10px;
  --shadow: 0 16px 48px rgba(15, 23, 42, 0.1);
  --shadow-sm: 0 4px 20px rgba(15, 23, 42, 0.06);
  --sidebar-w: 272px;
  --dock-h: 54px;
  --glass: blur(18px) saturate(1.4);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Assistant', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
}

.bg-mesh {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 80% 60% at 10% 20%, rgba(29, 110, 240, 0.12), transparent),
    radial-gradient(ellipse 60% 50% at 90% 80%, rgba(15, 45, 74, 0.1), transparent),
    linear-gradient(160deg, #e8edf5 0%, #dce6f2 50%, #e4eaf3 100%);
  animation: meshShift 18s ease-in-out infinite alternate;
}
@keyframes meshShift {
  0% { filter: hue-rotate(0deg); }
  100% { filter: hue-rotate(8deg); }
}

#app {
  position: relative; z-index: 1;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: 1fr auto;
  height: 100vh;
}

/* Toast */
.toast-host {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  z-index: 9999; display: flex; flex-direction: column; gap: 10px; pointer-events: none;
}
.toast {
  background: var(--accent); color: #fff; padding: 12px 22px; border-radius: 12px;
  font-size: 14px; font-weight: 600; box-shadow: var(--shadow);
  animation: toastIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: auto; max-width: 420px; text-align: center;
}
.toast.success { background: linear-gradient(135deg, #047857, #059669); }
.toast.warn { background: linear-gradient(135deg, #b45309, #d97706); }
.toast.error { background: linear-gradient(135deg, #b91c1c, #dc2626); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(-16px) scale(0.92); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Sidebar */
.sidebar {
  grid-row: 1 / 3;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: var(--glass);
  border-left: 1px solid var(--border);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  box-shadow: var(--shadow-sm);
}

.brand { display: flex; align-items: center; gap: 14px; padding: 6px 8px; }
.brand-icon-wrap { position: relative; flex-shrink: 0; }
.brand-icon {
  width: 52px; height: 52px; border-radius: 14px;
  background: linear-gradient(145deg, #0f2d4a 0%, #1d6ef0 100%);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 16px;
  box-shadow: 0 8px 24px rgba(29, 110, 240, 0.4);
  position: relative; z-index: 1;
}
.brand-pulse {
  position: absolute; inset: -4px; border-radius: 18px;
  background: linear-gradient(145deg, rgba(29,110,240,0.4), transparent);
  animation: pulse 2.5s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.4; transform: scale(1); }
  50% { opacity: 0.8; transform: scale(1.06); }
}
.brand-sub { display: block; font-size: 11px; color: var(--muted); margin-top: 3px; }

.status-pills { display: flex; flex-direction: column; gap: 6px; }
.pill {
  font-size: 11px; font-weight: 600; padding: 6px 12px; border-radius: 20px;
  text-align: center; transition: all 0.3s;
}
.pill-mesh { background: #e0e7ff; color: #3730a3; }
.pill-mesh.on { background: #d1fae5; color: #065f46; }
.pill-engine { background: #dbeafe; color: #1e40af; }

.nav { display: flex; flex-direction: column; gap: 5px; flex: 1; min-height: 0; overflow-y: auto; }
.sidebar-footer { margin-top: auto; display: flex; flex-direction: column; gap: 8px; flex-shrink: 0; }
.nav-item {
  border: none; background: transparent; text-align: right; padding: 12px 14px;
  border-radius: var(--radius-sm); cursor: pointer; font-size: 14px; font-weight: 600;
  color: var(--text); transition: all 0.2s; display: flex; align-items: center; gap: 10px;
  font-family: inherit;
}
.nav-icon { font-size: 16px; opacity: 0.85; }
.nav-item:hover { background: var(--accent-soft); color: var(--accent-2); transform: translateX(-2px); }
.nav-item.active {
  background: linear-gradient(135deg, var(--accent), #1a4a7a);
  color: #fff; box-shadow: 0 6px 20px rgba(15, 45, 74, 0.3);
}

.sidebar-card {
  background: var(--surface-2); border-radius: var(--radius-sm);
  padding: 12px; border: 1px solid var(--border); font-size: 12px;
}
.sidebar-card-title { font-weight: 700; color: var(--muted); margin-bottom: 8px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }
.recent-item {
  padding: 6px 0; border-bottom: 1px solid var(--border); cursor: pointer;
  transition: color 0.15s;
}
.recent-item:last-child { border-bottom: none; }
.recent-item:hover { color: var(--accent-2); }

.emergency-wrap {
  display: flex; align-items: center; gap: 12px; padding: 14px;
  background: linear-gradient(135deg, rgba(255,251,235,0.9), rgba(254,243,199,0.9));
  border-radius: var(--radius); border: 1px solid #fcd34d;
}
.emergency-toggle { position: relative; width: 48px; height: 26px; flex-shrink: 0; }
.emergency-toggle input { opacity: 0; width: 0; height: 0; }
.emergency-slider {
  position: absolute; inset: 0; background: #cbd5e1; border-radius: 26px;
  cursor: pointer; transition: 0.25s;
}
.emergency-slider::before {
  content: ''; position: absolute; height: 20px; width: 20px; right: 3px; bottom: 3px;
  background: #fff; border-radius: 50%; transition: 0.25s; box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.emergency-toggle input:checked + .emergency-slider { background: var(--danger); }
.emergency-toggle input:checked + .emergency-slider::before { transform: translateX(-22px); }
.emergency-label small { display: block; color: var(--muted); font-size: 11px; margin-top: 2px; }

/* Main */
.main { display: flex; flex-direction: column; overflow: hidden; padding-bottom: var(--dock-h); }
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 28px;
  background: rgba(255,255,255,0.65);
  backdrop-filter: var(--glass);
  border-bottom: 1px solid var(--border);
}
.topbar-left { display: flex; flex-direction: column; gap: 2px; }
.topbar-title { font-size: 22px; font-weight: 800; letter-spacing: -0.03em; }
.topbar-sub { font-size: 12px; color: var(--muted); }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.live-badge {
  display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600;
  color: var(--success); background: rgba(5,150,105,0.1); padding: 5px 12px; border-radius: 20px;
}
.live-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--success);
  animation: blink 1.5s ease-in-out infinite;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
.clock { font-size: 13px; color: var(--muted); direction: ltr; font-variant-numeric: tabular-nums; font-weight: 500; }

.view { display: none; flex: 1; overflow: auto; padding: 24px 28px; }
.view.active { display: block; }

/* Stats */
.stats-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px; margin-bottom: 20px;
}
.stat-card {
  background: var(--surface); backdrop-filter: var(--glass);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 16px 18px; box-shadow: var(--shadow-sm);
  transition: transform 0.2s, box-shadow 0.2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-card .stat-val { font-size: 26px; font-weight: 800; color: var(--accent); letter-spacing: -0.03em; }
.stat-card .stat-label { font-size: 12px; color: var(--muted); margin-top: 4px; font-weight: 500; }
.stat-card.accent .stat-val { color: var(--accent-2); }

.section-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px;
}
.section-head h2 { font-size: 18px; font-weight: 700; }
.section-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Hero */
.home-hero {
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, #0a1f35 0%, #0f2d4a 40%, #1d6ef0 100%);
  border-radius: var(--radius); padding: 36px 40px; margin-bottom: 28px;
  color: #fff; box-shadow: var(--shadow);
  display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: center;
}
.home-hero.hidden { display: none; }
.hero-glow {
  position: absolute; width: 300px; height: 300px; border-radius: 50%;
  background: radial-gradient(circle, rgba(59,130,246,0.35), transparent 70%);
  top: -80px; left: -60px; pointer-events: none;
}
.hero-badge {
  display: inline-block; background: rgba(255,255,255,0.15);
  padding: 5px 14px; border-radius: 20px; font-size: 11px; font-weight: 600;
  margin-bottom: 12px; backdrop-filter: blur(4px);
}
.hero-content h1 { font-size: 30px; font-weight: 800; margin-bottom: 10px; letter-spacing: -0.03em; }
.hero-content p { font-size: 15px; opacity: 0.92; line-height: 1.65; max-width: 520px; }
.hero-actions { display: flex; gap: 12px; margin: 20px 0 16px; flex-wrap: wrap; }
.hero-features {
  list-style: none; display: flex; flex-wrap: wrap; gap: 8px;
}
.hero-features li {
  background: rgba(255,255,255,0.12); backdrop-filter: blur(6px);
  padding: 7px 14px; border-radius: 20px; font-size: 12px; font-weight: 500;
  border: 1px solid rgba(255,255,255,0.15);
}
.hero-visual { position: relative; width: 140px; height: 140px; }
.orbit-ring {
  position: absolute; inset: 0; border: 2px dashed rgba(255,255,255,0.25);
  border-radius: 50%; animation: spin 12s linear infinite;
}
.orbit-core {
  position: absolute; inset: 30px; border-radius: 50%;
  background: rgba(255,255,255,0.12); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 22px; border: 1px solid rgba(255,255,255,0.2);
}
@keyframes spin { to { transform: rotate(360deg); } }

.glass-card {
  background: var(--surface); backdrop-filter: var(--glass);
  border: 1px solid var(--border);
}

/* Drives */
.drive-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px;
}
.drive-card {
  background: var(--surface); backdrop-filter: var(--glass);
  border-radius: var(--radius); padding: 22px;
  border: 2px solid transparent; cursor: pointer;
  transition: all 0.25s cubic-bezier(0.34, 1.2, 0.64, 1); box-shadow: var(--shadow-sm);
  position: relative; overflow: hidden;
}
.drive-card::before {
  content: ''; position: absolute; top: 0; right: 0; width: 100%; height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  opacity: 0; transition: opacity 0.2s;
}
.drive-card:hover { box-shadow: var(--shadow); transform: translateY(-4px); border-color: var(--accent-soft); }
.drive-card:hover::before { opacity: 1; }
.drive-card.active {
  border-color: var(--accent-2); background: rgba(29,110,240,0.06);
  box-shadow: 0 0 0 4px rgba(29, 110, 240, 0.12);
}
.drive-card h3 { font-size: 17px; margin-bottom: 6px; font-weight: 700; }
.drive-card .letter { color: var(--accent-2); font-weight: 800; }
.drive-card-actions { display: flex; gap: 8px; margin-top: 14px; }
.drive-quick-btn {
  flex: 1; padding: 8px; border: 1px solid var(--border); background: var(--surface-solid);
  border-radius: var(--radius-sm); cursor: pointer; font-size: 12px; font-weight: 600;
  font-family: inherit; transition: all 0.15s;
}
.drive-quick-btn:hover { background: var(--accent-2); color: #fff; border-color: var(--accent-2); }
.bar-wrap { height: 8px; background: rgba(15,45,74,0.08); border-radius: 4px; margin: 14px 0; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 4px; transition: width 0.5s cubic-bezier(0.34, 1.2, 0.64, 1); }
.drive-stats { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); font-weight: 500; }

/* Browser */
.browser-panel {
  background: var(--surface); backdrop-filter: var(--glass);
  border-radius: var(--radius); border: 1px solid var(--border);
  padding: 20px; box-shadow: var(--shadow-sm); margin-top: 20px;
  animation: slideUp 0.35s ease;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.browser-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.breadcrumb { font-size: 13px; color: var(--muted); font-weight: 500; }
.breadcrumb button { background: none; border: none; color: var(--accent-2); cursor: pointer; font-weight: 700; font-family: inherit; }

.logout-btn { width: 100%; }

.restore-action-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 18px 22px; margin-bottom: 16px; border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(29,110,240,0.08), rgba(15,45,74,0.04));
  border: 1px solid rgba(29,110,240,0.2);
}
.restore-action-info strong { display: block; font-size: 16px; margin-bottom: 4px; }
.restore-action-btns { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.scan-complete-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  margin-top: 16px; padding: 16px 18px; border-radius: var(--radius-sm);
  background: linear-gradient(135deg, rgba(5,150,105,0.12), rgba(16,185,129,0.06));
  border: 1px solid rgba(5,150,105,0.25);
}
.scan-complete-text { display: flex; flex-direction: column; gap: 4px; }

.view-toolbar, .results-toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px;
  padding: 4px 0 12px; max-width: 100%;
}
.results-panel { max-width: 100%; overflow: hidden; }
.results-split.preview-large {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, 320px); gap: 16px;
}
.results-container { min-width: 0; overflow: hidden; }
.preview-panel { min-width: 0; }
.results-list { max-height: min(520px, 50vh); overflow: auto; }
.toolbar-label { color: var(--muted); font-weight: 600; }
.toolbar-spacer { flex: 1; min-width: 12px; }

.search-wrap { position: relative; }
.search-input {
  padding: 8px 14px 8px 32px; border: 1px solid var(--border); border-radius: 20px;
  font-size: 13px; font-family: inherit; background: var(--surface-solid);
  min-width: 180px; transition: all 0.2s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%235b6b82' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85zm-5.242 1.156a5 5 0 1 1 0-10 5 5 0 0 1 0 10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 10px center;
}
.search-input:focus { outline: none; border-color: var(--accent-2); box-shadow: 0 0 0 3px rgba(29,110,240,0.12); min-width: 220px; }

.filter-chips { display: flex; gap: 4px; }
.filter-chip {
  padding: 5px 12px; border: 1px solid var(--border); border-radius: 16px;
  background: var(--surface-solid); cursor: pointer; font-size: 11px; font-weight: 600;
  font-family: inherit; transition: all 0.15s;
}
.filter-chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.filter-chip:hover:not(.active) { border-color: var(--accent-2); color: var(--accent-2); }

.view-btn {
  border: 1px solid var(--border); background: var(--surface-solid); padding: 7px 14px;
  border-radius: var(--radius-sm); cursor: pointer; font-size: 12px; font-weight: 600;
  transition: all 0.15s; font-family: inherit;
}
.view-btn:hover { border-color: var(--accent-2); color: var(--accent-2); }
.view-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* File / result rows */
.file-list, .results-list { min-height: 200px; }

.view-list .file-row,
.view-list .result-row {
  display: flex; align-items: center; gap: 14px; padding: 11px 14px;
  border-radius: var(--radius-sm); cursor: pointer; transition: all 0.15s;
  border-bottom: 1px solid var(--border);
}
.view-list .file-row:last-child,
.view-list .result-row:last-child { border-bottom: none; }

.view-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(115px, 1fr));
  gap: 14px; padding: 12px;
}
.view-grid .file-row,
.view-grid .result-row {
  flex-direction: column; text-align: center; padding: 16px 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.view-grid .file-icon, .view-grid .file-icon-placeholder { width: 48px; height: 48px; font-size: 24px; }
.view-grid .file-info .name { font-size: 12px; white-space: normal; word-break: break-word; }

.file-row:hover, .result-row:hover { background: var(--accent-soft); }
.file-row.selected, .result-row.selected { background: #dbeafe; }
.result-row.preview-active { background: #eff6ff; outline: 2px solid var(--accent-2); outline-offset: -2px; }

.file-icon { width: 36px; height: 36px; object-fit: contain; flex-shrink: 0; }
.file-icon-placeholder {
  width: 36px; height: 36px; background: var(--surface-2); border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0;
}

.file-info { flex: 1; min-width: 0; text-align: right; }
.file-info .name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-info .meta { font-size: 11px; color: var(--muted); margin-top: 2px; }

.view-tree .tree-group { margin-bottom: 16px; }
.view-tree .tree-folder {
  font-weight: 700; font-size: 13px; color: var(--accent); padding: 8px 12px;
  background: var(--surface-2); border-radius: var(--radius-sm); margin-bottom: 6px;
  display: flex; align-items: center; gap: 8px;
}
.view-tree .tree-item { padding-right: 24px; }

.view-timeline .timeline-group { margin-bottom: 20px; }
.view-timeline .timeline-date {
  font-size: 12px; font-weight: 700; color: var(--muted);
  letter-spacing: 0.05em; padding: 6px 0; border-bottom: 2px solid var(--border); margin-bottom: 8px;
}

.view-integrity .result-row { align-items: stretch; }
.integrity-bar-wrap { width: 80px; height: 6px; background: var(--bg); border-radius: 3px; margin-top: 6px; overflow: hidden; }
.integrity-bar { height: 100%; border-radius: 3px; }
.integrity-bar.high { background: var(--success); }
.integrity-bar.mid { background: var(--warn); }
.integrity-bar.low { background: var(--danger); }

.results-meta {
  font-size: 12px; color: var(--muted); padding: 8px 4px 12px; font-weight: 500;
}

.results-split { display: grid; grid-template-columns: 1fr 360px; gap: 18px; min-height: 440px; }
.results-container {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; backdrop-filter: var(--glass);
}
.results-list { max-height: 520px; overflow: auto; }

.preview-panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--shadow-sm);
  backdrop-filter: var(--glass);
}
.preview-header {
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 10px;
}
.preview-icon { width: 24px; height: 24px; object-fit: contain; }
.preview-body { flex: 1; padding: 16px; overflow: auto; font-size: 13px; line-height: 1.6; }
.preview-body img, .preview-body iframe { max-width: 100%; border-radius: var(--radius-sm); margin-top: 12px; }
.preview-body pre {
  white-space: pre-wrap; word-break: break-word; font-size: 12px;
  background: var(--surface-2); padding: 12px; border-radius: var(--radius-sm); margin-top: 12px;
}
.preview-empty { color: var(--muted); text-align: center; padding: 40px 20px; }
.preview-meta { color: var(--muted); font-size: 12px; margin-top: 8px; }
.preview-meta strong { color: var(--text); }
.preview-actions { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; gap: 8px; }

/* Recover */
.recover-layout { max-width: 640px; }
.recover-card { border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow-sm); }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.recover-card h2 { font-size: 22px; font-weight: 800; }
.card-tag {
  font-size: 11px; font-weight: 700; padding: 4px 12px; border-radius: 12px;
  background: var(--accent-soft); color: var(--accent-2);
}
.field-label {
  display: block; font-size: 11px; font-weight: 700; color: var(--muted);
  margin: 18px 0 8px; text-transform: uppercase; letter-spacing: 0.05em;
}

.mode-row { display: flex; gap: 10px; margin: 16px 0; }
.mode-btn {
  flex: 1; padding: 14px; border: 2px solid var(--border); background: var(--surface-solid);
  border-radius: var(--radius-sm); cursor: pointer; font-size: 14px; transition: all 0.2s;
  font-family: inherit; text-align: right;
}
.mode-btn strong { display: block; font-weight: 700; margin-bottom: 4px; }
.mode-btn small { color: var(--muted); font-size: 11px; }
.mode-btn.active {
  border-color: var(--accent-2); background: var(--accent-soft);
  box-shadow: 0 0 0 3px rgba(29,110,240,0.1);
}
.mode-btn.active strong { color: var(--accent); }

.drive-select, .folder-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.drive-chip, .folder-chip {
  padding: 9px 16px; border: 1px solid var(--border); border-radius: 24px;
  cursor: pointer; font-size: 13px; background: var(--surface-solid);
  transition: all 0.15s; font-family: inherit; font-weight: 600;
}
.drive-chip.selected { background: var(--accent); color: #fff; border-color: var(--accent); }
.folder-chip { background: #f0fdf4; border-color: #86efac; color: #166534; padding-left: 12px; }
.folder-chip button { background: none; border: none; cursor: pointer; margin-right: 6px; color: #166534; font-weight: 700; }
.folder-pick-row { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }

.btn {
  border: none; padding: 11px 22px; border-radius: var(--radius-sm); cursor: pointer;
  font-size: 14px; font-weight: 700; transition: all 0.2s; font-family: inherit;
  position: relative; overflow: hidden;
}
.btn:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), #1a4a7a);
  color: #fff; box-shadow: 0 6px 20px rgba(15,45,74,0.3);
}
.btn.ghost { background: var(--surface-solid); color: var(--text); border: 1px solid var(--border); }
.btn.ghost.light { background: rgba(255,255,255,0.15); color: #fff; border-color: rgba(255,255,255,0.3); }
.btn.ghost.light:hover { background: rgba(255,255,255,0.25); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.sm { padding: 7px 14px; font-size: 12px; }
.btn.wide { width: 100%; margin-top: 20px; }
.btn-shine {
  position: absolute; inset: 0;
  background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,0.2) 50%, transparent 60%);
  animation: shine 3s ease-in-out infinite;
}
@keyframes shine {
  0%, 100% { transform: translateX(-100%); }
  50% { transform: translateX(100%); }
}

.muted { color: var(--muted); font-size: 13px; margin: 6px 0; line-height: 1.5; }
.muted.sm { font-size: 12px; }

.scan-progress { border-radius: var(--radius); padding: 24px; margin-top: 24px; box-shadow: var(--shadow-sm); }
.scan-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; font-size: 14px; font-weight: 600; }
.scan-step-counter { font-size: 12px; color: var(--accent); font-weight: 600; }
.scan-step-detail { font-size: 13px; color: var(--muted); margin: 0 0 10px; line-height: 1.5; min-height: 1.2em; }
.scan-steps-log {
  list-style: none; margin: 12px 0 0; padding: 0; max-height: 120px; overflow-y: auto;
  font-size: 12px; color: var(--muted);
}
.scan-steps-log li { padding: 4px 0; border-bottom: 1px solid var(--border); }
.mode-steps-preview {
  list-style: none; margin: 8px 0 16px; padding: 0;
  display: flex; flex-wrap: wrap; gap: 6px;
}
.mode-steps-preview li {
  background: var(--surface-2); padding: 4px 10px; border-radius: 12px; font-size: 11px;
}
[data-theme="dark"] .scan-step-detail { color: #c5d3e3; }
[data-theme="dark"] .scan-steps-log { color: #a8bdd4; }
[data-theme="dark"] .mode-steps-preview li { background: var(--surface-solid); color: #c5d3e3; }
.progress-bar { height: 10px; background: rgba(15,45,74,0.08); border-radius: 5px; overflow: hidden; }
.progress-fill {
  height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2), #60a5fa);
  width: 0%; transition: width 0.35s; border-radius: 5px;
  background-size: 200% 100%; animation: progressGlow 2s ease infinite;
}
@keyframes progressGlow {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}
.scan-stats { display: flex; justify-content: space-between; margin-top: 10px; font-size: 12px; color: var(--muted); font-weight: 500; }
.scan-actions { display: flex; gap: 10px; margin-top: 18px; }

.history-table {
  width: 100%; border-radius: var(--radius);
  border-collapse: collapse; overflow: hidden; box-shadow: var(--shadow-sm);
}
.history-table th, .history-table td { padding: 14px 18px; text-align: right; border-bottom: 1px solid var(--border); font-size: 13px; }
.history-table th {
  background: var(--surface-2); font-weight: 700; color: var(--muted);
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em;
}
.history-table tr:hover td { background: var(--accent-soft); }

.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; }
.settings-card { padding: 28px; border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.settings-row { display: flex; gap: 10px; margin-top: 10px; }
.input {
  flex: 1; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 14px; font-family: inherit; transition: border-color 0.15s; background: var(--surface-solid);
}
.input:focus { outline: none; border-color: var(--accent-2); box-shadow: 0 0 0 3px rgba(29,110,240,0.12); }

.shortcut-list { list-style: none; margin-top: 12px; }
.shortcut-list li { padding: 8px 0; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--border); }
.shortcut-list li:last-child { border-bottom: none; }
kbd {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px;
  padding: 2px 6px; font-size: 11px; font-family: inherit; font-weight: 700;
}

/* Dock */
.progress-dock {
  grid-column: 2;
  background: rgba(255,255,255,0.85);
  backdrop-filter: var(--glass);
  border-top: 1px solid var(--border);
  box-shadow: 0 -8px 32px rgba(0,0,0,0.06);
}
.progress-dock.collapsed .dock-body { display: none; }
.progress-dock.expanded { min-height: 200px; }
.dock-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 28px; cursor: pointer; height: var(--dock-h); font-weight: 600; font-size: 13px;
}
.dock-toggle { border: none; background: none; cursor: pointer; font-size: 12px; color: var(--muted); }
.dock-body { padding: 0 28px 18px; max-height: 220px; overflow: auto; }
.dock-job { padding: 12px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.dock-job-head { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.dock-job .job-bar { height: 5px; background: var(--bg); border-radius: 3px; margin-top: 8px; overflow: hidden; }
.dock-job .job-fill { height: 100%; background: linear-gradient(90deg, var(--success), #34d399); border-radius: 3px; transition: width 0.3s; }
.dock-file { font-size: 11px; color: var(--muted); margin-top: 4px; display: flex; align-items: center; gap: 6px; }
.dock-file img { width: 16px; height: 16px; }

.integrity-badge { font-size: 10px; padding: 3px 9px; border-radius: 12px; font-weight: 700; flex-shrink: 0; }
.integrity-full { background: #d1fae5; color: #065f46; }
.integrity-partial { background: #fef3c7; color: #92400e; }
.integrity-reconstructed { background: #dbeafe; color: #1e40af; }

.empty { text-align: center; padding: 48px; color: var(--muted); font-weight: 500; }
.result-row input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent-2); cursor: pointer; flex-shrink: 0; }

@media (max-width: 1100px) {
  .results-split { grid-template-columns: 1fr; }
  .home-hero { grid-template-columns: 1fr; }
  .hero-visual { display: none; }
}

/* ── Dark theme ── */
[data-theme="dark"] {
  --bg: #0a0f18;
  --surface: rgba(18, 26, 40, 0.92);
  --surface-solid: #141c2b;
  --surface-2: #1a2436;
  --border: rgba(100, 120, 150, 0.28);
  --text: #f1f5f9;
  --muted: #b8c8dc;
  --accent: #60a5fa;
  --accent-2: #93c5fd;
  --accent-soft: rgba(59, 130, 246, 0.18);
  --shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
  --shadow-sm: 0 4px 20px rgba(0, 0, 0, 0.3);
}
[data-theme="dark"] .bg-mesh {
  background:
    radial-gradient(ellipse 80% 60% at 10% 20%, rgba(29, 110, 240, 0.08), transparent),
    radial-gradient(ellipse 60% 50% at 90% 80%, rgba(59, 130, 246, 0.06), transparent),
    linear-gradient(160deg, #0a0f18 0%, #0f1624 50%, #0a0f18 100%);
}
[data-theme="dark"] .sidebar { background: rgba(14, 20, 32, 0.92); }
[data-theme="dark"] .topbar { background: rgba(14, 20, 32, 0.85); }
[data-theme="dark"] .progress-dock { background: rgba(14, 20, 32, 0.92); }
[data-theme="dark"] .nav-item.active { background: linear-gradient(135deg, #1e3a5f, #2563eb); }
[data-theme="dark"] .home-hero { background: linear-gradient(135deg, #060d18 0%, #0f1f35 40%, #1d4ed8 100%); }
[data-theme="dark"] .file-row:hover, [data-theme="dark"] .result-row:hover { background: var(--accent-soft); }
[data-theme="dark"] .result-row.selected { background: rgba(59,130,246,0.2); }
[data-theme="dark"] .integrity-full { background: #064e3b; color: #6ee7b7; }
[data-theme="dark"] .integrity-partial { background: #78350f; color: #fcd34d; }
[data-theme="dark"] .integrity-reconstructed { background: #1e3a8a; color: #93c5fd; }
[data-theme="dark"] .emergency-wrap { background: linear-gradient(135deg, rgba(69,26,3,0.5), rgba(120,53,15,0.4)); border-color: #b45309; }
[data-theme="dark"] .input, [data-theme="dark"] .search-input { background: var(--surface-solid); color: var(--text); }
[data-theme="dark"] .btn.ghost { background: var(--surface-solid); color: var(--text); border-color: var(--border); }
[data-theme="dark"] .muted { color: #c5d3e3; }
[data-theme="dark"] .section-intro { color: #c5d3e3; }
[data-theme="dark"] .mode-card { color: var(--text); }
[data-theme="dark"] .mode-card small { color: #a8bdd4; }
[data-theme="dark"] .mode-desc { color: #c5d3e3; }
[data-theme="dark"] .drive-card { color: var(--text); }
[data-theme="dark"] .drive-stats { color: #a8bdd4; }
[data-theme="dark"] .drive-quick-btn {
  background: var(--surface-solid); color: var(--text); border-color: var(--border);
}
[data-theme="dark"] .drive-quick-btn:hover { background: var(--accent-2); color: #0f172a; border-color: var(--accent-2); }
[data-theme="dark"] .hero-content p { opacity: 0.95; color: #e8f0fa; }
[data-theme="dark"] .hero-features li { background: rgba(255,255,255,0.18); color: #f8fafc; border-color: rgba(255,255,255,0.25); }
[data-theme="dark"] .hero-badge { color: #f1f5f9; background: rgba(255,255,255,0.2); }
[data-theme="dark"] .btn.ghost.light {
  background: rgba(255,255,255,0.22); color: #fff; border-color: rgba(255,255,255,0.45);
}
[data-theme="dark"] .btn.ghost.light:hover { background: rgba(255,255,255,0.32); }
[data-theme="dark"] .btn.primary { color: #fff; }
[data-theme="dark"] .history-table th { color: #a8bdd4; }
[data-theme="dark"] .history-table td { color: var(--text); }
[data-theme="dark"] .filter-chip { background: var(--surface-solid); color: var(--text); }
[data-theme="dark"] .view-btn { background: var(--surface-solid); color: var(--text); }
[data-theme="dark"] .stat-card .stat-label { color: #a8bdd4; }
[data-theme="dark"] .topbar-sub { color: #a8bdd4; }
[data-theme="dark"] .git-repo-card .repo-meta { color: #a8bdd4; }
[data-theme="dark"] .pill-mesh { color: #c7d2fe; }
[data-theme="dark"] .field-label { color: #a8bdd4; }

/* Theme toggle */
.theme-toggle {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface-solid); cursor: pointer; font-size: 18px;
  display: flex; align-items: center; justify-content: center; transition: all 0.2s;
}
.theme-toggle:hover { border-color: var(--accent-2); }
[data-theme="light"] .theme-icon-dark, [data-theme="dark"] .theme-icon-light { display: none; }
.theme-picker { display: flex; gap: 8px; margin-top: 10px; }
.theme-opt {
  flex: 1; padding: 12px; border: 2px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-solid); cursor: pointer; font-family: inherit; font-weight: 600; font-size: 13px;
}
.theme-opt.active { border-color: var(--accent-2); background: var(--accent-soft); }

/* Auth */
.auth-gate {
  position: fixed; inset: 0; z-index: 10000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(10, 15, 24, 0.75); backdrop-filter: blur(12px);
}
.auth-card { width: min(420px, 92vw); padding: 36px; border-radius: var(--radius); }
.auth-brand { text-align: center; margin-bottom: 24px; }
.auth-brand .brand-icon {
  width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 16px;
  background: linear-gradient(145deg, #0f2d4a, #1d6ef0); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 20px;
}
.auth-brand h1 { font-size: 24px; margin-bottom: 8px; }
.auth-tabs { display: flex; gap: 8px; margin-bottom: 20px; }
.auth-tab {
  flex: 1; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-solid); cursor: pointer; font-family: inherit; font-weight: 600;
}
.auth-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-error {
  background: rgba(220, 38, 38, 0.12); color: #dc2626; border: 1px solid rgba(220, 38, 38, 0.35);
  padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; text-align: center;
}
[data-theme="dark"] .auth-error { background: rgba(220, 38, 38, 0.2); color: #fca5a5; }
.auth-form .btn:disabled { opacity: 0.65; cursor: wait; }
.auth-mesh-info { margin-top: 16px; text-align: center; }
.auth-mesh-info code { font-size: 11px; word-break: break-all; }
.logout-btn { margin-top: auto; width: 100%; }

/* Shard hero visual */
.shard-field { position: relative; width: 160px; height: 160px; }
.shard {
  position: absolute; width: 28px; height: 28px; border-radius: 6px;
  background: rgba(255,255,255,0.2); border: 1px solid rgba(255,255,255,0.35);
  animation: shardFloat 4s ease-in-out infinite;
}
.shard.s1 { top: 10px; right: 30px; animation-delay: 0s; }
.shard.s2 { top: 50px; right: 5px; animation-delay: 0.5s; }
.shard.s3 { bottom: 40px; right: 20px; animation-delay: 1s; }
.shard.s4 { top: 20px; left: 25px; animation-delay: 1.5s; }
.shard.s5 { bottom: 20px; left: 10px; animation-delay: 2s; }
.shard.s6 { top: 70px; left: 50px; animation-delay: 2.5s; }
.shard-core {
  position: absolute; inset: 45px; border-radius: 16px;
  background: rgba(255,255,255,0.1); backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.25);
  display: flex; align-items: center; justify-content: center; gap: 4px;
  font-weight: 800; font-size: 20px;
  box-shadow: 0 0 40px rgba(59,130,246,0.3);
}
@keyframes shardFloat {
  0%, 100% { transform: translate(0,0) rotate(0deg); opacity: 0.7; }
  50% { transform: translate(-6px, -10px) rotate(8deg); opacity: 1; }
}

/* Mode grid */
.mode-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px; margin: 16px 0 8px;
}
.mode-card {
  padding: 14px 12px; border: 2px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-solid); cursor: pointer; text-align: right;
  font-family: inherit; transition: all 0.2s;
}
.mode-card strong { display: block; font-size: 14px; margin-bottom: 4px; }
.mode-card small { color: var(--muted); font-size: 11px; }
.mode-card:hover { border-color: var(--accent-2); transform: translateY(-2px); }
.mode-card.active { border-color: var(--accent-2); background: var(--accent-soft); box-shadow: 0 0 0 3px rgba(29,110,240,0.1); }
.mode-card.mode-black {
  background: linear-gradient(135deg, #0a0a0a, #1a1a2e);
  color: #fff; border-color: #333;
}
.mode-card.mode-black.active { border-color: #60a5fa; box-shadow: 0 0 0 3px rgba(96,165,250,0.2); }
.mode-card.mode-black small { color: #94a3b8; }
.mode-desc { min-height: 20px; font-weight: 500; }
.recover-layout.wide { max-width: min(960px, 100%); }
.section-intro { margin-bottom: 20px; max-width: 720px; }

/* Preview large */
.preview-large .results-split { grid-template-columns: 1fr 420px; min-height: 520px; }
.preview-large .results-list { max-height: 600px; }
.preview-path {
  padding: 10px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border);
  font-family: 'Consolas', 'Courier New', monospace; font-size: 11px; word-break: break-all;
  color: var(--muted); line-height: 1.5; direction: ltr; text-align: left;
}
.preview-body img { max-height: 480px; object-fit: contain; }
.preview-body iframe { min-height: 400px; }

/* Snapshot */
.snapshot-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; margin-bottom: 24px; }
.snapshot-list { display: flex; flex-direction: column; gap: 12px; }
.snapshot-card {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 22px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); transition: all 0.2s;
}
.snapshot-card:hover { border-color: var(--accent-2); box-shadow: var(--shadow-sm); }
.snapshot-card h4 { font-size: 15px; margin-bottom: 4px; }
.snapshot-actions { display: flex; gap: 8px; }

/* Git */
.git-toolbar { display: flex; gap: 8px; margin-bottom: 18px; }
.git-repo-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px;
}
.git-repo-card {
  padding: 20px; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface); cursor: pointer; transition: all 0.2s;
  position: relative;
}
.git-repo-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--accent-2); }
.git-repo-card .repo-fav { position: absolute; top: 14px; left: 14px; color: #f59e0b; font-size: 16px; }
.git-repo-card h3 { font-size: 17px; margin-bottom: 6px; padding-left: 24px; }
.git-repo-card .repo-meta { font-size: 12px; color: var(--muted); }
.git-repo-card .repo-lang-bar {
  height: 4px; border-radius: 2px; margin-top: 12px;
  background: linear-gradient(90deg, var(--accent-2), var(--success));
}
.git-detail { margin-top: 8px; }
.git-detail-header { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.git-detail-title { flex: 1; }
.git-detail-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.git-timeline {
  border-right: 2px solid var(--border); padding-right: 20px; margin-bottom: 24px;
}
.git-timeline-item {
  position: relative; padding: 12px 0 12px 20px; cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.git-timeline-item::before {
  content: ''; position: absolute; right: -27px; top: 18px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--accent-2); border: 2px solid var(--bg);
}
.git-timeline-item:hover { color: var(--accent-2); }
.git-timeline-item.active { font-weight: 700; }
.git-files {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden;
}
.git-file-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px;
  border-bottom: 1px solid var(--border); font-size: 13px;
}
.git-file-row:hover { background: var(--accent-soft); }
.git-file-row .path { flex: 1; font-family: monospace; font-size: 12px; direction: ltr; text-align: left; word-break: break-all; }
.preview-meta.path-block code {
  display: block; margin-top: 6px; padding: 8px 10px;
  background: var(--surface-2); border-radius: 6px; font-size: 11px;
  word-break: break-all; direction: ltr; text-align: left;
}

/* Modal */
.modal {
  position: fixed; inset: 0; z-index: 9000;
  display: flex; align-items: center; justify-content: center;
}
.modal[hidden] { display: none !important; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(10, 15, 24, 0.65); backdrop-filter: blur(4px);
}
.modal-card {
  position: relative; z-index: 1; width: min(480px, 92vw);
  padding: 28px; border-radius: var(--radius); box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 8px;
}
.modal-card h3 { margin-bottom: 8px; font-size: 20px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 12px; }

/* History status */
.history-status {
  padding: 16px 20px; margin-bottom: 16px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  font-size: 13px;
}
.history-status .status-item { display: flex; align-items: center; gap: 6px; }
.history-status .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.history-status .dot.ok { background: var(--success); }
.history-status .dot.warn { background: var(--warn); }
.history-status .dot.err { background: var(--danger); }
.history-type-badge {
  display: inline-block; padding: 3px 10px; border-radius: 12px;
  font-size: 11px; font-weight: 700;
}
.badge-scan { background: #dbeafe; color: #1e40af; }
.badge-restore { background: #d1fae5; color: #065f46; }
.badge-deep { background: #ede9fe; color: #5b21b6; }
[data-theme="dark"] .badge-scan { background: #1e3a8a; color: #93c5fd; }
[data-theme="dark"] .badge-restore { background: #064e3b; color: #6ee7b7; }
[data-theme="dark"] .badge-deep { background: #4c1d95; color: #c4b5fd; }
[data-theme="dark"] .home-hero .btn.primary {
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: #fff; font-weight: 700;
  box-shadow: 0 6px 24px rgba(37, 99, 235, 0.45);
}
