/**
 * ============================================================
 * Workspace Page Styles — StudyHub
 * Personal Workspace: Repository, Starred, Search
 * ============================================================
 */

/* ============================================================
   Navbar & language switcher
   ------------------------------------------------------------
   The top bar is shared across every page and is defined ONCE in
   home.css (which this page also loads). The .workspace-page navbar
   overrides that used to live here made the top bar look different
   from the other pages (different sizes, spacing and text position),
   so they were removed for a single, consistent navbar.
   ============================================================ */

/* ── Main Container ───────────────────────────────────────── */
.workspace-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: calc(var(--navbar-height) + var(--spacing-3xl) + 1rem) 1.5rem 4rem;
}

/* ── Page Header ──────────────────────────────────────────── */
.workspace-header {
  text-align: center;
  margin-bottom: 2rem;
}

.workspace-title {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--color-text-primary, #1a1a1a);
  margin: 0 0 0.5rem;
}

.workspace-subtitle {
  font-size: 1.125rem;
  color: var(--color-text-secondary, #666);
  margin: 0;
}

/* ── Search Bar ───────────────────────────────────────────── */
.workspace-search {
  margin-bottom: 2rem;
}

.search-container {
  position: relative;
  max-width: 600px;
  margin: 0 auto;
}

.search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-secondary, #999);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 1rem 3rem;
  font-size: 1rem;
  font-family: inherit;
  border: 2px solid var(--color-border, #e5e5e5);
  border-radius: 12px;
  background: var(--color-bg-primary, #fff);
  color: var(--color-text-primary, #1a1a1a);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-input:focus {
  outline: none;
  border-color: var(--color-primary, #2563eb);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.search-input::placeholder {
  color: var(--color-text-secondary, #999);
}

.search-clear {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  padding: 0.25rem;
  cursor: pointer;
  color: var(--color-text-secondary, #999);
  border-radius: 4px;
  transition: color 0.2s ease, background 0.2s ease;
}

.search-clear:hover {
  color: var(--color-text-primary, #1a1a1a);
  background: var(--color-bg-secondary, #f5f5f5);
}

/* ── Tab Navigation ───────────────────────────────────────── */
.workspace-tabs {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin-bottom: 2rem;
  border-bottom: 2px solid var(--color-border, #e5e5e5);
  padding-bottom: 0;
}

.workspace-tab {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 500;
  font-family: inherit;
  color: var(--color-text-secondary, #666);
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.workspace-tab:hover {
  color: var(--color-text-primary, #1a1a1a);
}

.workspace-tab.is-active {
  color: var(--color-primary, #2563eb);
  border-bottom-color: var(--color-primary, #2563eb);
}

.workspace-tab svg {
  flex-shrink: 0;
}

/* ── Tab Panels ───────────────────────────────────────────── */
.workspace-panels {
  min-height: 400px;
}

.workspace-panel {
  display: none;
}

.workspace-panel.is-active {
  display: block;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Section Title ────────────────────────────────────────── */
.section-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--color-text-primary, #1a1a1a);
  margin: 0 0 1.5rem;
}

/* ── Upload Section ───────────────────────────────────────── */
.upload-section {
  margin-bottom: 2rem;
}

.upload-area {
  position: relative;
  border: 2px dashed rgba(0, 113, 227, 0.28);
  border-radius: var(--radius-xl, 24px);
  padding: 2.5rem 2rem;
  text-align: center;
  background:
    radial-gradient(ellipse at top, rgba(0, 113, 227, 0.04) 0%, transparent 60%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.7) 0%, rgba(0, 113, 227, 0.02) 100%);
  transition:
    border-color 280ms cubic-bezier(0.22, 1, 0.36, 1),
    background 280ms cubic-bezier(0.22, 1, 0.36, 1),
    transform 280ms cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 280ms cubic-bezier(0.22, 1, 0.36, 1);
  cursor: pointer;
  overflow: hidden;
}

.upload-area::before {
  content: '';
  position: absolute;
  inset: -50%;
  background: radial-gradient(circle at 50% 50%, rgba(0, 113, 227, 0.10) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 280ms cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
}

.upload-area:hover {
  border-color: rgba(0, 113, 227, 0.55);
  transform: translateY(-2px);
  box-shadow: 0 14px 32px -14px rgba(0, 113, 227, 0.25);
}

.upload-area:hover::before {
  opacity: 1;
}

.upload-area.drag-over {
  border-style: solid;
  border-color: var(--color-accent-primary, #0071e3);
  background:
    radial-gradient(ellipse at top, rgba(0, 113, 227, 0.10) 0%, transparent 70%),
    linear-gradient(180deg, rgba(0, 113, 227, 0.05) 0%, rgba(88, 86, 214, 0.05) 100%);
  transform: scale(1.005);
  box-shadow: 0 18px 44px -12px rgba(0, 113, 227, 0.32);
}

.upload-area > * {
  position: relative;
  z-index: 1;
}

.upload-icon {
  display: inline-grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: var(--color-gradient, linear-gradient(135deg, #0071e3, #5856d6));
  color: #fff;
  margin: 0 auto 1.25rem;
  box-shadow: 0 10px 24px -8px rgba(0, 113, 227, 0.45);
  transition: transform 320ms cubic-bezier(0.22, 1, 0.36, 1);
}

.upload-area:hover .upload-icon {
  transform: translateY(-4px) rotate(-3deg);
}

.upload-area.drag-over .upload-icon {
  animation: uploadIconBounce 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes uploadIconBounce {
  0%, 100% { transform: translateY(0) scale(1); }
  50%      { transform: translateY(-8px) scale(1.06); }
}

.upload-icon svg {
  width: 30px;
  height: 30px;
}

.upload-text {
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--color-text-primary, #1a1a1a);
  margin: 0 0 0.4rem;
  letter-spacing: -0.01em;
}

.upload-hint {
  font-size: 0.8125rem;
  color: var(--color-text-tertiary, #8a8a8a);
  margin: 0 0 1.25rem;
}

.file-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}

.upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 1.5rem;
  font-size: 0.9375rem;
  font-weight: 600;
  font-family: inherit;
  color: #fff;
  background: var(--color-gradient, linear-gradient(135deg, #0071e3, #5856d6));
  border: none;
  border-radius: var(--radius-full, 9999px);
  cursor: pointer;
  box-shadow: 0 8px 20px -8px rgba(0, 113, 227, 0.5);
  transition:
    transform 220ms cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 220ms cubic-bezier(0.22, 1, 0.36, 1);
  position: relative;
  z-index: 3;
}

.upload-btn:hover {
  transform: translateY(-1px) scale(1.03);
  box-shadow: 0 12px 26px -8px rgba(0, 113, 227, 0.55);
}

.upload-btn:active {
  transform: scale(0.97);
}

.upload-btn svg {
  flex-shrink: 0;
}

/* ── Upload Progress ──────────────────────────────────────── */
.upload-progress {
  margin-top: 1.25rem;
  padding: 1rem 1.25rem;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(0, 113, 227, 0.14);
  border-radius: var(--radius-lg, 16px);
  box-shadow: 0 10px 30px -12px rgba(0, 0, 0, 0.1);
  animation: progressSlideIn 320ms cubic-bezier(0.22, 1, 0.36, 1);
}

.upload-progress[hidden] {
  display: none;
}

@keyframes progressSlideIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.upload-progress__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.upload-progress__info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
  flex: 1;
}

.upload-progress__spinner {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: var(--color-gradient, linear-gradient(135deg, #0071e3, #5856d6));
  color: #fff;
  box-shadow: 0 4px 12px -3px rgba(0, 113, 227, 0.45);
  transition: background 280ms cubic-bezier(0.22, 1, 0.36, 1);
}

.upload-progress__spinner svg {
  width: 16px;
  height: 16px;
}

.upload-progress__spinner-arc {
  transform-origin: 12px 12px;
  animation: progressSpin 1.1s linear infinite;
}

.upload-progress__spinner-check,
.upload-progress__spinner-x {
  display: none;
}

@keyframes progressSpin {
  to { transform: rotate(360deg); }
}

.upload-progress.is-done .upload-progress__spinner {
  background: linear-gradient(135deg, #34c759, #00b341);
  box-shadow: 0 4px 12px -3px rgba(52, 199, 89, 0.45);
}
.upload-progress.is-done .upload-progress__spinner-arc { display: none; }
.upload-progress.is-done .upload-progress__spinner-check {
  display: block;
  animation: progressIconPop 360ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.upload-progress.is-error .upload-progress__spinner {
  background: linear-gradient(135deg, #ff3b30, #ff6b6b);
  box-shadow: 0 4px 12px -3px rgba(255, 59, 48, 0.45);
}
.upload-progress.is-error .upload-progress__spinner-arc { display: none; }
.upload-progress.is-error .upload-progress__spinner-x {
  display: block;
  animation: progressIconPop 360ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes progressIconPop {
  0%   { transform: scale(0.4); opacity: 0; }
  60%  { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); }
}

.upload-progress__text {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.upload-progress__title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text-primary, #1a1a1a);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.005em;
}

.upload-progress__count {
  font-size: 0.75rem;
  color: var(--color-text-tertiary, #8a8a8a);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.upload-progress__count:empty {
  display: none;
}

.upload-progress__percent {
  flex-shrink: 0;
  font-size: 0.95rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  background: var(--color-gradient, linear-gradient(135deg, #0071e3, #5856d6));
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  letter-spacing: -0.02em;
  transition: opacity 200ms ease;
}

.upload-progress.is-done .upload-progress__percent {
  background: linear-gradient(135deg, #34c759, #00b341);
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
}

.upload-progress.is-error .upload-progress__percent {
  background: linear-gradient(135deg, #ff3b30, #ff6b6b);
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
}

.progress-bar {
  position: relative;
  height: 8px;
  background: rgba(0, 113, 227, 0.08);
  border-radius: var(--radius-full, 9999px);
  overflow: hidden;
}

.progress-fill {
  position: relative;
  height: 100%;
  width: 0%;
  background: var(--color-gradient, linear-gradient(135deg, #0071e3, #5856d6));
  border-radius: var(--radius-full, 9999px);
  transition: width 420ms cubic-bezier(0.22, 1, 0.36, 1),
              background 280ms cubic-bezier(0.22, 1, 0.36, 1);
  overflow: hidden;
}

.progress-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.55) 50%,
    transparent 100%
  );
  animation: progressShimmer 1.4s linear infinite;
}

@keyframes progressShimmer {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.upload-progress.is-done .progress-fill {
  background: linear-gradient(135deg, #34c759, #00b341);
}

.upload-progress.is-done .progress-fill::after {
  animation: none;
  opacity: 0;
}

.upload-progress.is-error .progress-fill {
  background: linear-gradient(135deg, #ff3b30, #ff6b6b);
}

.upload-progress.is-error .progress-fill::after {
  animation: none;
  opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
  .progress-fill::after,
  .upload-progress__spinner-arc {
    animation: none !important;
  }
  .upload-progress,
  .upload-area .upload-icon {
    animation: none !important;
    transition: none !important;
  }
  .progress-fill {
    transition: none !important;
  }
}

/* ── Files Grid ───────────────────────────────────────────── */
.files-section {
  margin-top: 2rem;
}

/* ── Files Section Header (title + refresh) ───────────────── */
.files-section__header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

/* Title already has a bottom margin; the header owns the spacing now. */
.files-section__header .section-title {
  margin-bottom: 0;
}

.files-refresh-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: none;
  border: 1px solid var(--color-border, #e5e5e5);
  border-radius: 8px;
  color: var(--color-text-secondary, #666);
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.files-refresh-btn:hover {
  color: var(--color-primary, #2563eb);
  border-color: var(--color-primary, #2563eb);
  background: rgba(37, 99, 235, 0.05);
}

.files-refresh-btn:disabled {
  cursor: default;
  opacity: 0.6;
}

/* Spin the icon while a refresh is in flight (reuses the `spin` keyframe). */
.files-refresh-btn.is-loading svg {
  animation: spin 0.8s linear infinite;
}

.files-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.files-empty,
.starred-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 4rem 2rem;
  color: var(--color-text-secondary, #999);
}

.files-empty svg,
.starred-empty svg {
  margin-bottom: 1rem;
  opacity: 0.5;
}

.files-empty p,
.starred-empty p {
  font-size: 1.125rem;
  margin: 0;
}

.starred-hint {
  font-size: 0.875rem;
  margin-top: 0.5rem;
}

/* ── File Card ────────────────────────────────────────────── */
.file-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: var(--color-bg-primary, #fff);
  border: 1px solid var(--color-border, #e5e5e5);
  border-radius: 12px;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.file-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transform: translateY(-2px);
}

.file-icon {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg-secondary, #f5f5f5);
  border-radius: 8px;
  color: var(--color-primary, #2563eb);
}

.file-icon.pdf { color: #e53e3e; }
.file-icon.docx { color: #3182ce; }
.file-icon.txt { color: #38a169; }
.file-icon.image { color: #d69e2e; }

.file-info {
  flex: 1;
  min-width: 0;
}

.file-name {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--color-text-primary, #1a1a1a);
  margin: 0 0 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-meta {
  font-size: 0.8125rem;
  color: var(--color-text-secondary, #666);
  margin: 0;
}

.file-actions {
  display: flex;
  gap: 0.5rem;
}

.file-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: none;
  border: 1px solid var(--color-border, #e5e5e5);
  border-radius: 8px;
  color: var(--color-text-secondary, #666);
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.file-action-btn:hover {
  color: var(--color-primary, #2563eb);
  border-color: var(--color-primary, #2563eb);
  background: rgba(37, 99, 235, 0.05);
}

.file-action-btn.delete:hover {
  color: #e53e3e;
  border-color: #e53e3e;
  background: rgba(229, 62, 62, 0.05);
}

/* ── Clickable file (opens preview) ───────────────────────── */
.file-card__open {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: 1;
  min-width: 0;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  text-align: left;
  color: inherit;
}

.file-card__open:hover .file-name {
  color: var(--color-primary, #2563eb);
}

.file-card__open:focus-visible {
  outline: 2px solid var(--color-primary, #2563eb);
  outline-offset: 3px;
  border-radius: 8px;
}

/* ── File Preview Lightbox ────────────────────────────────── */
.file-preview {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.file-preview[hidden] {
  display: none;
}

.file-preview__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}

.file-preview__dialog {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(960px, 100%);
  max-height: 100%;
  background: var(--color-bg-primary, #fff);
  border-radius: 16px;
  box-shadow: 0 24px 60px -12px rgba(0, 0, 0, 0.4);
  overflow: hidden;
  animation: previewPop 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes previewPop {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.file-preview__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid var(--color-border, #e5e5e5);
  flex-shrink: 0;
}

.file-preview__title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--color-text-primary, #1a1a1a);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.file-preview__tools {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.file-preview__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: none;
  border: 1px solid var(--color-border, #e5e5e5);
  border-radius: 8px;
  color: var(--color-text-secondary, #666);
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.file-preview__btn:hover {
  color: var(--color-primary, #2563eb);
  border-color: var(--color-primary, #2563eb);
  background: rgba(37, 99, 235, 0.05);
}

.file-preview__body {
  flex: 1;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  background: var(--color-bg-secondary, #f5f5f5);
  padding: 1rem;
}

.file-preview__img {
  max-width: 100%;
  max-height: calc(90vh - 120px);
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.file-preview__frame {
  width: 100%;
  height: calc(90vh - 120px);
  border: none;
  background: #fff;
  border-radius: 8px;
}

.file-preview__text {
  width: 100%;
  max-height: calc(90vh - 120px);
  margin: 0;
  padding: 1.25rem;
  overflow: auto;
  background: #fff;
  border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8125rem;
  line-height: 1.6;
  color: var(--color-text-primary, #1a1a1a);
  white-space: pre-wrap;
  word-break: break-word;
}

.file-preview__fallback {
  text-align: center;
  color: var(--color-text-secondary, #666);
  padding: 2rem 1rem;
}

.file-preview__fallback svg {
  opacity: 0.5;
  margin-bottom: 1rem;
}

.file-preview__fallback p {
  margin: 0 0 1.25rem;
  font-size: 1rem;
}

.file-preview__fallback-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin: 0 0.35rem 0.5rem;
  padding: 0.6rem 1.25rem;
  font-size: 0.9375rem;
  font-weight: 600;
  font-family: inherit;
  color: #fff;
  background: var(--color-gradient, linear-gradient(135deg, #0071e3, #5856d6));
  border: none;
  border-radius: var(--radius-full, 9999px);
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.file-preview__fallback-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px -8px rgba(0, 113, 227, 0.5);
}

/* Secondary (e.g. Download) — outlined, sits beside the primary action */
.file-preview__fallback-btn--ghost {
  color: var(--color-accent-primary, #0071e3);
  background: transparent;
  border: 1px solid var(--color-border, #e5e5e5);
}

.file-preview__fallback-btn--ghost:hover {
  border-color: var(--color-accent-primary, #0071e3);
  background: rgba(0, 113, 227, 0.06);
  box-shadow: none;
}

/* Lock background scroll while the lightbox is open. */
body.is-preview-open {
  overflow: hidden;
}

@media (max-width: 767px) {
  /* Full-screen lightbox on phones */
  .file-preview {
    padding: 0;
  }
  .file-preview__dialog {
    width: 100%;
    height: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }
  /* Fit the content to the screen so it never renders blank or overflows.
     The bar is ~57px; leave a little breathing room. */
  .file-preview__img,
  .file-preview__text {
    max-height: calc(100dvh - 80px);
  }
  .file-preview__frame {
    height: calc(100dvh - 57px);
  }
}

/* ── Starred Grid ─────────────────────────────────────────── */
.starred-section {
  margin-top: 2rem;
}

.starred-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}

/* ── Starred Card ─────────────────────────────────────────── */
.starred-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem;
  background: var(--color-bg-primary, #fff);
  border: 1px solid var(--color-border, #e5e5e5);
  border-radius: 12px;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.starred-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  transform: translateY(-2px);
}

.starred-icon {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
  border-radius: 8px;
  color: #fff;
}

.starred-info {
  flex: 1;
  min-width: 0;
}

.starred-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text-primary, #1a1a1a);
  margin: 0 0 0.25rem;
}

.starred-date {
  font-size: 0.8125rem;
  color: var(--color-text-secondary, #666);
  margin: 0;
}

.starred-actions {
  display: flex;
  gap: 0.5rem;
}

.starred-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: none;
  border: 1px solid var(--color-border, #e5e5e5);
  border-radius: 8px;
  color: var(--color-text-secondary, #666);
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.starred-action-btn:hover {
  color: var(--color-primary, #2563eb);
  border-color: var(--color-primary, #2563eb);
  background: rgba(37, 99, 235, 0.05);
}

.starred-action-btn.remove:hover {
  color: #e53e3e;
  border-color: #e53e3e;
  background: rgba(229, 62, 62, 0.05);
}

/* ── Search Results ───────────────────────────────────────── */
.search-results {
  margin-top: 1rem;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: var(--color-bg-primary, #fff);
  border: 1px solid var(--color-border, #e5e5e5);
  border-radius: 8px;
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: background 0.2s ease;
}

.search-result-item:hover {
  background: var(--color-bg-secondary, #f5f5f5);
}

.search-result-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg-secondary, #f5f5f5);
  border-radius: 8px;
  color: var(--color-primary, #2563eb);
}

.search-result-info {
  flex: 1;
  min-width: 0;
}

.search-result-name {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--color-text-primary, #1a1a1a);
  margin: 0 0 0.25rem;
}

.search-result-type {
  font-size: 0.8125rem;
  color: var(--color-text-secondary, #666);
  margin: 0;
}

/* ============================================================
   Responsive Design  (tiers: ≤480 · ≤768 · ≤1024 · ≥1025 · ≥1440)
   Navbar collapse for this page is handled in the ≤767 block near
   the navbar styles above; this covers the workspace content.
   ============================================================ */

/* ---- Tablet (≤1024px) ---- */
@media (max-width: 1024px) {
  .workspace-main { padding: calc(var(--navbar-height) + 2rem) 1.5rem 4rem; }
  .files-grid,
  .starred-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---- Phones (≤768px) ---- */
@media (max-width: 768px) {
  .workspace-main { padding: calc(var(--navbar-height) + 1.5rem) 1rem 3rem; }
  .workspace-title { font-size: 2rem; }
  .workspace-subtitle { font-size: 1rem; }

  /* Tabs become a stacked, button-style switcher */
  .workspace-tabs {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    border-bottom: none;
  }
  .workspace-tab {
    justify-content: center;
    margin-bottom: 0;
    border-bottom: none;
    border: 2px solid var(--color-border, #e5e5e5);
    border-radius: 8px;
  }
  .workspace-tab.is-active {
    border-color: var(--color-primary, #2563eb);
    background: rgba(37, 99, 235, 0.05);
  }

  .files-grid,
  .starred-grid { grid-template-columns: 1fr; }
}

/* ---- Small phones (≤480px) ---- */
@media (max-width: 480px) {
  .workspace-main { padding: calc(var(--navbar-height) + 1rem) 0.75rem 2.5rem; }
  .workspace-title { font-size: 1.5rem; }
  .workspace-subtitle { font-size: 0.875rem; }

  .search-input { padding: 0.85rem 2.75rem; font-size: 0.9375rem; }

  .files-grid,
  .starred-grid { gap: 0.75rem; }

  /* Cards: let content wrap, keep the actions on their own row */
  .file-card,
  .starred-card { flex-wrap: wrap; padding: 0.85rem; }
  .file-info,
  .starred-info { min-width: 0; }
  .file-actions,
  .starred-actions {
    width: 100%;
    justify-content: flex-end;
    margin-top: 0.25rem;
  }
  .file-name,
  .starred-name { font-size: 0.875rem; }

  .files-empty,
  .starred-empty { padding: 2.5rem 1rem; }
  .files-empty p,
  .starred-empty p { font-size: 1rem; }

  .search-result-item { padding: 0.75rem; gap: 0.75rem; }
}

/* ---- Files / starred grid on larger screens ---- */
@media (min-width: 1025px) {
  .files-grid,
  .starred-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1440px) {
  .files-grid,
  .starred-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ---- Landscape phones: keep tabs in a row, two-up cards ---- */
@media (max-width: 1023px) and (orientation: landscape) {
  .workspace-tabs { flex-direction: row; flex-wrap: wrap; }
  .workspace-tab { flex: 1; min-width: 120px; }
  .files-grid,
  .starred-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
  .file-card,
  .starred-card,
  .workspace-panel.is-active { animation: none !important; transition: none !important; }
}

/* ── Loading State ────────────────────────────────────────── */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--color-border, #e5e5e5);
  border-top-color: var(--color-primary, #2563eb);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Upload Section Responsive Tweaks ─────────────────────── */
@media (max-width: 767px) {
  .upload-area {
    padding: 2rem 1.25rem;
    border-radius: 18px;
  }
  .upload-icon {
    width: 54px;
    height: 54px;
    border-radius: 15px;
    margin-bottom: 1rem;
  }
  .upload-icon svg {
    width: 26px;
    height: 26px;
  }
  .upload-text {
    font-size: 0.9375rem;
  }
  .upload-hint {
    font-size: 0.75rem;
  }
  .upload-btn {
    padding: 0.6rem 1.25rem;
    font-size: 0.875rem;
  }
  .upload-progress {
    padding: 0.875rem 1rem;
    border-radius: 14px;
  }
  .upload-progress__spinner {
    width: 30px;
    height: 30px;
    border-radius: 10px;
  }
  .upload-progress__spinner svg {
    width: 14px;
    height: 14px;
  }
  .upload-progress__title {
    font-size: 0.8125rem;
  }
  .upload-progress__count {
    font-size: 0.7rem;
  }
  .upload-progress__percent {
    font-size: 0.875rem;
  }
}

@media (max-width: 479px) {
  .upload-area {
    padding: 1.5rem 1rem;
  }
  .upload-icon {
    width: 48px;
    height: 48px;
    border-radius: 13px;
  }
  .upload-icon svg {
    width: 22px;
    height: 22px;
  }
  .upload-btn {
    width: 100%;
    justify-content: center;
  }
  .upload-progress {
    padding: 0.75rem 0.875rem;
  }
  .upload-progress__header {
    margin-bottom: 0.625rem;
  }
}

/* ============================================================
   REPOSITORY 2.0 — folders, view modes, batch ops, drag & drop
   A self-contained block appended so its .files-grid.view-* rules
   out-specify the legacy grid rules above (no edits needed there).
   ============================================================ */

/* ── Toolbar (breadcrumb + tools) ─────────────────────────── */
.repo-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  margin-bottom: 1rem;
}

.repo-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  min-width: 0;
  flex-wrap: wrap;
  font-size: 0.95rem;
}

.repo-crumb {
  display: inline-flex;
  align-items: center;
  max-width: 42vw;
  padding: 0.25rem 0.5rem;
  border: none;
  background: none;
  font: inherit;
  font-weight: 600;
  color: var(--color-text-secondary, #6b7280);
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.2s ease, background 0.2s ease;
}
button.repo-crumb:hover {
  color: var(--color-accent-primary, #0071e3);
  background: rgba(0, 113, 227, 0.07);
}
.repo-crumb--current {
  color: var(--color-text-primary, #1a1a1a);
  cursor: default;
}
.repo-crumb--current:hover { background: none; }
.repo-crumb__sep {
  display: inline-flex;
  color: var(--color-text-tertiary, #b0b0b0);
}

.repo-tools {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.repo-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.9rem;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  color: #fff;
  background: var(--color-gradient, linear-gradient(135deg, #0071e3, #5856d6));
  border: none;
  border-radius: var(--radius-full, 9999px);
  cursor: pointer;
  box-shadow: 0 6px 16px -8px rgba(0, 113, 227, 0.55);
  transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease;
}
.repo-btn:hover { transform: translateY(-1px); box-shadow: 0 10px 22px -8px rgba(0, 113, 227, 0.6); }
.repo-btn:active { transform: scale(0.97); }
.repo-btn svg { flex-shrink: 0; }

.repo-btn--ghost {
  color: var(--color-text-secondary, #555);
  background: var(--color-bg-primary, #fff);
  border: 1px solid var(--color-border, #e5e5e5);
  box-shadow: none;
}
.repo-btn--ghost:hover {
  color: var(--color-accent-primary, #0071e3);
  border-color: rgba(0, 113, 227, 0.4);
  background: rgba(0, 113, 227, 0.04);
  box-shadow: none;
}
.repo-btn--ghost.is-active {
  color: #fff;
  background: var(--color-gradient, linear-gradient(135deg, #0071e3, #5856d6));
  border-color: transparent;
  box-shadow: 0 6px 16px -8px rgba(0, 113, 227, 0.55);
}

/* Segmented view switch */
.repo-viewswitch {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  background: var(--color-bg-secondary, #f1f1f3);
  border-radius: var(--radius-full, 9999px);
  border: 1px solid var(--color-border, #e5e5e5);
}
.repo-view-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 30px;
  border: none;
  background: none;
  color: var(--color-text-tertiary, #9096a0);
  border-radius: var(--radius-full, 9999px);
  cursor: pointer;
  transition: color 0.2s ease, background 0.25s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.2s ease, transform 0.2s ease;
}
.repo-view-btn:hover { color: var(--color-text-primary, #1a1a1a); }
.repo-view-btn.is-active {
  color: var(--color-accent-primary, #0071e3);
  background: var(--color-bg-primary, #fff);
  box-shadow: 0 2px 6px -2px rgba(0, 0, 0, 0.18);
}
.repo-view-btn:active { transform: scale(0.92); }

/* ── Selection action bar ─────────────────────────────────── */
.repo-selbar {
  display: flex;
  align-items: center;
  gap: 0.75rem 1rem;
  flex-wrap: wrap;
  padding: 0.6rem 0.85rem;
  margin-bottom: 1rem;
  background: rgba(0, 113, 227, 0.05);
  border: 1px solid rgba(0, 113, 227, 0.16);
  border-radius: 14px;
  animation: selbarIn 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}
.repo-selbar[hidden] { display: none; }
@keyframes selbarIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.repo-selbar__count {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--color-accent-primary, #0071e3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.repo-selbar__actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-left: auto;
}
.repo-selbar__btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--color-text-primary, #1a1a1a);
  background: var(--color-bg-primary, #fff);
  border: 1px solid var(--color-border, #e5e5e5);
  border-radius: var(--radius-full, 9999px);
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.2s ease, background 0.2s ease, color 0.2s ease, opacity 0.2s ease;
}
.repo-selbar__btn:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: rgba(0, 113, 227, 0.4);
  color: var(--color-accent-primary, #0071e3);
}
.repo-selbar__btn:disabled { opacity: 0.45; cursor: default; }
.repo-selbar__btn--danger:hover:not(:disabled) {
  color: #e5484d;
  border-color: rgba(229, 72, 77, 0.5);
  background: rgba(229, 72, 77, 0.05);
}
.repo-selbar__btn--plain { border-color: transparent; background: transparent; }

/* ── Grid: view modes ─────────────────────────────────────── */
.files-grid.view-list  { display: flex; flex-direction: column; gap: 0.5rem; }
.files-grid.view-small { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 0.6rem; }
.files-grid.view-large { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 0.85rem; }
.files-grid.view-list .files-empty { width: 100%; }

/* ── Card entrance animation (staggered feel via transitions) ── */
@keyframes cardIn {
  from { opacity: 0; transform: translateY(8px) scale(0.985); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── File card (re-defined for the new markup + views) ────── */
.file-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.7rem 0.85rem;
  background: var(--color-bg-primary, #fff);
  border: 1px solid var(--color-border, #e5e5e5);
  border-radius: 14px;
  transition: box-shadow 0.25s ease, transform 0.25s cubic-bezier(0.22, 1, 0.36, 1), border-color 0.25s ease, background 0.2s ease, opacity 0.2s ease;
  animation: cardIn 0.36s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.file-card:hover {
  box-shadow: 0 10px 26px -14px rgba(0, 0, 0, 0.28);
  transform: translateY(-2px);
  border-color: rgba(0, 113, 227, 0.28);
}
.file-card.is-selected {
  border-color: var(--color-accent-primary, #0071e3);
  background: rgba(0, 113, 227, 0.05);
  box-shadow: 0 0 0 1px rgba(0, 113, 227, 0.35);
}
.file-card.is-dragging { opacity: 0.4; }

.file-card__open {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex: 1;
  min-width: 0;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  text-align: left;
  color: inherit;
}
.file-card__open:hover .file-name { color: var(--color-accent-primary, #0071e3); }
.file-card__open:focus-visible {
  outline: 2px solid var(--color-accent-primary, #0071e3);
  outline-offset: 3px;
  border-radius: 8px;
}

.file-icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg-secondary, #f4f4f6);
  border-radius: 11px;
  color: var(--color-accent-primary, #0071e3);
  transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}
.file-card:hover .file-icon { transform: scale(1.05); }
.file-icon.pdf   { color: #e5484d; background: rgba(229, 72, 77, 0.1); }
.file-icon.docx  { color: #2f6fed; background: rgba(47, 111, 237, 0.1); }
.file-icon.txt   { color: #2fa96a; background: rgba(47, 169, 106, 0.1); }
.file-icon.image { color: #d9860a; background: rgba(217, 134, 10, 0.12); }

.file-info { flex: 1; min-width: 0; }
.file-name {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text-primary, #1a1a1a);
  margin: 0 0 0.15rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.2s ease;
}
.file-meta {
  display: block;
  font-size: 0.78rem;
  color: var(--color-text-secondary, #7a7a7a);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Selection checkbox (hidden until selection mode) */
.file-card__check { display: none; flex-shrink: 0; align-items: center; }
.files-grid.is-selecting .file-card__check { display: flex; }
.file-card__check input {
  width: 18px;
  height: 18px;
  accent-color: var(--color-accent-primary, #0071e3);
  cursor: pointer;
}

/* Actions (⋯ menu trigger) */
.file-actions { display: flex; gap: 0.4rem; flex-shrink: 0; }
.file-action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: none;
  border: 1px solid transparent;
  border-radius: 9px;
  color: var(--color-text-secondary, #8a8a8a);
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease, opacity 0.2s ease;
}
.file-action-btn:hover {
  color: var(--color-accent-primary, #0071e3);
  border-color: rgba(0, 113, 227, 0.35);
  background: rgba(0, 113, 227, 0.06);
}

/* Small-icon view: tighter rows */
.files-grid.view-small .file-card { padding: 0.55rem 0.6rem; gap: 0.6rem; border-radius: 12px; }
.files-grid.view-small .file-icon { width: 38px; height: 38px; border-radius: 10px; }
.files-grid.view-small .file-meta { display: none; }
.files-grid.view-small .file-name { font-size: 0.85rem; }

/* Large-icon view: vertical tiles */
.files-grid.view-large .file-card {
  flex-direction: column;
  align-items: stretch;
  gap: 0.55rem;
  padding: 1.1rem 0.7rem 0.85rem;
  text-align: center;
}
.files-grid.view-large .file-card__open { flex-direction: column; align-items: center; gap: 0.6rem; }
.files-grid.view-large .file-icon { width: 58px; height: 58px; border-radius: 15px; }
.files-grid.view-large .file-icon svg { width: 30px; height: 30px; }
.files-grid.view-large .file-info { text-align: center; width: 100%; }
.files-grid.view-large .file-name { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; line-height: 1.3; }
.files-grid.view-large .file-meta { font-size: 0.72rem; }
.files-grid.view-large .file-actions {
  position: absolute;
  top: 6px;
  right: 6px;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.files-grid.view-large .file-card:hover .file-actions,
.files-grid.view-large .file-card:focus-within .file-actions { opacity: 1; }
.files-grid.view-large .file-card__check {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
}

/* ── Folder card ──────────────────────────────────────────── */
.folder-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.7rem 0.85rem;
  background: var(--color-bg-primary, #fff);
  border: 1px solid var(--color-border, #e5e5e5);
  border-radius: 14px;
  transition: box-shadow 0.25s ease, transform 0.25s cubic-bezier(0.22, 1, 0.36, 1), border-color 0.25s ease, background 0.2s ease;
  animation: cardIn 0.36s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.folder-card:hover {
  box-shadow: 0 10px 26px -14px rgba(0, 0, 0, 0.28);
  transform: translateY(-2px);
  border-color: rgba(0, 113, 227, 0.28);
}
.folder-card.is-droptarget,
.repo-crumb.is-droptarget {
  border-color: var(--color-accent-primary, #0071e3);
  background: rgba(0, 113, 227, 0.1);
  box-shadow: 0 0 0 2px rgba(0, 113, 227, 0.35);
  transform: scale(1.02);
}
.folder-card__open {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex: 1;
  min-width: 0;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  text-align: left;
  color: inherit;
}
.folder-icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 11px;
  color: #fff;
  background: var(--folder-color, #0071e3);
  box-shadow: 0 6px 14px -8px var(--folder-color, #0071e3);
  transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}
.folder-card:hover .folder-icon { transform: scale(1.05) rotate(-3deg); }
.folder-icon--sm { width: 30px; height: 30px; border-radius: 8px; box-shadow: none; }
.folder-icon--sm svg { width: 18px; height: 18px; }
.folder-info { flex: 1; min-width: 0; }
.folder-name {
  display: block;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--color-text-primary, #1a1a1a);
  margin: 0 0 0.12rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.folder-meta {
  display: block;
  font-size: 0.76rem;
  color: var(--color-text-secondary, #7a7a7a);
}
.folder-card__more {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  background: none;
  border: 1px solid transparent;
  border-radius: 9px;
  color: var(--color-text-secondary, #8a8a8a);
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.folder-card__more:hover {
  color: var(--color-accent-primary, #0071e3);
  border-color: rgba(0, 113, 227, 0.35);
  background: rgba(0, 113, 227, 0.06);
}

/* Folder in large view: vertical tile */
.files-grid.view-large .folder-card { flex-direction: column; align-items: stretch; text-align: center; gap: 0.55rem; padding: 1.1rem 0.7rem 0.85rem; }
.files-grid.view-large .folder-card__open { flex-direction: column; align-items: center; gap: 0.6rem; }
.files-grid.view-large .folder-icon { width: 58px; height: 58px; border-radius: 16px; }
.files-grid.view-large .folder-info { text-align: center; }
.files-grid.view-large .folder-card__more { position: absolute; top: 6px; right: 6px; opacity: 0; transition: opacity 0.2s ease; }
.files-grid.view-large .folder-card:hover .folder-card__more { opacity: 1; }
.files-grid.view-small .folder-card { padding: 0.55rem 0.6rem; gap: 0.6rem; border-radius: 12px; }
.files-grid.view-small .folder-icon { width: 38px; height: 38px; border-radius: 10px; }

/* While dragging a file, hint the drop zones */
body.is-dragging-file .folder-card { border-style: dashed; }

/* ── Floating action menu (⋯) ─────────────────────────────── */
.repo-menu {
  position: fixed;
  z-index: 2200;
  min-width: 172px;
  padding: 0.35rem;
  background: var(--color-bg-primary, #fff);
  border: 1px solid var(--color-border, #e5e5e5);
  border-radius: 12px;
  box-shadow: 0 18px 44px -12px rgba(0, 0, 0, 0.3);
  opacity: 0;
  transform: translateY(-6px) scale(0.97);
  transform-origin: top right;
  transition: opacity 0.16s ease, transform 0.18s cubic-bezier(0.22, 1, 0.36, 1);
}
.repo-menu.is-open { opacity: 1; transform: translateY(0) scale(1); }
.repo-menu__item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.55rem 0.7rem;
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  color: var(--color-text-primary, #1a1a1a);
  background: none;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease;
}
.repo-menu__item:hover { background: var(--color-bg-secondary, #f4f4f6); }
.repo-menu__icon { display: inline-flex; color: var(--color-text-secondary, #8a8a8a); }
.repo-menu__item--danger { color: #e5484d; }
.repo-menu__item--danger .repo-menu__icon { color: #e5484d; }
.repo-menu__item--danger:hover { background: rgba(229, 72, 77, 0.08); }

/* ── Modal (prompt / confirm / move) ──────────────────────── */
.repo-modal {
  position: fixed;
  inset: 0;
  z-index: 2300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.repo-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 18, 25, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.22s ease;
}
.repo-modal.is-open .repo-modal__backdrop { opacity: 1; }
.repo-modal__dialog {
  position: relative;
  width: min(400px, 100%);
  max-height: 85vh;
  overflow: auto;
  padding: 1.5rem;
  background: var(--color-bg-primary, #fff);
  border-radius: 18px;
  box-shadow: 0 30px 70px -20px rgba(0, 0, 0, 0.45);
  opacity: 0;
  transform: translateY(14px) scale(0.96);
  transition: opacity 0.24s ease, transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}
.repo-modal.is-open .repo-modal__dialog { opacity: 1; transform: translateY(0) scale(1); }
.repo-modal__title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--color-text-primary, #1a1a1a);
  margin: 0 0 1rem;
}
.repo-modal__message {
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--color-text-secondary, #555);
  margin: 0 0 1.35rem;
}
.repo-modal__input {
  width: 100%;
  padding: 0.75rem 0.9rem;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--color-text-primary, #1a1a1a);
  background: var(--color-bg-secondary, #f7f7f8);
  border: 1.5px solid var(--color-border, #e5e5e5);
  border-radius: 11px;
  margin-bottom: 1.35rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.repo-modal__input:focus {
  outline: none;
  background: var(--color-bg-primary, #fff);
  border-color: var(--color-accent-primary, #0071e3);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.14);
}
.repo-modal__actions { display: flex; justify-content: flex-end; gap: 0.6rem; }
.repo-modal__btn {
  padding: 0.6rem 1.15rem;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  border: 1px solid transparent;
  border-radius: var(--radius-full, 9999px);
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.repo-modal__btn:active { transform: scale(0.97); }
.repo-modal__btn--ghost {
  color: var(--color-text-secondary, #555);
  background: var(--color-bg-primary, #fff);
  border-color: var(--color-border, #e5e5e5);
}
.repo-modal__btn--ghost:hover { background: var(--color-bg-secondary, #f4f4f6); color: var(--color-text-primary, #1a1a1a); }
.repo-modal__btn--primary {
  color: #fff;
  background: var(--color-gradient, linear-gradient(135deg, #0071e3, #5856d6));
  box-shadow: 0 8px 20px -8px rgba(0, 113, 227, 0.55);
}
.repo-modal__btn--primary:hover { transform: translateY(-1px); box-shadow: 0 12px 26px -8px rgba(0, 113, 227, 0.6); }
.repo-modal__btn--danger {
  color: #fff;
  background: linear-gradient(135deg, #ff453a, #e5484d);
  box-shadow: 0 8px 20px -8px rgba(229, 72, 77, 0.55);
}
.repo-modal__btn--danger:hover { transform: translateY(-1px); box-shadow: 0 12px 26px -8px rgba(229, 72, 77, 0.6); }

/* Move-to list */
.repo-movelist { display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 1.35rem; max-height: 46vh; overflow: auto; }
.repo-movelist__item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  width: 100%;
  padding: 0.6rem 0.7rem;
  font-size: 0.92rem;
  font-weight: 500;
  font-family: inherit;
  color: var(--color-text-primary, #1a1a1a);
  background: none;
  border: 1px solid transparent;
  border-radius: 11px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.repo-movelist__item:hover { background: var(--color-bg-secondary, #f4f4f6); }
.repo-movelist__item.is-current {
  border-color: rgba(0, 113, 227, 0.35);
  background: rgba(0, 113, 227, 0.06);
}

/* Lock background scroll while a modal is open (separate from the lightbox). */
body.is-modal-open { overflow: hidden; }

/* ── Repository responsive tweaks ─────────────────────────── */
@media (max-width: 768px) {
  .repo-toolbar { align-items: flex-start; }
  .repo-tools { width: 100%; justify-content: space-between; }
  .repo-crumb { max-width: 60vw; }
  .files-grid.view-small { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .files-grid.view-large { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); }
  .repo-selbar__actions { width: 100%; margin-left: 0; }
}
@media (max-width: 480px) {
  .repo-btn span { display: none; }              /* icon-only buttons to save room */
  .repo-btn { padding: 0.5rem 0.7rem; }
  .repo-tools { gap: 0.4rem; }
  .files-grid.view-large { grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); }
  .files-grid.view-small { grid-template-columns: 1fr; }
  .repo-selbar__btn span { display: none; }
  .repo-selbar__btn#selAllBtn span,
  .repo-selbar__btn#selCancelBtn span { display: inline; }
  /* Keep the new file row on a single line (override the legacy wrap rule). */
  .files-grid .file-card { flex-wrap: nowrap; }
  .files-grid .file-actions { width: auto; margin-top: 0; }
}

/* ── Reduced motion ───────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .file-card, .folder-card, .repo-selbar, .repo-menu, .repo-modal__dialog, .repo-modal__backdrop {
    animation: none !important;
    transition: none !important;
  }
  .file-card:hover, .folder-card:hover { transform: none; }
}

/* ── Toast Customization ──────────────────────────────────── */
.toast-container {
  z-index: 9999;
}
/* ============================================================
   Community panel (saved posts from the Community forum)
   ============================================================ */
.wc-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.wc-openlink {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-accent-primary);
  text-decoration: none;
  padding: 8px 16px;
  border: 1px solid var(--color-border);
  border-radius: 9999px;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.wc-openlink:hover { background: var(--color-surface-glass-hover); border-color: var(--color-border-hover); }

.wc-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 20px; }
.wc-stat { text-align: center; padding: 14px; border-radius: 14px; background: var(--color-bg-secondary); border: 1px solid var(--color-border); }
.wc-stat__num { display: block; font-size: 1.5rem; font-weight: 700; color: var(--color-text-primary); font-variant-numeric: tabular-nums; }
.wc-stat__label { font-size: 0.75rem; color: var(--color-text-tertiary); }

.wc-list { display: flex; flex-direction: column; gap: 12px; }
.wc-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas: "type title actions" "type meta actions";
  align-items: center;
  gap: 4px 12px;
  padding: 14px 16px;
  border: 1px solid var(--color-border);
  border-radius: 14px;
  background: var(--color-surface);
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}
.wc-card:hover { border-color: var(--color-border-hover); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.wc-card__type { grid-area: type; align-self: start; margin-top: 2px; color: #fff; font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 9999px; white-space: nowrap; }
.wc-card__title { grid-area: title; font-size: 1rem; font-weight: 600; color: var(--color-text-primary); text-decoration: none; line-height: 1.35; }
.wc-card__title:hover { color: var(--color-accent-primary); }
.wc-card__meta { grid-area: meta; display: flex; flex-wrap: wrap; gap: 6px; font-size: 0.75rem; color: var(--color-text-tertiary); }
.wc-card__actions { grid-area: actions; display: flex; align-items: center; gap: 8px; }
.wc-btn {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  text-decoration: none;
  padding: 7px 14px;
  border: 1px solid var(--color-border);
  border-radius: 9999px;
  background: transparent;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
}
.wc-btn:hover { background: var(--color-surface-glass-hover); color: var(--color-text-primary); }
.wc-btn--del:hover { border-color: var(--color-error); color: var(--color-error); background: rgba(255, 59, 48, 0.06); }

@media (max-width: 640px) {
  .wc-stats { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .wc-card { grid-template-columns: 1fr; grid-template-areas: "type" "title" "meta" "actions"; }
  .wc-card__actions { justify-content: flex-end; }
}
