@font-face {
  font-family: "Smiley Sans";
  src: url("../../public/fonts/SmileySans-Oblique.ttf.woff2") format("woff2");
  font-weight: 400 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #20223a;
  --muted: #6f7390;
  --secondary: #9aa0bd;
  --line: rgba(49, 54, 132, 0.14);
  --line-strong: rgba(49, 54, 132, 0.24);
  --paper: #f4f6ff;
  --panel: #ffffff;
  --panel-soft: #f7f8ff;
  --panel-raised: #eef1ff;
  --accent: #5963ff;
  --accent-dark: #2d2c95;
  --accent-soft: rgba(89, 99, 255, 0.14);
  --purple: #2d2c95;
  --purple-deep: #211774;
  --pink: #ff76b7;
  --gold: #f5c66d;
  --danger: #ff4d6d;
  --warning-bg: #fff3cb;
  --shadow: 0 12px 26px rgba(44, 50, 130, 0.14);
  --font-rounded: "Resource Han Rounded CN", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI", "Microsoft YaHei", system-ui, sans-serif;
  --font-display: "Smiley Sans", "Resource Han Rounded CN", "PingFang SC", "Microsoft YaHei UI", system-ui, sans-serif;
  color-scheme: light;
  font-family: var(--font-rounded);
  font-size: 16px;
  line-height: 1.4;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--paper);
  overscroll-behavior: none;
  touch-action: pan-x pan-y;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(180deg, #2b2a92 0 196px, var(--paper) 196px),
    linear-gradient(90deg, rgba(89, 99, 255, 0.04) 0 1px, transparent 1px 28px),
    var(--paper);
  color: var(--ink);
  font-family: var(--font-rounded);
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  text-rendering: optimizeLegibility;
  touch-action: pan-x pan-y;
}

body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto;
  z-index: -1;
  height: 214px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.08) 25%, transparent 25%) 0 0 / 44px 44px,
    linear-gradient(225deg, rgba(255, 255, 255, 0.08) 25%, transparent 25%) 0 0 / 44px 44px,
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.08) 0 1px, transparent 1px 34px),
    linear-gradient(180deg, #2f2ba2, #27248a);
  pointer-events: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
label:focus-visible {
  outline: 3px solid rgba(89, 99, 255, 0.28);
  outline-offset: 2px;
}

.app-shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: calc(14px + env(safe-area-inset-top)) 12px calc(116px + env(safe-area-inset-bottom));
}

.swipe-back-preview {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background: var(--paper);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.14s ease;
}

.swipe-back-preview.visible {
  opacity: 1;
}

.swipe-back-preview .app-shell {
  min-height: 100vh;
  padding-bottom: calc(116px + env(safe-area-inset-bottom)) !important;
}

.swipe-back-preview .tabbar {
  display: grid !important;
}

.swipe-back-surface {
  --swipe-back-x: 0px;
  transform: translate3d(var(--swipe-back-x), 0, 0);
  will-change: transform;
}

.app-shell.swipe-back-surface {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  background: var(--paper);
  box-shadow: -18px 0 32px rgba(31, 30, 112, 0.18);
}

.swipe-back-surface.swiping {
  transition: none !important;
}

.swipe-back-surface.swipe-back-release {
  transition: transform 0.2s cubic-bezier(0.2, 0.78, 0.22, 1);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  gap: 12px;
  margin: calc(-14px - env(safe-area-inset-top)) -12px 12px;
  padding: calc(16px + env(safe-area-inset-top)) 12px 0;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.08) 25%, transparent 25%) 0 0 / 42px 42px,
    linear-gradient(225deg, rgba(255, 255, 255, 0.08) 25%, transparent 25%) 0 0 / 42px 42px,
    linear-gradient(180deg, rgba(47, 43, 162, 0.96), rgba(42, 39, 145, 0.96));
  box-shadow: 0 10px 24px rgba(36, 34, 116, 0.22);
  backdrop-filter: blur(18px);
}

.topbar-panel {
  display: none;
  width: min(1120px, 100%);
  margin: 0 auto;
}

.topbar-panel.active {
  display: grid;
  gap: 10px;
  padding-bottom: 10px;
}

.brand-row {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  width: 100%;
}

.topbar-panel[data-topbar-panel="wantlist"] .brand-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.brand-avatar {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 3px solid rgba(255, 255, 255, 0.48);
  border-radius: 50%;
  background: linear-gradient(135deg, #7fa8ff, #ff86c7);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(14, 17, 82, 0.24);
}

.brand-lockup,
.brand-copy {
  display: none;
}

.page-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.page-top-row h1 {
  color: white;
  font-size: 1.58rem;
  text-shadow: 0 3px 10px rgba(11, 11, 72, 0.2);
}

.top-eyebrow {
  margin: 0 0 2px;
  color: rgba(255, 255, 255, 0.64);
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 820;
  letter-spacing: 0.06em;
}

.top-tools-row {
  display: grid;
  gap: 8px;
  width: 100%;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 2.25rem;
  font-weight: 850;
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 4px;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.34rem;
  font-weight: 820;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 8px;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 780;
}

.primary-button,
.ghost-button,
.icon-button,
.tab,
.segment,
.top-icon-button {
  font-family: var(--font-display);
  min-height: 42px;
  border: 0;
  border-radius: 999px;
  padding: 0 16px;
  color: var(--ink);
  background: transparent;
}

.primary-button {
  background: linear-gradient(180deg, #7f83ff, var(--accent));
  color: white;
  font-weight: 800;
  box-shadow: 0 10px 22px rgba(89, 99, 255, 0.25);
}

.primary-button:hover {
  background: linear-gradient(180deg, #6b70f7, var(--accent-dark));
}

.ghost-button,
.top-icon-button {
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.12);
  color: white;
  font-weight: 760;
}

.ghost-button {
  border-color: var(--line);
  background: var(--panel);
  color: var(--accent-dark);
}

.ghost-button:hover,
.ghost-button.active,
.top-icon-button:hover,
.top-icon-button.active {
  border-color: rgba(255, 255, 255, 0.72);
  background: rgba(255, 255, 255, 0.22);
}

.ghost-button.danger {
  border-color: rgba(255, 77, 109, 0.24);
  color: var(--danger);
}

.icon-button {
  width: 38px;
  min-height: 38px;
  padding: 0;
  background: var(--panel-raised);
  color: var(--muted);
  font-weight: 820;
}

.top-icon-button {
  width: 58px;
  min-width: 58px;
  padding: 0;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.top-icon-button.wide {
  width: auto;
  min-width: 68px;
  padding: 0 16px;
}

.top-icon-button.icon-only {
  width: 46px;
  min-width: 46px;
  border-radius: 50%;
  font-size: 1.18rem;
}

.search-field {
  position: relative;
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 760;
}

.top-search span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.top-search::before {
  content: "";
  position: absolute;
  left: 17px;
  top: 50%;
  width: 13px;
  height: 13px;
  border: 2px solid #8e93ad;
  border-radius: 50%;
  transform: translateY(-58%);
}

.top-search::after {
  content: "";
  position: absolute;
  left: 30px;
  top: 50%;
  width: 8px;
  height: 2px;
  border-radius: 999px;
  background: #8e93ad;
  transform: rotate(45deg) translate(1px, 5px);
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid rgba(49, 54, 132, 0.16);
  border-radius: 8px;
  padding: 12px;
  background: #ffffff;
  color: var(--ink);
  font-size: 16px;
  outline: 0;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.72);
}

.top-search input {
  min-height: 48px;
  border-radius: 999px;
  padding: 12px 16px 12px 44px;
  background: white;
  color: #30334c;
  box-shadow: 0 8px 18px rgba(14, 17, 82, 0.18);
}

.topbar-panel:not([data-topbar-panel="collection"]) .top-search input {
  box-shadow: none;
}

input::placeholder,
textarea::placeholder {
  color: #8e93ad;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(89, 99, 255, 0.42);
  background: white;
}

textarea {
  resize: vertical;
}

.tabbar {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 30;
  width: min(100%, 760px);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  transform: translateX(-50%);
  padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(255, 255, 255, 0.18);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.09) 25%, transparent 25%) 0 0 / 36px 36px,
    linear-gradient(225deg, rgba(255, 255, 255, 0.08) 25%, transparent 25%) 0 0 / 36px 36px,
    linear-gradient(180deg, rgba(48, 43, 158, 0.96), rgba(35, 29, 121, 0.98));
  box-shadow: 0 -12px 28px rgba(35, 29, 121, 0.28);
  backdrop-filter: blur(20px);
}

body[data-view="settings"] .tabbar {
  display: none;
}

body[data-view="settings"] .app-shell {
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
}

.tab {
  position: relative;
  min-height: 54px;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.64);
  font-size: 0.78rem;
  font-weight: 820;
}

.tab span {
  display: grid;
  place-items: center;
}

.tab.active {
  background: rgba(255, 255, 255, 0.12);
  color: white;
  box-shadow: inset 0 3px 0 #ff85c7;
}

.tab-add {
  width: 64px;
  min-height: 64px;
  justify-self: center;
  align-self: start;
  margin-top: -28px;
  border: 4px solid rgba(255, 255, 255, 0.42);
  border-radius: 50%;
  background: linear-gradient(180deg, #ffe37a, #ffb23f);
  color: var(--purple-deep);
  box-shadow: 0 12px 22px rgba(16, 14, 89, 0.36), 0 0 0 8px rgba(36, 29, 121, 0.42);
  font-size: 2.1rem;
  font-weight: 900;
}

.tab-add span {
  transform: translateY(-2px);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.feed-hero {
  position: relative;
  min-height: 118px;
  margin: 2px 0 12px;
  overflow: hidden;
  border: 1px solid rgba(89, 99, 255, 0.16);
  border-radius: 8px;
  padding: 16px;
  background:
    linear-gradient(135deg, rgba(89, 99, 255, 0.13), transparent 54%),
    linear-gradient(90deg, rgba(255, 255, 255, 0.88), rgba(255, 255, 255, 0.72)),
    var(--panel);
  box-shadow: var(--shadow);
}

.feed-hero::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 4px;
  background: linear-gradient(90deg, var(--accent), var(--pink), var(--gold));
}

.feed-hero h2 {
  margin-bottom: 6px;
  font-size: 1.38rem;
}

.feed-hero p:last-child {
  margin: 0;
  color: var(--muted);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.toolbar {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 8px 20px rgba(44, 50, 130, 0.08);
  backdrop-filter: blur(14px);
}

.toolbar > * {
  min-width: 0;
}

label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 760;
}

label span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.field-label {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 760;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap !important;
  clip-path: inset(50%) !important;
}

.view-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  align-items: end;
  min-width: 0;
}

.segmented {
  min-width: 0;
  min-height: 42px;
  display: grid;
  grid-template-columns: repeat(2, minmax(76px, 1fr));
  align-items: center;
  gap: 3px;
  border-radius: 8px;
  padding: 3px;
  background: #dfe5ff;
  border: 1px solid rgba(49, 54, 132, 0.12);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5);
}

.segmented.triple {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.segmented.archive-segmented {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.segment {
  min-width: 0;
  min-height: 36px;
  border-radius: 7px;
  padding: 0 12px;
  color: #5e638b;
  background: rgba(255, 255, 255, 0.62);
  font-size: 0.9rem;
  font-weight: 820;
}

.segment.active {
  background: white;
  color: var(--accent-dark);
  box-shadow: 0 4px 12px rgba(44, 50, 130, 0.12);
}

.filter-panel {
  display: none;
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
  gap: 10px;
  border: 1px solid rgba(49, 54, 132, 0.14);
  border-radius: 8px;
  padding: 10px;
  background: #ffffff;
  box-shadow: 0 8px 18px rgba(14, 17, 82, 0.16);
}

.filter-panel.compact-filter {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.filter-clear-button {
  align-self: end;
  min-height: 44px;
  white-space: nowrap;
}

.topbar-panel.filters-open .filter-panel {
  display: grid;
}

.subpage-top-row {
  justify-content: flex-start;
}

.subpage-top-row h1 {
  margin-bottom: 0;
}

.poster-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 12px;
}

.poster-grid.compact {
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
}

.poster-grid.want-list {
  grid-template-columns: 1fr;
}

.poster-grid.list-layout {
  grid-template-columns: 1fr;
}

.poster-card,
.poster-list-row,
.want-list-row,
.movie-card,
.stat-card,
.panel,
.breakdown-card {
  border: 1px solid rgba(49, 54, 132, 0.1);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 18px rgba(44, 50, 130, 0.1);
}

.poster-card {
  overflow: hidden;
  text-align: left;
}

.poster-card button,
.poster-list-row button,
.want-list-row button {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.poster-card button {
  display: grid;
}

.poster-card button:hover .poster-image img {
  transform: scale(1.025);
}

.poster-list-row button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 14px;
}

.want-list-row button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
}

.poster-list-text {
  min-width: 0;
}

.poster-list-row .pill-row,
.want-list-row .pill-row {
  justify-content: flex-end;
  margin-top: 0;
}

.poster-image {
  width: 100%;
  aspect-ratio: 0.707 / 1;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #e7ebff;
}

.poster-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.22s ease;
}

.poster-image.placeholder {
  padding: 20px;
  color: var(--secondary);
  font-weight: 760;
  text-align: center;
}

.poster-card-body {
  padding: 12px;
}

.poster-title {
  margin: 0 0 5px;
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 800;
  overflow-wrap: anywhere;
}

.poster-meta,
.movie-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  overflow-wrap: anywhere;
}

.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.pill,
.missing-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 2px 9px;
  background: #eef1ff;
  color: #5b6293;
  font-size: 0.74rem;
  font-weight: 760;
}

.missing-pill {
  background: var(--warning-bg);
  color: #9a6500;
}

.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--panel);
  box-shadow: 0 8px 18px rgba(44, 50, 130, 0.08);
}

.section-header p,
.panel p {
  margin-bottom: 0;
  color: var(--muted);
}

.section-header.compact {
  margin-bottom: 12px;
  padding: 12px 14px;
}

.profile-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  margin-bottom: 12px;
  border: 1px solid rgba(89, 99, 255, 0.16);
  border-radius: 8px;
  padding: 16px;
  background:
    linear-gradient(135deg, rgba(255, 118, 183, 0.12), transparent 52%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(246, 248, 255, 0.96));
  box-shadow: var(--shadow);
}

.profile-hero p:last-child {
  margin-bottom: 0;
  color: var(--muted);
}

.settings-drawer {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f7f8ff;
  box-shadow: 0 8px 18px rgba(44, 50, 130, 0.08);
}

.quick-add,
.lookup-panel,
.form-section {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--panel-soft);
}

.upload-field {
  display: grid;
  gap: 7px;
}

.upload-card,
.upload-tile {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 180px;
  overflow: hidden;
  border: 1px solid rgba(89, 99, 255, 0.22);
  border-radius: 8px;
  padding: 14px;
  background:
    linear-gradient(135deg, rgba(89, 99, 255, 0.09), transparent 56%),
    #ffffff;
  color: var(--accent-dark);
  text-align: center;
  box-shadow: 0 8px 18px rgba(44, 50, 130, 0.08);
  cursor: pointer;
}

.upload-card:hover,
.upload-tile:hover {
  border-color: rgba(89, 99, 255, 0.44);
  background:
    linear-gradient(135deg, rgba(89, 99, 255, 0.13), transparent 56%),
    #ffffff;
}

.upload-card.invalid {
  border-color: rgba(255, 77, 109, 0.82);
  box-shadow: 0 0 0 3px rgba(255, 77, 109, 0.12);
}

.front-upload {
  min-height: 248px;
}

.compact-upload {
  min-height: 168px;
}

.upload-empty,
.upload-preview {
  display: grid;
  place-items: center;
  gap: 5px;
}

.upload-empty strong,
.upload-preview strong,
.upload-tile strong {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 840;
}

.upload-empty small,
.upload-preview small,
.upload-tile small {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 680;
}

.upload-preview {
  width: 100%;
  grid-template-columns: minmax(96px, 170px) minmax(0, 1fr);
  justify-items: start;
  text-align: left;
}

.upload-preview img {
  width: 100%;
  aspect-ratio: 0.707 / 1;
  border-radius: 8px;
  object-fit: cover;
  background: #e7ebff;
  box-shadow: 0 8px 16px rgba(44, 50, 130, 0.12);
}

.extra-upload-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
}

.extra-preview-tile {
  display: grid;
  gap: 5px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px;
  background: var(--panel);
}

.extra-preview-tile img {
  width: 100%;
  aspect-ratio: 0.707 / 1;
  border-radius: 6px;
  object-fit: cover;
  background: #e7ebff;
}

.extra-preview-tile small {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.72rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.add-extra,
.backup-import {
  min-height: 86px;
}

.quick-add {
  gap: 14px;
}

.quick-add-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.quick-add-heading h3 {
  margin-bottom: 4px;
}

.quick-add-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.quick-grid,
.section-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.form-section {
  padding: 0;
  overflow: hidden;
  background: var(--panel);
}

.form-section summary {
  min-height: 50px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  color: var(--ink);
  font-weight: 780;
  cursor: pointer;
  list-style-position: inside;
}

.form-section[open] summary {
  border-bottom: 1px solid var(--line);
}

.form-section .section-grid {
  padding: 14px;
}

.lookup-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
}

.movie-results {
  display: grid;
  gap: 8px;
}

.movie-result {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 10px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: var(--panel);
  color: inherit;
}

.movie-result:hover {
  border-color: rgba(89, 99, 255, 0.32);
}

.movie-result-poster {
  width: 54px;
  height: 80px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 6px;
  background: #e7ebff;
  color: var(--secondary);
  font-size: 0.72rem;
  font-weight: 720;
  text-align: center;
}

.movie-result-poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.movie-result strong,
.movie-result span,
.movie-result p {
  display: block;
}

.movie-result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.movie-result-actions .ghost-button {
  min-height: 36px;
  padding: 0 12px;
}

.movie-result span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.82rem;
}

.movie-result p {
  display: -webkit-box;
  margin: 6px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.82rem;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.empty-state {
  border: 1px solid rgba(89, 99, 255, 0.16);
  border-radius: 8px;
  padding: 28px 20px;
  background:
    linear-gradient(135deg, rgba(89, 99, 255, 0.1), transparent 58%),
    var(--panel);
  text-align: center;
  box-shadow: 0 8px 18px rgba(44, 50, 130, 0.08);
}

.empty-state p {
  color: var(--muted);
}

.hidden {
  display: none !important;
}

.movie-list,
.timeline-list,
.stats-grid,
.breakdown-grid,
.settings-grid {
  display: grid;
  gap: 12px;
}

.movie-list {
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.timeline-list {
  position: relative;
  gap: 14px;
}

.timeline-list::before {
  content: "";
  position: absolute;
  left: 13px;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--accent), var(--pink), var(--gold));
}

.timeline-group {
  position: relative;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 10px;
}

.timeline-marker {
  position: relative;
  z-index: 1;
  width: 16px;
  height: 16px;
  margin: 18px auto 0;
  border: 4px solid white;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 4px 10px rgba(89, 99, 255, 0.28);
}

.timeline-content {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--panel);
  box-shadow: 0 8px 18px rgba(44, 50, 130, 0.08);
}

.timeline-content h3 {
  margin-bottom: 2px;
}

.timeline-posters {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(138px, 168px);
  gap: 10px;
  margin-top: 12px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.timeline-poster {
  min-width: 0;
  border: 1px solid rgba(49, 54, 132, 0.1);
  border-radius: 8px;
  padding: 8px;
  background: #f7f8ff;
  color: inherit;
  text-align: left;
}

.timeline-poster img {
  width: 100%;
  aspect-ratio: 0.707 / 1;
  border-radius: 6px;
  object-fit: cover;
  background: #e7ebff;
}

.timeline-poster span,
.timeline-poster small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timeline-poster span {
  margin-top: 7px;
  color: var(--ink);
  font-weight: 800;
}

.timeline-poster small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.74rem;
}

.movie-card,
.stat-card,
.panel,
.breakdown-card {
  padding: 16px;
}

.movie-posters {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  overflow-x: auto;
}

.movie-thumb {
  width: 52px;
  height: 74px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  object-fit: cover;
  background: #e7ebff;
}

.stats-grid {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  margin-bottom: 12px;
}

.stat-card {
  background:
    linear-gradient(180deg, rgba(89, 99, 255, 0.08), transparent),
    var(--panel);
}

.stat-number {
  margin: 0;
  color: var(--accent-dark);
  font-size: 2rem;
  font-weight: 860;
}

.breakdown-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.breakdown-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.breakdown-row:last-child {
  border-bottom: 0;
}

.settings-grid {
  grid-template-columns: 1fr;
}

.settings-disclosure {
  padding: 0;
  overflow: hidden;
}

.settings-disclosure > summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  min-height: 64px;
  padding: 12px 16px;
  cursor: pointer;
  list-style: none;
}

.settings-disclosure > summary::-webkit-details-marker {
  display: none;
}

.settings-disclosure > summary::after {
  content: "+";
  justify-self: end;
  align-self: center;
  color: var(--accent-dark);
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 820;
}

.settings-disclosure[open] > summary::after {
  content: "-";
}

.settings-summary-copy,
.settings-summary-copy strong,
.settings-summary-copy span {
  min-width: 0;
}

.settings-summary-copy {
  display: grid;
  gap: 3px;
}

.settings-summary-copy strong {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 840;
  line-height: 1.12;
}

.settings-summary-copy span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 680;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-disclosure-body {
  display: grid;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding: 14px 16px 16px;
}

.settings-form {
  display: grid;
  gap: 12px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.toggle-row {
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f7f8ff;
  cursor: pointer;
}

.toggle-row > span {
  display: grid;
  gap: 4px;
  overflow: visible;
  white-space: normal;
}

.toggle-row strong {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 840;
}

.toggle-row small {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 680;
  overflow: visible;
  white-space: normal;
}

.toggle-row input {
  position: relative;
  width: 54px;
  min-height: 32px;
  height: 32px;
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 0;
  background: #d9def5;
  box-shadow: inset 0 0 0 1px rgba(49, 54, 132, 0.1);
  transition: background 0.18s ease;
}

.toggle-row input::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 4px 10px rgba(44, 50, 130, 0.18);
  transition: transform 0.18s ease;
}

.toggle-row input:checked {
  background: linear-gradient(180deg, #7f83ff, var(--accent));
}

.toggle-row input:checked::after {
  transform: translateX(22px);
}

.preset-editor {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.release-panel {
  background:
    linear-gradient(135deg, rgba(89, 99, 255, 0.08), transparent 58%),
    var(--panel);
}

.release-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.release-list details {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f8ff;
}

.release-list summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  padding: 10px;
  cursor: pointer;
  list-style: none;
}

.release-list summary::-webkit-details-marker {
  display: none;
}

.release-list summary::after {
  content: "+";
  grid-column: 2;
  grid-row: 1;
  justify-self: end;
  color: var(--muted);
  font-family: var(--font-display);
  font-weight: 840;
}

.release-list details[open] summary::after {
  content: "-";
}

.release-list span {
  width: max-content;
  border-radius: 999px;
  padding: 2px 9px;
  background: #e9edff;
  color: var(--accent-dark);
  font-family: var(--font-display);
  font-size: 0.76rem;
  font-weight: 820;
}

.release-list strong {
  color: var(--ink);
  min-width: 0;
  padding-right: 22px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.release-list p {
  margin: 0;
  border-top: 1px solid var(--line);
  padding: 10px;
  color: var(--muted);
  font-size: 0.86rem;
}

.preset-group {
  display: grid;
  gap: 8px;
}

.preset-add {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

dialog {
  width: min(880px, calc(100% - 24px));
  max-height: calc(100vh - 24px);
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 0;
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow);
}

dialog.swipe-back-surface {
  transform: translate3d(var(--swipe-back-x), 0, 0);
}

dialog[data-fallback-open="true"] {
  position: fixed;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  z-index: 1000;
}

dialog[data-fallback-open="true"].swipe-back-surface {
  transform: translate(calc(-50% + var(--swipe-back-x)), -50%);
}

body.dialog-fallback-open {
  overflow: hidden;
}

body.dialog-fallback-open::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 999;
  height: auto;
  background: rgba(26, 26, 86, 0.48);
}

dialog::backdrop {
  background: rgba(26, 26, 86, 0.48);
}

dialog.swiping::backdrop,
dialog.swipe-back-release::backdrop {
  background: rgba(26, 26, 86, 0.14);
}

.modal-form {
  padding: 20px;
}

.modal-heading {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin: -20px -20px 18px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(16px);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.span-2 {
  grid-column: span 2;
}

.form-actions {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin: 18px -20px -20px;
  padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(16px);
}

.form-error {
  margin-top: 16px;
  border: 1px solid rgba(255, 77, 109, 0.24);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff0f4;
  color: #b72b48;
  font-size: 0.92rem;
}

.detail-modal {
  padding: 20px;
}

.detail-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.poster-detail-body {
  display: grid;
  grid-template-columns: minmax(220px, 0.74fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.detail-image {
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #e7ebff;
  color: var(--muted);
  min-height: 320px;
}

.detail-image-button {
  width: 100%;
  padding: 0;
  color: var(--muted);
  cursor: pointer;
}

.detail-image img {
  width: 100%;
  height: 100%;
  max-height: min(70vh, 720px);
  object-fit: cover;
}

.detail-info {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 12px;
}

.detail-mode-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.small-button {
  min-height: 34px;
  padding: 0 12px;
  font-size: 0.86rem;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.detail-field {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #f7f8ff;
}

.detail-field span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 760;
}

.detail-field strong {
  min-width: 0;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.detail-notes {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--panel);
}

.detail-section {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #ffffff;
  box-shadow: 0 8px 18px rgba(44, 50, 130, 0.06);
}

.detail-notes h3,
.detail-section h3 {
  margin-bottom: 6px;
}

.detail-notes p,
.detail-copy,
.detail-footnote {
  margin: 0;
  color: var(--muted);
}

.detail-copy {
  line-height: 1.65;
}

.detail-core-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
}

.detail-extra-images {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(82px, 1fr));
  gap: 8px;
}

.detail-extra-image {
  display: grid;
  gap: 6px;
  min-width: 0;
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: transparent;
  color: var(--accent-dark);
  text-align: left;
}

.detail-extra-image img {
  width: 100%;
  aspect-ratio: 0.707 / 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  object-fit: cover;
  background: #e7ebff;
}

.detail-extra-image span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 760;
  text-align: center;
}

#image-viewer-dialog {
  width: min(760px, calc(100% - 24px));
  max-height: calc(100vh - 24px);
  background: #101245;
  color: white;
}

.image-viewer-modal {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.image-viewer-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.image-viewer-bar strong {
  min-width: 0;
  overflow: hidden;
  color: white;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-viewer-frame {
  display: grid;
  place-items: center;
  min-height: min(72vh, 720px);
  overflow: hidden;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.image-viewer-frame img {
  display: block;
  max-width: 100%;
  max-height: min(78vh, 780px);
  object-fit: contain;
}

.primary-button:disabled,
.ghost-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(94px + env(safe-area-inset-bottom));
  z-index: 50;
  transform: translateX(-50%) translateY(20px);
  max-width: min(440px, calc(100% - 32px));
  border-radius: 999px;
  padding: 12px 16px;
  background: rgba(39, 36, 138, 0.94);
  color: white;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.update-prompt {
  position: fixed;
  left: 50%;
  bottom: calc(94px + env(safe-area-inset-bottom));
  z-index: 70;
  width: min(520px, calc(100% - 24px));
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  border: 1px solid rgba(89, 99, 255, 0.18);
  border-radius: 8px;
  padding: 14px;
  background:
    linear-gradient(135deg, rgba(89, 99, 255, 0.1), transparent 56%),
    rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 36px rgba(35, 29, 121, 0.28);
  transform: translateX(-50%);
  backdrop-filter: blur(18px);
}

.update-prompt strong {
  display: block;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.02rem;
  font-weight: 840;
}

.update-prompt p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.update-actions {
  display: flex;
  gap: 8px;
}

.update-actions button {
  min-height: 38px;
  padding: 0 13px;
}

@media (max-width: 860px) {
  .filter-panel {
    grid-template-columns: 1fr;
  }

  .filter-panel.compact-filter {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .app-shell {
    padding: calc(12px + env(safe-area-inset-top)) 12px calc(104px + env(safe-area-inset-bottom));
  }

  .topbar {
    margin: calc(-12px - env(safe-area-inset-top)) -12px 12px;
    padding: calc(14px + env(safe-area-inset-top)) 12px 0;
  }

  .brand-row {
    grid-template-columns: 44px minmax(0, 1fr) 56px;
  }

  .topbar-panel[data-topbar-panel="wantlist"] .brand-row {
    grid-template-columns: minmax(0, 1fr) 56px;
  }

  .brand-avatar {
    width: 44px;
    height: 44px;
    font-size: 0.85rem;
  }

  .section-header {
    display: block;
  }

  .section-header .primary-button {
    width: 100%;
    margin-top: 12px;
  }

  .form-grid,
  .quick-grid,
  .section-grid,
  .lookup-row {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: auto;
  }

  .poster-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .poster-card-body {
    padding: 10px;
  }

  .poster-title {
    font-size: 0.96rem;
  }

  .poster-list-row button,
  .want-list-row button {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .poster-list-row .pill-row,
  .want-list-row .pill-row {
    justify-content: flex-start;
    margin-top: 8px;
  }

  .profile-hero,
  .poster-detail-body,
  .detail-grid,
  .detail-mode-bar {
    grid-template-columns: 1fr;
  }

  .detail-mode-bar .ghost-button {
    width: 100%;
  }

  .profile-hero .primary-button {
    width: 100%;
  }

  .upload-preview {
    grid-template-columns: minmax(92px, 120px) minmax(0, 1fr);
  }

  .front-upload {
    min-height: 214px;
  }

  .timeline-posters {
    grid-auto-columns: minmax(124px, 148px);
  }

  .detail-modal {
    padding: 14px;
  }

  .detail-image {
    min-height: 280px;
  }

  dialog {
    width: 100%;
    max-width: none;
    max-height: min(92vh, 860px);
    margin: auto 0 0;
    border-radius: 8px 8px 0 0;
  }

  dialog[data-fallback-open="true"] {
    inset: auto 0 0 0;
    transform: none;
  }

  dialog[data-fallback-open="true"].swipe-back-surface {
    transform: translate3d(var(--swipe-back-x), 0, 0);
  }

  .modal-form {
    padding: 14px;
  }

  .modal-heading {
    margin: -14px -14px 14px;
    padding: 14px;
  }

  .detail-modal .modal-heading {
    margin: -14px -14px 14px;
  }

  .form-actions {
    flex-wrap: wrap;
    margin: 18px -14px -14px;
    padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  }

  .form-actions button {
    flex: 1 1 130px;
  }

  .update-prompt {
    grid-template-columns: 1fr;
  }

  .update-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 380px) {
  .top-icon-button {
    width: 52px;
    min-width: 52px;
    font-size: 0.86rem;
  }

  .poster-grid {
    grid-template-columns: 1fr 1fr;
  }

  .segment {
    padding: 0 8px;
    font-size: 0.82rem;
  }
}
