:root {
  --bg:     #ffffff;
  --bg2:    #f5f5f7;
  --bg3:    #e8e8ed;
  --text:   #1d1d1f;
  --text2:  #6e6e73;
  --text3:  #86868b;
  --accent: #0071e3;
  --border: #d2d2d7;
  --green:  #34c759;
  --red:    #ff3b30;
}
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg2); color: var(--text);
  -webkit-font-smoothing: antialiased; min-height: 100vh;
  line-height: 1.6;
}

/* ── DASHBOARD NAV ───────────────────────────────────── */
.dashboard-nav {
  position: sticky; top: 0; z-index: 200;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 40px; height: 56px;
  background: rgba(255,255,255,.92);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
}
.nav-brand { font-size: 17px; font-weight: 700; color: var(--text); text-decoration: none; letter-spacing: -.02em; }
.nav-brand span { color: var(--accent); }

.user-menu { display: flex; align-items: center; gap: 10px; }

/* ── BUTTONS ─────────────────────────────────────────── */
.btn-primary {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 18px; background: var(--accent); border: none; border-radius: 980px;
  color: #fff; font-size: .84rem; font-weight: 500; cursor: pointer; font-family: inherit;
  transition: background .15s, transform .1s;
}
.btn-primary:hover { background: #0064cc; transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.btn-ghost {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 16px; background: transparent; border: 1px solid var(--border);
  border-radius: 980px; color: var(--text2); font-size: .84rem;
  cursor: pointer; font-family: inherit; transition: all .15s;
}
.btn-ghost:hover { border-color: var(--text); color: var(--text); }

.btn-import {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 16px; background: var(--bg2); border: 1px solid var(--border);
  border-radius: 980px; color: var(--text); font-size: .84rem; font-weight: 500;
  cursor: pointer; font-family: inherit; transition: all .15s;
}
.btn-import:hover { background: var(--bg3); border-color: #b8b8bd; }

/* ── DASHBOARD MAIN ─────────────────────────────────── */
.dashboard-main {
  padding: 36px 48px 60px;
  min-height: calc(100vh - 56px);
}

.dashboard-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 28px; gap: 16px; flex-wrap: wrap;
}
.dh-left { display: flex; align-items: baseline; gap: 12px; }
.dh-left h2 { font-size: 22px; font-weight: 600; letter-spacing: -.02em; }
.project-count {
  font-size: .78rem; color: var(--text3); font-weight: 400;
  background: var(--bg3); padding: 2px 10px; border-radius: 980px;
}
.dh-right { display: flex; align-items: center; gap: 10px; }

.btn-home-link {
  font-size: .78rem; color: var(--text3); text-decoration: none; padding: 4px 10px;
  border-radius: 8px; transition: all .15s; display: inline-flex; align-items: center; gap: 5px;
}
.btn-home-link:hover { color: var(--text2); background: var(--bg3); }

.search-wrapper { position: relative; display: flex; align-items: center; }
.search-icon { position: absolute; left: 12px; color: var(--text3); font-size: 12px; pointer-events: none; }
.search-input {
  padding: 8px 16px 8px 32px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 980px; color: var(--text); width: 220px; font-size: 13px;
  font-family: inherit; outline: none; transition: border-color .15s, box-shadow .15s;
}
.search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0,113,227,.1); }

.sort-select {
  padding: 7px 14px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 980px; color: var(--text); font-size: .82rem; font-family: inherit;
  cursor: pointer; outline: none; transition: border-color .15s;
  appearance: none; padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2386868b'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.sort-select:focus { border-color: var(--accent); }

.view-toggle { display: flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.vt-btn {
  padding: 7px 10px; background: var(--bg); border: none; color: var(--text3);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
}
.vt-btn.active { background: var(--bg3); color: var(--text); }
.vt-btn:hover:not(.active) { background: var(--bg2); }

/* ── PROJECTS GRID ───────────────────────────────────── */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
}

/* ── PROJECT CARD ────────────────────────────────────── */
.project-card {
  background: var(--bg); border: 1.5px solid var(--border); border-radius: 16px;
  overflow: hidden; cursor: pointer; transition: all .2s;
  display: flex; flex-direction: column;
  outline: none;
}
.project-card:hover {
  border-color: #b0b0b5;
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(0,0,0,.1);
}
.project-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.project-thumb {
  height: 150px; background: var(--bg2);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; position: relative;
}
.project-thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-placeholder { font-size: 52px; color: var(--bg3); user-select: none; }

.project-body { padding: 14px 14px 12px; flex: 1; display: flex; flex-direction: column; gap: 10px; }
.proj-meta { flex: 1; }
.proj-title-row { display: flex; align-items: center; gap: 6px; margin-bottom: 3px; }
.proj-name {
  font-size: .875rem; font-weight: 600; flex: 1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.proj-tag {
  font-size: .62rem; font-weight: 600; letter-spacing: .04em;
  background: rgba(0,113,227,.1); color: var(--accent);
  padding: 1px 7px; border-radius: 980px; flex-shrink: 0;
}
.proj-date { font-size: .72rem; color: var(--text3); }

.project-actions {
  display: flex; gap: 6px; align-items: center;
  opacity: 0; transform: translateY(4px);
  transition: opacity .18s, transform .18s;
}
.project-card:hover .project-actions,
.project-card:focus-within .project-actions {
  opacity: 1; transform: translateY(0);
}

.act-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 10px; border-radius: 8px; font-family: inherit;
  font-size: .75rem; font-weight: 500; cursor: pointer; border: 1px solid var(--border);
  background: var(--bg2); color: var(--text2); transition: all .15s;
}
.act-btn:hover { border-color: #b8b8bd; color: var(--text); background: var(--bg3); }
.act-open {
  flex: 1; justify-content: center;
  background: var(--text); color: #fff; border-color: var(--text);
}
.act-open:hover { background: #333; border-color: #333; color: #fff; }
.act-export, .act-rename { padding: 5px 8px; }
.act-delete:hover { border-color: var(--red); color: var(--red); background: rgba(255,59,48,.05); }

/* ── LIST VIEW ───────────────────────────────────────── */
.projects-grid.list-view {
  grid-template-columns: 1fr;
  gap: 8px;
}
.list-view .project-card {
  flex-direction: row; border-radius: 12px; transform: none !important;
}
.list-view .project-card:hover { transform: none !important; box-shadow: 0 2px 12px rgba(0,0,0,.08); }
.list-view .project-thumb {
  width: 72px; height: 72px; flex-shrink: 0; border-radius: 0;
}
.list-view .thumb-placeholder { font-size: 28px; }
.list-view .project-body { flex-direction: row; align-items: center; padding: 12px 14px; gap: 12px; }
.list-view .proj-meta { flex: 1; min-width: 0; }
.list-view .project-actions { opacity: 1; transform: none; flex-shrink: 0; }
.list-view .act-open { flex: none; }

/* ── EMPTY STATE ─────────────────────────────────────── */
.empty-state { grid-column: 1 / -1; }
.empty-drop-zone {
  display: flex; flex-direction: column; align-items: center;
  padding: 80px 32px; text-align: center;
  border: 2px dashed var(--border); border-radius: 20px;
  background: var(--bg); color: var(--text3);
  transition: border-color .2s, background .2s;
}
.empty-icon { font-size: 64px; margin-bottom: 16px; opacity: .3; }
.empty-drop-zone h3 { font-size: 18px; font-weight: 500; color: var(--text2); margin-bottom: 8px; }
.empty-drop-zone p { font-size: .84rem; color: var(--text3); margin-bottom: 24px; }
.empty-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* ── DROP OVERLAY ────────────────────────────────────── */
#drop-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,113,227,.12);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
#drop-overlay.visible { opacity: 1; pointer-events: all; }
.drop-msg {
  background: var(--bg); border: 2px dashed var(--accent);
  border-radius: 24px; padding: 60px 80px;
  text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.15);
}
.drop-icon { font-size: 56px; margin-bottom: 16px; }
.drop-msg h2 { font-size: 1.4rem; font-weight: 600; letter-spacing: -.02em; margin-bottom: 8px; }
.drop-msg p { font-size: .85rem; color: var(--text3); letter-spacing: .02em; }

/* ── MODAL ───────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.22);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
  backdrop-filter: blur(4px);
}
.modal-content {
  background: var(--bg); border: 1px solid var(--border); border-radius: 20px;
  padding: 32px 36px; width: 420px; display: flex; flex-direction: column; gap: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,.12);
}
.modal-content h3 { font-size: 17px; font-weight: 600; letter-spacing: -.02em; }
.modal-content input, .modal-content textarea {
  padding: 10px 14px; background: var(--bg2); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text); font-family: inherit; font-size: .875rem; width: 100%;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.modal-content input:focus, .modal-content textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px rgba(0,113,227,.1);
}
.modal-content textarea { height: 80px; resize: none; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 4px; }

/* ── FLOATING EXPORT MENU ────────────────────────────── */
.floating-menu {
  position: absolute; z-index: 500;
  background: var(--bg); border: 1px solid var(--border); border-radius: 12px;
  padding: 6px; box-shadow: 0 8px 32px rgba(0,0,0,.12);
  min-width: 180px;
}
.fm-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: 8px; font-size: .82rem; color: var(--text);
  cursor: pointer; transition: background .12s;
}
.fm-item:hover { background: var(--bg2); }

/* ── TOAST NOTIFICATIONS ─────────────────────────────── */
#toast-container {
  position: fixed; bottom: 24px; right: 24px; z-index: 9000;
  display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
}
.toast {
  padding: 12px 18px; border-radius: 12px; font-size: .84rem; font-weight: 500;
  box-shadow: 0 4px 20px rgba(0,0,0,.12); max-width: 320px;
  opacity: 0; transform: translateY(8px) scale(.97);
  transition: opacity .25s, transform .25s;
  background: var(--text); color: #fff;
}
.toast.show { opacity: 1; transform: none; }
.toast.success { background: #1a7f37; }
.toast.error { background: var(--red); }
.toast.info { background: var(--accent); }

/* ── RESPONSIVE ─────────────────────────────────────── */
@media (max-width: 680px) {
  .dashboard-main { padding: 24px 20px 48px; }
  .dashboard-nav { padding: 0 20px; }
  .dh-right { gap: 8px; }
  .search-input { width: 160px; }
  .sort-select { display: none; }
}
