:root {
  color-scheme: dark;
  --bg: #0f1115;
  --surface: #171a21;
  --border: #2a3040;
  --text: #e8eaed;
  --muted: #9aa3b2;
  --accent: #5865f2;
  --accent-hover: #4752c4;
  --danger: #c94c4c;
  --success-bg: #13261a;
  --error-bg: #2a1414;
  --radius: 10px;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, Ubuntu, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body.page {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: radial-gradient(1200px 600px at 20% -10%, #1a2030 0%, var(--bg) 55%);
  color: var(--text);
  line-height: 1.5;
}

a {
  color: #a8b7ff;
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

.container {
  width: min(1100px, 92vw);
  margin: 0 auto;
  padding: 1.5rem 0 3rem;
}

.container.narrow {
  width: min(560px, 92vw);
}

.site-header {
  border-bottom: 1px solid var(--border);
  background: rgba(15, 17, 21, 0.85);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  width: min(1100px, 92vw);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0;
  gap: 1rem;
}

.brand {
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text);
  text-decoration: none;
}
.brand:hover {
  color: #fff;
  text-decoration: none;
}

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

.nav-user {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.nav-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.inline-form {
  display: inline;
  margin: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.45rem 0.9rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover {
  filter: brightness(1.08);
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-discord {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
  padding: 0.65rem 1.25rem;
  font-size: 1rem;
}

.btn-ghost {
  background: transparent;
}

.btn-small {
  font-size: 0.8rem;
  padding: 0.25rem 0.55rem;
}

.btn-danger {
  border-color: #5c2a2a;
  color: #ffb4b4;
  background: #241313;
}

.hero h1 {
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  margin: 0 0 0.5rem;
}

.lede {
  color: var(--muted);
  max-width: 42rem;
}

.hero-actions {
  margin: 1.5rem 0 0.75rem;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.875rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
}

.card.denied h1 {
  margin-top: 0;
}

.welcome {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.welcome h1 {
  margin: 0;
  font-size: 1.5rem;
}

.avatar {
  border-radius: 50%;
  border: 1px solid var(--border);
  object-fit: cover;
  flex-shrink: 0;
  background: var(--surface);
}

.avatar-lg {
  width: 56px;
  height: 56px;
}

.banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.75rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  border: 1px solid var(--border);
}

.banner.success {
  background: var(--success-bg);
  border-color: #2f5c40;
}

.banner.error {
  background: var(--error-bg);
  border-color: #6b3030;
}

.url-chip,
.url-text {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
  word-break: break-all;
}

.upload-card h2 {
  margin-top: 0;
}

.upload-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.drop-zone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 140px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  cursor: pointer;
  background: rgba(0, 0, 0, 0.2);
  transition: border-color 0.15s, background 0.15s;
}

.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--accent);
  background: rgba(88, 101, 242, 0.08);
}

.drop-zone input[type='file'] {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.drop-label {
  color: var(--muted);
  text-align: center;
  pointer-events: none;
}

.drop-cta {
  color: #a8b7ff;
  text-decoration: underline;
}

.upload-advanced {
  margin-top: 0.25rem;
}

.upload-advanced summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.875rem;
  user-select: none;
}

.upload-advanced-body {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-top: 0.65rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
}

.field-label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.875rem;
}

.field-label input[type='text'],
.search-input {
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.meta-tags {
  flex-wrap: wrap;
  gap: 0.35rem;
}

.tag {
  font-size: 0.75rem;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
}

.meta-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.35rem;
}

.crumb-sep {
  color: var(--muted);
}

.crumb-current {
  color: var(--text);
}

.modal-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.modal-header-row h3 {
  margin: 0;
}

.share-modal {
  width: min(420px, 92vw);
}

.member-results {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.5rem 0;
  min-height: 0;
}

.member-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 160px;
  overflow-y: auto;
}

.member-list li {
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.gallery-section {
  margin-top: 2rem;
}

.gallery-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.gallery-head h2 {
  margin: 0;
}

.image-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}

.image-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.thumb-link {
  display: block;
  aspect-ratio: 16 / 10;
  background: #000;
}

.thumb-link img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.meta {
  padding: 0.65rem 0.75rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.meta-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.filename {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.9rem;
}

.url-row {
  flex-wrap: wrap;
}

.delete-form {
  margin-top: 0.25rem;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.dashboard-page {
  width: min(1200px, 94vw);
  margin: 0 auto;
  padding: 1.25rem 0 3rem;
  display: grid;
  grid-template-columns: minmax(220px, 260px) 1fr;
  gap: 1.25rem;
  align-items: start;
}

@media (max-width: 860px) {
  .dashboard-page {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }
}

.sidebar {
  position: sticky;
  top: 4.5rem;
}

.dashboard-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem 1.5rem;
  padding: 1rem 1.25rem;
}

.page-header-user {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.page-header h1 {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.2;
}

.page-header-user strong {
  color: var(--text);
  font-weight: 600;
}

.storage-inline {
  min-width: 200px;
  max-width: 280px;
  flex: 1;
}

.storage-numbers {
  display: block;
  font-size: 0.85rem;
  margin: 0.15rem 0 0.35rem;
}

.btn-block {
  width: 100%;
  margin-top: 0.5rem;
}

.sidebar-title {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

.folder-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 1rem;
}

.folder-link {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 0.35rem 0.5rem;
  padding: 0.45rem 0.55rem;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
}

.folder-icon {
  opacity: 0.7;
  font-size: 0.85rem;
}

.folder-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.folder-count {
  font-size: 0.75rem;
  color: var(--muted);
  min-width: 1.25rem;
  text-align: right;
}

.folder-link:hover,
.folder-link.active {
  background: rgba(88, 101, 242, 0.15);
  text-decoration: none;
}

.badge {
  font-size: 0.65rem;
  text-transform: uppercase;
  background: rgba(88, 101, 242, 0.25);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

.folder-create {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.folder-create input[type='text'] {
  flex: 1;
  min-width: 120px;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.storage-bar {
  margin-bottom: 1rem;
}

.storage-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.35rem;
}

.welcome {
  display: none;
}

.progress-track {
  height: 8px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.2s;
}

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.upload-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.upload-options input[type='text'] {
  width: 100%;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.upload-queue {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.queue-item {
  display: grid;
  grid-template-columns: 1fr 120px auto;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.85rem;
}

.toast-root {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  padding: 0.65rem 1rem;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.toast-success {
  border-color: #2f5c40;
}

.toast-error {
  border-color: #6b3030;
}

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-root.hidden {
  display: none;
}

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

.modal {
  position: relative;
  z-index: 1;
  width: min(400px, 92vw);
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 1rem;
}

.share-panel.hidden {
  display: none;
}

.admin-nav {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

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

.stat-grid strong {
  display: block;
  font-size: 1.25rem;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.search-form {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.search-form input {
  flex: 1;
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.activity-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.empty-state {
  padding: 2rem;
  text-align: center;
}

.maintenance-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 480px;
}

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

.filter-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.audit-filters select {
  width: 100%;
  padding: 0.4rem 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.quota-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.35rem;
}

.quota-input {
  width: 4.5rem;
  padding: 0.25rem 0.4rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.admin-actions-cell {
  min-width: 200px;
}

.badge-warn {
  background: rgba(254, 231, 117, 0.2);
  color: #fee75c;
}

.badge-warn-inline {
  color: #fee75c;
  font-size: 0.8rem;
}

.image-card.is-disabled {
  opacity: 0.75;
  border-color: #6b5a20;
}

.report-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.report-item .report-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.scope-fieldset {
  border: none;
  padding: 0;
  margin: 0.5rem 0;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.api-key-list {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
}

.api-key-list li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.api-key-form {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

html[data-theme='light'] {
  color-scheme: light;
  --bg: #f4f5f7;
  --surface: #fff;
  --border: #d8dce3;
  --text: #1a1d23;
  --muted: #5c6573;
  --accent: #5865f2;
  --accent-hover: #4752c4;
  --success-bg: #e8f5ec;
  --error-bg: #fdeaea;
}
