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

html, body {
  height: 100%;
  font-family: Georgia, serif;
  background: #e8e3db;
  color: #222;
}

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

header {
  background: #1a1a2e;
  color: #fff;
  padding: 1rem 2rem;
  text-align: center;
  flex-shrink: 0;
}

header h1 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.22em;
}

/* ── Cards layout ─────────────────────────────────────────────────────────── */

#cards-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  gap: 0.65rem;
  min-height: 0;
  padding: 0.75rem;
}

.card-label {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  padding: 0.55rem 1rem 0;
  text-transform: uppercase;
}

#movie-card {
  background: #1a1a2e;
  border-radius: 10px;
  flex-shrink: 0;
  overflow: hidden;
}

#movie-card .card-label {
  color: rgba(255, 255, 255, 0.4);
}

#crossword-card {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

#crossword-card .card-label {
  color: #aaa;
  cursor: pointer;
  user-select: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 0.55rem;
}

#crossword-chevron {
  font-size: 0.75rem;
  transition: transform 0.25s;
}

#crossword-card.collapsed #crossword-chevron {
  transform: rotate(180deg);
}

#crossword-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

#crossword-card.collapsed #crossword-body {
  display: none;
}

#crossword-card.collapsed {
  flex: 0 0 auto;
}

/* ── Puzzle nav ───────────────────────────────────────────────────────────── */

#puzzle-nav {
  border-bottom: 1px solid #f0ece4;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.2rem;
  padding: 0.5rem 1rem 0.65rem;
  flex-shrink: 0;
}

#current-date {
  color: #444;
  font-size: 0.95rem;
  min-width: 160px;
  text-align: center;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */

button {
  background: #f0ece4;
  color: #1a1a2e;
  border: none;
  padding: 0.45rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
  font-family: inherit;
  transition: background 0.15s;
}

button:disabled {
  opacity: 0.35;
  cursor: default;
}

button:not(:disabled):hover {
  background: #e0dbd2;
}

/* ── Crossword viewer ─────────────────────────────────────────────────────── */

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 0.75rem;
  min-height: 0;
}

#pdf-viewer {
  flex: 1;
  width: 100%;
  border: none;
  border-radius: 6px;
  background: #fff;
}

#no-puzzle {
  text-align: center;
  padding: 3rem;
  font-size: 1.1rem;
  color: #999;
}

/* ── Movie search bar ─────────────────────────────────────────────────────── */

#movie-search-bar {
  display: flex;
  flex-shrink: 0;
  gap: 0.5rem;
  padding: 0.55rem 1rem 0.75rem;
}

#movie-search-bar input {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 4px;
  color: #fff;
  flex: 1;
  font-family: inherit;
  font-size: 0.875rem;
  outline: none;
  padding: 0.4rem 0.75rem;
}

#movie-search-bar input::placeholder { color: rgba(255, 255, 255, 0.4); }
#movie-search-bar input:focus { border-color: rgba(255, 255, 255, 0.45); }

#movie-btn {
  background: #c40812;
  color: #fff;
  font-size: 0.85rem;
  padding: 0.4rem 0.9rem;
  white-space: nowrap;
}

#movie-btn:hover { background: #a5060f; }

/* ── Movie overlay ────────────────────────────────────────────────────────── */

#movie-overlay {
  background: #1a1a2e;
  border: 1px solid #2e2e4a;
  border-radius: 10px;
  bottom: 0.75rem;
  color: #f0f0f0;
  display: flex;
  flex-direction: column;
  left: 0.75rem;
  overflow: hidden;
  position: fixed;
  right: 0.75rem;
  z-index: 50;
}

#movie-overlay[hidden] { display: none; }

#movie-overlay-header {
  align-items: center;
  border-bottom: 1px solid #2a2a2a;
  display: flex;
  flex-shrink: 0;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
}

#movie-back {
  background: none;
  border: none;
  color: #c40812;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.85rem;
  opacity: 1;
  padding: 0;
}

#movie-overlay-title {
  color: #ccc;
  flex: 1;
  font-size: 0.85rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#movie-close {
  background: none;
  border: none;
  color: #666;
  cursor: pointer;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1;
  opacity: 1;
  padding: 0;
}

#movie-results {
  flex: 1;
  overflow-y: auto;
  padding: 0 1rem;
}

.movie-item {
  align-items: center;
  border-bottom: 1px solid #222;
  cursor: pointer;
  display: flex;
  gap: 0.75rem;
  padding: 0.65rem 0;
}

.movie-item:last-child { border-bottom: none; }

.movie-item img {
  border-radius: 3px;
  flex-shrink: 0;
  height: 54px;
  object-fit: cover;
  width: 36px;
}

.movie-item .no-poster {
  align-items: center;
  background: #2a2a2a;
  border-radius: 3px;
  color: #555;
  display: flex;
  flex-shrink: 0;
  font-size: 1.1rem;
  height: 54px;
  justify-content: center;
  width: 36px;
}

.movie-item-info { flex: 1; min-width: 0; }

.movie-item-info .title {
  font-size: 0.875rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.movie-item-info .meta {
  color: #777;
  font-size: 0.75rem;
  margin-top: 0.15rem;
}

.movie-item .chevron { color: #555; flex-shrink: 0; }

.nzb-item {
  border-bottom: 1px solid #222;
  padding: 0.65rem 0;
}

.nzb-item:last-child { border-bottom: none; }

.nzb-item .nzb-title {
  font-size: 0.78rem;
  font-weight: 500;
  margin-bottom: 0.35rem;
  word-break: break-all;
}

.nzb-item .nzb-meta {
  color: #777;
  font-size: 0.72rem;
  margin-bottom: 0.5rem;
}

.nzb-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.password-input {
  background: #1a1a1a;
  border: 1px solid #444;
  border-radius: 4px;
  color: #f0f0f0;
  flex: 1;
  font-family: inherit;
  font-size: 0.8rem;
  min-width: 0;
  outline: none;
  padding: 0.4rem 0.6rem;
}

.password-input:focus { border-color: #888; }

.confirm-btn {
  background: #c40812;
  border: none;
  border-radius: 4px;
  color: #fff;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  opacity: 1;
  padding: 0.4rem 0.75rem;
  white-space: nowrap;
}

.confirm-btn:hover { background: #a5060f; }

.see-all-btn {
  background: #2a2a2a;
  border: 1px solid #444;
  border-radius: 4px;
  color: #ccc;
  cursor: pointer;
  flex: 1;
  font-family: inherit;
  font-size: 0.8rem;
  opacity: 1;
  padding: 0.4rem 0.5rem;
}

.see-all-btn:hover { background: #333; }

.nzb-item .add-btn {
  background: #c40812;
  border: none;
  border-radius: 4px;
  color: #fff;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  opacity: 1;
  padding: 0.4rem 0.85rem;
  width: 100%;
}

.nzb-item .add-btn:disabled {
  background: #2a2a2a;
  color: #555;
  cursor: default;
}

.movie-msg {
  color: #666;
  font-family: Georgia, serif;
  font-size: 0.875rem;
  padding: 1.5rem 0;
  text-align: center;
}

/* ── Movie toast ──────────────────────────────────────────────────────────── */

#movie-toast {
  background: #1e1e1e;
  border: 1px solid #333;
  border-radius: 6px;
  bottom: 1.5rem;
  color: #f0f0f0;
  display: none;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.85rem;
  left: 50%;
  padding: 0.6rem 1.1rem;
  position: fixed;
  text-align: center;
  transform: translateX(-50%);
  white-space: nowrap;
  z-index: 100;
}

#movie-toast.success { border-color: #2a7a2a; }
#movie-toast.error   { border-color: #c40812; }
