/* ── Variables ────────────────────────────────────────────────── */
:root {
  --ink:        #0f0f0f;
  --ink-2:      #1a1a1a;
  --ink-3:      #2d2d2d;
  --paper:      #fafaf8;
  --paper-2:    #f2f1ee;
  --paper-3:    #e8e6e2;
  --accent:     #2563eb;
  --accent-h:   #1d4ed8;
  --danger:     #dc2626;
  --danger-h:   #b91c1c;
  --green:      #16a34a;
  --muted:      #9ca3af;
  --border:     #e5e4e0;
  --text:       #1c1c1c;
  --text-2:     #5a5a5a;
  --radius:     10px;
  --radius-sm:  6px;
  --sidebar-w:  220px;
  --shadow:     0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.04);
}

/* ── Reset ────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-font-smoothing: antialiased; }
body {
  font-family: 'DM Sans', sans-serif;
  background: var(--paper-2);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, textarea, select { font-family: inherit; font-size: inherit; }
ul { list-style: none; }

/* ── Auth ─────────────────────────────────────────────────────── */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  background: var(--paper-2);
}

.auth-card {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin-bottom: 2rem;
}
.auth-brand span {
  font-family: 'DM Serif Display', serif;
  font-size: 1.3rem;
  color: var(--ink);
}

.auth-title {
  font-family: 'DM Serif Display', serif;
  font-size: 1.8rem;
  color: var(--ink);
  margin-bottom: .3rem;
}
.auth-sub {
  color: var(--text-2);
  margin-bottom: 1.5rem;
  font-size: .9rem;
}

.auth-form { display: flex; flex-direction: column; gap: 1.1rem; }

.field { display: flex; flex-direction: column; gap: .4rem; }
.field label {
  font-size: .825rem;
  font-weight: 500;
  color: var(--text);
  letter-spacing: .01em;
}
.req { color: var(--danger); }
.opt { color: var(--muted); font-weight: 400; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
textarea,
select {
  background: var(--paper);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .6rem .85rem;
  color: var(--text);
  outline: none;
  transition: border-color .15s;
  width: 100%;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
}
textarea { resize: vertical; }

/* username prefix */
.input-prefix {
  display: flex;
  align-items: stretch;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--paper);
  transition: border-color .15s;
}
.input-prefix:focus-within { border-color: var(--accent); }
.input-prefix > span {
  display: flex;
  align-items: center;
  padding: 0 .7rem;
  background: var(--paper-2);
  color: var(--muted);
  border-right: 1.5px solid var(--border);
  font-size: .9rem;
}
.input-prefix input {
  border: none;
  border-radius: 0;
  flex: 1;
}
.input-prefix input:focus { border-color: transparent; }

/* password eye */
.pw-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.pw-wrap input { padding-right: 2.8rem; }
.pw-eye {
  position: absolute;
  right: .75rem;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  display: flex;
  align-items: center;
  padding: 0;
}
.pw-eye:hover { color: var(--text); }

.auth-switch {
  text-align: center;
  margin-top: 1.2rem;
  font-size: .88rem;
  color: var(--text-2);
}

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .55rem 1.1rem;
  border-radius: var(--radius-sm);
  border: 1.5px solid transparent;
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s;
  white-space: nowrap;
  text-decoration: none;
}
.btn--primary {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}
.btn--primary:hover { background: var(--ink-2); text-decoration: none; color: var(--paper); }
.btn--ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn--ghost:hover { background: var(--paper-3); text-decoration: none; }
.btn--danger {
  background: transparent;
  color: var(--danger);
  border-color: #fca5a5;
}
.btn--danger:hover { background: #fef2f2; text-decoration: none; }
.btn--sm { padding: .35rem .75rem; font-size: .8rem; }
.btn--full { width: 100%; justify-content: center; }
.btn--upload { margin-top: .5rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.link-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--accent);
  font-size: .82rem;
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: 0;
  margin-top: .3rem;
}
.link-btn:hover { text-decoration: underline; }

/* ── Flash messages ───────────────────────────────────────────── */
.flash {
  padding: .65rem 1rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  margin-bottom: 1rem;
  border: 1px solid;
}
.flash--success { background: #f0fdf4; border-color: #86efac; color: #166534; }
.flash--error   { background: #fef2f2; border-color: #fca5a5; color: #991b1b; }
.flash--info    { background: #eff6ff; border-color: #93c5fd; color: #1e40af; }

/* ── App Layout ───────────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--ink);
  display: flex;
  flex-direction: column;
  padding: 1.25rem 1rem;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-top { margin-bottom: 1.5rem; }
.brand {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .2rem 0;
}
.brand span {
  font-family: 'DM Serif Display', serif;
  font-size: 1.15rem;
  color: var(--paper);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: .2rem;
  flex: 1;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .6rem .75rem;
  border-radius: var(--radius-sm);
  color: #9ca3af;
  font-size: .875rem;
  font-weight: 400;
  transition: background .12s, color .12s;
  text-decoration: none;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: var(--paper); text-decoration: none; }
.nav-item.active { background: rgba(255,255,255,.1); color: var(--paper); }

.sidebar-footer {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255,255,255,.08);
}
.user-chip {
  display: flex;
  align-items: center;
  gap: .6rem;
  flex: 1;
  min-width: 0;
}
.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: .75rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.user-meta { display: flex; flex-direction: column; min-width: 0; }
.user-name  { font-size: .8rem; font-weight: 500; color: var(--paper); truncate: ellipsis; white-space: nowrap; overflow: hidden; }
.user-handle { font-size: .72rem; color: #6b7280; white-space: nowrap; overflow: hidden; }
.logout-btn {
  color: #6b7280;
  display: flex;
  align-items: center;
  padding: .4rem;
  border-radius: var(--radius-sm);
  transition: color .12s, background .12s;
  text-decoration: none;
}
.logout-btn:hover { color: #ef4444; background: rgba(239,68,68,.1); text-decoration: none; }

/* ── Main content ─────────────────────────────────────────────── */
.main-content {
  flex: 1;
  padding: 2rem 2.5rem;
  overflow-y: auto;
  max-width: 900px;
}
.main-content--public {
  max-width: 780px;
  margin: 0 auto;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.8rem;
}
.page-title {
  font-family: 'DM Serif Display', serif;
  font-size: 1.65rem;
  color: var(--ink);
  line-height: 1.2;
}
.page-sub {
  color: var(--text-2);
  font-size: .875rem;
  margin-top: .25rem;
}

.breadcrumb {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  color: var(--text-2);
  font-size: .85rem;
  margin-bottom: 1.2rem;
  text-decoration: none;
  transition: color .12s;
}
.breadcrumb:hover { color: var(--text); text-decoration: none; }

/* ── Project grid ─────────────────────────────────────────────── */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}

.project-card {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  transition: border-color .15s, box-shadow .15s;
}
.project-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 10px rgba(37,99,235,.1);
  text-decoration: none;
}

.project-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .25rem;
}
.project-icon {
  width: 36px;
  height: 36px;
  background: var(--paper-2);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-2);
}
.project-name {
  font-size: 1rem;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.project-desc {
  font-size: .8rem;
  color: var(--text-2);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.project-meta {
  display: flex;
  justify-content: space-between;
  font-size: .75rem;
  color: var(--muted);
  margin-top: auto;
  padding-top: .5rem;
  border-top: 1px solid var(--paper-3);
}

/* Privacy badges */
.privacy-badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .7rem;
  padding: .25rem .6rem;
  border-radius: 20px;
  background: var(--paper-2);
  color: var(--muted);
  border: 1px solid var(--border);
}
.privacy-badge--public { color: var(--green); border-color: #bbf7d0; background: #f0fdf4; }

.privacy-btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: .78rem;
  padding: .35rem .75rem;
  border-radius: 20px;
  background: var(--paper-2);
  color: var(--muted);
  border: 1.5px solid var(--border);
  cursor: pointer;
  font-family: inherit;
  transition: background .12s, border-color .12s, color .12s;
}
.privacy-btn:hover { background: var(--paper-3); }
.privacy-btn--public { color: var(--green); border-color: #86efac; background: #f0fdf4; }
.privacy-btn--public:hover { background: #dcfce7; }

/* ── Empty state ──────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 4rem 2rem;
  text-align: center;
  color: var(--text-2);
}
.empty-state--sm {
  padding: 2rem;
}
.empty-state p { font-size: .9rem; }

/* ── Upload page ──────────────────────────────────────────────── */
.upload-container {
  max-width: 580px;
}

.form-section {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.drop-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--paper);
  transition: border-color .15s, background .15s;
  overflow: hidden;
  min-height: 160px;
}
.drop-zone.drag-over {
  border-color: var(--accent);
  background: #eff6ff;
}
.drop-zone-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .75rem;
  padding: 2.5rem 1rem;
}
.drop-label {
  font-size: .9rem;
  color: var(--text-2);
}
.drop-label button {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: inherit;
  padding: 0;
  text-decoration: underline;
}
.drop-sub { font-size: .78rem; color: var(--muted); }

.file-preview { padding: .75rem 1rem; display: flex; flex-direction: column; gap: .5rem; }
.preview-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .5rem .6rem;
  background: var(--paper-2);
  border-radius: var(--radius-sm);
  font-size: .845rem;
}
.preview-icon { font-size: 1.1rem; }
.preview-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preview-size { color: var(--muted); font-size: .78rem; flex-shrink: 0; font-family: 'DM Mono', monospace; }

/* Privacy section */
.privacy-section {
  margin: 1.25rem 0;
  padding: 1rem 1.1rem;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.privacy-toggle-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.toggle-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  cursor: pointer;
  width: 100%;
  user-select: none;
}
.toggle-text {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-size: .875rem;
  font-weight: 500;
  color: var(--text);
}
.toggle {
  width: 40px;
  height: 22px;
  background: var(--border);
  border-radius: 20px;
  position: relative;
  transition: background .2s;
  flex-shrink: 0;
}
.toggle.on { background: var(--accent); }
.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.toggle.on .toggle-thumb { transform: translateX(18px); }
.privacy-hint {
  font-size: .78rem;
  color: var(--muted);
  margin-top: .5rem;
}

/* ── Project view ─────────────────────────────────────────────── */
.project-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.project-header-left { flex: 1; min-width: 0; }
.project-header-actions {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}

.project-id-bar {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .6rem .9rem;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .8rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.pid-label { color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: .05em; font-size: .7rem; }
.pid-code { font-family: 'DM Mono', monospace; color: var(--ink); background: var(--paper-2); padding: .1rem .45rem; border-radius: 4px; }
.pid-sep { color: var(--border); }
.pid-url { font-family: 'DM Mono', monospace; color: var(--text-2); font-size: .75rem; word-break: break-all; }

/* Files section */
.files-section {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.files-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .85rem 1.1rem;
  border-bottom: 1px solid var(--border);
}
.files-header h3 {
  font-size: .9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.file-count {
  background: var(--paper-2);
  color: var(--muted);
  font-size: .72rem;
  font-weight: 500;
  padding: .1rem .5rem;
  border-radius: 20px;
  border: 1px solid var(--border);
}

.files-list { display: flex; flex-direction: column; }
.file-row {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .7rem 1.1rem;
  border-bottom: 1px solid var(--paper-2);
  transition: background .1s;
  font-size: .875rem;
}
.file-row:last-child { border-bottom: none; }
.file-row:hover { background: var(--paper-2); }
.file-row-icon { font-size: 1rem; flex-shrink: 0; }
.file-row-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 400; }
.file-row-size { color: var(--muted); font-size: .78rem; font-family: 'DM Mono', monospace; flex-shrink: 0; min-width: 60px; text-align: right; }
.file-row-date { color: var(--muted); font-size: .78rem; flex-shrink: 0; min-width: 50px; text-align: right; }
.file-row-actions { display: flex; align-items: center; gap: .35rem; flex-shrink: 0; }

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  transition: background .12s, color .12s;
  text-decoration: none;
}
.icon-btn:hover { background: var(--paper-3); color: var(--text); text-decoration: none; }
.icon-btn--danger:hover { background: #fef2f2; color: var(--danger); }

/* Inline edit */
.inline-input {
  background: var(--paper);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .5rem .75rem;
  color: var(--text);
  outline: none;
  width: 100%;
  font-family: 'DM Serif Display', serif;
  font-size: 1.4rem;
}
.inline-input:focus { border-color: var(--accent); }
.inline-textarea {
  font-family: 'DM Sans', sans-serif;
  font-size: .9rem;
  margin-top: .4rem;
}

/* Spinner */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Folder section (upload page) ─────────────────────────────── */
.folder-section {
  margin-bottom: 1.25rem;
}
.folder-toggle {
  display: flex;
  align-items: center;
  gap: .45rem;
  width: 100%;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .6rem .9rem;
  color: var(--text-2);
  font-size: .85rem;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  text-align: left;
}
.folder-toggle:hover {
  border-color: var(--accent);
  background: #eff6ff;
  color: var(--accent);
}
.field-hint {
  font-size: .78rem;
  color: var(--muted);
  margin-top: .35rem;
}
.folder-path {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-family: 'DM Mono', monospace;
  font-size: .78rem;
  color: var(--text-2);
  background: var(--paper-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: .15rem .5rem;
  margin-top: .25rem;
}

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 700px) {
  /* Layout */
  .app-layout { flex-direction: column; }

  /* Sidebar becomes top nav bar */
  .sidebar {
    width: 100%;
    height: auto;
    position: sticky;
    top: 0;
    z-index: 100;
    flex-direction: row;
    align-items: center;
    padding: .65rem 1rem;
    gap: .5rem;
  }
  .sidebar-top { margin-bottom: 0; flex-shrink: 0; }
  .sidebar-nav {
    flex-direction: row;
    flex: 1;
    justify-content: center;
    gap: .4rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .nav-item {
    font-size: .8rem;
    padding: .45rem .6rem;
    white-space: nowrap;
    flex-shrink: 0;
  }
  .sidebar-footer {
    padding-top: 0;
    border-top: none;
    border-left: 1px solid rgba(255,255,255,.12);
    padding-left: .65rem;
    flex-shrink: 0;
  }
  .user-meta { display: none; }  /* hide name/handle on mobile — only avatar */

  /* Main content */
  .main-content { padding: 1rem .85rem; }

  /* Project grid */
  .project-grid { grid-template-columns: 1fr; }

  /* Project header: stack vertically, actions wrap tightly */
  .project-header {
    flex-direction: column;
    gap: .75rem;
  }
  .project-header-actions {
    flex-wrap: wrap;
    gap: .4rem;
  }
  /* Hide text labels on small action buttons to save space */
  .btn-label { display: none; }

  /* File row: hide date col, shrink size col */
  .file-row {
    gap: .5rem;
    padding: .65rem .85rem;
  }
  .file-row-date { display: none; }
  .file-row-size {
    min-width: 48px;
    font-size: .72rem;
  }
  .file-row-name { font-size: .82rem; }

  /* Project ID bar: stack on narrow screens */
  .project-id-bar {
    flex-wrap: wrap;
    gap: .4rem;
  }
  .pid-sep--hide { display: none; }
  .pid-url {
    width: 100%;
    font-size: .7rem;
    word-break: break-all;
  }

  /* Upload container: full width */
  .upload-container { max-width: 100%; }

  /* Auth card padding */
  .auth-card { padding: 1.75rem 1.25rem; }
}
