:root {
  --bg: #0b0f14;
  --bg-accent: #101822;
  --surface: #151d28;
  --surface-2: #1c2736;
  --surface-3: #243044;
  --text: #eef2f7;
  --muted: #8fa3bb;
  --primary: #5b9cff;
  --primary-hover: #4a88eb;
  --primary-glow: rgba(91, 156, 255, 0.22);
  --danger: #ef6461;
  --danger-soft: rgba(239, 100, 97, 0.14);
  --success: #6ee7a8;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  --shadow-soft: 0 4px 18px rgba(0, 0, 0, 0.18);

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --duration-fast: 140ms;
  --duration-ui: 220ms;
  --duration-enter: 280ms;
}

* { box-sizing: border-box; }

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(91, 156, 255, 0.12), transparent),
    linear-gradient(180deg, var(--bg-accent) 0%, var(--bg) 100%);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

h1 {
  margin: 0 0 0.25rem;
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

h2 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.muted { color: var(--muted); }

.container {
  max-width: 920px;
  margin: 0 auto;
  padding: 1.25rem 1rem 2.5rem;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: rgba(11, 15, 20, 0.72);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.topbar .brand-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 10px rgba(110, 231, 168, 0.55);
  margin-right: 0.45rem;
  vertical-align: middle;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.auth-card,
.panel {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent), var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  padding: 1.35rem;
}

.auth-card {
  width: min(100%, 420px);
  animation: enter-up var(--duration-enter) var(--ease-out) both;
}

.auth-card label {
  font-size: 0.84rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  margin-bottom: -0.35rem;
}

.auth-card .stack label + input {
  margin-top: 0;
}

.auth-card input[type="text"],
.auth-card input[type="password"] {
  padding: 0.8rem 0.95rem;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0.015em;
  -webkit-appearance: none;
  appearance: none;
  touch-action: manipulation;
}

.auth-card input:-webkit-autofill,
.auth-card input:-webkit-autofill:hover,
.auth-card input:-webkit-autofill:focus,
.auth-card input:-webkit-autofill:active {
  box-shadow: 0 0 0 1000px var(--surface-2) inset !important;
  -webkit-box-shadow: 0 0 0 1000px var(--surface-2) inset !important;
}

.panel {
  margin-bottom: 1rem;
  animation: enter-up var(--duration-enter) var(--ease-out) both;
}

.panel:nth-of-type(2) { animation-delay: 60ms; }
.panel:nth-of-type(3) { animation-delay: 120ms; }

@keyframes enter-up {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.stack {
  display: grid;
  gap: 0.9rem;
}

.stack.compact { margin-top: 0.75rem; }

label {
  display: grid;
  gap: 0.4rem;
  font-size: 0.92rem;
  color: var(--muted);
}

input[type="text"],
input[type="password"],
textarea {
  width: 100%;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 0.72rem 0.9rem;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0.01em;
  transition:
    border-color var(--duration-ui) var(--ease-out),
    box-shadow var(--duration-ui) var(--ease-out),
    background-color var(--duration-ui) var(--ease-out);
}

input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
  -webkit-text-fill-color: var(--text) !important;
  caret-color: var(--text);
  box-shadow: 0 0 0 1000px var(--surface-2) inset !important;
  -webkit-box-shadow: 0 0 0 1000px var(--surface-2) inset !important;
  transition: background-color 9999s ease-out 0s;
}

input::placeholder,
textarea::placeholder {
  color: rgba(143, 163, 187, 0.65);
}

input:focus-visible,
textarea:focus-visible {
  outline: none;
  border-color: rgba(91, 156, 255, 0.55);
  box-shadow: 0 0 0 3px var(--primary-glow);
  background: var(--surface-3);
}

textarea { resize: vertical; min-height: 120px; }

.btn {
  border: 0;
  border-radius: var(--radius-sm);
  padding: 0.68rem 1rem;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  transition:
    transform var(--duration-fast) var(--ease-out),
    background-color var(--duration-ui) var(--ease-out),
    border-color var(--duration-ui) var(--ease-out),
    color var(--duration-ui) var(--ease-out),
    box-shadow var(--duration-ui) var(--ease-out);
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(180deg, #6aa8ff 0%, var(--primary) 100%);
  color: white;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.12) inset, 0 8px 20px rgba(91, 156, 255, 0.22);
}

@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover {
    background: linear-gradient(180deg, #7cb3ff 0%, var(--primary-hover) 100%);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.12) inset, 0 10px 24px rgba(91, 156, 255, 0.28);
  }
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border-strong);
}

@media (hover: hover) and (pointer: fine) {
  .btn-ghost:hover {
    color: var(--text);
    border-color: rgba(255, 255, 255, 0.22);
    background: rgba(255, 255, 255, 0.04);
  }
}

.btn-danger {
  background: var(--danger-soft);
  color: #ffb4b2;
  border: 1px solid rgba(239, 100, 97, 0.35);
}

@media (hover: hover) and (pointer: fine) {
  .btn-danger:hover {
    background: rgba(239, 100, 97, 0.22);
  }
}

.btn-small {
  padding: 0.42rem 0.72rem;
  font-size: 0.84rem;
}

.btn-success {
  background: rgba(110, 231, 168, 0.14);
  color: var(--success);
  border: 1px solid rgba(110, 231, 168, 0.35);
}

.btn-download {
  background: rgba(91, 156, 255, 0.08);
  color: #a8c4ef;
  border: 1px solid rgba(91, 156, 255, 0.22);
}

@media (hover: hover) and (pointer: fine) {
  .btn-download:hover {
    background: rgba(91, 156, 255, 0.14);
    color: #c2d8f8;
    border-color: rgba(91, 156, 255, 0.34);
  }
}

a.btn {
  color: inherit;
}

.tabs {
  display: flex;
  gap: 0.45rem;
  margin: 0 0 0.65rem;
  padding: 0.25rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 999px;
  width: fit-content;
}

.tab {
  color: var(--muted);
  text-decoration: none;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  border: 1px solid transparent;
  font-weight: 500;
  font-size: 0.92rem;
  transition:
    color var(--duration-ui) var(--ease-out),
    background-color var(--duration-ui) var(--ease-out),
    border-color var(--duration-ui) var(--ease-out);
}

.tab.active {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-soft);
}

.storage-card {
  display: grid;
  gap: 0.55rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  margin-bottom: 0.85rem;
}

.storage-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  font-size: 0.88rem;
  color: var(--muted);
}

.storage-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.storage-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), #7ecbff);
  transition: width var(--duration-enter) var(--ease-out);
}

.storage-fill.warn {
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.storage-fill.danger {
  background: linear-gradient(90deg, #ef6461, #f87171);
}

.cards {
  display: grid;
  gap: 0.75rem;
}

.card,
.file-row {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition:
    border-color var(--duration-ui) var(--ease-out),
    background-color var(--duration-ui) var(--ease-out);
}

.card {
  padding: 0.95rem;
  animation: enter-up var(--duration-enter) var(--ease-out) both;
}

.card:nth-child(1) { animation-delay: 40ms; }
.card:nth-child(2) { animation-delay: 80ms; }
.card:nth-child(3) { animation-delay: 120ms; }
.card:nth-child(4) { animation-delay: 160ms; }
.card:nth-child(n+5) { animation-delay: 200ms; }

@media (hover: hover) and (pointer: fine) {
  .card:hover,
  .file-row:hover {
    border-color: rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.02);
  }
}

.card-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: baseline;
  margin-bottom: 0.55rem;
}

.note-content {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0 0 0.8rem;
  font: inherit;
  color: var(--text);
  background: rgba(0, 0, 0, 0.18);
  padding: 0.75rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

.file-list { display: grid; gap: 0.65rem; }

.file-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 0.85rem;
  animation: enter-up var(--duration-enter) var(--ease-out) both;
}

.file-row:nth-child(1) { animation-delay: 40ms; }
.file-row:nth-child(2) { animation-delay: 80ms; }
.file-row:nth-child(3) { animation-delay: 120ms; }

.alert {
  padding: 0.75rem 0.85rem;
  border-radius: 8px;
  margin-bottom: 0.85rem;
  animation: enter-up var(--duration-enter) var(--ease-out) both;
}

.alert-error {
  background: rgba(239, 100, 97, 0.12);
  border: 1px solid rgba(239, 100, 97, 0.35);
  color: #ffcaca;
}

.alert-success {
  background: rgba(110, 231, 168, 0.12);
  border: 1px solid rgba(110, 231, 168, 0.35);
  color: #b8f5d8;
}

.is-hidden {
  display: none !important;
}

.upload-form {
  position: relative;
  gap: 0.85rem;
  overflow: hidden;
}

.file-input-hidden {
  position: absolute !important;
  left: -9999px !important;
  top: auto !important;
  width: 0 !important;
  height: 0 !important;
  opacity: 0 !important;
  visibility: hidden !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  pointer-events: none !important;
}

.file-drop {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 1.5rem 1.15rem;
  cursor: default;
  text-align: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.02);
  transition:
    border-color var(--duration-ui) var(--ease-out),
    background-color var(--duration-ui) var(--ease-out),
    box-shadow var(--duration-ui) var(--ease-out),
    transform var(--duration-fast) var(--ease-out);
}

.file-drop.is-dragover {
  border-color: rgba(91, 156, 255, 0.65);
  background: rgba(91, 156, 255, 0.08);
  color: var(--text);
  transform: scale(0.995);
  box-shadow: 0 0 0 3px rgba(91, 156, 255, 0.12);
}

.file-drop.has-file {
  border-style: solid;
  border-color: rgba(110, 231, 168, 0.35);
  background: rgba(110, 231, 168, 0.05);
  padding: 1rem;
  text-align: left;
}

.file-drop-visual {
  display: grid;
  gap: 0.45rem;
  justify-items: center;
}

.file-drop-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.file-drop-hint {
  margin: 0;
  font-size: 0.82rem;
}

.file-drop-limit {
  margin: 0.15rem 0 0;
  font-size: 0.78rem;
}

.file-drop-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 999px;
  background: rgba(91, 156, 255, 0.12);
  color: #9ec5ff;
  margin-bottom: 0.15rem;
}

.file-selected {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.file-selected-icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 12px;
  background: rgba(91, 156, 255, 0.14);
  color: #9ec5ff;
}

.file-selected-meta {
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  gap: 0.15rem;
}

.file-selected-meta strong {
  font-size: 0.95rem;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-selected-meta .muted {
  font-size: 0.82rem;
}

.upload-progress {
  display: grid;
  gap: 0.45rem;
}

.upload-progress-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.upload-progress-track {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.upload-progress-fill {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, #4d8fff, #6ee7a8);
  transition: width 120ms linear;
}

#upload-submit:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.empty {
  margin: 0.75rem 0 0;
  padding: 1.25rem;
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.02);
}

.view-tabs {
  margin-top: 0;
  margin-bottom: 1rem;
}

.tabs + .view-tabs {
  margin-top: 0.35rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  vertical-align: middle;
}

.badge-admin {
  background: rgba(91, 156, 255, 0.18);
  color: #9ec5ff;
  border: 1px solid rgba(91, 156, 255, 0.35);
}

.badge-user {
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  border: 1px solid var(--border);
}

.badge-shared {
  background: rgba(110, 231, 168, 0.12);
  color: var(--success);
  border: 1px solid rgba(110, 231, 168, 0.35);
  margin-bottom: 0.35rem;
}

.badge-share {
  background: rgba(91, 156, 255, 0.1);
  color: #a8caff;
  border: 1px solid rgba(91, 156, 255, 0.25);
}

.card-shared {
  border-color: rgba(110, 231, 168, 0.35);
  background: linear-gradient(180deg, rgba(110, 231, 168, 0.04), transparent), var(--surface-2);
}

.share-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.55rem;
}

.share-details summary,
.edit-details summary {
  list-style: none;
}

.share-details summary::-webkit-details-marker,
.edit-details summary::-webkit-details-marker {
  display: none;
}

.share-form {
  margin-top: 0.65rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.12);
}

.share-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text);
  font-size: 0.9rem;
}

.share-revoke-list {
  display: grid;
  gap: 0.45rem;
  margin-top: 0.65rem;
}

.share-revoke-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.45rem 0.55rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
}

.alert-success {
  background: rgba(110, 231, 168, 0.1);
  border: 1px solid rgba(110, 231, 168, 0.35);
  color: #b7f5d4;
}

.admin-form {
  max-width: 420px;
}

.admin-table-wrap {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.admin-table th,
.admin-table td {
  padding: 0.65rem 0.5rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.admin-table th {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.admin-table tbody tr {
  transition: background-color var(--duration-ui) var(--ease-out);
}

@media (hover: hover) and (pointer: fine) {
  .admin-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
  }
}

.edit-details summary { list-style: none; }
.edit-details summary::-webkit-details-marker { display: none; }

.edit-details[open] > summary {
  margin-bottom: 0.65rem;
}

.edit-details .stack.compact {
  animation: enter-up var(--duration-ui) var(--ease-out) both;
}

@media (max-width: 640px) {
  .file-row,
  .card-head,
  .topbar,
  .chat-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .chat-msg {
    max-width: 92%;
  }

  .tabs {
    width: 100%;
    justify-content: stretch;
  }

  .tab {
    flex: 1;
    text-align: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .btn:active {
    transform: none;
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.badge-chat-ip {
  background: rgba(91, 156, 255, 0.14);
  color: #9ec5ff;
  border: 1px solid rgba(91, 156, 255, 0.35);
  font-size: 0.78rem;
}

.chat-panel {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-height: min(70vh, 640px);
}

.chat-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.chat-header h2 {
  margin: 0 0 0.35rem;
}

.chat-subtitle {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.45;
  max-width: 42rem;
}

.chat-header-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
  flex-shrink: 0;
}

.chat-thread {
  flex: 1 1 auto;
  min-height: 280px;
  max-height: min(52vh, 480px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.18);
}

.chat-empty {
  margin: auto;
  text-align: center;
  max-width: 22rem;
  line-height: 1.5;
}

.chat-msg {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  max-width: 78%;
  animation: enter-up var(--duration-enter) var(--ease-out) both;
}

.chat-msg-mine {
  align-self: flex-end;
  align-items: flex-end;
}

.chat-msg-other {
  align-self: flex-start;
  align-items: flex-start;
}

.chat-msg-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.65rem;
  align-items: center;
  font-size: 0.74rem;
}

.chat-ip-label {
  font-weight: 600;
  color: var(--muted);
}

.chat-msg-mine .chat-ip-label {
  color: #9ec5ff;
}

.chat-msg-other .chat-ip-label {
  color: var(--success);
}

.chat-msg-body {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.35rem;
  max-width: 100%;
}

.chat-msg-other .chat-msg-body {
  align-items: flex-start;
}

.chat-copy-btn {
  flex-shrink: 0;
  font-size: 0.74rem;
  padding: 0.28rem 0.55rem;
}

.chat-bubble {
  padding: 0.72rem 0.9rem;
  border-radius: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.94rem;
}

.chat-msg-mine .chat-bubble {
  background: linear-gradient(180deg, rgba(91, 156, 255, 0.28), rgba(91, 156, 255, 0.18));
  border: 1px solid rgba(91, 156, 255, 0.35);
  border-bottom-right-radius: 4px;
}

.chat-msg-other .chat-bubble {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-strong);
  border-bottom-left-radius: 4px;
}

.chat-compose {
  display: grid;
  gap: 0.65rem;
}

.chat-compose-label {
  display: block;
}

.chat-compose textarea {
  min-height: 88px;
  resize: vertical;
}

.chat-compose-actions {
  display: flex;
  justify-content: flex-end;
}
