* { box-sizing: border-box; }
body {
  font-family: -apple-system, Segoe UI, Roboto, sans-serif;
  background: #f4f5f7;
  color: #1a1a1a;
  margin: 0;
}

.auth-box {
  max-width: 360px;
  margin: 10vh auto;
  background: #fff;
  padding: 32px;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

.auth-box h1 { margin-top: 0; font-size: 1.4rem; }

.auth-box form { display: flex; flex-direction: column; gap: 14px; }
.auth-box label { display: flex; flex-direction: column; gap: 6px; font-size: 0.9rem; }
.auth-box input {
  padding: 8px 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 1rem;
}
.auth-box button, .container button {
  padding: 8px 14px;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.95rem;
}
.auth-box button:hover, .container button:hover { background: #1d4ed8; }
.error { color: #dc2626; font-size: 0.9rem; }

.container {
  max-width: 800px;
  margin: 40px auto;
  background: #fff;
  padding: 24px 32px;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.logout-form {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
}

.area-switch {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.area-switch a {
  padding: 6px 12px;
  border-radius: 999px;
  background: #f4f5f7;
  color: #444;
  text-decoration: none;
  font-size: 0.85rem;
}
.area-switch a:hover { background: #e5e7eb; }
.area-switch a.active {
  background: #2563eb;
  color: #fff;
}

.breadcrumbs {
  margin-bottom: 16px;
  font-size: 0.9rem;
  color: #444;
}
.breadcrumbs a { color: #2563eb; text-decoration: none; }
.breadcrumbs a:hover { text-decoration: underline; }
.breadcrumbs .sep { margin: 0 6px; color: #999; }
.breadcrumbs .current { font-weight: 600; }

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.upload-form {
  display: flex;
  gap: 10px;
}

#newFolderBtn {
  padding: 8px 14px;
  background: #10b981;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
}
#newFolderBtn:hover { background: #059669; }

.progress-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}
.progress-wrap[hidden] { display: none; }

.bulk-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 8px 12px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  font-size: 0.85rem;
}
.bulk-bar[hidden] { display: none; }
.bulk-bar button {
  padding: 5px 12px;
  border: none;
  border-radius: 4px;
  background: #e5e7eb;
  cursor: pointer;
  font-size: 0.85rem;
}
.bulk-bar button:hover { background: #d1d5db; }
.bulk-bar button.danger { background: #dc2626; color: #fff; }
.bulk-bar button.danger:hover { background: #b91c1c; }
#bulkCount { margin-right: auto; font-weight: 600; color: #1d4ed8; }

.select-cell { width: 32px; text-align: center; }

.progress-track {
  flex: 1;
  height: 10px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: #2563eb;
  transition: width 0.15s ease;
}

#progressText {
  font-size: 0.85rem;
  color: #444;
  min-width: 60px;
}

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid #eee; font-size: 0.9rem; }
.name-cell { max-width: 320px; word-break: break-word; }
.entry-link { color: #1a1a1a; text-decoration: none; }
.entry-link:hover { color: #2563eb; text-decoration: underline; }
.actions { display: flex; gap: 6px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.actions a, .actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  min-height: 34px;
  color: #1a1a1a;
  text-decoration: none;
  font-size: 1rem;
}
.actions a { background: #e5e7eb; border-radius: 4px; }
.actions a:hover { background: #d1d5db; }
.actions form { margin: 0; }
.actions button {
  padding: 4px 8px;
  background: #e5e7eb;
}
.actions button:hover { background: #d1d5db; }
button.danger { background: #dc2626 !important; color: #fff !important; }
button.danger:hover { background: #b91c1c !important; }
.empty { color: #666; }

.table-scroll { overflow-x: auto; }

/* Icon buttons throughout the app need a comfortable tap target and no
   text-button padding assumptions now that labels are gone. */
.logout-form button,
#newFolderBtn,
.bulk-bar button,
.close-btn {
  min-width: 34px;
  min-height: 34px;
}

.select-cell input[type="checkbox"],
.row-check {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

/* --- Modals --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-overlay[hidden] { display: none; }
.modal {
  background: #fff;
  border-radius: 8px;
  max-width: 90vw;
  width: 640px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}
.small-modal { width: 360px; }
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid #eee;
  font-weight: 600;
}
.close-btn {
  background: none;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  color: #666;
  padding: 0 4px;
}
.close-btn:hover { color: #1a1a1a; }
.modal-body {
  padding: 18px;
  overflow: auto;
}

.preview-modal .modal-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 300px;
}
.preview-modal img,
.preview-modal video {
  max-width: 100%;
  max-height: 70vh;
}
.preview-modal audio { width: 100%; }
.preview-modal iframe {
  width: 100%;
  height: 65vh;
  border: none;
}

.folder-form { display: flex; gap: 10px; }
#newFolderName {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 1rem;
}
#createFolderConfirm {
  flex-shrink: 0;
  padding: 8px 14px;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1.1rem;
}
#createFolderConfirm:hover { background: #1d4ed8; }

.folder-tree {
  max-height: 40vh;
  overflow: auto;
  border: 1px solid #eee;
  border-radius: 4px;
  margin-bottom: 14px;
}
.tree-row {
  padding: 6px 10px;
  cursor: pointer;
  font-size: 0.9rem;
  white-space: nowrap;
}
.tree-row:hover { background: #f4f5f7; }
.tree-row.selected { background: #dbeafe; font-weight: 600; }

.picker-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 0.9rem;
}
#pickerConfirm {
  padding: 8px 16px;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}
#pickerConfirm:hover { background: #1d4ed8; }

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 16px;
}
.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  min-height: 34px;
  border-radius: 4px;
  background: #e5e7eb;
  text-decoration: none;
  color: #1a1a1a;
  font-size: 1rem;
}
a.page-btn:hover { background: #d1d5db; }
.page-btn.disabled { opacity: 0.4; cursor: default; }
.page-info { font-size: 0.85rem; color: #444; }

/* --- Mobile --- */
@media (max-width: 640px) {
  .container {
    margin: 0;
    padding: 16px;
    border-radius: 0;
    max-width: 100%;
    min-height: 100vh;
  }

  header { flex-wrap: wrap; gap: 8px; }
  header h1 { font-size: 1.2rem; }

  .toolbar { flex-direction: column; align-items: stretch; }
  .upload-form { flex-direction: column; align-items: stretch; }
  .upload-form input[type="file"] { max-width: 100%; }
  #newFolderBtn { align-self: flex-start; }

  .bulk-bar { flex-wrap: wrap; }
  #bulkCount { flex-basis: 100%; margin-right: 0; }

  .col-updated { display: none; }

  th, td { padding: 8px 4px; font-size: 0.85rem; }
  .name-cell { max-width: 55vw; }

  .picker-footer { flex-direction: column; align-items: stretch; gap: 10px; }
  #pickerConfirm { width: 100%; }

  .modal { width: 100%; max-width: 100%; max-height: 100%; height: 100%; border-radius: 0; }
  .small-modal { width: 100%; }
}
