:root {
  --bg: #0f1116;
  --bg-soft: #191d26;
  --panel: rgba(20, 23, 31, 0.86);
  --panel-soft: rgba(245, 235, 218, 0.08);
  --border: rgba(226, 179, 60, 0.2);
  --border-strong: rgba(226, 179, 60, 0.42);
  --text: #f6f0e7;
  --muted: #c5b9a9;
  --gold: #e2b33c;
  --gold-deep: #b88619;
  --danger: #ff7b72;
  --success: #59d499;
  --warning: #f5c96c;
  --shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
html { font-size: 16px; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(226, 179, 60, 0.14), transparent 32%),
    radial-gradient(circle at top right, rgba(88, 112, 255, 0.14), transparent 28%),
    linear-gradient(180deg, #11141b 0%, #090b10 100%);
}

body.modal-open { overflow: hidden; }

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; }

.shell {
  width: min(1480px, calc(100% - 1.2rem));
  margin: 0 auto;
  padding: 0 0.6rem;
}

@media (min-width: 1024px) {
  .shell { padding: 0 0.4rem; }
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem 0.8rem;
}

.login-card,
.panel,
.modal-stage,
.user-row {
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}

.login-card {
  width: min(460px, 100%);
  padding: 1.8rem;
  border-radius: 1.3rem;
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-mark img {
  width: 52px;
  height: 52px;
  border-radius: 0.9rem;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.eyebrow {
  margin: 0 0 0.15rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.72rem;
  color: var(--gold);
}

h1, h2, h3, h4 {
  margin: 0;
  font-family: "Fraunces", serif;
  letter-spacing: -0.03em;
}

h1 { font-size: clamp(1.4rem, 3vw, 1.9rem); }
h2 { font-size: clamp(1.3rem, 2.5vw, 1.8rem); }
h3 { font-size: 1.15rem; }
h4 { font-size: 1rem; }

.lead {
  color: var(--muted);
  line-height: 1.6;
  margin: 0.5rem 0 0;
}

.form-stack {
  display: grid;
  gap: 0.9rem;
  margin-top: 1rem;
}

.form-stack label {
  display: grid;
  gap: 0.35rem;
}

.form-stack span {
  font-size: 0.85rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}

input, select, textarea {
  width: 100%;
  padding: 0.75rem 0.85rem;
  border-radius: 0.8rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(6, 9, 14, 0.7);
  color: var(--text);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--border-strong);
  box-shadow: 0 0 0 0.15rem rgba(226, 179, 60, 0.12);
}

textarea { resize: vertical; min-height: 100px; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  border: 0;
  border-radius: 999px;
  padding: 0.7rem 1.05rem;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
  font-weight: 500;
}

.button:hover { transform: translateY(-1px); }

.button.primary {
  color: #211400;
  background: linear-gradient(135deg, #f2c861 0%, #d8a72f 100%);
  box-shadow: 0 10px 24px rgba(226, 179, 60, 0.22);
}

.button.secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.button.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.button.ghost.danger { color: var(--danger); border-color: rgba(255, 123, 114, 0.35); }
.button.ghost.danger:hover { background: rgba(255, 123, 114, 0.12); }

.button.primary.danger {
  color: #fff;
  background: linear-gradient(135deg, #ff6b6b 0%, #c63838 100%);
  box-shadow: 0 10px 24px rgba(255, 107, 107, 0.28);
}

.button.small {
  padding: 0.5rem 0.8rem;
  font-size: 0.82rem;
}

.help-text { color: var(--muted); font-size: 0.82rem; margin: 0.35rem 0 0; }

.flash {
  margin: 0.8rem 0;
  padding: 0.8rem 0.95rem;
  border-radius: 0.9rem;
  border: 1px solid transparent;
  font-size: 0.92rem;
}

.flash-success { background: rgba(89, 212, 153, 0.12); border-color: rgba(89, 212, 153, 0.35); }
.flash-error { background: rgba(255, 123, 114, 0.12); border-color: rgba(255, 123, 114, 0.35); }
.flash-warning { background: rgba(245, 201, 108, 0.12); border-color: rgba(245, 201, 108, 0.35); }

.app-shell, .public-shell { padding: 1rem 0 3rem; }

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  align-items: center;
  margin-bottom: 0.8rem;
  flex-wrap: wrap;
}

.topbar-nav {
  display: flex;
  gap: 0.45rem;
  align-items: center;
  flex-wrap: wrap;
}

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

.user-chip {
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  background: rgba(226, 179, 60, 0.14);
  color: var(--gold);
  font-size: 0.82rem;
}

.panel {
  border-radius: 1.1rem;
  padding: 1rem 1.1rem;
}

.panel.compact { padding: 0.85rem 1rem; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.8rem;
}

.stack-form {
  display: grid;
  gap: 0.5rem;
}

.form-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(160px, 1fr) minmax(200px, 1.4fr) auto;
  gap: 0.7rem;
  align-items: end;
}

.field { display: grid; gap: 0.3rem; }
.field span { color: var(--muted); font-size: 0.8rem; letter-spacing: 0.02em; }
.submit-cell { align-self: end; }

.submit-cell .button { width: 100%; }

@media (max-width: 900px) {
  .form-row { grid-template-columns: 1fr; }
}

.drop-zone {
  margin-top: 0.6rem;
  padding: 1rem 1rem 0.8rem;
  border-radius: 1rem;
  border: 1px dashed rgba(226, 179, 60, 0.35);
  background: rgba(226, 179, 60, 0.04);
  display: grid;
  gap: 0.6rem;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease;
}

.drop-zone.is-dragging {
  background: rgba(226, 179, 60, 0.14);
  border-color: var(--gold);
}

.drop-zone-hint {
  display: grid;
  gap: 0.15rem;
  text-align: center;
  color: var(--muted);
  pointer-events: none;
}

.drop-zone-hint strong { color: var(--text); font-size: 0.95rem; }
.drop-zone-hint span { font-size: 0.8rem; }

.drop-zone-actions {
  display: flex;
  gap: 0.4rem;
  justify-content: center;
  flex-wrap: wrap;
}

.drop-zone-thumbs {
  margin: 0.3rem 0 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, 88px);
  justify-content: start;
  gap: 0.4rem;
  max-height: 260px;
  overflow-y: auto;
  padding: 0.1rem;
}

.dz-thumb {
  position: relative;
  width: 88px;
  height: 88px;
  border-radius: 0.55rem;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.dz-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.dz-thumb-name {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 0.25rem 0.4rem;
  font-size: 0.68rem;
  color: var(--text);
  background: linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,0.75) 100%);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dz-thumb-remove {
  position: absolute;
  top: 0.25rem;
  right: 0.25rem;
  width: 1.55rem;
  height: 1.55rem;
  border-radius: 999px;
  border: 0;
  background: rgba(0, 0, 0, 0.65);
  color: var(--text);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.dz-thumb-remove:hover { background: var(--danger); color: #fff; }

/* Folder tiles (default gallery view) — compact, Drive-like */
.folder-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, 200px);
  justify-content: start;
  gap: 0.8rem;
  margin-top: 0.3rem;
}

.folder-card {
  position: relative;
  display: flex;
  flex-direction: column;
  border-radius: 0.9rem;
  overflow: hidden;
  background: rgba(8, 12, 18, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: inherit;
  transition: transform 160ms ease, border-color 160ms ease;
}

.folder-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
}

.folder-card-link {
  display: flex;
  flex-direction: column;
  color: inherit;
  text-decoration: none;
}

.folder-card-actions {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  display: flex;
  gap: 0.3rem;
  z-index: 2;
  opacity: 0;
  transition: opacity 160ms ease;
}

.folder-card:hover .folder-card-actions,
.folder-card:focus-within .folder-card-actions { opacity: 1; }

.folder-action-btn {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 999px;
  border: 0;
  background: rgba(0, 0, 0, 0.6);
  color: var(--text);
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  display: grid;
  place-items: center;
  transition: background 160ms ease, color 160ms ease;
}

.folder-action-btn:hover { background: var(--gold); color: #201200; }
.folder-action-btn.danger:hover { background: var(--danger); color: #fff; }

.folder-cover {
  position: relative;
  aspect-ratio: 1 / 1;
  background: #0a0d12;
  overflow: hidden;
}

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

.folder-cover-empty {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  background: linear-gradient(135deg, rgba(226,179,60,0.08), rgba(88,112,255,0.08));
}

.folder-count {
  position: absolute;
  bottom: 0.5rem;
  left: 0.5rem;
  padding: 0.16rem 0.5rem;
  background: rgba(0, 0, 0, 0.65);
  color: var(--text);
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
}

.folder-meta {
  padding: 0.55rem 0.7rem 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.folder-meta h4 {
  font-size: 0.9rem;
  font-family: "Space Grotesk", sans-serif;
  letter-spacing: 0;
  word-break: break-word;
}

.folder-meta .meta-line { font-size: 0.72rem; }

.folder-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  padding: 0.7rem 0.2rem;
  margin: 0.8rem 0;
  overflow-x: auto;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.48rem 0.82rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.86rem;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}

.tag span {
  font-size: 0.76rem;
  opacity: 0.8;
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.25);
}

.tag.active {
  color: #201200;
  background: linear-gradient(135deg, #f2c861, #d7a229);
  border-color: transparent;
}

.tag.active span { background: rgba(0, 0, 0, 0.18); color: #201200; }

.tag.ghost {
  color: var(--text);
  border: 1px solid rgba(226, 179, 60, 0.3);
  background: transparent;
}

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

.gallery-grid {
  display: grid;
  gap: 0.55rem;
  grid-template-columns: repeat(auto-fill, 180px);
  justify-content: start;
}

.gallery-grid.tiles {
  grid-template-columns: repeat(auto-fill, 180px);
}

@media (max-width: 600px) {
  .gallery-grid.tiles { grid-template-columns: repeat(auto-fill, minmax(140px, 160px)); }
}

.image-tile {
  position: relative;
  width: 180px;
  height: 180px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0.75rem;
  background: #0a0d12;
  cursor: pointer;
  overflow: hidden;
  transition: transform 160ms ease, border-color 160ms ease;
}

.image-tile:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
}

.image-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-date {
  position: absolute;
  bottom: 0.35rem;
  left: 0.35rem;
  padding: 0.14rem 0.5rem;
  background: rgba(0, 0, 0, 0.65);
  color: var(--text);
  border-radius: 999px;
  font-size: 0.68rem;
  letter-spacing: 0.03em;
}

.meta-line {
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
}

.empty-state {
  padding: 2rem 1rem;
  border-radius: 1rem;
  border: 1px dashed rgba(255, 255, 255, 0.16);
  text-align: center;
  color: var(--muted);
}

.empty-state.compact { padding: 1rem; }

/* Modal */
.modal[hidden] { display: none; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
}

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

.modal-stage {
  position: relative;
  z-index: 1;
  width: min(1040px, calc(100vw - 1.5rem));
  max-height: calc(100vh - 1.5rem);
  padding: 0.8rem;
  border-radius: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.modal-main {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 200px;
  flex: 1 1 auto;
  overflow: hidden;
}

.modal-main img {
  max-width: 100%;
  max-height: calc(100vh - 9rem);
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 0.7rem;
  background: #090c10;
  display: block;
  margin: 0 auto;
}

.modal-close {
  position: absolute;
  top: 0.5rem;
  right: 0.6rem;
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.6);
  border: 0;
  color: var(--text);
  font-size: 1.1rem;
  cursor: pointer;
  line-height: 1;
  z-index: 2;
}

.modal-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 1.1rem;
  cursor: pointer;
  z-index: 2;
}

.modal-nav:hover { background: var(--gold); color: #201200; border-color: transparent; }

.modal-nav.prev { left: 0.5rem; }
.modal-nav.next { right: 0.5rem; }

.modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.modal-info {
  display: grid;
  gap: 0.12rem;
  min-width: 0;
}

.modal-info strong { font-size: 0.95rem; word-break: break-word; }
.modal-info span { color: var(--muted); font-size: 0.78rem; }

.modal-actions {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  align-items: center;
}

.modal-actions .inline-form { display: inline-flex; }

/* Confirm modal */
.confirm-modal .confirm-stage {
  position: relative;
  z-index: 1;
  width: min(440px, calc(100vw - 1.5rem));
  padding: 1.2rem 1.3rem;
  border-radius: 1rem;
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  display: grid;
  gap: 0.9rem;
}

.confirm-stage h3 {
  font-size: 1.1rem;
  font-family: "Space Grotesk", sans-serif;
  letter-spacing: 0;
  color: var(--text);
}

.confirm-stage p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 0.92rem;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* Share page — existing classes kept compatible */
.share-shell { padding: 1rem 0 3rem; }

.share-layout { display: grid; gap: 1rem; }

.share-header {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  align-items: center;
  flex-wrap: wrap;
}

.share-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.share-image-frame {
  border-radius: 1rem;
  overflow: hidden;
  background: rgba(4, 6, 10, 0.92);
}

.share-image-frame img {
  width: 100%;
  max-height: 78vh;
  object-fit: contain;
}

.share-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.6rem;
  margin-top: 0.8rem;
}

.meta-chip {
  padding: 0.7rem;
  border-radius: 0.9rem;
  background: var(--panel-soft);
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.meta-chip span {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.meta-chip strong { font-size: 0.92rem; }

.comment-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 900px) { .comment-grid { grid-template-columns: 1fr; } }

.comment-list { display: grid; gap: 0.6rem; }

.comment-card {
  padding: 0.8rem;
  border-radius: 0.9rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.07);
}

.comment-card-head {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.4rem;
  color: var(--muted);
  font-size: 0.82rem;
}

/* Admin page */
.admin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem;
  margin-bottom: 0.9rem;
}
@media (max-width: 900px) { .admin-grid { grid-template-columns: 1fr; } }

.user-list { display: grid; gap: 0.5rem; }

.user-row {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.8rem 0.95rem;
  border-radius: 0.8rem;
  align-items: center;
  flex-wrap: wrap;
}

.user-row-info { display: grid; gap: 0.15rem; }
.user-row-info strong { font-size: 0.98rem; }
.user-row-info span { color: var(--muted); font-size: 0.85rem; }
.user-row-info small { color: var(--muted); font-size: 0.75rem; }
.user-row-actions { display: flex; gap: 0.4rem; }
