:root {
  --bg: #F7F6F3;
  --surface: #FFFFFF;
  --surface-2: #F1EFEA;
  --text: #16150F;
  --muted: #6E6D64;
  --border: #E5E2D9;
  --accent: #DE4636;
  --accent-soft: rgba(222, 70, 54, 0.12);
  --shadow: 0 1px 3px rgba(0, 0, 0, .06), 0 10px 34px rgba(0, 0, 0, .06);
}

html[data-theme="dark"] {
  --bg: #0D0D10;
  --surface: #161619;
  --surface-2: #1E1E24;
  --text: #F3F2EE;
  --muted: #9A99A2;
  --border: #292930;
  --accent: #FF6B5E;
  --accent-soft: rgba(255, 107, 94, 0.15);
  --shadow: 0 1px 3px rgba(0, 0, 0, .45), 0 14px 44px rgba(0, 0, 0, .4);
}

* { box-sizing: border-box; }

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

body {
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  color: var(--text);
  font-family: 'IBM Plex Sans', system-ui, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent); text-decoration: underline; }

input, button, select { font-family: inherit; }
input::placeholder { color: var(--muted); }
select { color: var(--text); }

@keyframes sf-spin { to { transform: rotate(360deg); } }
@keyframes sf-up {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}
::selection { background: var(--accent-soft); }

.sf-app {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  transition: background .25s, color .25s;
}
.sf-wrap {
  max-width: 920px;
  margin: 0 auto;
  padding: 22px 20px 90px;
}

/* Header */
.sf-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 26px;
}
.sf-brand { display: flex; align-items: center; gap: 11px; }
.sf-brand-mark {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sf-brand-name {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -.02em;
}
.sf-controls { display: flex; align-items: center; gap: 8px; }

.sf-region { position: relative; display: flex; align-items: center; }
.sf-region-label {
  position: absolute; left: 11px;
  font-size: 12px; font-weight: 600;
  color: var(--muted);
  pointer-events: none;
}
.sf-region select {
  appearance: none; -webkit-appearance: none;
  padding: 9px 30px 9px 62px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 14px; font-weight: 500;
  cursor: pointer;
  box-shadow: var(--shadow);
}
.sf-region .sf-chevron {
  position: absolute; right: 10px;
  pointer-events: none;
  color: var(--text);
}

.sf-theme-btn {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  box-shadow: var(--shadow);
}

/* Hero */
.sf-hero { text-align: center; margin-bottom: 22px; }
.sf-hero h1 {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 34px;
  line-height: 1.08;
  letter-spacing: -.03em;
  margin: 0 0 8px;
}
.sf-hero p { margin: 0; color: var(--muted); font-size: 15px; }
.sf-hero p b { color: var(--text); }

/* Search */
.sf-search { position: relative; max-width: 600px; margin: 0 auto 8px; z-index: 20; }
.sf-search-inner { position: relative; }
.sf-search-icon {
  position: absolute; left: 17px; top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
}
.sf-search input {
  width: 100%;
  padding: 16px 46px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 16px;
  outline: none;
  box-shadow: var(--shadow);
}
.sf-clear {
  position: absolute; right: 12px; top: 50%;
  transform: translateY(-50%);
  width: 26px; height: 26px;
  border: none; border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

/* Autocomplete */
.sf-dropdown {
  position: absolute; left: 0; right: 0;
  top: calc(100% + 8px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: sf-up .16s ease;
}
.sf-suggestion {
  display: flex; align-items: center; gap: 13px;
  width: 100%; text-align: left;
  padding: 9px 13px;
  border: none;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.sf-suggestion:last-child { border-bottom: none; }
.sf-suggestion:hover { background: var(--surface-2); }
.sf-thumb {
  width: 40px; height: 56px;
  flex-shrink: 0;
  border-radius: 6px;
  overflow: hidden;
  position: relative;
  display: flex; align-items: center; justify-content: center;
}
.sf-thumb span {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700; font-size: 15px; color: #fff;
}
.sf-thumb img,
.sf-poster img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
}
.sf-suggestion-text { min-width: 0; flex: 1; }
.sf-suggestion-title {
  font-weight: 600; font-size: 14.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sf-suggestion-sub { font-size: 12.5px; color: var(--muted); }

/* Demo note */
.sf-demo-note {
  max-width: 600px;
  margin: 14px auto 0;
  font-size: 12.5px;
  color: var(--muted);
  text-align: center;
  line-height: 1.5;
}
.sf-demo-note b { color: var(--text); }

/* States */
.sf-body { margin-top: 32px; }
.sf-loading {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 60px 0; color: var(--muted);
}
.sf-spinner {
  width: 30px; height: 30px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: sf-spin .8s linear infinite;
}
.sf-error {
  max-width: 600px; margin: 0 auto;
  text-align: center; padding: 24px;
  color: var(--muted); font-size: 14px;
}

/* Result card */
.sf-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: sf-up .22s ease;
}
.sf-card-top {
  display: flex; gap: 22px; padding: 22px; flex-wrap: wrap;
}
.sf-poster {
  width: 150px; height: 222px;
  flex-shrink: 0;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .22);
}
.sf-poster span {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700; font-size: 34px; color: #fff;
  padding: 10px; text-align: center; line-height: 1.05;
}
.sf-info { flex: 1; min-width: 230px; }
.sf-badge-row {
  display: inline-flex; align-items: center; gap: 7px; margin-bottom: 8px;
}
.sf-type-pill {
  font-size: 11px; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 4px 9px;
  border-radius: 20px;
}
.sf-rating {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 13px; font-weight: 600;
}
.sf-info h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700; font-size: 26px;
  line-height: 1.12; letter-spacing: -.02em;
  margin: 0 0 6px;
}
.sf-meta { font-size: 13.5px; color: var(--muted); margin-bottom: 12px; }
.sf-genres {
  display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px;
}
.sf-genre {
  font-size: 12px; font-weight: 500;
  color: var(--text);
  background: var(--surface-2);
  padding: 4px 10px;
  border-radius: 20px;
}
.sf-overview {
  font-size: 14.5px; line-height: 1.55;
  color: var(--text); margin: 0 0 12px; opacity: .9;
}
.sf-cast { font-size: 13px; color: var(--muted); }
.sf-cast b { color: var(--text); font-weight: 600; }

/* Where to watch */
.sf-card-bottom {
  border-top: 1px solid var(--border);
  padding: 20px 22px;
}
.sf-watch-head {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px; margin-bottom: 18px;
}
.sf-watch-title {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600; font-size: 16px;
}
.sf-watch-title span { color: var(--muted); font-weight: 500; }
.sf-toggles { display: flex; gap: 7px; flex-wrap: wrap; }
.sf-toggle {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 13px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px; font-weight: 600;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
}
.sf-toggle .sf-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--border);
}
.sf-toggle.on {
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}
.sf-toggle.on .sf-dot { background: var(--accent); }

.sf-none {
  padding: 18px; border-radius: 12px;
  background: var(--surface-2);
  color: var(--muted); font-size: 14px;
  text-align: center;
}
.sf-groups { display: flex; flex-direction: column; gap: 18px; }
.sf-group-head {
  display: flex; align-items: baseline; gap: 9px; margin-bottom: 10px;
}
.sf-group-name { font-weight: 600; font-size: 14.5px; }
.sf-group-sub { font-size: 12.5px; color: var(--muted); }
.sf-providers { display: flex; flex-wrap: wrap; gap: 9px; }
.sf-provider {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 8px 14px 8px 8px;
  border-radius: 12px;
  font-weight: 600; font-size: 14px;
}
.sf-provider-badge {
  width: 24px; height: 24px;
  border-radius: 7px;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700; font-size: 13px;
}
.sf-all-hidden {
  padding: 14px; color: var(--muted);
  font-size: 13.5px; text-align: center;
}
.sf-footnote { margin-top: 16px; font-size: 11.5px; color: var(--muted); }

/* Popular chips */
.sf-popular { text-align: center; padding: 30px 0 0; }
.sf-popular-label { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.sf-chips {
  display: flex; flex-wrap: wrap; gap: 8px;
  justify-content: center; max-width: 560px; margin: 0 auto;
}
.sf-chip {
  padding: 9px 15px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 14px; font-weight: 500;
  cursor: pointer;
  box-shadow: var(--shadow);
}

/* Favorites — header button */
.sf-fav-btn { position: relative; }
.sf-fav-count {
  position: absolute; top: -6px; right: -6px;
  min-width: 17px; height: 17px;
  padding: 0 4px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-size: 11px; font-weight: 600;
  line-height: 17px; text-align: center;
}

/* Favorites — result-card Save/Saved toggle */
.sf-info-top {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
}
.sf-fav-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  flex-shrink: 0;
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px; font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
}
.sf-fav-toggle:hover { color: var(--text); }
.sf-fav-toggle.on {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

/* Favorites — home-view list */
.sf-favorites { padding-bottom: 6px; }
.sf-favorites .sf-popular-label {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--accent);
}
.sf-fav-chip {
  display: inline-flex; align-items: stretch;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.sf-fav-open {
  border: none; background: transparent;
  color: var(--text);
  font-size: 14px; font-weight: 500;
  padding: 9px 8px 9px 15px;
  cursor: pointer;
}
.sf-fav-open:hover { color: var(--accent); }
.sf-fav-year { color: var(--muted); font-weight: 400; font-size: 12.5px; }
.sf-fav-remove {
  border: none; background: transparent;
  color: var(--muted);
  padding: 0 10px 0 6px;
  cursor: pointer;
  display: flex; align-items: center;
}
.sf-fav-remove:hover { color: var(--accent); }

.sf-hidden { display: none !important; }

/* Small screens: keep the header controls from overflowing */
@media (max-width: 480px) {
  .sf-wrap { padding: 18px 14px 70px; }
  .sf-header { flex-wrap: wrap; gap: 10px; }
  .sf-controls { flex: 1 1 100%; justify-content: flex-end; }
  .sf-region { flex: 1; }
  .sf-region select { width: 100%; padding: 9px 28px 9px 54px; font-size: 13px; }
  .sf-brand-name { font-size: 17px; }
  .sf-hero h1 { font-size: 28px; }
}
