:root {
  --pixar: #1f7a54;
  --disney: #2b4c8c;
  --fox: #a13d3d;
  --recent: #6b5a1e;
  --bg: #faf8f3;
  --card: #ffffff;
  --text: #2a2a2a;
  --muted: #767676;
  --border: #e5e1d8;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding: 20px 14px 60px;
}
main { max-width: 640px; margin: 0 auto; }
h1 { font-size: 1.4rem; margin: 0 0 4px; text-align: center; }
.sub { text-align: center; color: var(--muted); font-size: 0.85rem; }
.userbar { text-align: center; color: var(--muted); font-size: 0.78rem; margin: 6px 0 16px; }
button { font: inherit; cursor: pointer; }
button.link { background: none; border: none; padding: 0; color: var(--disney); text-decoration: underline; font-size: inherit; }
button.primary {
  background: var(--text); color: #fff; border: none; border-radius: 8px;
  padding: 9px 16px; font-weight: 600; font-size: 0.9rem;
}
button.primary:disabled { opacity: 0.5; }
input, textarea {
  font: inherit; font-size: 16px; /* stops iOS zoom */
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; background: #fff; color: var(--text);
}
#search { width: 100%; margin-bottom: 4px; }

/* Login */
.login-card { max-width: 340px; margin: 24px auto 0; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.login-card label { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: var(--muted); }
.error { color: var(--fox); font-size: 0.85rem; margin: 0; min-height: 1em; }

/* Sections */
.section-title {
  font-size: 1.1rem; font-weight: 700;
  margin: 28px 0 10px; padding-left: 10px;
  border-left: 5px solid var(--accent); color: var(--accent);
}
.pixar { --accent: var(--pixar); --tint: #f2f7f4; }
.disney { --accent: var(--disney); --tint: #f0f4fa; }
.fox { --accent: var(--fox); --tint: #faf0f0; }
.recent-title { --accent: var(--recent); }
.progress-wrap { background: var(--border); border-radius: 999px; height: 8px; overflow: hidden; margin: 6px 4px 4px; }
.progress-bar { height: 100%; border-radius: 999px; background: var(--accent); transition: width 0.25s ease; }
.progress-label { font-size: 0.75rem; color: var(--muted); padding-left: 4px; margin-bottom: 10px; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }

/* Movie rows */
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  cursor: pointer; user-select: none;
}
.movie:last-child .row, .movie:last-child .panel { border-bottom: none; }
.row.watched { background: var(--tint); }
.row input[type="checkbox"] { width: 20px; height: 20px; flex-shrink: 0; accent-color: var(--accent); pointer-events: none; }
.info { flex: 1; min-width: 0; }
.movie-name { font-weight: 600; font-size: 0.95rem; line-height: 1.25; }
.meta { font-size: 0.78rem; color: var(--muted); margin-top: 2px; }
.meta .last { color: var(--accent); font-weight: 600; }
.badge {
  font-size: 0.72rem; font-weight: 700; padding: 3px 8px; border-radius: 999px;
  white-space: nowrap; color: #fff; background: var(--accent);
}

/* Expanded panel */
.panel { padding: 10px 12px 14px 44px; border-bottom: 1px solid var(--border); background: #fcfbf8; }
.history { list-style: none; margin: 0 0 10px; padding: 0; font-size: 0.85rem; }
.history li { display: flex; align-items: baseline; gap: 8px; padding: 4px 0; }
.history .date { font-weight: 600; white-space: nowrap; }
.history .note { color: var(--muted); flex: 1; overflow-wrap: anywhere; }
.history .del { background: none; border: none; color: var(--muted); font-size: 1rem; padding: 0 4px; margin-left: auto; }
.history .empty { color: var(--muted); }
.log-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.log-form input[type="date"] { flex: 0 0 auto; }
.log-form input[name="note"] { flex: 1 1 140px; min-width: 0; }

/* Recent */
.recent-row { display: flex; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--border); font-size: 0.88rem; align-items: baseline; }
.recent-row:last-child { border-bottom: none; }
.recent-row .date { color: var(--muted); white-space: nowrap; width: 92px; flex-shrink: 0; font-size: 0.8rem; }
.recent-row .name { flex: 1; font-weight: 600; }
.recent-row .badge { align-self: center; }
.empty-card { padding: 12px; color: var(--muted); font-size: 0.85rem; }

/* Footer */
footer { margin-top: 32px; text-align: center; font-size: 0.85rem; }
.pill {
  display: inline-block; border: 1px solid var(--border); color: var(--muted);
  font-size: 0.8rem; padding: 8px 16px; border-radius: 999px; text-decoration: none; background: #fff;
}
.import { text-align: left; margin: 18px 0; background: #fff9e6; border: 1px solid #f0dfa0; border-radius: 8px; padding: 10px 12px; color: #6b5a1e; }
.import summary { cursor: pointer; font-weight: 600; }
.import pre { white-space: pre-wrap; word-break: break-all; background: #fff; border: 1px solid #f0dfa0; padding: 6px; border-radius: 6px; font-size: 0.72rem; }
.import textarea { width: 100%; margin-bottom: 8px; font-size: 0.8rem; }
.version { color: var(--muted); font-size: 0.7rem; margin-top: 12px; }

#toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: #fff; padding: 8px 16px; border-radius: 999px; font-size: 0.85rem;
  opacity: 0; transition: opacity 0.2s, transform 0.2s; pointer-events: none;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
