:root,
[data-theme="dark"] {
  --bg: #000;
  --bg-secondary: #000;
  --bg-tertiary: #000;
  --text: #fff;
  --text-bold: #fff;
  --text-muted: #fff;
  --text-lead: #fff;
  --border: #fff;
  --border-strong: #fff;
  --link: #fff;
  --link-hover: #fff;
  --toggle-track: #000;
  --toggle-dot: #fff;
  --toggle-border: #fff;
  --danger-color: #fff;
  --pending-color: #fff;
  --processing-color: #fff;
  --success-color: #fff;
}

[data-theme="light"] {
  --bg: #fff;
  --bg-secondary: #fff;
  --bg-tertiary: #fff;
  --text: #000;
  --text-bold: #000;
  --text-muted: #000;
  --text-lead: #000;
  --border: #000;
  --border-strong: #000;
  --link: #000;
  --link-hover: #000;
  --toggle-track: #fff;
  --toggle-dot: #000;
  --toggle-border: #000;
  --danger-color: #000;
  --pending-color: #000;
  --processing-color: #000;
  --success-color: #000;
}

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

html, body {
  background: var(--bg);
}

body {
  font-family: ui-sans-serif, system-ui, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
  font-size: 1rem;
  line-height: 1.7;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---- Layout ---- */

.container {
  max-width: 680px;
  margin: 0 auto;
  padding: 0 28px;
  width: 100%;
}

.container-wide {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 28px;
  width: 100%;
}

main {
  flex: 1;
}

.main-narrow {
  padding: 0 0 96px;
}

.main-wide {
  padding: 0 0 96px;
}

/* ---- Nav ---- */

nav {
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.85rem;
  padding: 28px 0 12px;
}

nav .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1400px;
}

nav .nav-left {
  display: flex;
  align-items: center;
  gap: 28px;
}

nav .site-name {
  font-weight: 650;
  font-size: 0.95rem;
  color: var(--text-bold);
  text-decoration: none;
  border-bottom: none;
  line-height: 1;
}

nav .site-name:hover {
  opacity: 0.68;
}

nav .nav-links {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 18px;
}

nav .nav-links li {
  line-height: 1;
}

nav .nav-links a {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-bold);
  text-decoration: none;
  border-bottom: none;
  line-height: 1;
}

nav .nav-links a:hover {
  opacity: 0.68;
}

/* ---- Theme toggle ---- */

.theme-toggle {
  position: relative;
  display: flex;
  align-items: center;
  height: 16px;
  opacity: 0.72;
}

.theme-toggle .toggle-inputs {
  position: relative;
  display: flex;
  align-items: center;
  height: 16px;
  z-index: 2;
}

.theme-toggle label {
  position: relative;
  display: flex;
  align-items: center;
  cursor: pointer;
}

.theme-toggle input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  inset: 0;
}

.theme-toggle .toggle-icon {
  width: 16px;
  height: 16px;
  display: block;
  opacity: 0.4;
  color: var(--text-bold);
}

.theme-toggle .toggle-icon svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}

.theme-toggle input:checked ~ .toggle-icon {
  opacity: 1;
}

.theme-toggle .toggle-label-light {
  width: 64px;
  height: 24px;
  justify-content: flex-end;
  padding-right: 16px;
}

.theme-toggle .toggle-label-auto {
  width: 24px;
  height: 24px;
  justify-content: center;
}

.theme-toggle .auto-text {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.5rem;
  font-weight: 700;
  color: var(--text-bold);
  opacity: 0.4;
  cursor: pointer;
  display: none;
}

.theme-toggle .toggle-label-auto input:checked ~ .auto-text {
  opacity: 1;
}

.theme-toggle .toggle-label-dark {
  width: 64px;
  height: 24px;
  padding-left: 16px;
}

.theme-toggle .track-wrapper {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 48px;
  height: 16px;
  z-index: 1;
}

.theme-toggle .track {
  width: 48px;
  height: 16px;
  background: var(--toggle-track);
  border: 1px solid var(--toggle-border);
  border-radius: 999px;
}

.theme-toggle .track-dot {
  position: absolute;
  top: 4px;
  left: 20px;
  width: 8px;
  height: 8px;
  background: var(--toggle-dot);
  transition: left 0.15s linear;
  border-radius: 999px;
}

[data-theme-pref="light"] .theme-toggle .track-dot {
  left: 4px;
}

[data-theme-pref="auto"] .theme-toggle .track-dot {
  left: 20px;
}

[data-theme-pref="dark"] .theme-toggle .track-dot {
  left: 36px;
}

/* ---- Typography ---- */

h1, h2, h3, h4 {
  color: var(--text-bold);
  font-weight: 650;
  line-height: 1.18;
}

h1 {
  font-size: 2.25rem;
  margin-bottom: 10px;
}

h2 {
  font-size: 1.1rem;
  margin-top: 2.4em;
  margin-bottom: 0.65em;
}

h3 {
  font-size: 1rem;
  margin-top: 1.8em;
  margin-bottom: 0.5em;
}

p {
  margin-bottom: 1em;
}

a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
  text-decoration-color: var(--text-muted);
  font-weight: 500;
}

a:hover {
  text-decoration-color: var(--link);
}

strong {
  color: var(--text-bold);
  font-weight: 700;
}

em {
  font-style: italic;
}

/* ---- Home page ---- */

.page-header {
  padding: 72px 0 20px;
}

.page-header h1 {
  font-size: 3rem;
  margin-bottom: 8px;
}

.page-header .subtitle {
  color: var(--text-muted);
  font-size: 1rem;
  font-weight: 400;
  margin-bottom: 0;
  opacity: 0.72;
}

.intro {
  padding: 20px 0 28px;
}

.intro p {
  font-size: 1.05rem;
  line-height: 1.75;
}

.intro p:last-child {
  margin-bottom: 0;
}

.section {
  padding: 14px 0;
}

.section:last-child {
  border-bottom: none;
}

.section h2 {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  margin-top: 0;
  font-weight: 600;
  opacity: 0.72;
}

.section p {
  font-size: 1rem;
  margin-bottom: 0;
}

.section ul {
  list-style: none;
}

.section li {
  margin-bottom: 6px;
  font-size: 1rem;
}

.section .desc {
  color: var(--text-muted);
  font-weight: 400;
  opacity: 0.7;
}

/* ---- Watches page ---- */

.watches-page {
  width: 100%;
}

.watches-header {
  max-width: 1400px;
  margin: 0 auto;
  padding: 56px 28px 28px;
}

.watches-header h1 {
  font-size: 2.5rem;
  margin-bottom: 14px;
}

.search-form {
  margin: 0 0 12px;
}

.search-input {
  width: 100%;
  padding: 12px 0;
  font-family: inherit;
  font-size: 1rem;
  border: none;
  border-bottom: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
}

.search-input:focus {
  outline: none;
  box-shadow: 0 1px 0 var(--border-strong);
}

.search-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0;
  opacity: 0.68;
}

.search-meta a {
  color: var(--text-muted);
  text-decoration-color: var(--text-muted);
}

.posters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 16px;
  background: var(--bg);
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 28px;
}

.poster-tile {
  display: block;
  aspect-ratio: 2/3;
  position: relative;
  overflow: hidden;
  background: var(--bg-secondary);
  border: none;
  text-decoration: none;
  font-weight: normal;
  color: var(--text);
}

.poster-tile img {
  opacity: 0.96;
}

.poster-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.poster-tile:hover img {
  opacity: 1;
}

.watches-header .admin-actions {
  margin-top: 12px;
}

/* ---- Detail page ---- */

.detail-hero {
  text-align: center;
  margin-bottom: 36px;
  padding-top: 56px;
}

.detail-hero h1 {
  font-size: 2rem;
  margin-bottom: 12px;
}

.detail-hero .year-info {
  color: var(--text-muted);
  font-weight: 400;
  opacity: 0.7;
}

.detail-hero .poster-container {
  margin: 0 auto;
  max-width: 280px;
}

.detail-hero .poster-container img {
  width: 100%;
  display: block;
}

.detail-container {
  display: flex;
  flex-direction: column;
  margin: 32px 0 48px;
  gap: 36px;
}

.poster-container {
  border: none;
}

.poster {
  width: 100%;
  aspect-ratio: 2/3;
  object-fit: cover;
  background: var(--bg-tertiary);
  display: block;
}

.info-container {
  flex: 1;
}

.meta-table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  border: none;
}

.meta-table th {
  text-align: left;
  padding: 8px 16px 8px 0;
  border-bottom: none;
  width: 30%;
  vertical-align: top;
  background: var(--bg-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  opacity: 0.7;
}

.meta-table td {
  padding: 8px 0;
  border-bottom: none;
  line-height: 1.6;
  font-size: 0.95rem;
}

.meta-table tr:last-child th,
.meta-table tr:last-child td {
  border-bottom: none;
}

.data-attribution {
  font-size: 0.85rem;
  margin-top: 24px;
  color: var(--text-muted);
  padding: 12px 0;
  text-align: center;
  opacity: 0.62;
}

.rating {
  font-size: 1.1rem;
  margin: 0 0 16px;
  padding: 6px 0;
  font-weight: 700;
  color: var(--text-bold);
}

.tagline {
  font-size: 1rem;
  margin: 0 0 24px;
  padding: 8px 0;
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  opacity: 0.72;
}

.overview {
  line-height: 1.65;
  padding: 8px 0;
}

.overview h2 {
  margin-bottom: 12px;
  font-size: 1rem;
  color: var(--text-muted);
  margin-top: 0;
  opacity: 0.72;
}

.overview p {
  margin-bottom: 12px;
  font-size: 0.95rem;
}

.navigation-controls {
  display: flex;
  flex-wrap: wrap;
  flex-direction: column;
  align-items: center;
  margin: 44px 0 16px;
  padding-top: 0;
  gap: 12px;
}

.back-link {
  display: inline-block;
  padding: 6px 0;
  font-size: 0.9rem;
}

/* ---- Buttons / Admin ---- */

.admin-button {
  padding: 0 0 2px;
  background: transparent;
  color: var(--text-bold);
  border: none;
  border-bottom: 1px solid var(--text-bold);
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
  font-size: 0.9rem;
  text-decoration: none;
  display: inline-block;
}

.admin-button:hover {
  opacity: 0.68;
}

button.admin-button {
  -webkit-appearance: none;
  appearance: none;
}

.danger-button {
  background: transparent;
  color: var(--danger-color);
  padding: 0 0 2px;
  border: none;
  border-bottom: 1px solid var(--danger-color);
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
  font-size: 0.9rem;
  text-decoration: none;
  display: inline-block;
}

.danger-button:hover {
  opacity: 0.68;
}

.admin-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ---- Admin pages (manage media) ---- */

.admin-header {
  margin: 24px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.admin-section {
  padding: 24px 0;
  margin-bottom: 24px;
  background: var(--bg-secondary);
}

.admin-section h3 {
  margin-top: 0;
  font-size: 1rem;
  padding-bottom: 0;
  margin-bottom: 16px;
  color: var(--text-bold);
}

.admin-input,
.admin-textarea,
input[type="file"] {
  width: 100%;
  font-family: inherit;
  font-size: 0.9rem;
  padding: 10px 0;
  margin-bottom: 14px;
  border: none;
  border-bottom: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
}

.admin-input:focus,
.admin-textarea:focus {
  outline: none;
  border-color: var(--text-bold);
}

.admin-textarea {
  min-height: 240px;
  resize: vertical;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-bold);
}

.form-actions {
  margin: 16px 0;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.danger-section {
  border-color: var(--danger-color);
}

.error-message,
.success-message {
  padding: 0;
  margin: 12px 0;
  font-size: 0.85rem;
}

.error-message {
  color: var(--danger-color);
}

.success-message {
  color: var(--success-color);
}

.progress-bar-container {
  width: 100%;
  height: 2px;
  background: var(--bg-tertiary);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--text-bold);
  transition: width 0.2s linear;
}

/* ---- Error page ---- */

.error-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  text-align: center;
}

.error-page h1 {
  font-size: 5rem;
  font-weight: 650;
  color: var(--text-bold);
  line-height: 1;
  margin-bottom: 16px;
}

.error-page h2 {
  font-size: 1.1rem;
  color: var(--text-muted);
  margin-top: 0;
  margin-bottom: 12px;
  opacity: 0.72;
}

.error-page p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ---- Responsive ---- */

@media (min-width: 768px) {
  .theme-toggle .auto-text {
    display: block;
  }
}

@media (max-width: 768px) {
  .posters-grid {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  }

  .watches-header {
    padding: 40px 20px 24px;
  }

  h1 {
    font-size: 1.6rem;
  }

  .page-header h1 {
    font-size: 2.4rem;
  }
}

@media (max-width: 480px) {
  .posters-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    padding: 0 20px;
  }
}
