/* My Better Drive — phone-first */
:root {
  --bg: #0f1419;
  --bg-elev: #1a222c;
  --bg-card: #232d3a;
  --text: #f0f4f8;
  --muted: #8b9aab;
  --accent: #4da3ff;
  --accent-press: #2f8aeb;
  --danger: #ff6b6b;
  --border: rgba(255,255,255,0.08);
  --radius: 14px;
  --tap: 48px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --fab-size: 58px;
  --dots-h: 36px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
body { overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; border: none; background: none; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

.app {
  height: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-t);
}

.view {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
}

/* Splash */
.view-splash {
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.splash-inner {
  width: 100%;
  max-width: 360px;
  text-align: center;
}
.splash-logo {
  width: 88px; height: 88px; margin: 0 auto 20px;
  border-radius: 22px;
  background: var(--bg-elev);
  display: grid; place-items: center;
}
.splash-inner h1 { font-size: 1.75rem; margin: 0 0 8px; font-weight: 700; letter-spacing: -0.02em; }
.splash-tagline { color: var(--muted); margin: 0 0 28px; line-height: 1.45; font-size: 1.05rem; }
.splash-hint { margin-top: 16px; font-size: 0.9rem; }

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  min-height: var(--tap);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.topbar-text { flex: 1; min-width: 0; }
.topbar-title {
  margin: 0; font-size: 1.1rem; font-weight: 650;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-sub {
  margin: 2px 0 0; font-size: 0.78rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.icon-btn {
  width: var(--tap); height: var(--tap);
  border-radius: 12px;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.icon-btn:active { background: var(--bg-elev); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: var(--tap);
  padding: 0 18px;
  border-radius: 12px;
  font-weight: 600;
  transition: background 0.15s ease, transform 0.05s ease;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: #061018; width: 100%; }
.btn-primary:active { background: var(--accent-press); }
.btn-secondary { background: var(--bg-card); border: 1px solid var(--border); }
.btn-ghost { color: var(--muted); margin-top: 8px; width: 100%; }
.btn-lg { min-height: 52px; font-size: 1.05rem; }
.btn-block { width: 100%; }

.panel { padding: 24px 18px; display: flex; flex-direction: column; gap: 12px; }
.lede { color: var(--muted); line-height: 1.45; margin: 0 0 8px; }
.muted { color: var(--muted); }
.danger { color: var(--danger) !important; }

/* Mode tabs */
.mode-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 14px 4px;
  flex-shrink: 0;
  position: relative;
}
.mode-tab {
  flex: 1;
  min-height: 40px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--muted);
  background: transparent;
}
.mode-tab.is-active {
  color: var(--text);
  background: var(--bg-elev);
}

/* Pager */
.pager {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  touch-action: pan-y;
  position: relative;
  margin-bottom: calc(var(--dots-h) + var(--safe-b) + 8px);
}
.pager-track {
  display: flex;
  height: 100%;
  width: 200%;
  transform: translateX(0);
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
}
.pager-track.is-dragging { transition: none; }
.pager-track.mode-folders { transform: translateX(-50%); }
.pager-page {
  width: 50%;
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Shortcuts / pins */
.pins-canvas {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 16px calc(var(--fab-size) + 28px);
}
.pins-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.pin-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 14px;
  min-height: 96px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
}
.pin-card:active { background: #2a3544; }
.pin-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--bg-elev);
  display: grid; place-items: center;
  font-size: 1.1rem;
}
.pin-name {
  font-weight: 650;
  font-size: 0.95rem;
  line-height: 1.25;
  word-break: break-word;
}
.pin-remove {
  position: absolute;
  top: 6px; right: 6px;
  width: 32px; height: 32px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
}
.pin-remove:active { background: var(--bg); color: var(--danger); }

.empty-state {
  padding: 48px 24px;
  text-align: center;
}
.empty-title { margin: 0 0 8px; font-weight: 650; font-size: 1.05rem; }

/* Folders mode */
.folders-chrome {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.folders-breadcrumbs {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  overflow-x: auto;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
}
.breadcrumbs {
  font-size: 0.8rem;
  color: var(--muted);
}
.breadcrumbs button {
  color: var(--accent);
  font-weight: 560;
  padding: 4px 2px;
  min-height: 28px;
}
.breadcrumbs .crumb-sep { margin: 0 4px; opacity: 0.5; }
.breadcrumbs .crumb-current { color: var(--text); font-weight: 600; }

.file-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 0 calc(12px + var(--safe-b));
  min-height: 0;
}
.file-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: var(--tap);
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.file-row:active { background: var(--bg-elev); }
.file-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: var(--bg-card);
  display: grid; place-items: center;
  flex-shrink: 0;
  overflow: hidden;
}
.file-icon img { width: 24px; height: 24px; }
.file-meta { flex: 1; min-width: 0; }
.file-name {
  font-weight: 560;
  font-size: 0.95rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.file-sub {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 2px;
}
.file-chevron { color: var(--muted); flex-shrink: 0; }

/* FAB — Shortcuts only */
.fab {
  position: absolute;
  right: 18px;
  bottom: calc(var(--dots-h) + var(--safe-b) + 18px);
  width: var(--fab-size);
  height: var(--fab-size);
  border-radius: 50%;
  background: var(--accent);
  color: #061018;
  display: grid; place-items: center;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
  z-index: 5;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.fab:active { transform: scale(0.94); background: var(--accent-press); }
.view-main.mode-folders .fab {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.8);
}

/* Bottom mode dots — always visible on main */
.mode-dots-bar {
  position: absolute;
  left: 0; right: 0;
  bottom: 0;
  height: calc(var(--dots-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 6;
  background: linear-gradient(to top, var(--bg) 55%, transparent);
  pointer-events: none;
}
.mode-dot-btn {
  pointer-events: auto;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  padding: 0;
}
.mode-dot-btn::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  opacity: 0.45;
  transition: transform 0.2s ease, background 0.2s ease, opacity 0.2s ease;
}
.mode-dot-btn.is-active::after {
  width: 10px;
  height: 10px;
  background: var(--text);
  opacity: 1;
  transform: scale(1.05);
}
.mode-dot-btn:active::after { opacity: 0.85; }

/* Browse overlay (picker) */
.view-browse {
  position: absolute;
  inset: 0;
  background: var(--bg);
  z-index: 20;
  padding-top: var(--safe-t);
}
.browse-toolbar {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.view-browse .file-list {
  padding-bottom: calc(16px + var(--safe-b));
}

/* Sheet menu */
.sheet {
  position: absolute;
  inset: 0;
  z-index: 30;
}
.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.5);
}
.sheet-panel {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  background: var(--bg-elev);
  border-radius: 18px 18px 0 0;
  padding: 10px 8px calc(12px + var(--safe-b));
  display: flex;
  flex-direction: column;
}
.sheet-item {
  min-height: var(--tap);
  padding: 0 16px;
  text-align: left;
  font-weight: 560;
  border-radius: 12px;
}
.sheet-item:active { background: var(--bg-card); }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-b));
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 0.9rem;
  z-index: 50;
  max-width: calc(100% - 32px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
}

@media (min-width: 560px) {
  .pins-list { grid-template-columns: 1fr 1fr 1fr; }
  .app { max-width: 480px; margin: 0 auto; border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
}
