/* animux web app — cyberpunk dark-only shell */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600;700&family=Noto+Sans+JP:wght@400;500;700&display=swap');

:root {
  --bg: #0a0a0f;
  --bg-1: #0f0f17;
  --surface: #14141c;
  --surface-2: #1c1c28;
  --line: #23232f;
  --line-2: #2c2c3c;
  --text: #f4f4f8;
  --text-2: #c4c4d2;
  --text-3: #7a7a8c;
  --text-4: #4a4a5c;
  --cyan: #00f0ff;
  --magenta: #ff2d92;
  --yellow: #fcee0c;
  --success: #a8ff60;
  --danger: #ff3d5a;
  --display: 'Space Grotesk', system-ui, sans-serif;
  --ui: 'Inter', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --jp: 'Noto Sans JP', system-ui, sans-serif;
  --glow-cyan: 0 0 18px rgba(0,240,255,0.35);
  --nav-h: 56px;
  --bot-h: 60px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: var(--ui); min-height: 100%; }
a { color: var(--cyan); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

body::before {
  content: "";
  pointer-events: none;
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    rgba(255,255,255,0.018) 0,
    rgba(255,255,255,0.018) 1px,
    transparent 1px,
    transparent 3px
  );
  z-index: 9999;
  opacity: 0.5;
}

/* shell */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; padding-bottom: var(--bot-h); }
@media (min-width: 900px) {
  .app-shell { padding-bottom: 0; padding-left: 72px; }
}

.topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--nav-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
  background: rgba(10,10,15,0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.topbar .brand {
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text);
  text-decoration: none;
  display: flex; align-items: center; gap: 8px;
}
.topbar .brand span.mark {
  color: var(--cyan);
  text-shadow: var(--glow-cyan);
}
.topbar .brand:hover { text-decoration: none; }
.topbar .demo-chip {
  font-family: var(--mono); font-size: 9px; letter-spacing: 0.16em;
  color: var(--cyan); border: 1px solid rgba(0,240,255,.45);
  padding: 2px 6px; background: rgba(0,240,255,.08);
}
/* Hairok embeds /demo in a 390×844 phone iframe on mentasystems.com/#apps.
   Pin html/body to the iframe viewport so the iframe itself never grows a
   grey document scrollbar. .app-shell stays the touch scroller.
   /app login is unaffected (no html.demo). */
html.demo,
html.demo body {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  min-height: 0;
  overflow: hidden;
  position: fixed;
  inset: 0;
  overscroll-behavior: none;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
html.demo::-webkit-scrollbar,
html.demo body::-webkit-scrollbar,
html.demo .app-shell::-webkit-scrollbar,
html.demo main::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
  background: transparent;
}
html.demo .app-shell {
  position: absolute;
  inset: 0;
  height: auto;
  max-height: none;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
html.demo main {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
html.demo,
html.demo *,
html.demo *::before,
html.demo *::after {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
html.demo *::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
  background: transparent;
}
html.demo,
html.demo * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
}
html.demo img {
  -webkit-user-drag: none;
}
html.demo .app-shell,
html.demo .h-scroll { cursor: grab; }
html.demo .is-dragging,
html.demo .is-dragging * {
  cursor: grabbing;
}
/* Nested x-rows must be their own scrollport (not clip on .app-shell). */
html.demo .h-scroll {
  min-width: 0;
  width: 100%;
  max-width: 100%;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}
html.demo .h-scroll::-webkit-scrollbar { display: none; width: 0; height: 0; }
/* Flutter shell has no web topbar; keep the bottom nav as the only chrome. */
html.demo .topbar { display: none; }
html.demo .side-nav { display: none !important; }
html.demo .bottom-nav { display: flex !important; }
.topbar .spacer { flex: 1; }
.topbar .user-chip {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 11px; color: var(--text-3);
}
.topbar .avatar {
  width: 28px; height: 28px; border-radius: 2px;
  background: var(--surface-2); object-fit: cover;
  border: 1px solid var(--line-2);
}

.bottom-nav, .side-nav {
  background: var(--surface);
  border-color: #1f1f2b;
  z-index: 80;
}
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0;
  height: var(--bot-h);
  display: flex; border-top: 1px solid #1f1f2b;
}
.bottom-nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; color: var(--text-3); text-decoration: none;
  font-family: var(--mono); font-size: 9px; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase;
}
.bottom-nav a:hover { text-decoration: none; color: var(--text); }
.bottom-nav a .ico { width: 18px; height: 18px; font-size: 18px; line-height: 1; fill: currentColor; display: block; }
.bottom-nav a.active { color: var(--magenta); }
.side-nav a.active { color: var(--magenta); }
.side-nav { display: none; }
@media (min-width: 900px) {
  .bottom-nav { display: none; }
  .side-nav {
    display: flex; flex-direction: column; gap: 4px;
    position: fixed; left: 0; top: 0; bottom: 0; width: 72px;
    border-right: 1px solid var(--line);
    padding: 72px 8px 16px;
  }
  .side-nav a {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 4px; padding: 10px 4px; color: var(--text-3); text-decoration: none;
    font-family: var(--mono); font-size: 9px; letter-spacing: 0.04em; text-transform: uppercase;
    border-radius: 2px;
  }
  .side-nav a:hover { background: var(--surface); color: var(--text); text-decoration: none; }
}

main { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: 16px 16px 40px; }

/* header */
.screen-header {
  display: flex; align-items: baseline; gap: 10px; margin-bottom: 18px; flex-wrap: wrap;
}
.screen-header .num {
  font-family: var(--mono); font-size: 11px; color: var(--cyan);
}
.screen-header h1 {
  margin: 0; font-family: var(--display); font-size: 22px; font-weight: 700; letter-spacing: 0.02em;
}
.screen-header .kanji {
  font-family: var(--jp); font-size: 12px; color: var(--text-3);
}
.screen-header .sub {
  width: 100%; font-family: var(--mono); font-size: 11px; color: var(--text-3); margin-top: -4px;
}

/* sections */
.section { margin-bottom: 28px; }
.section-head {
  display: flex; align-items: center; gap: 8px; margin-bottom: 12px;
  font-family: var(--mono); font-size: 11px; font-weight: 700; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--text);
}
.section-head .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--cyan); }
.section-head .dot.magenta { background: var(--magenta); }
.section-head .dot.yellow { background: var(--yellow); }
.section-head .kanji { color: var(--text-3); font-weight: 400; }
.section-head .right { margin-left: auto; color: var(--cyan); font-weight: 500; text-decoration: none; }
.section-head .right:hover { text-decoration: underline; }

/* h-scroll */
.h-scroll {
  display: flex; gap: 12px; overflow-x: auto; padding-bottom: 6px;
  scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch;
}
.h-scroll::-webkit-scrollbar { height: 4px; }
.h-scroll::-webkit-scrollbar-thumb { background: var(--line-2); }

/* poster card */
.poster-card {
  flex: 0 0 120px; width: 120px; scroll-snap-align: start;
  text-decoration: none; color: inherit;
}
.poster-card:hover { text-decoration: none; }
.poster-card .art {
  aspect-ratio: 2/3; background: var(--surface-2); border: 1px solid var(--line);
  overflow: hidden; position: relative;
}
.poster-card .art img { width: 100%; height: 100%; object-fit: cover; }
.poster-card .art .badge {
  position: absolute; top: 6px; left: 6px;
  font-family: var(--mono); font-size: 9px; padding: 2px 5px;
  background: rgba(0,0,0,0.75); color: var(--cyan); border: 1px solid var(--cyan);
}
.poster-card .meta {
  margin-top: 6px; font-size: 12px; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.poster-card .meta .sub {
  font-family: var(--mono); font-size: 10px; color: var(--text-3); margin-top: 2px;
}

/* grid */
.poster-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 14px;
}

/* list rows */
.list-row {
  display: flex; gap: 12px; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.list-row .thumb {
  width: 48px; height: 68px; flex-shrink: 0;
  background: var(--surface-2); border: 1px solid var(--line); overflow: hidden;
}
.list-row .thumb img { width: 100%; height: 100%; object-fit: cover; }
.list-row .body { flex: 1; min-width: 0; }
.list-row .body .title {
  font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.list-row .body .meta {
  font-family: var(--mono); font-size: 11px; color: var(--text-3); margin-top: 3px;
}
.list-row .actions { display: flex; gap: 6px; flex-shrink: 0; }

/* chips / buttons */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.04em;
  padding: 4px 8px; border: 1px solid var(--line-2); background: var(--surface);
  color: var(--text-2); text-decoration: none; border-radius: 2px;
}
.chip:hover { border-color: var(--cyan); color: var(--cyan); text-decoration: none; }
.chip.active { border-color: var(--cyan); color: var(--cyan); box-shadow: var(--glow-cyan); }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-family: var(--mono); font-size: 11px; font-weight: 600; letter-spacing: 0.04em;
  text-transform: uppercase; padding: 10px 14px;
  border: 1px solid var(--cyan); background: transparent; color: var(--cyan);
  border-radius: 2px; text-decoration: none; cursor: pointer;
}
.btn:hover { background: rgba(0,240,255,0.08); text-decoration: none; box-shadow: var(--glow-cyan); }
.btn.primary {
  background: linear-gradient(95deg, #ff2d92 0%, #b438c8 50%, #00f0ff 100%);
  border: none; color: #0a0a0f;
}
.btn.primary:hover { filter: brightness(1.08); box-shadow: var(--glow-cyan); }
.btn.ghost { border-color: var(--line-2); color: var(--text-2); }
.btn.danger { border-color: var(--danger); color: var(--danger); }
.btn.sm { padding: 6px 10px; font-size: 10px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* forms */
.field { margin-bottom: 14px; }
.field label {
  display: block; font-family: var(--mono); font-size: 10px; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text-3); margin-bottom: 6px;
}
.field input, .field select, .field textarea {
  width: 100%; background: var(--surface); border: 1px solid var(--line-2);
  color: var(--text); padding: 12px 14px; border-radius: 2px; outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--cyan); box-shadow: 0 0 0 1px rgba(0,240,255,0.25);
}
.field textarea { min-height: 120px; resize: vertical; font-family: var(--ui); }
.search-bar input {
  width: 100%; background: var(--surface); border: 1px solid var(--line-2);
  color: var(--text); padding: 12px 14px; border-radius: 2px; outline: none;
  font-family: var(--mono); font-size: 13px;
}
.search-bar input:focus { border-color: var(--cyan); }

/* cards */
.card {
  background: var(--surface); border: 1px solid var(--line); padding: 16px; border-radius: 2px;
}
.card + .card { margin-top: 12px; }
.alert {
  padding: 12px 14px; border: 1px solid var(--danger); color: var(--danger);
  background: rgba(255,61,90,0.08); font-size: 13px; margin-bottom: 14px;
}
.notice {
  padding: 12px 14px; border: 1px solid var(--cyan); color: var(--cyan);
  background: rgba(0,240,255,0.06); font-size: 13px; margin-bottom: 14px;
  font-family: var(--mono);
}
.empty {
  padding: 28px 16px; text-align: center; color: var(--text-3);
  font-family: var(--mono); font-size: 12px; border: 1px dashed var(--line);
}

/* home upcoming */
.upcoming-row {
  display: flex; gap: 12px; align-items: center;
  padding: 10px 12px; background: var(--surface); border: 1px solid var(--line);
  margin-bottom: 8px; text-decoration: none; color: inherit;
}
.upcoming-row:hover { border-color: var(--cyan); text-decoration: none; }
.upcoming-row .when {
  font-family: var(--mono); font-size: 11px; color: var(--yellow); min-width: 72px;
}
.upcoming-row .title { font-weight: 600; font-size: 14px; }
.upcoming-row .ep { font-family: var(--mono); font-size: 11px; color: var(--text-3); }

/* news */
.news-item {
  display: grid; grid-template-columns: 72px 1fr; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.news-item .thumb {
  width: 72px; height: 72px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--line);
}
.news-item .thumb img { width: 100%; height: 100%; object-fit: cover; }
.news-item .headline { font-weight: 600; font-size: 14px; line-height: 1.35; color: var(--text); }
.news-item .summary { font-size: 12px; color: var(--text-3); margin-top: 4px; line-height: 1.4; }
.news-item .meta { font-family: var(--mono); font-size: 10px; color: var(--text-4); margin-top: 6px; }

/* calendar */
.cal-nav {
  display: flex; align-items: center; gap: 10px; margin-bottom: 16px;
}
.cal-nav .label { flex: 1; font-family: var(--mono); font-size: 12px; color: var(--text-2); text-align: center; }
.day-block { margin-bottom: 22px; }
.day-block .day-head {
  display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px;
  font-family: var(--mono); font-size: 12px; font-weight: 700;
  padding-bottom: 6px; border-bottom: 1px solid var(--line);
}
.day-block .day-head.today { color: var(--cyan); border-color: var(--cyan); }
.day-block .day-head .kanji { color: var(--text-3); font-weight: 400; }
.airing-row {
  display: flex; gap: 10px; align-items: center; padding: 8px 0;
  border-bottom: 1px solid rgba(35,35,47,0.6); text-decoration: none; color: inherit;
}
.airing-row:hover { text-decoration: none; color: var(--cyan); }
.airing-row .time { font-family: var(--mono); font-size: 11px; color: var(--text-3); min-width: 44px; }
.airing-row .thumb { width: 36px; height: 50px; background: var(--surface-2); overflow: hidden; flex-shrink: 0; }
.airing-row .thumb img { width: 100%; height: 100%; object-fit: cover; }
.airing-row .title { font-size: 13px; font-weight: 600; }
.airing-row .ep { font-family: var(--mono); font-size: 10px; color: var(--text-3); }

/* anime detail */
.anime-hero {
  display: grid; grid-template-columns: 140px 1fr; gap: 18px; margin-bottom: 20px;
}
@media (min-width: 700px) {
  .anime-hero { grid-template-columns: 180px 1fr; gap: 24px; }
}
.anime-hero .poster {
  aspect-ratio: 2/3; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden;
}
.anime-hero .poster img { width: 100%; height: 100%; object-fit: cover; }
.anime-hero h2 {
  margin: 0 0 6px; font-family: var(--display); font-size: 22px; font-weight: 700; line-height: 1.2;
}
.anime-hero .native { font-family: var(--jp); color: var(--text-3); font-size: 13px; margin-bottom: 10px; }
.meta-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.synopsis {
  font-size: 14px; line-height: 1.6; color: var(--text-2); margin: 16px 0;
  white-space: pre-wrap;
}
.track-panel {
  background: var(--surface); border: 1px solid var(--line); padding: 14px; margin-bottom: 16px;
}
.track-panel .row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }
.track-panel .row:last-child { margin-bottom: 0; }
.track-panel .label { font-family: var(--mono); font-size: 10px; color: var(--text-3); min-width: 64px; }

/* profile */
.stats-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 20px;
}
@media (min-width: 600px) { .stats-grid { grid-template-columns: repeat(4, 1fr); } }
.stat-card {
  background: var(--surface); border: 1px solid var(--line); padding: 14px;
}
.stat-card .n {
  font-family: var(--display); font-size: 28px; font-weight: 700; color: var(--cyan);
  text-shadow: var(--glow-cyan);
}
.stat-card .l {
  font-family: var(--mono); font-size: 10px; color: var(--text-3); letter-spacing: 0.06em;
  text-transform: uppercase; margin-top: 4px;
}
.profile-head {
  display: flex; gap: 16px; align-items: center; margin-bottom: 22px;
}
.profile-head .av {
  width: 72px; height: 72px; border-radius: 2px; background: var(--surface-2);
  border: 1px solid var(--line-2); object-fit: cover;
}
.profile-head .name { font-family: var(--display); font-size: 20px; font-weight: 700; }
.profile-head .email { font-family: var(--mono); font-size: 11px; color: var(--text-3); margin-top: 4px; }

/* reviews */
.review-card {
  background: var(--surface); border: 1px solid var(--line); padding: 14px; margin-bottom: 10px;
}
.review-card .head { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.review-card .av {
  width: 32px; height: 32px; border-radius: 2px; background: var(--surface-2); object-fit: cover;
}
.review-card .who { font-weight: 600; font-size: 13px; }
.review-card .when { font-family: var(--mono); font-size: 10px; color: var(--text-3); }
.review-card .body { font-size: 14px; line-height: 1.5; color: var(--text-2); white-space: pre-wrap; }
.review-card .foot {
  display: flex; gap: 10px; align-items: center; margin-top: 10px;
  font-family: var(--mono); font-size: 11px; color: var(--text-3);
}
.spoiler-tag {
  font-family: var(--mono); font-size: 9px; color: var(--yellow);
  border: 1px solid var(--yellow); padding: 1px 5px;
}

/* login */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background:
    radial-gradient(ellipse at 20% 0%, rgba(0,240,255,0.07), transparent 50%),
    radial-gradient(ellipse at 90% 100%, rgba(255,45,146,0.06), transparent 45%),
    var(--bg);
}
.login-card {
  width: 100%; max-width: 400px; background: var(--surface);
  border: 1px solid var(--line); padding: 28px 24px;
}
.login-card h1 {
  margin: 0 0 4px; font-family: var(--display); font-size: 24px;
}
.login-card .brand-sub {
  font-family: var(--mono); font-size: 11px; color: var(--text-3); margin-bottom: 18px;
}
.login-card .actions { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }

/* QR step: the branded QR plate *is* the card body */
.login-card--qr {
  max-width: min(440px, 100%);
  padding: 0;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line-2);
  box-shadow:
    0 0 0 1px rgba(0,240,255,0.1),
    0 0 48px rgba(0,240,255,0.14),
    0 28px 56px -24px rgba(0,0,0,0.85);
}
.login-card-head {
  padding: 20px 22px 12px;
  text-align: center;
  border-bottom: 1px solid var(--line);
}
.login-card-head h1 { margin: 0 0 6px; font-size: 22px; }
.login-card-head .brand-sub {
  margin: 0; margin-bottom: 0;
  font-size: 10px; letter-spacing: 0.08em;
}
.qr-hero {
  /* QR PNG already has white card + margin; full-bleed as the card face */
  display: block;
  width: 100%;
  background: #0a0a0f;
  line-height: 0;
}
.qr-img {
  display: block;
  width: 100%;
  height: auto;
  /* Drop nested card feel — image fills the middle of the login card */
  margin: 0;
}
.login-card-foot {
  padding: 16px 20px 20px;
  border-top: 1px solid var(--line);
  text-align: center;
}
.qr-hint {
  margin: 0 0 6px; font-size: 13px; line-height: 1.5; color: var(--text-2);
}
.qr-meta {
  margin: 0 0 14px; font-family: var(--mono); font-size: 10px; color: var(--text-4);
}
.actions-row {
  display: flex !important;
  flex-direction: row !important;
  gap: 8px !important;
  justify-content: center;
  margin-top: 0 !important;
}
.actions-row .btn { flex: 1; max-width: 160px; }
.login-footnote {
  margin: 14px 0 0;
  font-family: var(--mono); font-size: 10px; color: var(--text-4); text-align: center;
}
.login-footnote a { color: var(--text-3); }

@media (min-width: 520px) {
  .login-card--qr { max-width: 480px; }
  .login-card-head h1 { font-size: 24px; }
}

/* connect AI */
.pre-block {
  background: var(--bg); border: 1px solid var(--line-2); padding: 12px;
  font-family: var(--mono); font-size: 11px; line-height: 1.5; white-space: pre-wrap;
  overflow-x: auto; color: var(--text-2); max-height: 280px;
}

.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline; }
.htmx-request.htmx-indicator { display: inline; }

.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--mono); font-size: 11px; color: var(--text-3);
  margin-bottom: 12px; text-decoration: none;
}
.back-link:hover { color: var(--cyan); }

@media (prefers-reduced-motion: reduce) {
  body::before { display: none; }
  * { transition: none !important; animation: none !important; }
}
