:root {
  color-scheme: light dark;
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --bg: #0f172a;
  --panel: rgba(15, 23, 42, 0.85);
  --panel-border: rgba(148, 163, 184, 0.25);
  --text: #f8fafc;
  --text-muted: rgba(226, 232, 240, 0.7);
  --accent: #38bdf8;
  --accent-strong: #0ea5e9;
  --danger: #fb7185;
  --shadow: 0 15px 60px rgba(15, 23, 42, 0.45);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top, rgba(56, 189, 248, 0.15), transparent 45%),
    radial-gradient(circle at bottom, rgba(124, 58, 237, 0.18), transparent 50%),
    var(--bg);
  color: var(--text);
  display: flex;
  justify-content: center;
  padding: clamp(1.5rem, 2vw, 3rem);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

body.dragging #file-board {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2);
}

.app-shell {
  width: min(1200px, 100%);
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid var(--panel-border);
  border-radius: 28px;
  padding: clamp(1.25rem, 2vw, 2.5rem);
  box-shadow: var(--shadow);
  backdrop-filter: blur(25px);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.app-header {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  align-items: flex-start;
}

.app-title h1 {
  margin: 0;
  font-size: clamp(1.4rem, 4vw, 2.1rem);
}

.app-title p {
  margin: 0.3rem 0 0;
  color: var(--text-muted);
}

.board-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

select, button {
  font-family: inherit;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: rgba(15, 23, 42, 0.65);
  color: var(--text);
  padding: 0.55rem 1.3rem;
  font-size: 0.95rem;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

select:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button:hover,
select:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.view-toggle {
  display: inline-flex;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.3);
}

.view-toggle button {
  border: none;
  border-radius: 0;
  padding-inline: 1rem;
  min-width: 56px;
}

.view-toggle button.active {
  background: var(--accent);
  color: #03111f;
}

.drop-hint {
  border: 1px dashed rgba(148, 163, 184, 0.45);
  border-radius: 20px;
  padding: 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.auth-banner {
  border: 1px solid rgba(56, 189, 248, 0.35);
  background: rgba(56, 189, 248, 0.12);
  color: var(--text);
  border-radius: 18px;
  padding: 0.95rem 1rem;
  line-height: 1.5;
}

#file-board {
  min-height: 280px;
  border: 1px dashed rgba(148, 163, 184, 0.35);
  border-radius: 22px;
  padding: clamp(1rem, 2vw, 1.5rem);
  display: grid;
  gap: 1rem;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

#file-board[data-view='grid'] {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

#file-board[data-view='list'] {
  grid-template-columns: 1fr;
}

.file-card,
.file-row {
  background: rgba(2, 6, 23, 0.65);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 18px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  box-shadow: 0 10px 20px rgba(2, 6, 23, 0.4);
  transition: transform 140ms ease, border-color 140ms ease;
}

.file-card:hover,
.file-row:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
}

.file-card a,
.file-row a {
  text-decoration: none;
  color: inherit;
  display: flex;
  gap: 0.75rem;
}

.file-type-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: rgba(56, 189, 248, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: var(--accent);
  flex-shrink: 0;
}

.file-meta h3 {
  margin: 0;
  font-size: 1.02rem;
}

.file-meta p {
  margin: 0.3rem 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.file-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.file-footer-actions {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.55rem;
}

.share-link-button {
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: rgba(56, 189, 248, 0.08);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  line-height: 1;
  flex-shrink: 0;
}

.delete-file-button {
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(251, 113, 133, 0.35);
  background: rgba(127, 29, 29, 0.25);
  color: #fecdd3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  line-height: 1;
  flex-shrink: 0;
}

.share-link-button:hover,
.share-link-button:focus-visible {
  border-color: var(--accent);
  background: rgba(56, 189, 248, 0.18);
}

.delete-file-button:hover,
.delete-file-button:focus-visible {
  border-color: rgba(251, 113, 133, 0.75);
  background: rgba(153, 27, 27, 0.42);
}

.share-link-button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.delete-file-button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-muted);
  padding: 3rem 1rem;
}

.empty-state strong {
  display: block;
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.loading {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-muted);
}

.bottom-bar {
  border-top: 1px solid rgba(148, 163, 184, 0.25);
  padding-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.bottom-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
}

.action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: flex-end;
}

.bottom-note {
  color: var(--text-muted);
  font-size: 0.9rem;
}

button.danger {
  border: 1px solid rgba(251, 113, 133, 0.45);
  background: rgba(127, 29, 29, 0.35);
  color: #ffe4e6;
}

button.danger:hover,
button.danger:focus-visible {
  border-color: rgba(251, 113, 133, 0.8);
  background: rgba(153, 27, 27, 0.5);
}

#upload-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.7);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 20;
}

#upload-overlay.active {
  display: flex;
}

.overlay-card {
  width: min(480px, 95vw);
  background: rgba(15, 23, 42, 0.95);
  border-radius: 24px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: var(--shadow);
}

.overlay-card h2 {
  margin: 0;
}

.overlay-card label {
  font-size: 0.9rem;
  color: var(--text-muted);
  display: block;
  margin-bottom: 0.35rem;
}

.overlay-card input,
.overlay-card textarea {
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: rgba(2, 6, 23, 0.55);
  color: var(--text);
  padding: 0.65rem 0.85rem;
  font-size: 1rem;
  font-family: inherit;
}

.overlay-card textarea {
  min-height: 92px;
  resize: vertical;
}

.overlay-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
}

button.secondary {
  background: rgba(148, 163, 184, 0.2);
}

button.primary {
  background: var(--accent);
  color: #021426;
  border: none;
}

.status-line {
  font-size: 0.9rem;
  color: var(--text-muted);
}

#toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: rgba(15, 23, 42, 0.9);
  color: var(--text);
  padding: 0.75rem 1rem;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
  transition: opacity 200ms ease, transform 200ms ease;
  z-index: 30;
}

#toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 700px) {
  body {
    padding: 1rem;
  }

  .app-shell {
    border-radius: 16px;
    padding: 1rem;
  }

  .board-actions {
    width: 100%;
    justify-content: space-between;
  }

  .view-toggle button {
    min-width: 48px;
  }

  #file-board {
    padding: 0.75rem;
  }

  .file-card,
  .file-row {
    padding: 0.85rem;
  }

  .bottom-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .bottom-actions button {
    width: 100%;
    justify-content: center;
  }
}
