:root {
  --bg: #090b11;
  --panel: #090b11;
  --panel-alt: #0a0d14;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #172449;
  --accent-hover: #10337d;
  --accent-2: #10b981;
  --danger: #ef4444;
  --border: #212a36;
  --border-soft: #212a36;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
  color: var(--text);
  min-height: 100vh;
  background-color: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
.brand {
  font-family: inherit;
  font-weight: 700;
  letter-spacing: -0.025em;
  margin-top: 0;
}

h1 {
  font-size: 2.25rem;
  line-height: 2.5rem;
}

@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }

  100% {
    background-position: 200% 0;
  }
}

h2 {
  font-size: 1.875rem;
  line-height: 2.25rem;
}

h3 {
  font-size: 1.5rem;
  line-height: 2rem;
}

.shell {
  position: relative;
  z-index: 1;
  padding: 32px clamp(20px, 4vw, 60px) 60px;
  max-width: 1200px;
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 40px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.brand {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}

.actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
}

.panel.center {
  max-width: 480px;
  margin: 40px auto 0;
}

.panel-card h1 {
  margin-bottom: 12px;
  font-size: 1.75rem;
}

.sub {
  color: var(--muted);
  margin: 0 0 32px;
  font-size: 0.95rem;
}

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

.vault {
  display: grid;
  gap: 24px;
}

.stack {
  display: grid;
  gap: 20px;
}

.field {
  display: grid;
  gap: 8px;
}

.field label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted);
}

input[type="password"],
input[type="file"],
input[type="text"],
input[type="email"],
input[type="number"],
select {
  font: inherit;
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border-soft);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 8px;
  transition: border-color 0.15s ease;
  outline: none;
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke%3D%22%2394a3b8%22%20stroke-width%3D%222%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpolyline%20points%3D%226%209%2012%2015%2018%209%22%3E%3C%2Fpolyline%3E%3C%2Fsvg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px;
  padding-right: 40px;
}

input:focus,
select:focus {
  border-color: var(--accent);
}

.totp-setup {
  display: grid;
  gap: 24px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  margin-top: 8px;
}

.totp-card,
.totp-secret {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  background: var(--panel-alt);
}

.totp-title {
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 12px;
}

#totp-qr {
  width: 100%;
  max-width: 180px;
  height: auto;
  display: block;
  border-radius: 4px;
}

.totp-value {
  font-family: monospace;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.05em;
  background: var(--bg);
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  display: inline-block;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  font-family: inherit;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn.primary {
  background-color: var(--accent);
  color: white;
}

.btn.primary:hover {
  background-color: var(--accent-hover);
}

.btn.ghost {
  background-color: transparent;
  color: var(--text);
  border: 1px solid var(--border-soft);
}

.btn.ghost:hover {
  background-color: var(--panel-alt);
  border-color: var(--muted);
}

.btn.danger {
  background-color: transparent;
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn.danger:hover {
  background-color: rgba(239, 68, 68, 0.1);
  border-color: var(--danger);
}

.btn.small {
  padding: 8px 14px;
  font-size: 0.85rem;
}

.drop-zone {
  position: relative;
  border: 2px dashed var(--border-soft);
  border-radius: 12px;
  padding: 40px;
  text-align: center;
  background: var(--panel-alt);
  transition: all 0.2s ease;
  cursor: pointer;
  min-height: 240px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.drop-zone input {
  opacity: 0;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.drop-zone:hover,
.drop-zone.is-dragging {
  border-color: var(--accent);
  background: rgba(59, 130, 246, 0.05);
}

.drop-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.drop-sub {
  color: var(--muted);
  font-size: 0.9rem;
}

.files-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.meta {
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 500;
}

.filters {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.search {
  flex: 1;
  min-width: 200px;
}

.search input {
  width: 100%;
}

.filter-group {
  display: flex;
  gap: 12px;
}

.filter-group select {
  cursor: pointer;
}

.storage {
  margin-bottom: 32px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--panel);
}

.storage-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.875rem;
  color: var(--muted);
  font-weight: 500;
  margin-bottom: 12px;
}

.storage-track {
  width: 100%;
  height: 8px;
  border-radius: 4px;
  background: var(--border-soft);
  overflow: hidden;
}

.storage-fill {
  height: 100%;
  background-color: var(--accent-hover);
  border-radius: 4px;
}

.file-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.file-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 20px;
  background: var(--panel);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  transition: background-color 0.2s ease-in-out;
}

.file-card:hover {
  background-color: var(--panel-alt);
}

.file-main {
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 16px;
}

.file-preview {
  margin: 0;
  width: 60px;
  height: 60px;
  background: var(--bg);
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
  background: linear-gradient(90deg, var(--bg) 25%, var(--panel-alt) 50%, var(--bg) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

.file-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity 0.3s ease-in;
}

.file-preview img.is-loaded {
  opacity: 1;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border-soft);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 16px;
}

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

#loading-indicator p {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0;
}

.btn.icon-btn {
  padding: 8px;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.settings-wrapper {
  position: relative;
}

.settings-popup {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 12px;
  width: 300px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
  z-index: 50;
  padding: 16px;
  transform-origin: top right;
  animation: popupIn 0.2s ease-out;
}

.settings-header {
  font-weight: 600;
  border-bottom: 1px solid var(--border-soft);
  padding-bottom: 12px;
  margin-bottom: 12px;
  font-size: 1.1rem;
}

@keyframes popupIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

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

.file-name {
  font-weight: 600;
  font-size: 1rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-meta {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 2px;
}

.file-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.hint {
  color: var(--muted);
  margin-top: 12px;
  font-size: 0.875rem;
}

.hint.error {
  color: var(--danger);
}

.note {
  color: var(--muted);
  margin-top: 24px;
  font-size: 0.9rem;
  line-height: 1.6;
}

.empty {
  color: var(--muted);
  padding: 40px;
  text-align: center;
  border-radius: 12px;
  border: 2px dashed var(--border-soft);
  background: var(--panel-alt);
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}

.modal.is-open {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
}

.modal-card {
  position: relative;
  width: min(440px, 90vw);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
}

.modal-card h3 {
  margin: 0 0 12px;
  font-size: 1.25rem;
  color: var(--text);
}

.modal-text {
  color: var(--muted);
  margin: 0 0 24px;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

@media (max-width: 650px) {
  .shell {
    padding: 20px 16px;
  }

  .panel {
    padding: 20px;
  }

  .drop-zone {
    padding: 24px 20px;
    min-height: 200px;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 24px;
  }

  .actions {
    width: 100%;
  }

  .actions .btn {
    flex: 1;
  }

  .file-card {
    flex-direction: column;
    align-items: flex-start;
  }

  .file-actions {
    width: 100%;
    margin-top: 12px;
  }

  .file-actions .btn {
    flex: 1;
  }

  .filters {
    flex-direction: column;
  }

  .filter-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .modal-actions {
    flex-direction: column;
  }

  .modal-actions .btn {
    width: 100%;
  }
}

.setup-config {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  padding: 16px;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.file-card.appearing {
  opacity: 0;
  animation: fadeInUp 0.5s ease forwards;
  animation-delay: calc(var(--i) * 0.07s);
}