body:has(.films-page) {
  background: #000;
}

/* Films — 3-column grid on black */

.films-page.phone-frame {
  background: #000;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.55);
  overflow: hidden;
  container-type: inline-size;
  --films-col-gap: 12px;
}

.films-page.phone-frame::before {
  display: none;
}

.films-page .app-header {
  background: #000;
}

.films-page .app-header.films-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  position: relative;
}

.films-page .films-header .back-link {
  grid-column: 1;
  justify-self: start;
  position: relative;
  z-index: 2;
}

.films-header-center {
  grid-column: 1 / -1;
  grid-row: 1;
  position: relative;
  height: 1.35rem;
  pointer-events: none;
}

.films-header-center .films-view-tab {
  position: absolute;
  top: 0;
  pointer-events: auto;
}

.films-header-center #filmsTabActive {
  left: 50%;
  transform: translateX(-50%);
}

.films-header-center #filmsTabArchived {
  left: calc(50% + 46px);
  top: 0.18em;
}

.films-view-tab {
  border: none;
  background: transparent;
  padding: 0;
  cursor: pointer;
  color: #ffffff;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.films-view-tab-archived {
  font-size: 0.72rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.42);
  letter-spacing: 0.02em;
  text-transform: lowercase;
}

.films-view-tab-archived.is-active {
  color: #ffffff;
}

.films-view-tab:not(.is-active) {
  opacity: 0.72;
}

.films-view-tab.is-active {
  opacity: 1;
}

.films-view-tab.is-hidden {
  display: none;
}

.films-page .films-header .films-add-btn {
  grid-column: 3;
  justify-self: end;
  position: relative;
  z-index: 2;
}

.films-page .app-header .page-title {
  color: #ffffff;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.films-page .back-link {
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  flex-shrink: 0;
  color: #86E8E8;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.films-page .back-link:hover,
.films-page .back-link:focus-visible {
  color: #a8f0f0;
}

.films-add-btn {
  background: rgba(134, 232, 232, 0.16);
  color: #86E8E8;
  box-shadow: none;
}

.films-main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0 0 calc(var(--nav-clearance) + 4px);
  background: #000;
  overflow: hidden;
}

.films-hero-deco {
  display: none;
}

.films-subtitle {
  display: none;
}

.films-scroll-area {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  background: #000;
}

.films-scroll-area::-webkit-scrollbar {
  display: none;
}

#filmsStack {
  min-height: 100%;
}

.films-stack {
  display: flex;
  flex-direction: column;
  gap: 30px;
  padding: 10px 0 28px;
  background: #000;
}

.films-empty {
  color: rgba(255, 255, 255, 0.42);
  padding: 48px 24px;
  text-align: center;
}

/* ── Fixed 3-column rows — as many rows as posts ── */
.films-grid {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: flex-start;
  justify-content: flex-start;
  gap: var(--films-col-gap, 12px);
  width: 100%;
  max-width: 100%;
  overflow: visible;
  --films-card-width: calc((100cqw - 12px - var(--films-col-gap, 12px) * 2) / 3);
  padding: 0 6px 4px;
  background: #000;
  box-sizing: border-box;
}

.films-grid-item {
  flex: 0 0 var(--films-card-width);
  width: var(--films-card-width);
  min-width: var(--films-card-width);
  max-width: var(--films-card-width);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  cursor: pointer;
  -webkit-touch-callout: none;
  user-select: none;
  touch-action: manipulation;
}

.films-grid-photo {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: visible;
  background: #111;
  border-radius: 0;
}

.films-grid-photo .films-photo-fill,
.films-grid-photo > img:not(.films-sticker-badge) {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 0;
  pointer-events: none;
  -webkit-touch-callout: none;
  user-select: none;
}

.films-photo-fill {
  background-size: cover;
  background-position: center;
}

.films-grid-title {
  margin: 0;
  padding: 6px 2px 2px;
  min-height: 2.7em;
  height: 2.7em;
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans JP", "Nunito", sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: 0.01em;
  color: #ffffff;
  text-align: center;
  display: block;
  overflow: hidden;
  word-break: break-word;
  text-overflow: ellipsis;
}

.films-grid-title.is-empty {
  visibility: hidden;
}

.films-grid-item:active .films-grid-photo {
  opacity: 0.88;
  transition: opacity 0.12s ease;
}

.films-grid-item.is-long-pressing .films-grid-photo {
  opacity: 0.72;
  transform: scale(0.98);
}

.films-grid-item.is-just-published .films-grid-photo {
  box-shadow:
    inset 0 0 0 2px rgba(134, 232, 232, 0.95),
    0 0 18px rgba(134, 232, 232, 0.35);
}

.films-grid-item.is-pinned .films-grid-photo {
  box-shadow: inset 0 0 0 2px rgba(134, 232, 232, 0.55);
}

.films-pin-badge {
  position: absolute;
  top: 4px;
  left: 4px;
  z-index: 2;
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #050505;
  background: #86E8E8;
}

.films-sticker-badge {
  position: absolute;
  top: -11%;
  left: -11%;
  width: 31%;
  z-index: 3;
  transform: rotate(-30deg);
  pointer-events: none;
  user-select: none;
}

.films-sticker-badge--chrome-cross {
  top: -14%;
  left: -11%;
  width: 25%;
}

.films-sticker-badge--angel-wings {
  top: -27%;
  left: -17%;
  width: 52%;
  transform: rotate(-23deg);
}

.film-sticker-picker {
  width: 100%;
}

.film-sticker-options {
  display: flex;
  align-items: center;
  gap: 12px;
}

.film-sticker-option {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.film-sticker-option.is-selected {
  border-color: #86E8E8;
  border-width: 2px;
  background: rgba(255, 255, 255, 0.14);
}

.film-sticker-option img {
  width: 70%;
  height: 70%;
  object-fit: contain;
  transform: rotate(-30deg);
  pointer-events: none;
}

.film-sticker-option-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
}

.films-action-sheet {
  position: fixed;
  inset: 0;
  z-index: 140;
}

.films-action-sheet[hidden] {
  display: none;
}

.films-action-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

.films-action-panel {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: calc(var(--nav-clearance) + 8px);
  padding: 8px 0;
  border-radius: 16px;
  background: rgba(24, 24, 24, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

.films-action-item {
  width: 100%;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.92);
  font-size: 0.92rem;
  font-weight: 500;
  text-align: left;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
}

.films-action-label {
  flex: 0 0 auto;
  font-weight: 500;
}

.films-action-hint {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.72rem;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.42);
  text-align: right;
  line-height: 1.35;
}

.films-action-item + .films-action-item {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.films-action-item-danger .films-action-label {
  color: #ff8e8e;
}

.film-edit-modal[hidden] {
  display: none;
}

.film-edit-modal {
  position: fixed;
  inset: 0;
  z-index: 150;
}

/* Bottom nav — dark on films */
.films-page .bottom-nav-glass {
  background: rgba(18, 18, 18, 0.94);
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.films-page .nav-label {
  color: rgba(255, 255, 255, 0.45);
}

.films-page .nav-item.active .nav-label {
  color: rgba(255, 255, 255, 0.88);
}

.films-page .nav-item.active svg:not(.nav-chat-icon):not(.nav-films-icon):not(.nav-profile-icon) {
  stroke: #86E8E8;
}

@media (max-width: 520px), (hover: none) and (pointer: coarse) {
  body:has(.films-page) {
    background: #000;
  }

  .films-page .bottom-nav-glass {
    background: rgba(14, 14, 14, 0.96);
    border-color: rgba(255, 255, 255, 0.1);
  }
}
