:root {
  --bg: #0b1020;
  --surface: rgba(18, 24, 48, 0.85);
  --surface-2: rgba(28, 36, 68, 0.9);
  --border: rgba(120, 140, 220, 0.22);
  --text: #e8ecff;
  --muted: #9aa8d8;
  --accent: #5b8cff;
  --accent-2: #7c5cff;
  --success: #3dd68c;
  --danger: #ff6b8a;
  --radius: 14px;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: radial-gradient(ellipse at top, #141b38 0%, var(--bg) 55%);
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(91, 140, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(91, 140, 255, 0.04) 1px, transparent 1px);
  background-size: 32px 32px;
  pointer-events: none;
}

.app {
  position: relative;
  max-width: 920px;
  margin: 0 auto;
  padding: 28px 20px 48px;
}

.header {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
}

.brand-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  font-size: 22px;
  box-shadow: var(--shadow);
}

h1 {
  margin: 0;
  font-size: 1.6rem;
  letter-spacing: -0.02em;
}

h2 {
  margin: 0 0 8px;
  font-size: 1.1rem;
}

.subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.server-info {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.5;
}

.server-info a {
  color: var(--accent);
  text-decoration: none;
}

.server-info a:hover {
  text-decoration: underline;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.tab {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-size: 0.95rem;
  cursor: pointer;
  transition: 0.2s ease;
}

.tab:hover {
  color: var(--text);
  border-color: rgba(91, 140, 255, 0.45);
}

.tab.active {
  color: var(--text);
  background: linear-gradient(135deg, rgba(91, 140, 255, 0.18), rgba(124, 92, 255, 0.18));
  border-color: rgba(91, 140, 255, 0.55);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
}

.hint-card p,
.hint {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.hidden {
  display: none !important;
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin-top: 14px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--muted);
  flex: 1;
  min-width: 140px;
}

input[type="text"],
input[type="password"],
input[type="number"] {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.95rem;
}

input:focus {
  outline: 2px solid rgba(91, 140, 255, 0.45);
  border-color: transparent;
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: 0.15s ease;
}

.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  font-weight: 600;
}

.btn.primary:hover {
  filter: brightness(1.08);
}

.btn.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
}

.btn.ghost:hover {
  color: var(--text);
}

.btn.small {
  padding: 6px 10px;
  font-size: 0.82rem;
}

.btn.danger {
  background: rgba(255, 107, 138, 0.15);
  color: var(--danger);
  border: 1px solid rgba(255, 107, 138, 0.35);
}

.status {
  min-height: 1.2em;
  margin: 10px 0 0;
  font-size: 0.88rem;
}

.status.ok {
  color: var(--success);
}

.status.err {
  color: var(--danger);
}

.upload-header,
.files-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.ttl-label {
  flex: 0 0 auto;
  min-width: 120px;
}

.dropzone {
  border: 2px dashed rgba(91, 140, 255, 0.35);
  border-radius: 12px;
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
  transition: 0.2s ease;
}

.dropzone.dragover {
  border-color: var(--accent);
  background: rgba(91, 140, 255, 0.08);
  color: var(--text);
}

.dropzone-hint {
  font-size: 0.82rem;
  margin-top: 8px;
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font-size: inherit;
  text-decoration: underline;
}

.upload-progress {
  margin-top: 12px;
}

.paste-zone {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.paste-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.paste-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

.paste-filename-label {
  flex: 1;
  min-width: 160px;
  max-width: 280px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.78rem;
  color: var(--muted);
}

.paste-filename-label input {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.88rem;
}

.paste-textarea {
  width: 100%;
  min-height: 88px;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.88rem;
  line-height: 1.5;
  resize: vertical;
}

.paste-textarea:focus {
  outline: 2px solid rgba(91, 140, 255, 0.45);
  border-color: transparent;
}

.paste-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.paste-hint {
  font-size: 0.82rem;
  color: var(--muted);
}

.paste-hint.ok {
  color: var(--success);
}

.paste-hint.err {
  color: var(--danger);
}

.bar {
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.2s ease;
}

#progressText {
  display: block;
  margin-top: 6px;
  font-size: 0.82rem;
  color: var(--muted);
}

.file-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.file-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.file-item:last-child {
  border-bottom: none;
}

.file-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
}

.file-thumb-wrap {
  flex: 0 0 auto;
}

.file-thumb-btn {
  display: block;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  cursor: pointer;
  overflow: hidden;
  width: 72px;
  height: 72px;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.file-thumb-btn:hover {
  border-color: rgba(91, 140, 255, 0.55);
  transform: scale(1.02);
}

.file-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.file-name {
  display: block;
  font-weight: 600;
  word-break: break-all;
}

.file-name.previewable {
  color: var(--accent);
  cursor: pointer;
}

.file-name.previewable:hover {
  text-decoration: underline;
}

.file-sub {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 2px;
}

.file-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.file-ttl {
  font-size: 0.8rem;
  color: var(--success);
  min-width: 72px;
  text-align: right;
}

.file-ttl:has(+ .admin-btns),
.admin-actions .file-ttl {
  min-width: auto;
  margin-bottom: 6px;
  display: block;
  text-align: left;
}

.admin-tab.active {
  background: linear-gradient(135deg, rgba(255, 180, 80, 0.2), rgba(255, 107, 138, 0.18));
  border-color: rgba(255, 180, 80, 0.5);
}

.admin-badge {
  color: #ffc266;
  font-weight: 600;
}

.admin-hint p {
  margin: 0;
}

.room-badge {
  display: inline-block;
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 999px;
  margin-bottom: 4px;
  background: rgba(91, 140, 255, 0.18);
  color: #a8c0ff;
  border: 1px solid rgba(91, 140, 255, 0.35);
}

.room-badge.private {
  background: rgba(124, 92, 255, 0.18);
  color: #c9b8ff;
  border-color: rgba(124, 92, 255, 0.35);
}

.admin-file-item.expired {
  opacity: 0.55;
}

.admin-file-item.expired .file-ttl {
  color: var(--danger);
}

.admin-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.admin-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 24px 0 8px;
  margin: 0;
}

.empty.hidden {
  display: none;
}

.loading-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 6px;
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 1; }
}

.preview-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(5, 8, 18, 0.82);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  padding: 20px;
}

.preview-panel {
  width: min(960px, 100%);
  max-height: min(90vh, 900px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.preview-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.preview-copy-btn {
  background: rgba(91, 140, 255, 0.15);
  border: 1px solid rgba(91, 140, 255, 0.4);
  color: var(--accent);
}

.preview-header h3 {
  margin: 0;
  font-size: 1rem;
  word-break: break-all;
}

.preview-close {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.preview-close:hover {
  background: rgba(255, 107, 138, 0.2);
}

.preview-body {
  overflow: auto;
  padding: 16px 18px 20px;
}

.preview-body img {
  display: block;
  max-width: 100%;
  max-height: calc(90vh - 120px);
  margin: 0 auto;
  border-radius: 8px;
}

.preview-body pre {
  margin: 0;
  padding: 14px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.06);
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.85rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  color: #dbe4ff;
}

.preview-loading,
.preview-error {
  text-align: center;
  color: var(--muted);
  padding: 40px 12px;
}

@media (max-width: 600px) {
  .form-row {
    flex-direction: column;
    align-items: stretch;
  }

  .file-item {
    flex-direction: row;
  }

  .file-body {
    flex-direction: column;
  }

  .file-actions {
    width: 100%;
    justify-content: flex-end;
  }
}
