/* ==========================================================================
   EP. LOG — Classic 80s / 90s Cel Anime Aesthetic
   (Cowboy Bebop · Evangelion · Akira · Retro Laserdisc)
   ========================================================================== */

:root {
  --bg: #1d1f2b;
  --surface: #26293a;
  --surface-light: #30344a;
  --surface-border: #424765;
  --anime-red: #ff3366;
  --anime-yellow: #ffb703;
  --anime-cyan: #00e5ff;
  --anime-green: #10b981;
  --anime-purple: #a855f7;
  --text: #f3f5fa;
  --text-muted: #9aa2be;
  --font-title: 'Anton', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --font-jp: 'Noto Sans JP', sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  min-height: 100vh;
  position: relative;
  letter-spacing: -0.01em;
}

/* Subtle 35mm Film Cel Grain */
.film-cel-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
  opacity: 0.25;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.05'/%3E%3C/svg%3E");
}

/* ── 90s Anime Masthead / Title Screen ── */
.masthead {
  padding: 2.25rem 1.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  background: linear-gradient(180deg, #2b2e42 0%, var(--surface) 100%);
  border-bottom: 3px solid var(--anime-red);
  position: relative;
  box-shadow: 0 6px 20px rgba(10, 12, 18, 0.4);
}

.scene-tag {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--anime-yellow);
  letter-spacing: 0.15em;
  margin-bottom: 0.35rem;
  text-transform: uppercase;
}

.masthead-inner {
  text-align: center;
}

.title {
  font-family: var(--font-title);
  font-size: clamp(2.5rem, 8vw, 4.25rem);
  color: #ffffff;
  margin: 0;
  line-height: 0.9;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-shadow:
    3px 3px 0 var(--anime-red),
    -1px -1px 0 var(--anime-cyan);
}

.japanese-title {
  font-family: var(--font-jp);
  font-size: 0.75rem;
  font-weight: 900;
  color: var(--anime-cyan);
  letter-spacing: 0.35em;
  margin-top: 0.35rem;
}

.tagline {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0.5rem 0 0;
  font-style: italic;
}

.film-stamp {
  position: absolute;
  top: 1.25rem;
  right: 1.5rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--anime-yellow);
  background: #14151e;
  padding: 0.2rem 0.6rem;
  border: 1px solid var(--surface-border);
  letter-spacing: 0.1em;
}

/* ── Layout Grid ── */
.grid {
  max-width: 1020px;
  margin: 0 auto;
  padding: 1.75rem 1.25rem 3.5rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.panel-list, .panel-stats { grid-column: 1 / -1; }

/* ── Panels (Vintage Anime LD Frame / Console) ── */
.panel {
  background: var(--surface);
  border: 2px solid var(--surface-border);
  box-shadow: 5px 5px 0 rgba(12, 14, 22, 0.6);
  padding: 1.35rem;
  position: relative;
}

/* Top corner registration mark */
.panel::after {
  content: '+';
  position: absolute;
  top: 0.3rem;
  right: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--surface-border);
  pointer-events: none;
}

.panel-label {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  color: var(--anime-yellow);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--surface-border);
  text-transform: uppercase;
}

/* ── Forms ── */
.add-form {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.row {
  display: flex;
  gap: 0.65rem;
}

input, select {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  padding: 0.7rem 0.85rem;
  border: 1.5px solid var(--surface-border);
  background: #191b24;
  color: var(--text);
  outline: none;
  transition: all 0.15s ease;
}

input:focus, select:focus {
  border-color: var(--anime-cyan);
  box-shadow: 0 0 0 3px rgba(0, 229, 255, 0.15);
}

input::placeholder { color: var(--text-muted); opacity: 0.65; }

#f-title, #f-notes { width: 100%; }
#f-episode { width: 6.5rem; }
#f-status { flex: 1; }

select option {
  background: #191b24;
  color: var(--text);
}

/* ── Buttons (Tactile 90s Anime Action Controls) ── */
.btn {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  padding: 0.85rem 1.1rem;
  border: 2px solid transparent;
  cursor: pointer;
  text-transform: uppercase;
  transition: all 0.1s ease;
}

.btn:active { transform: translate(2px, 2px); }

.btn-primary {
  background: var(--anime-red);
  color: #ffffff;
  border-color: var(--anime-red);
  box-shadow: 3px 3px 0 rgba(10, 12, 18, 0.7);
}

.btn-primary:hover {
  background: #e62254;
  box-shadow: 4px 4px 0 rgba(10, 12, 18, 0.9);
}

.btn-accent {
  background: transparent;
  color: var(--anime-cyan);
  border-color: var(--anime-cyan);
  width: 100%;
  box-shadow: 3px 3px 0 rgba(10, 12, 18, 0.7);
}

.btn-accent:hover {
  background: var(--anime-cyan);
  color: #14151e;
}

/* ── Recommendation Output ── */
.recommend-copy {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 0 0 1rem;
  line-height: 1.5;
}

.recommend-output {
  margin-top: 1rem;
  font-size: 0.85rem;
  white-space: pre-wrap;
  line-height: 1.6;
  color: var(--text);
  background: #191b24;
  padding: 1rem;
  border: 1px solid var(--surface-border);
  border-left: 3px solid var(--anime-yellow);
}

.recommend-output:empty {
  display: none;
}

.recommend-output.error {
  color: var(--anime-red);
  border-left-color: var(--anime-red);
}

.recommend-output.loading {
  color: var(--text-muted);
  font-style: italic;
}

/* ── Mission Stats / Data ── */
.stats-row {
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
  margin-bottom: 1.35rem;
}

.stat-block {
  background: #191b24;
  border: 2px solid var(--surface-border);
  padding: 0.85rem 1.35rem;
  min-width: 7.5rem;
  text-align: center;
  box-shadow: 3px 3px 0 rgba(10, 12, 18, 0.5);
}

.stat-value {
  font-family: var(--font-title);
  font-size: 2.5rem;
  line-height: 1;
  color: #ffffff;
  letter-spacing: 0.02em;
}

.stat-label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--anime-yellow);
  margin-top: 0.35rem;
}

.stats-subheading {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

.stats-status { margin-bottom: 1.35rem; }

.status-bars {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.status-bar-row {
  display: grid;
  grid-template-columns: 8rem 1fr 2.5rem;
  align-items: center;
  gap: 0.75rem;
}

.status-bar-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text);
  font-weight: 600;
}

.status-bar-track {
  height: 1.1rem;
  background: #191b24;
  border: 1.5px solid var(--surface-border);
  overflow: hidden;
}

.status-bar-fill {
  height: 100%;
  min-width: 4px;
  transition: width 0.3s ease;
}

.status-bar-count {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  text-align: right;
  color: #ffffff;
  font-weight: 700;
}

/* Status bar palette (90s Cel Anime Tones) */
.status-watching .status-bar-fill,
.status-watching { background: var(--anime-cyan); color: #14151e; }

.status-completed .status-bar-fill,
.status-completed { background: var(--anime-green); color: #14151e; }

.status-on-hold .status-bar-fill,
.status-on-hold { background: var(--anime-yellow); color: #14151e; }

.status-dropped .status-bar-fill,
.status-dropped { background: var(--anime-red); color: #ffffff; }

.status-plan-to-watch .status-bar-fill,
.status-plan-to-watch { background: #64748b; color: #ffffff; }

.genre-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.genre-pill {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  border: 1.5px solid var(--surface-border);
  background: #191b24;
  color: var(--text);
  padding: 0.25rem 0.6rem;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.genre-count {
  font-weight: 700;
  background: var(--anime-yellow);
  color: #14151e;
  padding: 0.05rem 0.35rem;
  font-size: 0.65rem;
}

/* ── Anime Card List (Cel Film Log) ── */
.anime-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.empty-state {
  color: var(--text-muted);
  font-style: italic;
  padding: 1.25rem 0;
}

.anime-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1.25rem;
  padding: 1rem 1.15rem;
  background: var(--surface-light);
  border: 2px solid var(--surface-border);
  box-shadow: 4px 4px 0 rgba(10, 12, 18, 0.5);
  transition: all 0.15s ease;
}

.anime-card:hover {
  border-color: var(--anime-cyan);
  box-shadow: 5px 5px 0 rgba(0, 229, 255, 0.2);
}

/* Episode Counter Badge */
.ep-counter {
  font-family: var(--font-title);
  font-size: 1.35rem;
  color: #ffffff;
  background: #14151e;
  padding: 0.35rem 0.65rem;
  min-width: 4.2rem;
  text-align: center;
  border: 1.5px solid var(--anime-yellow);
  box-shadow: 2px 2px 0 var(--anime-yellow);
  letter-spacing: 0.04em;
}

.anime-info .anime-title {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1.05rem;
  color: #ffffff;
  letter-spacing: -0.01em;
}

.anime-info .anime-genre {
  font-size: 0.75rem;
  color: var(--anime-cyan);
  font-family: var(--font-mono);
  margin-top: 0.2rem;
  font-weight: 600;
}

.anime-info .anime-notes {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.genre-refresh-btn {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  background: #191b24;
  border: 1px dashed var(--surface-border);
  padding: 0.2rem 0.5rem;
  margin-top: 0.25rem;
  cursor: pointer;
}

.genre-refresh-btn:hover {
  border-color: var(--anime-cyan);
  color: var(--anime-cyan);
}

/* Mecha Tier Rating Buttons (S, A, B, C) */
.tier-selector {
  display: flex;
  gap: 0.3rem;
  margin-top: 0.45rem;
}

.tier-btn {
  font-family: var(--font-title);
  font-size: 0.8rem;
  width: 1.75rem;
  height: 1.75rem;
  line-height: 1.75rem;
  text-align: center;
  padding: 0;
  border: 1.5px solid var(--surface-border);
  background: #14151e;
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0.65;
  transition: all 0.1s ease;
}

.tier-btn:hover { opacity: 1; }
.tier-btn.active { opacity: 1; border-color: transparent; }
.tier-btn.tier-S.active { background: var(--anime-red); color: #ffffff; box-shadow: 2px 2px 0 #990033; }
.tier-btn.tier-A.active { background: var(--anime-yellow); color: #14151e; box-shadow: 2px 2px 0 #b38000; }
.tier-btn.tier-B.active { background: var(--anime-cyan); color: #14151e; box-shadow: 2px 2px 0 #0088a3; }
.tier-btn.tier-C.active { background: #64748b; color: #ffffff; }

/* Title row */
.anime-title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.type-badge {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--anime-yellow);
  border: 1px solid var(--anime-yellow);
  padding: 0.1rem 0.4rem;
}

/* Status Tags */
.status-tag {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.35rem 0.6rem;
  border: 1.5px solid rgba(0, 0, 0, 0.4);
}

/* Card Footer (Status & Actions) */
.card-footer {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

/* Card Action Buttons */
.card-actions {
  display: flex;
  gap: 0.4rem;
}

.icon-btn {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  background: #14151e;
  border: 1.5px solid var(--surface-border);
  color: #ffffff;
  padding: 0.4rem 0.7rem;
  cursor: pointer;
  transition: all 0.1s ease;
}

.icon-btn:hover {
  color: var(--anime-cyan);
  border-color: var(--anime-cyan);
}

.icon-btn.btn-del:hover {
  color: var(--anime-red);
  border-color: var(--anime-red);
}

/* Type Filter */
.type-filter {
  display: inline-flex;
  border: 2px solid var(--surface-border);
  background: #14151e;
  margin-bottom: 1.25rem;
  overflow: hidden;
}

.type-filter-btn {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.6rem 1.15rem;
  border: none;
  border-right: 2px solid var(--surface-border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.12s ease;
}

.type-filter-btn:last-child { border-right: none; }
.type-filter-btn:hover { color: #ffffff; }
.type-filter-btn.active {
  background: var(--anime-red);
  color: #ffffff;
}

/* ── Footer ── */
.footer {
  text-align: center;
  padding: 2rem 1.5rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  border-top: 2px solid var(--surface-border);
  background: var(--surface);
  letter-spacing: 0.08em;
}

/* ── Auth Topbar ── */
.auth-topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 0.55rem 1.5rem;
  background: #14151e;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  border-bottom: 2px solid var(--surface-border);
  z-index: 10;
}

.pilot-tag {
  color: var(--anime-yellow);
  font-weight: 700;
  margin-right: 0.35rem;
}

.auth-topbar-email {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-topbar-signout {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 700;
  background: none;
  border: 1px solid var(--text-muted);
  color: var(--text-muted);
  padding: 0.35rem 0.85rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.auth-topbar-signout:hover {
  border-color: var(--anime-red);
  color: var(--anime-red);
}

/* ── Sign-In View ── */
.signed-out-view {
  max-width: 520px;
  margin: 4rem auto;
  padding: 0 1.25rem;
}

.signin-panel { text-align: center; }

.signin-copy {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin: 0 0 1.75rem;
  line-height: 1.5;
}

/* ── Claim Banner ── */
.claim-banner {
  max-width: 1020px;
  margin: 0 auto 1.25rem;
  padding: 0.85rem 1.35rem;
  border: 2px solid var(--anime-yellow);
  background: rgba(255, 183, 3, 0.1);
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--anime-yellow);
  font-weight: 600;
}

/* ── Mobile Responsive (Phones & Small Screens) ── */
@media (max-width: 680px) {
  .grid {
    grid-template-columns: 1fr;
    padding: 1rem 0.75rem 2.5rem;
    gap: 1rem;
  }

  .masthead {
    padding: 1.5rem 1rem 1.25rem;
  }

  .title {
    font-size: 2.25rem;
  }

  .scene-tag {
    font-size: 0.55rem;
  }

  .film-stamp {
    position: static;
    margin-top: 0.65rem;
    font-size: 0.75rem;
    display: inline-block;
  }

  .panel {
    padding: 1rem;
    box-shadow: 3px 3px 0 rgba(10, 12, 18, 0.6);
  }

  .panel-label {
    font-size: 0.7rem;
    margin-bottom: 0.85rem;
  }

  /* Segmented Type Filter Bar — full width on mobile */
  .type-filter {
    display: flex;
    width: 100%;
    margin-bottom: 1rem;
  }

  .type-filter-btn {
    flex: 1;
    text-align: center;
    padding: 0.65rem 0.35rem;
    font-size: 0.65rem;
  }

  /* Anime Cards — Structured 3-Row Mobile Layout */
  .anime-card {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 0.95rem;
    box-shadow: 3px 3px 0 rgba(10, 12, 18, 0.5);
  }

  /* Header inside card: Ep counter + Title side-by-side */
  .anime-card .ep-counter {
    align-self: flex-start;
    font-size: 1.25rem;
    min-width: 3.5rem;
    padding: 0.25rem 0.5rem;
  }

  .anime-info .anime-title {
    font-size: 1rem;
    line-height: 1.3;
  }

  .anime-title-row {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.4rem;
  }

  .type-badge {
    font-size: 0.6rem;
    padding: 0.05rem 0.35rem;
  }

  /* Bottom Row inside card: Status Tag (Left) + Action Buttons (Right) */
  .anime-card > .status-tag,
  .anime-card > .card-actions {
    margin-top: 0;
  }

  .card-footer-mobile {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding-top: 0.4rem;
    border-top: 1px dashed var(--surface-border);
  }

  /* Touch Targets — Tier Buttons */
  .tier-selector {
    gap: 0.35rem;
    margin-top: 0.5rem;
  }

  .tier-btn {
    width: 2.2rem;
    height: 2.2rem;
    line-height: 2.2rem;
    font-size: 0.9rem;
  }

  /* Touch Targets — Action Buttons */
  .card-actions {
    display: flex;
    gap: 0.5rem;
  }

  .icon-btn {
    padding: 0.55rem 0.85rem;
    font-size: 0.75rem;
    min-height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* Form controls — iOS zoom prevention */
  .btn {
    padding: 0.85rem 1rem;
    font-size: 0.85rem;
    width: 100%;
  }

  input, select {
    font-size: 1rem;
    padding: 0.75rem 0.85rem;
    min-height: 2.75rem;
  }

  /* Stats Section — Clean responsive flex */
  .stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.6rem;
  }

  .stat-block {
    min-width: 0;
    padding: 0.65rem 0.35rem;
  }

  .stat-value {
    font-size: 1.85rem;
  }

  .stat-label {
    font-size: 0.55rem;
  }

  .status-bar-row {
    grid-template-columns: 5.5rem 1fr 2rem;
    gap: 0.45rem;
  }

  .status-bar-label {
    font-size: 0.7rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .status-bar-track {
    height: 0.95rem;
  }

  .signed-out-view {
    margin: 2rem auto;
  }

  .claim-banner {
    margin: 0 0.5rem 1.25rem;
    flex-direction: column;
    text-align: center;
    font-size: 0.8rem;
  }

  .auth-topbar {
    padding: 0.5rem 1rem;
    font-size: 0.75rem;
  }
}

/* Extra Small Screens (320px - 360px) */
@media (max-width: 380px) {
  .stats-row {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .status-bar-row {
    grid-template-columns: 4.5rem 1fr 1.5rem;
  }

  .title {
    font-size: 1.85rem;
  }

  .japanese-title {
    font-size: 0.65rem;
  }

  .tier-btn {
    width: 1.9rem;
    height: 1.9rem;
    line-height: 1.9rem;
    font-size: 0.8rem;
  }
}