:root {
  --bg: #0d0d18;
  --bg-2: #141426;
  --card: rgba(27, 27, 44, 0.92);
  --card-2: rgba(37, 37, 58, 0.92);
  --text: #f6f4ff;
  --muted: #a7a1be;
  --line: rgba(255,255,255,0.10);
  --brand: #b76cff;
  --brand-2: #ff6fb1;
  --good: #54d58a;
  --ok: #76a6ff;
  --warm: #f0b85a;
  --bad: #ff6b79;
  --shadow: 0 24px 60px rgba(0,0,0,0.42);
  --radius: 24px;
  --nav-h: 76px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
body { overflow-x: hidden; }
button, input, textarea { font: inherit; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 18% 10%, rgba(183,108,255,0.26), transparent 28%),
    radial-gradient(circle at 82% 16%, rgba(255,111,177,0.18), transparent 25%),
    radial-gradient(circle at 50% 92%, rgba(84,213,138,0.10), transparent 30%),
    linear-gradient(180deg, #10101d 0%, #0d0d18 58%, #090911 100%);
  z-index: -1;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(420px, 100%);
  background: linear-gradient(155deg, rgba(35,35,57,0.96), rgba(21,21,36,0.96));
  border: 1px solid var(--line);
  border-radius: 34px;
  padding: 28px;
  box-shadow: var(--shadow);
}
.brand-mark {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: white;
  font-weight: 900;
  font-size: 26px;
  box-shadow: 0 18px 38px rgba(183,108,255,0.28);
}
.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 800;
}
h1, h2, h3, p { margin-top: 0; }
.login-card h1 { margin: 10px 0 8px; font-size: 2rem; }
.login-copy { color: var(--muted); line-height: 1.5; }
.login-form { display: grid; gap: 10px; margin-top: 22px; }
label { color: var(--muted); font-size: 0.9rem; font-weight: 700; }
input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.07);
  color: var(--text);
  border-radius: 18px;
  padding: 13px 14px;
  outline: none;
}
textarea { min-height: 76px; resize: vertical; }
input:focus, textarea:focus { border-color: rgba(183,108,255,0.65); box-shadow: 0 0 0 4px rgba(183,108,255,0.12); }
.form-error { background: rgba(255,107,121,0.12); color: #ffcbd0; border: 1px solid rgba(255,107,121,0.3); padding: 10px 12px; border-radius: 14px; }

.app-shell {
  min-height: 100vh;
  padding: env(safe-area-inset-top) 12px calc(var(--nav-h) + env(safe-area-inset-bottom) + 12px);
  max-width: 980px;
  margin: 0 auto;
}
.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 13px 4px 10px;
  backdrop-filter: blur(18px);
}
.app-header h1 { margin: 0; font-size: 1.35rem; line-height: 1.1; }
.header-actions { display: flex; gap: 8px; }
.ghost-icon {
  width: 38px;
  height: 38px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.06);
  display: grid;
  place-items: center;
  font-weight: 900;
  cursor: pointer;
}

.main-area { min-height: 50vh; }
.view { display: none; animation: softIn 160ms ease-out; }
.view.active { display: block; }
@keyframes softIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

.person-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--line);
  padding: 6px;
  border-radius: 20px;
  margin-bottom: 10px;
}
.person-btn {
  border: 0;
  border-radius: 15px;
  padding: 11px 12px;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
  cursor: pointer;
}
.person-btn.active {
  background: linear-gradient(135deg, rgba(183,108,255,0.95), rgba(255,111,177,0.92));
  color: white;
  box-shadow: 0 12px 28px rgba(183,108,255,0.25);
}

.progress-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 10px;
}
.progress-strip div {
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255,255,255,0.055);
}
.progress-strip span { display: block; font-size: 0.72rem; color: var(--muted); }
.progress-strip strong { font-size: 0.95rem; }

.rate-content { min-height: 500px; }
.anime-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 30px;
  background: linear-gradient(160deg, rgba(36,36,60,0.96), rgba(20,20,35,0.98));
  box-shadow: var(--shadow);
}
.anime-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 130px;
  background: radial-gradient(circle at 15% 0%, rgba(183,108,255,0.38), transparent 38%), radial-gradient(circle at 82% 4%, rgba(255,111,177,0.28), transparent 32%);
  pointer-events: none;
}
.card-body { position: relative; padding: 17px; }
.card-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.card-title { margin: 0 0 2px; font-size: clamp(1.35rem, 8vw, 2.35rem); line-height: 1.02; letter-spacing: -0.04em; }
.card-subtitle { margin: 0; color: #d9d3ed; font-size: 0.92rem; }
.open-detail-btn {
  min-width: 44px;
  height: 44px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(255,255,255,0.10);
  cursor: pointer;
  font-weight: 900;
  box-shadow: 0 10px 22px rgba(0,0,0,0.18);
}
.quick-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 14px 0 10px;
}
.meta-pill, .tag, .risk-tag, .mini-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.07);
  border-radius: 999px;
  padding: 6px 9px;
  color: #eae5fb;
  font-size: 0.78rem;
  line-height: 1;
  white-space: nowrap;
}
.meta-pill.good { color: #d9ffe5; background: rgba(84,213,138,0.12); border-color: rgba(84,213,138,0.24); }
.meta-pill.warm { color: #ffedcd; background: rgba(240,184,90,0.12); border-color: rgba(240,184,90,0.24); }
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 12px; }
.tag { background: rgba(183,108,255,0.13); color: #eadbff; border-color: rgba(183,108,255,0.26); }
.risk-tag { background: rgba(255,107,121,0.11); color: #ffd7dc; border-color: rgba(255,107,121,0.20); }
.short-summary {
  color: #f0ecff;
  font-size: 0.98rem;
  line-height: 1.45;
  margin: 6px 0 12px;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.partner-strip {
  display: flex;
  gap: 8px;
  align-items: center;
  margin: 12px 0;
  padding: 10px;
  border-radius: 18px;
  background: rgba(255,255,255,0.055);
  border: 1px solid var(--line);
  color: #e9e5f8;
  font-size: 0.88rem;
}
.partner-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--brand-2);
  box-shadow: 0 0 0 5px rgba(255,111,177,0.12);
  flex: 0 0 auto;
}
.choice-section { margin: 13px 0; }
.choice-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 8px;
  color: #e9e5fa;
  font-weight: 900;
}
.choice-title small { color: var(--muted); font-weight: 700; }
.choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.choice-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.choice-btn {
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 17px;
  min-height: 48px;
  padding: 9px 8px;
  background: rgba(255,255,255,0.065);
  color: #f5f1ff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-weight: 850;
  text-align: center;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}
.choice-btn:active { transform: scale(0.98); }
.choice-btn.active {
  border-color: rgba(255,255,255,0.32);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.10), 0 10px 24px rgba(0,0,0,0.24);
}
.choice-btn.want.active { background: linear-gradient(135deg, rgba(84,213,138,0.40), rgba(37,159,94,0.32)); }
.choice-btn.ok.active { background: linear-gradient(135deg, rgba(118,166,255,0.35), rgba(83,102,255,0.28)); }
.choice-btn.no.active { background: rgba(255,255,255,0.14); }
.choice-btn.veto.active { background: linear-gradient(135deg, rgba(255,107,121,0.38), rgba(179,45,67,0.30)); }
.choice-btn.later.active { background: linear-gradient(135deg, rgba(240,184,90,0.32), rgba(180,120,39,0.22)); }
.choice-btn.knowledge.active { background: linear-gradient(135deg, rgba(183,108,255,0.35), rgba(255,111,177,0.22)); }
.choice-icon {
  width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  border-radius: 9px;
  background: rgba(255,255,255,0.10);
  font-size: 0.78rem;
  font-weight: 1000;
}
.extra-fields {
  display: none;
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255,255,255,0.045);
}
.extra-fields.active { display: block; }
.note-field { margin-top: 10px; }
.sticky-actions {
  position: sticky;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 8px);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
  z-index: 12;
}
.primary-btn, .soft-btn, .danger-btn {
  border: 0;
  border-radius: 18px;
  min-height: 48px;
  padding: 12px 15px;
  font-weight: 950;
  cursor: pointer;
}
.primary-btn { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: white; box-shadow: 0 12px 32px rgba(183,108,255,0.28); }
.primary-btn.full { width: 100%; }
.soft-btn { background: rgba(255,255,255,0.08); color: #f0edfc; border: 1px solid var(--line); }
.danger-btn { background: rgba(255,107,121,0.14); color: #ffd8dd; border: 1px solid rgba(255,107,121,0.28); }

.bottom-nav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 30;
  width: min(620px, calc(100% - 18px));
  min-height: var(--nav-h);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 8px;
  border-radius: 26px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(18,18,31,0.86);
  backdrop-filter: blur(22px);
  box-shadow: 0 20px 55px rgba(0,0,0,0.42);
}
.nav-btn {
  border: 0;
  border-radius: 18px;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  gap: 3px;
  padding: 8px 2px;
  font-size: 0.74rem;
  font-weight: 850;
  cursor: pointer;
}
.nav-btn.active { color: white; background: rgba(255,255,255,0.10); }
.nav-ico { font-size: 1rem; line-height: 1; }

.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 8px 2px 12px; }
.section-head h2 { margin: 0; font-size: 1.35rem; }
.stack { display: grid; gap: 18px; }
.result-section {
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.055);
  border-radius: 24px;
  padding: 13px;
}
.result-section h3 { margin: 0 0 9px; font-size: 1rem; }
.result-list { display: grid; gap: 8px; }
.result-card, .library-card {
  border: 1px solid rgba(255,255,255,0.09);
  background: rgba(255,255,255,0.055);
  border-radius: 19px;
  padding: 12px;
  cursor: pointer;
}
.result-card h4, .library-card h4 { margin: 0 0 4px; font-size: 0.98rem; }
.result-card p, .library-card p { margin: 0; color: var(--muted); font-size: 0.82rem; line-height: 1.35; }
.empty-state {
  color: var(--muted);
  padding: 16px;
  text-align: center;
  border: 1px dashed rgba(255,255,255,0.15);
  border-radius: 18px;
}
.search-row { margin-bottom: 10px; }
.filter-row { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 12px; }
.filter-chip {
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.06);
  color: #e9e5f9;
  border-radius: 999px;
  padding: 7px 10px;
  cursor: pointer;
  font-weight: 800;
  font-size: 0.8rem;
}
.filter-chip.active { background: rgba(183,108,255,0.24); border-color: rgba(183,108,255,0.35); }
.library-list { display: grid; gap: 9px; }

.admin-grid { display: grid; gap: 12px; }
.admin-card {
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.055);
  border-radius: 24px;
  padding: 14px;
}
.admin-card h3 { margin: 0 0 6px; }
.admin-card p { color: var(--muted); font-size: 0.9rem; line-height: 1.45; }
.upload-line { display: grid; gap: 8px; margin-top: 12px; }
.upload-line input[type=file] { padding: 10px; }
.admin-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.log-list { display: grid; gap: 8px; margin-top: 10px; }
.log-item { border: 1px solid var(--line); border-radius: 14px; padding: 9px; color: var(--muted); font-size: 0.82rem; }

.detail-panel { position: fixed; inset: 0; pointer-events: none; z-index: 80; }
.detail-panel.open { pointer-events: auto; }
.panel-backdrop {
  position: absolute;
  inset: 0;
  opacity: 0;
  background: rgba(0,0,0,0.50);
  transition: opacity 180ms ease;
}
.detail-panel.open .panel-backdrop { opacity: 1; }
.panel-card {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: min(480px, 92vw);
  padding: 22px 16px 24px;
  overflow: auto;
  background: linear-gradient(165deg, rgba(33,33,53,0.98), rgba(13,13,24,0.98));
  border-left: 1px solid var(--line);
  box-shadow: -30px 0 70px rgba(0,0,0,0.42);
  transform: translateX(104%);
  transition: transform 220ms cubic-bezier(.2,.8,.2,1);
}
.detail-panel.open .panel-card { transform: translateX(0); }
.panel-close {
  position: sticky;
  top: 0;
  margin-left: auto;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.08);
  cursor: pointer;
  font-weight: 900;
  z-index: 2;
}
.detail-title { margin: -28px 48px 4px 0; font-size: 1.75rem; line-height: 1.04; letter-spacing: -0.03em; }
.detail-subtitle { color: var(--muted); margin-bottom: 12px; }
.detail-block {
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.055);
  border-radius: 22px;
  padding: 13px;
  margin: 10px 0;
}
.detail-block h3 { margin: 0 0 7px; font-size: 0.98rem; }
.detail-block p { margin: 0; color: #e7e1f5; line-height: 1.5; font-size: 0.93rem; }
.source-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 9px 0; border-top: 1px solid var(--line); }
.source-row:first-child { border-top: 0; }
.source-row strong { display: block; }
.source-row span { color: var(--muted); font-size: 0.82rem; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + 22px + env(safe-area-inset-bottom));
  z-index: 120;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  max-width: min(420px, calc(100% - 28px));
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(244,241,255,0.96);
  color: #181626;
  font-weight: 850;
  box-shadow: 0 18px 46px rgba(0,0,0,0.32);
  transition: opacity 150ms ease, transform 150ms ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 520px) {
  :root { --nav-h: 72px; }
  .app-shell { padding-left: 10px; padding-right: 10px; }
  .progress-strip { gap: 6px; }
  .progress-strip div { padding: 8px; }
  .card-body { padding: 14px; }
  .choice-grid.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .choice-btn { min-height: 44px; font-size: 0.84rem; }
  .sticky-actions { grid-template-columns: 1fr; }
  .bottom-nav { grid-template-columns: repeat(4, 1fr); }
  .nav-btn { font-size: 0.68rem; }
  .panel-card {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: 88vh;
    border-left: 0;
    border-top: 1px solid var(--line);
    border-radius: 28px 28px 0 0;
    transform: translateY(105%);
  }
  .detail-panel.open .panel-card { transform: translateY(0); }
}

@media (min-width: 760px) {
  .app-shell { padding-left: 18px; padding-right: 18px; }
  .rate-content { display: grid; place-items: start center; }
  .anime-card { width: min(720px, 100%); }
  .admin-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.bottom-nav.without-admin { grid-template-columns: repeat(3, 1fr); }
.bottom-nav.with-admin { grid-template-columns: repeat(4, 1fr); }
