:root {
  color-scheme: light;
  --bg: #ededeb;
  --paper: #f7f7f4;
  --ink: #171716;
  --muted: #9a9994;
  --soft-line: #dfded8;
  --green: #4b8b58;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  letter-spacing: 0;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: 0;
}

.frame-stage {
  width: 100%;
  height: 100vh;
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  padding: 54px 78px 56px 34px;
  background: var(--paper);
  overflow: hidden;
}

.stage-rail {
  display: grid;
  align-content: space-between;
  padding: 28px 0;
  color: #77756d;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.stage-rail span {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}

.stage-main {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
}

.control-row {
  min-height: 56px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.tabs,
.detail-actions,
.tag-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tabs {
  flex-wrap: wrap;
}

.tab,
.primary-button,
.secondary-button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--soft-line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.42);
  cursor: pointer;
}

.tab.active,
.primary-button {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.view-toggle {
  min-height: 34px;
  padding: 0 16px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-size: 14px;
  font-weight: 800;
  text-transform: uppercase;
  box-shadow: 0 1px 0 rgba(23, 23, 22, 0.08);
}

.view-actions {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  flex: 0 0 auto;
}

.view-toggle.is-active {
  background: var(--ink);
  color: #fff;
}

.search-wrap {
  width: min(560px, 42vw);
  height: 44px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 16px;
  border: 1px solid var(--soft-line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.54);
  margin: 12px 0 20px;
}

.search-icon {
  color: var(--muted);
  font-size: 20px;
}

.search-wrap input {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
}

.search-wrap input::-webkit-search-cancel-button,
.search-wrap input::-webkit-search-decoration {
  appearance: none;
  display: none;
}

.search-clear {
  position: relative;
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 1px solid var(--soft-line);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.42);
  cursor: pointer;
}

.search-clear::before,
.search-clear::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 9px;
  height: 1.5px;
  border-radius: 999px;
  background: #77756d;
  transform-origin: center;
}

.search-clear::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.search-clear::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.search-clear[hidden] {
  display: none;
}

.timeline-scroll {
  position: relative;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scroll-behavior: smooth;
}

.timeline-grid {
  position: relative;
  display: grid;
  grid-template-columns: minmax(420px, 0.86fr) minmax(560px, 1fr);
  column-gap: 64px;
  min-height: 100%;
  padding: 0 0 42vh;
}

.project-window {
  position: sticky;
  top: 0;
  grid-column: 1;
  height: 100%;
  min-height: 0;
  align-self: start;
  overflow: hidden;
  pointer-events: none;
}

.project-list {
  display: grid;
  gap: 8px;
  padding: 35vh 0 42vh;
  will-change: transform;
}

.project-item {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: #d3d2cd;
  text-align: left;
  font-size: clamp(30px, 3.25vw, 50px);
  line-height: 1.02;
  cursor: pointer;
  transition: color 140ms ease, transform 140ms ease;
  pointer-events: auto;
}

.project-item.active {
  color: var(--ink);
  transform: translateX(2px);
}

.project-item span {
  display: inline-block;
  margin-left: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  vertical-align: middle;
}

.frame-list {
  grid-column: 2;
  display: grid;
  gap: 26px;
  padding-top: 0;
}

.frame-card {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.frame-card.portrait {
  width: min(54%, 420px);
  justify-self: center;
}

.frame-card.square {
  width: min(72%, 560px);
  justify-self: center;
}

.frame-card.ultrawide {
  width: 100%;
}

.thumb-wrap {
  position: relative;
  overflow: hidden;
  background: #ddd;
}

.thumb-wrap img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  filter: saturate(0.92) contrast(0.96);
  transition: transform 220ms ease, filter 220ms ease;
}

.frame-card:hover img {
  transform: scale(1.015);
  filter: saturate(1.04) contrast(1);
}

.time-badge {
  position: absolute;
  left: 12px;
  top: 12px;
  padding: 5px 8px;
  border-radius: 999px;
  background: rgba(247, 247, 244, 0.78);
  color: var(--ink);
  font-size: 12px;
}

.tag {
  padding: 4px 7px;
  border-radius: 999px;
  background: #e7e5df;
  color: #65635d;
  font-size: 12px;
}

.detail-intro .tag-row {
  margin-bottom: 8px;
}

.tag.color {
  color: #fff;
  background: var(--ink);
}

.detail-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(237, 237, 235, 0.82);
  padding: 32px;
  overflow: auto;
}

.detail-panel {
  position: relative;
  max-width: 1280px;
  margin: 0 auto;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: 26px;
  overflow: hidden;
  padding: 0 0 34px;
}

.close-button {
  position: absolute;
  right: 18px;
  top: 18px;
  z-index: 2;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.18);
  background: rgba(255, 255, 255, 0.78);
  font-size: 24px;
  cursor: pointer;
}

.detail-still {
  position: relative;
  background: #0a0a0a;
}

.detail-still img {
  width: 100%;
  display: block;
  max-height: 62vh;
  object-fit: contain;
}

.download-button {
  position: absolute;
  right: 18px;
  bottom: 18px;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  padding: 0 13px;
  border-radius: 999px;
  background: rgba(247, 247, 244, 0.9);
  color: var(--ink);
  font-size: 13px;
  text-decoration: none;
  font-weight: 700;
}

.detail-intro {
  border-bottom: 1px solid var(--soft-line);
  padding-bottom: 34px;
}

.detail-hero {
  display: grid;
  grid-template-columns: 1fr;
  padding: 34px 42px 0;
}

.video-heading {
  margin-bottom: 18px;
}

.detail-media {
  background: #000;
  display: grid;
  place-items: center;
  min-height: min(56vh, 560px);
}

.detail-media video {
  width: 100%;
  height: 100%;
  max-height: 80vh;
  object-fit: contain;
}

.detail-media iframe {
  width: 100%;
  height: 100%;
  min-height: 480px;
  border: 0;
}

.detail-media video[hidden],
.detail-media iframe[hidden] {
  display: none;
}

.detail-copy {
  padding: 28px 42px 0;
}

.detail-time {
  display: block;
  margin-bottom: 12px;
  color: var(--ink);
  font-size: 18px;
  font-weight: 500;
}

.detail-copy h2 {
  margin: 0 0 18px;
  font-size: clamp(28px, 2.5vw, 42px);
  line-height: 1.04;
}

.detail-copy p {
  color: #65635d;
  font-size: 15px;
  line-height: 1.5;
  max-width: 700px;
}

.secondary-button {
  background: transparent;
}

.detail-section {
  padding: 34px 42px 0;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.section-heading span {
  font-size: clamp(22px, 2.3vw, 34px);
  font-weight: 700;
}

.section-heading small,
.section-heading a {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  text-transform: uppercase;
}

.section-link {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--soft-line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.42);
  color: var(--ink);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.cut-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.cut-item {
  position: relative;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.cut-item img {
  width: 100%;
  display: block;
  aspect-ratio: 16 / 7.7;
  object-fit: cover;
}

.cut-item span {
  position: absolute;
  left: 10px;
  top: 10px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(247, 247, 244, 0.78);
  font-size: 12px;
}

.similar-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.similar-item {
  overflow: hidden;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
}

.similar-item img {
  width: 100%;
  display: block;
  aspect-ratio: 16 / 10;
  object-fit: cover;
}

.empty-state {
  margin: 24px 0;
  color: var(--muted);
}

.loading-state {
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: #77756d;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.loading-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(23, 23, 22, 0.16);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: loading-spin 760ms linear infinite;
}

@keyframes loading-spin {
  to {
    transform: rotate(360deg);
  }
}

.end-note {
  display: block;
  width: 100vw;
  margin: 24px 0 4px -126px;
  color: #77756d;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
}

.library-scroll {
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  padding: 18px 0 48px;
}

.library-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  margin: 0 0 22px;
}

.library-head span {
  font-size: clamp(42px, 5.2vw, 82px);
  line-height: 1;
  font-weight: 820;
}

.library-head small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.library-grid {
  display: block;
}

.library-project {
  width: 100%;
  display: grid;
  grid-template-columns: clamp(130px, 10vw, 190px) minmax(0, 1fr);
  align-items: start;
  gap: 28px;
  padding: 0 0 54px;
  margin: 0 0 54px;
  border-bottom: 1px solid var(--soft-line);
}

.library-project-info {
  position: sticky;
  top: 0;
  padding-top: 4px;
  text-align: right;
}

.library-kicker {
  display: block;
  margin-top: 16px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.library-project-info h2 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(20px, 1.7vw, 32px);
  line-height: 1.08;
  font-weight: 650;
}

.library-project-info p {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  font-weight: 800;
  text-transform: uppercase;
}

.library-project-frames {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: start;
  column-gap: 24px;
  row-gap: 34px;
}

.library-card {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.library-card.portrait {
  grid-row: auto;
}

.library-card.portrait .library-thumb {
  aspect-ratio: 16 / 9 !important;
}

.library-card.square .library-thumb {
  aspect-ratio: 16 / 9 !important;
}

.library-card.ultrawide {
  grid-column: auto;
}

.library-project .library-thumb {
  aspect-ratio: 16 / 9 !important;
}

.library-thumb {
  position: relative;
  overflow: hidden;
  background: #ddd;
}

.library-thumb img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  filter: saturate(0.92) contrast(0.96);
  transition: transform 220ms ease, filter 220ms ease;
}

.library-card:hover img {
  transform: scale(1.015);
  filter: saturate(1.04) contrast(1);
}

.library-card > span {
  display: block;
  margin-top: 8px;
  color: var(--ink);
  font-size: 18px;
  line-height: 1.08;
  font-weight: 650;
}

.library-card > small {
  display: block;
  margin-top: 9px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
  font-weight: 800;
  text-transform: uppercase;
}

.storyboard-scroll {
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
}

.storyboard-shell {
  display: grid;
  grid-template-columns: 1fr;
  gap: 30px;
  align-items: start;
  padding: 26px 0 44px;
}

.storyboard-input {
  display: grid;
  gap: 18px;
  max-width: 840px;
}

.storyboard-heading {
  display: grid;
  gap: 18px;
}

.storyboard-heading span {
  display: block;
  font-size: clamp(42px, 5.2vw, 82px);
  line-height: 1;
  font-weight: 820;
  letter-spacing: 0;
  max-width: 100%;
}

.storyboard-heading small,
.storyboard-tools small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  font-weight: 800;
  text-transform: uppercase;
}

.storyboard-input textarea {
  width: 100%;
  min-height: 360px;
  resize: vertical;
  border: 1px solid var(--soft-line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.46);
  padding: 18px;
  color: var(--ink);
  outline: 0;
  line-height: 1.5;
}

.storyboard-tools {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.storyboard-output {
  min-width: 0;
}

.storyboard-board {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 22px 16px;
}

.story-card {
  display: grid;
  gap: 10px;
}

.story-card-visual {
  position: relative;
  width: 100%;
  padding: 0;
  border: 0;
  background: #ddd;
  cursor: pointer;
  overflow: hidden;
}

.story-card-visual img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.story-card-visual span {
  position: absolute;
  top: 10px;
  left: 10px;
  min-width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(247, 247, 244, 0.82);
  color: var(--ink);
  font-weight: 800;
}

.story-card-copy {
  display: grid;
  gap: 6px;
}

.story-card-copy p {
  margin: 0;
  font-size: 13px;
  line-height: 1.4;
}

.story-card-copy small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  font-weight: 700;
}

.story-card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.story-card-actions button {
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid var(--soft-line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.42);
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.story-card-actions small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.story-card.empty .story-card-visual {
  min-height: 180px;
  display: grid;
  place-items: center;
  border: 1px solid var(--soft-line);
  background: rgba(255, 255, 255, 0.28);
  color: var(--muted);
  font-weight: 800;
}

@media (max-width: 980px) {
  .frame-stage {
    grid-template-columns: 1fr;
    padding: 26px 18px;
  }

  .stage-rail {
    display: none;
  }

  .search-wrap {
    width: 100%;
  }

  .control-row {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .view-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .timeline-grid {
    display: grid;
    grid-template-columns: 1fr;
    padding: 10vh 0 30vh;
  }

  .project-window {
    position: static;
    height: auto;
    mask-image: none;
  }

  .project-list {
    padding: 0 0 20px;
    transform: none !important;
  }

  .project-item {
    font-size: 30px;
    margin-bottom: 12px;
  }

  .frame-list {
    grid-column: 1;
  }

  .storyboard-shell {
    grid-template-columns: 1fr;
    gap: 28px;
    padding-top: 8px;
  }

  .storyboard-input {
    position: static;
  }

  .storyboard-input textarea {
    min-height: 220px;
  }

  .storyboard-board {
    grid-template-columns: 1fr;
  }

  .end-note {
    margin-left: -18px;
  }

  .library-head {
    display: block;
  }

  .library-project {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .library-project-info {
    position: static;
    text-align: left;
  }

  .library-project-info p {
    max-width: none;
  }

  .library-project-frames {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .library-card,
  .library-card.portrait,
  .library-card.ultrawide {
    width: 100%;
  }

  .library-card.ultrawide {
    grid-column: auto;
  }

  .frame-card.portrait,
  .frame-card.square {
    width: min(100%, 520px);
  }

  .detail-hero {
    grid-template-columns: 1fr;
  }

  .detail-media,
  .detail-media iframe {
    min-height: 320px;
  }

  .detail-copy,
  .detail-section {
    padding-left: 22px;
    padding-right: 22px;
  }

  .cut-strip,
  .similar-grid {
    grid-template-columns: 1fr;
  }
}
