/* =====================================================================
   Movie Club - mobile-first, app-shaped UI
   ===================================================================== */

:root {
  --bg:        #0b0d12;
  --surface:   #141821;
  --surface-2: #1c2130;
  --line:      #262c3b;
  --text:      #e9ecf4;
  --muted:     #8b93a7;
  --accent:    #f5b544;
  --accent-dk: #b9822a;
  --danger:    #fb7185;
  --radius:    16px;
  --tabbar-h:  58px;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);

  --ease: cubic-bezier(.32, .72, 0, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior-y: none;
}

body {
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  text-rendering: optimizeLegibility;
}

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

button { cursor: pointer; border: 0; background: none; }

h1, h2, h3, h4, p { margin: 0; }

[hidden] { display: none !important; }

/* Only inputs get to be selectable - everything else should feel native. */
body { -webkit-user-select: none; user-select: none; }
input, textarea, .selectable { -webkit-user-select: text; user-select: text; }

/* =====================================================================
   Lock screen
   ===================================================================== */

.lock {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(24px + var(--safe-t)) 20px calc(24px + var(--safe-b));
  background:
    radial-gradient(120% 80% at 50% 0%, #1a2030 0%, var(--bg) 60%);
  overflow-y: auto;
}

.lock-inner { width: 100%; max-width: 420px; }

.brand { text-align: center; margin-bottom: 34px; }

.brand-mark {
  width: 62px; height: 62px;
  margin: 0 auto 14px;
  border-radius: 18px;
  background: linear-gradient(150deg, var(--accent), var(--accent-dk));
  position: relative;
  display: flex; align-items: center; justify-content: center; gap: 4px;
  box-shadow: 0 10px 30px rgba(245, 181, 68, .22);
}
.brand-mark span {
  width: 6px; height: 30px;
  border-radius: 3px;
  background: rgba(11, 13, 18, .78);
}
.brand-mark span:nth-child(2) { height: 40px; }

.brand h1 { font-size: 26px; font-weight: 700; letter-spacing: -.5px; }
.brand-sub { color: var(--muted); font-size: 15px; margin-top: 4px; }

.profile-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.profile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 12px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  transition: transform .15s var(--ease), border-color .15s;
}
.profile:active { transform: scale(.96); border-color: var(--accent); }
.profile .name { font-weight: 600; font-size: 16px; }
.profile .sub { font-size: 12px; color: var(--muted); }

.avatar {
  --sz: 40px;
  width: var(--sz); height: var(--sz);
  flex: 0 0 var(--sz);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: calc(var(--sz) * .42);
  color: #0b0d12;
  letter-spacing: .3px;
}
.avatar-lg { --sz: 56px; }
.avatar-sm { --sz: 26px; }

/* --- PIN pane --- */

.pin-pane { position: relative; padding-top: 6px; }

.pin-back {
  position: absolute; top: -46px; left: -4px;
  width: 40px; height: 40px;
  font-size: 20px; color: var(--muted);
  border-radius: 50%;
}

.pin-who {
  display: flex; align-items: center; gap: 14px;
  justify-content: center;
  margin-bottom: 22px;
}
.pin-name { font-size: 19px; font-weight: 650; }
.pin-hint { font-size: 13px; color: var(--muted); }
.pin-hint.error { color: var(--danger); }

.pin-dots {
  display: flex; justify-content: center; gap: 14px;
  margin-bottom: 28px; height: 14px;
}
.pin-dots i {
  width: 13px; height: 13px;
  border-radius: 50%;
  background: transparent;
  border: 2px solid var(--line);
  transition: background .12s, transform .12s var(--ease), border-color .12s;
}
.pin-dots i.on {
  background: var(--accent);
  border-color: var(--accent);
  transform: scale(1.12);
}

.pin-pane.shake { animation: shake .4s; }
@keyframes shake {
  10%, 90% { transform: translateX(-3px); }
  20%, 80% { transform: translateX(5px); }
  30%, 50%, 70% { transform: translateX(-8px); }
  40%, 60% { transform: translateX(8px); }
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  max-width: 300px;
  margin: 0 auto;
}
.keypad button {
  height: 66px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 25px;
  font-weight: 500;
  transition: transform .1s var(--ease), background .1s;
}
.keypad button:active { transform: scale(.92); background: var(--surface-2); }
.keypad .key-alt { background: transparent; border-color: transparent; font-size: 21px; }

/* =====================================================================
   App shell
   ===================================================================== */

.app { display: flex; flex-direction: column; min-height: 100%; }

.appbar {
  position: sticky; top: 0; z-index: 30;
  padding-top: var(--safe-t);
  background: rgba(11, 13, 18, .86);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line);
}

.appbar-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px 6px;
}
.appbar-title { font-size: 24px; font-weight: 700; letter-spacing: -.4px; }
.appbar-actions { display: flex; gap: 6px; }

.icon-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  display: grid; place-items: center;
  color: var(--text);
}
.icon-btn:active { background: var(--surface-2); }
.icon-btn svg { width: 21px; height: 21px; }

svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.searchbar {
  display: flex; align-items: center; gap: 8px;
  padding: 2px 16px 10px;
}
.searchbar input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 10px 13px;
  outline: none;
}
.searchbar input:focus { border-color: var(--accent); }

.link-btn { color: var(--accent); font-size: 14px; padding: 6px; }

.chiprow {
  display: flex; gap: 8px;
  padding: 0 16px 10px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.chiprow::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  padding: 7px 13px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13.5px;
  white-space: nowrap;
  transition: all .15s;
}
.chip.is-on {
  background: var(--accent);
  border-color: var(--accent);
  color: #10131a;
  font-weight: 600;
}
.chip-alt.is-on { background: #34d399; border-color: #34d399; }

.views { flex: 1; padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 12px); }
.pad { padding: 16px; }

/* =====================================================================
   Movie list
   ===================================================================== */

.movie-list { padding: 12px 16px; display: flex; flex-direction: column; gap: 12px; }

.card {
  display: flex;
  gap: 13px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px;
  transition: transform .13s var(--ease);
}
.card:active { transform: scale(.985); }

.poster {
  width: 62px; height: 93px;
  flex: 0 0 62px;
  border-radius: 9px;
  object-fit: cover;
  background: linear-gradient(150deg, var(--surface-2), #0f131c);
  display: grid; place-items: center;
  color: var(--muted);
  font-size: 11px; font-weight: 700;
  text-align: center;
  overflow: hidden;
}

.card-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.card-head { display: flex; align-items: flex-start; gap: 10px; }

.card-title {
  font-size: 15.5px; font-weight: 650; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-meta { font-size: 12.5px; color: var(--muted); margin-top: 3px; }

.avg {
  flex: 0 0 auto;
  width: 46px; height: 46px;
  border-radius: 13px;
  display: grid; place-items: center;
  background: var(--surface-2);
  border: 1px solid var(--line);
  line-height: 1;
}
.avg b { font-size: 17px; font-weight: 700; }
.avg small { display: block; font-size: 8.5px; color: var(--muted); letter-spacing: .6px; margin-top: 2px; }
.avg.good { background: rgba(52, 211, 153, .13); border-color: rgba(52, 211, 153, .4); }
.avg.good b { color: #34d399; }
.avg.mid  { background: rgba(245, 181, 68, .13); border-color: rgba(245, 181, 68, .4); }
.avg.mid b { color: var(--accent); }
.avg.bad  { background: rgba(251, 113, 133, .13); border-color: rgba(251, 113, 133, .4); }
.avg.bad b { color: var(--danger); }
.avg.none b { color: var(--muted); font-size: 15px; }

/* the 4 per-person scores */
.scores { display: flex; gap: 6px; margin-top: auto; padding-top: 9px; flex-wrap: wrap; }

.score {
  display: flex; align-items: center; gap: 5px;
  padding: 3px 8px 3px 3px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 12.5px;
  font-weight: 600;
}
.score .avatar { --sz: 19px; }
.score.empty { opacity: .42; }
.score.empty .val { color: var(--muted); font-weight: 500; }
.score.mine { border-color: rgba(245, 181, 68, .55); }

/* stars */
.stars { position: relative; display: inline-block; white-space: nowrap; line-height: 1; }
.stars .layer { letter-spacing: 2px; }
.stars .bg { color: #333c50; }
.stars .fg {
  position: absolute; inset: 0;
  overflow: hidden;
  color: var(--accent);
  width: 0;
}

.empty-state { text-align: center; color: var(--muted); padding: 60px 24px; }
.empty-state h3 { font-size: 17px; color: var(--text); margin-bottom: 6px; }
.empty-state p { font-size: 14px; line-height: 1.5; }

/* =====================================================================
   Tab bar
   ===================================================================== */

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  background: rgba(11, 13, 18, .92);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-top: 1px solid var(--line);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted);
  font-size: 10.5px;
  transition: color .15s;
}
.tab svg { width: 22px; height: 22px; }
.tab.is-on { color: var(--accent); }
.tab:active { opacity: .6; }

/* =====================================================================
   Add view
   ===================================================================== */

.search-wrap { position: relative; margin-bottom: 14px; }
.search-wrap input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px 42px 13px 14px;
  outline: none;
}
.search-wrap input:focus { border-color: var(--accent); }

.spinner {
  position: absolute; right: 14px; top: 50%; margin-top: -8px;
  width: 16px; height: 16px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.result-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }

.result {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 9px;
}
.result .poster { width: 46px; height: 69px; flex-basis: 46px; }
.result .r-body { flex: 1; min-width: 0; }
.result .r-title { font-size: 14.5px; font-weight: 600; }
.result .r-year { font-size: 12.5px; color: var(--muted); }

.pill-btn {
  flex: 0 0 auto;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--accent);
  color: #10131a;
  font-size: 13px; font-weight: 650;
}
.pill-btn:active { transform: scale(.95); }
.pill-btn.done { background: var(--surface-2); color: var(--muted); }

.ghost-btn {
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px dashed var(--line);
  color: var(--muted);
  font-size: 14px;
}
.ghost-btn.wide { display: block; width: 100%; }
.ghost-btn:active { border-color: var(--accent); color: var(--accent); }

/* =====================================================================
   Stats / Me
   ===================================================================== */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px;
  margin-bottom: 14px;
}
.panel h3 {
  font-size: 12px; text-transform: uppercase; letter-spacing: .8px;
  color: var(--muted); font-weight: 600; margin-bottom: 12px;
}

.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat-box { text-align: center; background: var(--surface-2); border-radius: 12px; padding: 13px 6px; }
.stat-box b { display: block; font-size: 22px; font-weight: 700; }
.stat-box span { font-size: 11px; color: var(--muted); }

.rank-row {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.rank-row:last-child { border-bottom: 0; }
.rank-row .rr-name { flex: 1; font-weight: 600; font-size: 14.5px; }
.rank-row .rr-sub { font-size: 12px; color: var(--muted); font-weight: 400; }
.rank-row .rr-val { font-size: 18px; font-weight: 700; }

.bar { height: 5px; border-radius: 3px; background: var(--surface-2); overflow: hidden; margin-top: 5px; }
.bar i { display: block; height: 100%; border-radius: 3px; }

.row-btn {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%;
  padding: 14px 15px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 13px;
  margin-bottom: 10px;
  font-size: 15px;
}
.row-btn:active { background: var(--surface-2); }
.row-btn.danger { color: var(--danger); }
.row-btn .chev { color: var(--muted); }

/* =====================================================================
   Detail (full screen) + Sheet (bottom)
   ===================================================================== */

.scrim {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0, 0, 0, .6);
  opacity: 0;
  transition: opacity .25s var(--ease);
}
.scrim.show { opacity: 1; }

.detail {
  position: fixed; inset: 0; z-index: 55;
  background: var(--bg);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  transform: translateY(100%);
  transition: transform .3s var(--ease);
}
.detail.show { transform: translateY(0); }

.hero { position: relative; height: 260px; overflow: hidden; }
.hero .backdrop {
  position: absolute; inset: -20px;
  background-size: cover; background-position: center;
  filter: blur(26px) saturate(140%) brightness(.55);
  transform: scale(1.15);
}
.hero::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(11,13,18,.35) 0%, rgba(11,13,18,.2) 40%, var(--bg) 100%);
}
.hero-content {
  position: absolute; inset: 0; z-index: 2;
  display: flex; align-items: flex-end; gap: 14px;
  padding: 0 16px 14px;
}
.hero-content .poster { width: 92px; height: 138px; flex-basis: 92px; box-shadow: 0 10px 28px rgba(0,0,0,.5); }
.hero-title { font-size: 21px; font-weight: 700; line-height: 1.2; }
.hero-meta { font-size: 13px; color: var(--muted); margin-top: 5px; }

.detail-close {
  position: absolute; z-index: 3;
  top: calc(10px + var(--safe-t)); left: 12px;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(11, 13, 18, .6);
  backdrop-filter: blur(8px);
  display: grid; place-items: center;
  color: #fff;
}
.detail-body { padding: 16px 16px calc(28px + var(--safe-b)); }

.plot { font-size: 14.5px; color: #c4cbdb; line-height: 1.55; }

.rate-cta {
  display: flex; align-items: center; justify-content: center; gap: 9px;
  width: 100%;
  padding: 14px;
  border-radius: 13px;
  background: var(--accent);
  color: #10131a;
  font-weight: 700; font-size: 15.5px;
  margin: 16px 0;
}
.rate-cta:active { transform: scale(.98); }
.rate-cta.rated { background: var(--surface-2); color: var(--text); border: 1px solid var(--line); }

.rating-row {
  display: flex; align-items: center; gap: 11px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.rating-row:last-child { border-bottom: 0; }
.rating-row .rr-main { flex: 1; min-width: 0; }
.rating-row .rr-who { font-weight: 600; font-size: 14.5px; }
.rating-row .rr-review {
  font-size: 13px; color: var(--muted); margin-top: 3px;
  line-height: 1.45; white-space: pre-wrap;
}
.rating-row .rr-num { font-size: 17px; font-weight: 700; }
.rating-row .rr-num.dim { color: var(--muted); font-size: 14px; font-weight: 500; }

/* --- bottom sheet --- */

.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 58;
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  border-top: 1px solid var(--line);
  transform: translateY(100%);
  transition: transform .3s var(--ease);
  max-height: 92vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.sheet.show { transform: translateY(0); }
.sheet-inner { padding: 8px 18px calc(22px + var(--safe-b)); }

.grabber {
  width: 38px; height: 4px; border-radius: 2px;
  background: var(--line);
  margin: 6px auto 14px;
}
.sheet h3 { font-size: 18px; font-weight: 700; margin-bottom: 3px; }
.sheet .sub { font-size: 13px; color: var(--muted); margin-bottom: 18px; }

.big-score {
  text-align: center;
  font-size: 52px; font-weight: 800;
  letter-spacing: -2px;
  line-height: 1;
  margin-bottom: 4px;
}
.big-score.unset { color: var(--muted); font-size: 34px; }
.big-word { text-align: center; font-size: 13px; color: var(--muted); margin-bottom: 18px; }

.star-input {
  display: flex; justify-content: center;
  padding: 6px 0 20px;
  touch-action: none;
}
.star-input .stars .layer { font-size: 27px; letter-spacing: 2.5px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.field input, .field textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 12px;
  outline: none;
  resize: none;
}
.field input:focus, .field textarea:focus { border-color: var(--accent); }

.sheet-actions { display: flex; gap: 10px; margin-top: 6px; }
.btn {
  flex: 1;
  padding: 14px;
  border-radius: 13px;
  font-weight: 650; font-size: 15px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); color: #10131a; border-color: var(--accent); }
.btn-danger { color: var(--danger); }
.btn[disabled] { opacity: .5; }

/* =====================================================================
   Toast
   ===================================================================== */

.toast {
  position: fixed; z-index: 70;
  left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-b) + 18px);
  transform: translate(-50%, 14px);
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 11px 18px;
  border-radius: 999px;
  font-size: 14px;
  box-shadow: 0 8px 26px rgba(0, 0, 0, .45);
  opacity: 0;
  transition: opacity .2s, transform .2s var(--ease);
  pointer-events: none;
  max-width: 88vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* =====================================================================
   Larger phones / tablets
   ===================================================================== */

@media (min-width: 620px) {
  .movie-list, .pad { max-width: 620px; margin: 0 auto; }
  .appbar-row, .chiprow, .searchbar { max-width: 620px; margin-left: auto; margin-right: auto; }
  .sheet { left: 50%; transform: translate(-50%, 100%); max-width: 560px; border-radius: 22px 22px 0 0; }
  .sheet.show { transform: translate(-50%, 0); }
  .detail-body, .hero-content { max-width: 620px; margin: 0 auto; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
