:root {
  --font: "Inter", sans-serif;

  --color-N1000: #000000;
  --color-N400: #6e6e6e;
  --color-N60: #dddddd;
  --color-N40: #e4e4e4;
  --color-N10: #f6f6f6;
  --color-N0: #ffffff;

  --grid-item-min: 162px;
  --grid-layout-gap: 16px;
  --panel-w: 481px;
}

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

*:not(dialog) {
  margin: 0;
}

html,
body {
  height: 100%;
}

body {
  font-family: var(--font);
  background: var(--color-N0);

  height: 100dvh;
  display: grid;
  grid-template-columns: 1fr 0px; /* panel closed */
  overflow: hidden;
}

body.panel-open {
  grid-template-columns: 1fr var(--panel-w);
}

.page {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

.collection-header {
  background-color: var(--color-N1000);
  padding: 12px 24px;
  min-height: 56px;

  display: flex;
  align-items: center;
  gap: 8px;
}

.collection-title {
  font: 400 20px/24px var(--font);
  color: var(--color-N0);
}

.grid-layout {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--grid-item-min), 1fr));
  gap: var(--grid-layout-gap);
  grid-auto-flow: dense;
  align-items: end;
  padding: 24px;
  overflow-y: auto;
}

.skeleton-card {
  display: grid;
  gap: 4px;
  width: 100%;
}

.skeleton-image {
  width: 100%;
  border-radius: 8px;
  aspect-ratio: 9 / 16;
  background: #f1f3f5;
  position: relative;
  overflow: hidden;
}

.skeleton-text {
  height: 12px;
  border-radius: 4px;
  background: #f1f3f5;
}

.skeleton-image::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.06), transparent);
  animation: sk-shimmer 1.2s linear infinite;
  pointer-events: none;
}

@keyframes sk-shimmer {
  to {
    transform: translateX(100%);
  }
}

.clip-card {
  display: grid;
  gap: 4px;
  cursor: pointer;
  user-select: none;
}

.clip-card.is-active .clip-thumb::after {
  box-shadow: inset 0 0 0 2px #cbfe00;
}

.clip-thumb {
  width: 100%;
  border-radius: 8px;
  aspect-ratio: 9 / 16;
  background: #e9ecef;
  overflow: hidden;
  position: relative;
}

.clip-thumb::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px var(--color-N1000);
  transition: box-shadow 0.25s;
  z-index: 3;
}

.clip-video-layer {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
}

.clip-card.is-previewing .clip-video-layer {
  opacity: 1;
}

.clip-video-layer video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.clip-download {
  position: absolute;
  z-index: 1;
  top: 6px;
  right: 6px;

  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;

  border: 0;
  border-radius: 8px;
  cursor: pointer;

  background: rgba(0, 0, 0, 0.9);
  color: #fff;

  /* important: nu fura focus outline aiurea */
  outline: none;
}

.clip-download:focus-visible {
  box-shadow: 0 0 0 2px rgba(88, 253, 223, 0.6);
}

.clip-duration {
  position: absolute;
  right: 4px;
  bottom: 4px;

  padding: 2px 6px;
  border-radius: 100px;

  font: 400 10px/12px var(--font);
  color: var(--color-N0);

  background: rgba(0, 0, 0, 0.5);

  pointer-events: none;
  white-space: nowrap;
}

.clip-duration:empty {
  display: none;
}

.clip-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 10px;
}

/* landscape behavior */
.clip-card.landscape {
  grid-column: span 2;
}

.clip-card.landscape .clip-thumb {
  aspect-ratio: 16 / 9;
}

.clip-card.square .clip-thumb {
  aspect-ratio: 1 / 1;
}

.clip-meta {
  display: grid;
  gap: 6px;
}

.clip-title {
  font: 400 13px/16px var(--font);
  color: var(--color-N1000);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.clip-subtitle {
  font: 400 12px/12px var(--font);
  color: var(--color-N1000);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;

  padding: 4px 6px;
  background: var(--color-N40);
  border-radius: 100px;
  width: fit-content;
}

.grid-info-row {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.collection-name {
  font: 400 24px/24px var(--font);
  color: var(--color-N1000);
}

.download-all-btn {
  appearance: none;
  border: 0;
  background: transparent;
  font: 600 13px/20px var(--font);
  cursor: pointer;
  text-decoration: underline;
}

.download-all-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  text-decoration: none;
}

/* right panel is NOT fixed anymore; it just lives in column 2 */
.right-panel {
  height: 100dvh;
  background: #fff;
  border-left: 1px solid rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

/* optional: slide-in feel, without breaking layout */
.right-panel .panel {
  height: 100%;
}

.right-panel {
  position: relative;
}

.right-panel .panel {
  transform: translateX(16px);
  opacity: 0;
  transition: transform 200ms cubic-bezier(0.2, 0.8, 0.2, 1), opacity 200ms ease;
}

body.panel-open .right-panel .panel {
  transform: translateX(0);
  opacity: 1;
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
}

.panel-h2 {
  font: 300 15px / 24px var(--font);
  color: var(--color-N1000);
}

.panel-subtitle {
  font: 400 10px / 12px var(--font);
  color: var(--color-N0);
  padding: 2px 6px;
  border-radius: 100px;
  background: rgba(0, 0, 0, 0.5);
  width: fit-content;
}

.panel-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.panel-download,
.panel-close {
  border-radius: 8px;
  background-color: #e6ebec;
  border: none;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.panel-body {
  margin: 0 16px 16px 16px;
  overflow: hidden;
}

.panel-video {
  width: 100%;
  border-radius: 8px;
  background: #e9ecef;
}

.grid-message {
  grid-column: 1 / -1;
  font-size: 16px;
  color: #111;
}

.auth-wrap {
  grid-column: 1 / -1;
  min-height: calc(100dvh - 104px);
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
  display: grid;
  gap: 12px;
  font-family: var(--font);
}

.auth-title {
  margin: 0;
  font: 300 24px/32px var(--font);
  color: var(--color-N1000);
}

.auth-subtitle {
  margin: 0;
  color: var(--color-N400);
  font: 400 13px/18px var(--font);
}

.auth-label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  color: #222;
  margin-top: 12px;
}

.auth-input {
  height: 40px;
  border-radius: 10px;
  border: 1px solid #d5d9de;
  padding: 0 12px;
  font-size: 14px;
  outline: none;
}

.auth-input:focus {
  border-color: #0b5fff;
}

.auth-button {
  border-radius: 8px;
  border: 0;
  cursor: pointer;
  font: 600 13px/20px var(--font);
  background-color: var(--color-N1000);
  color: var(--color-N0);
  padding: 8px;
}

.auth-error {
  margin: 0;
  color: #b00020;
  font-size: 13px;
}

.auth-error:empty {
  display: none;
}

/* --------------------------- Modal --------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 1000;
}

.modal {
  width: min(500px, 100%);
  background: #fff;
  border-radius: 12px;
  /* overflow: hidden; */
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.25);
  position: relative;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 32px 8px 32px;
}

.modal-title {
  margin: 0;
  font: 300 24px/32px var(--font);
  color: var(--color-N1000);
}

.modal-close {
  appearance: none;
  cursor: pointer;
  border-radius: 100px;
  position: absolute;
  right: -48px;
  top: 0px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid var(--color-N60);
  background-color: var(--color-N1000);
}

.modal-body {
  display: grid;
  gap: 12px;
}

.modal-data {
  margin-inline: 32px;
}

.modal-subtitle {
  margin: 0;
  font: 400 13px/18px var(--font);
  color: var(--color-N400);
}

.modal-label {
  display: grid;
  gap: 6px;
  font-size: 14px;
  margin-top: 24px;
}

.modal-input {
  height: 40px;
  border: 1px solid #d8d8d8;
  border-radius: 10px;
  padding: 0 12px;
  font: inherit;
}

.modal-error {
  margin: 0;
  color: #b00020;
  min-height: 18px;
}

.modal-actions {
  display: flex;
  gap: 14px;
  padding: 24px 32px;
  background-color: var(--color-N10);
  border-radius: 0 0 12px 12px;
}

.modal-cancel,
.modal-submit {
  padding: 5px;
  border-radius: 8px;
  font: 600 13px/20px var(--font);
  cursor: pointer;
  flex: 1;
}

.modal-cancel {
  border: 1px solid var(--color-N60);
  background: var(--color-N0);
}

.modal-submit {
  border: 0;
  background: var(--color-N1000);
  color: var(--color-N0);
}

.modal-submit:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}
