:root {
  --bg: #0a0a0b;
  --bg-elev: #131316;
  --ink: #f4f1ea;
  --ink-dim: #a9a49b;
  --ink-faint: #55524c;
  --accent: #e8b04b;
  --accent-soft: rgba(232, 176, 75, 0.14);
  --danger: #e5484d;
  --line: rgba(244, 241, 234, 0.12);
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Manrope", "Segoe UI", sans-serif;
  --font-mono: "Space Mono", ui-monospace, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

::selection {
  background: var(--accent);
  color: #0a0a0b;
}

button {
  font-family: inherit;
  color: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

/* ==================== CAROUSEL ==================== */

.carousel {
  position: fixed;
  inset: 0;
  background: #000;
}

.slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  transform: scale(1.06);
  transition: opacity 1.1s var(--ease), transform 1.4s var(--ease);
  will-change: opacity, transform;
  pointer-events: none;
}

.slide.is-active {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
  z-index: 1;
}

.slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

.slide::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to top,
    rgba(0, 0, 0, 0.78) 0%,
    rgba(0, 0, 0, 0.25) 38%,
    rgba(0, 0, 0, 0) 62%
  );
  pointer-events: none;
}

.slide-caption {
  position: absolute;
  left: clamp(1.5rem, 5vw, 5rem);
  bottom: clamp(6rem, 14vh, 11rem);
  right: clamp(1.5rem, 5vw, 5rem);
  max-width: 62rem;
  z-index: 3;
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.9s var(--ease) 0.35s, transform 0.9s var(--ease) 0.35s;
}

.slide.is-active .slide-caption {
  opacity: 1;
  transform: translateY(0);
}

.slide-index {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.42em;
  text-transform: uppercase;
  color: var(--accent);
  display: block;
  margin-bottom: 1.1rem;
}

.slide-title {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: clamp(1.9rem, 5.4vw, 4.6rem);
  line-height: 1.02;
  letter-spacing: -0.02em;
  text-wrap: balance;
  text-shadow: 0 2px 40px rgba(0, 0, 0, 0.55);
}

/* Progress bar */
.progress {
  position: absolute;
  top: 0;
  left: 0;
  height: 3px;
  width: 100%;
  z-index: 6;
  background: rgba(244, 241, 234, 0.14);
}

.progress__fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  box-shadow: 0 0 14px var(--accent);
}

/* Controls */
.controls {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

.nav-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(10, 10, 11, 0.28);
  backdrop-filter: blur(10px);
  display: grid;
  place-items: center;
  pointer-events: auto;
  opacity: 0;
  transition: opacity 0.4s var(--ease), background 0.3s, border-color 0.3s,
    transform 0.3s var(--ease);
}

.carousel:hover .nav-arrow {
  opacity: 1;
}

.nav-arrow:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #0a0a0b;
}

.nav-arrow:active {
  transform: translateY(-50%) scale(0.92);
}

.nav-arrow svg {
  width: 20px;
  height: 20px;
}

.nav-arrow--prev {
  left: clamp(1rem, 3vw, 2.4rem);
}

.nav-arrow--next {
  right: clamp(1rem, 3vw, 2.4rem);
}

.nav-arrow--prev:hover {
  transform: translateY(-50%) translateX(-3px);
}

.nav-arrow--next:hover {
  transform: translateY(-50%) translateX(3px);
}

/* Dots */
.dots {
  position: absolute;
  bottom: clamp(1.6rem, 4vh, 2.6rem);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0.7rem;
  pointer-events: auto;
  z-index: 5;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: rgba(244, 241, 234, 0.34);
  transition: all 0.4s var(--ease);
}

.dot:hover {
  background: rgba(244, 241, 234, 0.7);
}

.dot.is-active {
  background: var(--accent);
  width: 30px;
  border-radius: 999px;
}

/* Empty state */
.empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  gap: 1.2rem;
  padding: 2rem;
}

.empty__title {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 4vw, 3rem);
  font-weight: 300;
}

.empty__text {
  color: var(--ink-dim);
  font-size: 0.95rem;
  max-width: 34ch;
  margin: 0 auto;
  line-height: 1.6;
}

.empty__link {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  text-decoration: none;
  border-bottom: 1px solid var(--accent-soft);
  padding-bottom: 0.3rem;
  transition: border-color 0.3s;
}

.empty__link:hover {
  border-color: var(--accent);
}

/* Admin link floating */
.admin-link {
  position: fixed;
  top: 1.4rem;
  right: 1.6rem;
  z-index: 20;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--ink-dim);
  text-decoration: none;
  opacity: 0;
  transition: opacity 0.4s;
}

.carousel:hover ~ .admin-link,
.admin-link:hover {
  opacity: 1;
}

/* ==================== ADMIN ==================== */

body.admin {
  overflow: auto;
}

.admin-shell {
  min-height: 100vh;
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(1.5rem, 4vw, 3.5rem);
}

.admin-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 1.6rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 2.2rem;
  flex-wrap: wrap;
}

.admin-title {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: clamp(1.6rem, 3.4vw, 2.5rem);
  letter-spacing: -0.02em;
}

.admin-title span {
  color: var(--accent);
  font-style: italic;
}

.admin-actions {
  display: flex;
  gap: 0.7rem;
  align-items: center;
}

.btn {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0.72rem 1.25rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: all 0.28s var(--ease);
  white-space: nowrap;
}

.btn:hover {
  border-color: var(--ink-dim);
  background: rgba(244, 241, 234, 0.05);
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #0a0a0b;
  font-weight: 700;
}

.btn--primary:hover {
  background: #f2c05f;
  border-color: #f2c05f;
}

.btn--danger {
  color: var(--danger);
  border-color: rgba(229, 72, 77, 0.35);
}

.btn--danger:hover {
  background: rgba(229, 72, 77, 0.12);
  border-color: var(--danger);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Login */
.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 2.6rem 2.2rem;
  display: grid;
  gap: 1.4rem;
}

.login-card h1 {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: 1.9rem;
  letter-spacing: -0.02em;
}

.login-card p {
  color: var(--ink-dim);
  font-size: 0.88rem;
  line-height: 1.6;
}

/* Grid of images */
.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 1.1rem;
}

.image-card {
  position: relative;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  transition: transform 0.3s var(--ease), border-color 0.3s;
  cursor: grab;
}

.image-card:hover {
  border-color: rgba(244, 241, 234, 0.28);
}

.image-card.is-dragging {
  opacity: 0.4;
}

.image-card.is-drop-target {
  border-color: var(--accent);
}

.image-card__thumb-link {
  position: relative;
  display: block;
  overflow: hidden;
  text-decoration: none;
}

.image-card__thumb {
  aspect-ratio: 16 / 10;
  width: 100%;
  object-fit: cover;
  display: block;
  background: #1c1c20;
  transition: transform 0.45s var(--ease);
}

.image-card__thumb-link:hover .image-card__thumb {
  transform: scale(1.05);
}

.image-card__open {
  position: absolute;
  bottom: 0.6rem;
  right: 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink);
  background: rgba(10, 10, 11, 0.74);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.28rem 0.62rem;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.25s var(--ease), transform 0.25s var(--ease);
  pointer-events: none;
}

.image-card__thumb-link:hover .image-card__open {
  opacity: 1;
  transform: translateY(0);
}

.image-card__body {
  padding: 0.85rem 0.95rem 1rem;
  display: grid;
  gap: 0.55rem;
}

.image-card__alt {
  font-size: 0.82rem;
  line-height: 1.4;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-card__url {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.64rem;
  color: var(--ink-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-decoration: none;
  transition: color 0.25s;
}

.image-card__url:hover {
  color: var(--accent);
  text-decoration: underline;
}

.image-card__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.3rem;
}

.image-card__order {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--accent);
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  transition: all 0.25s var(--ease);
}

.icon-btn:hover {
  border-color: var(--ink-dim);
  background: rgba(244, 241, 234, 0.06);
}

.icon-btn--danger:hover {
  color: var(--danger);
  border-color: var(--danger);
  background: rgba(229, 72, 77, 0.12);
}

.icon-btn svg {
  width: 15px;
  height: 15px;
}

/* Form fields */
.field {
  display: grid;
  gap: 0.5rem;
}

.field label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-dim);
}

.field input,
.field textarea {
  width: 100%;
  background: #0e0e10;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.8rem 0.9rem;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 0.92rem;
  transition: border-color 0.25s;
}

.field textarea {
  resize: vertical;
  min-height: 70px;
}

.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.field input::placeholder,
.field textarea::placeholder {
  color: var(--ink-faint);
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(5, 5, 6, 0.72);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  padding: 1.5rem;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s var(--ease);
}

.modal-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  width: 100%;
  max-width: 460px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1.9rem;
  display: grid;
  gap: 1.2rem;
  transform: translateY(18px) scale(0.98);
  transition: transform 0.35s var(--ease);
}

.modal-backdrop.is-open .modal {
  transform: translateY(0) scale(1);
}

.modal h2 {
  font-family: var(--font-display);
  font-weight: 300;
  font-size: 1.5rem;
}

.modal__foot {
  display: flex;
  justify-content: flex-end;
  gap: 0.7rem;
  margin-top: 0.4rem;
}

/* Toast */
.toast-wrap {
  position: fixed;
  bottom: 1.6rem;
  right: 1.6rem;
  z-index: 300;
  display: grid;
  gap: 0.6rem;
}

.toast {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
  padding: 0.85rem 1.1rem;
  font-size: 0.85rem;
  min-width: 240px;
  animation: toast-in 0.35s var(--ease);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5);
}

.toast--error {
  border-left-color: var(--danger);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
}

.hint {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  color: var(--ink-faint);
  letter-spacing: 0.06em;
}

.error-text {
  color: var(--danger);
  font-size: 0.82rem;
  min-height: 1.1em;
}

.skeleton {
  background: linear-gradient(
    100deg,
    var(--bg-elev) 30%,
    #1b1b20 50%,
    var(--bg-elev) 70%
  );
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: 14px;
  height: 210px;
}

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

@media (max-width: 640px) {
  .slide-caption {
    bottom: 6.5rem;
  }
  .nav-arrow {
    display: none;
  }
  .admin-header {
    flex-direction: column;
    align-items: flex-start;
  }
}
