:root {
  --bg: #0b0f19;
  --surface: #131a2a;
  --surface-hover: #1a2338;
  --border: #25304a;
  --text: #eef2ff;
  --text-muted: #94a3b8;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --danger: #ef4444;
  --stock: #64748b;
  --watching: #0ea5e9;
  --completed: #10b981;
  --amber: #f59e0b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", "Hiragino Sans", "Yu Gothic UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

.container {
  max-width: 1220px;
  margin: 0 auto;
  padding: 0 20px;
}

.site-header {
  border-bottom: 1px solid var(--border);
  background: rgba(11, 15, 25, 0.9);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding-top: 8px;
  padding-bottom: 8px;
  gap: 10px 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 2px 10px rgba(56, 189, 248, 0.22);
}

.brand-title {
  font-family: "Nunito", "Rounded Mplus 1c", "Hiragino Maru Gothic ProN", system-ui, sans-serif;
  font-size: 21px;
  font-weight: 800;
  margin: 0;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: baseline;
}

.brand-ani {
  color: #f8fafc;
}

.brand-graphy {
  background: linear-gradient(135deg, #818cf8 0%, #38bdf8 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
}

@media (max-width: 680px) {
  .header-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .user-menu {
    margin-left: auto;
  }
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border);
}

.user-display-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.main-content {
  padding: 28px 20px 60px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.btn-lg {
  padding: 12px 22px;
  font-size: 15px;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--surface-hover);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.4);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.28);
}

.btn-link {
  background: none;
  border: none;
  color: #818cf8;
  cursor: pointer;
  font-size: 13px;
  padding: 0;
  white-space: nowrap;
}

.hero-panel,
.state-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 40px 24px;
  text-align: center;
  margin-top: 24px;
}

.hero-panel h2 {
  margin-top: 0;
  font-size: 24px;
}

.hero-panel p {
  color: var(--text-muted);
  margin-bottom: 24px;
}

.config-warning {
  margin-top: 16px;
  color: #fbbf24 !important;
  font-size: 13px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 22px;
}

.status-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tab-btn {
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.tab-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.filter-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.filter-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}

.select-input,
.text-input {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 14px;
}

.textarea-input {
  width: 100%;
  resize: vertical;
  font-family: inherit;
}

.feedback-banner {
  background: rgba(239, 68, 68, 0.14);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fecaca;
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 14px;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
}

.anime-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.16s ease, border-color 0.16s ease;
}

.anime-card:hover {
  transform: translateY(-3px);
  border-color: #475569;
}

.card-poster {
  position: relative;
  aspect-ratio: 16 / 10;
  background: #172033;
  overflow: hidden;
}

.card-poster img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.poster-placeholder {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #131a2a;
}

.poster-placeholder-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.92;
}

.poster-placeholder-title {
  position: relative;
  z-index: 1;
  padding: 12px 14px;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: #e2e8f0;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.7);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.status-pill {
  position: absolute;
  top: 10px;
  left: 10px;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  color: #fff;
}

.status-stock { background: var(--stock); }
.status-watching { background: var(--watching); }
.status-completed { background: var(--completed); }

.rating-pill {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(11, 15, 25, 0.85);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.45);
}

.card-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}

.card-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.provider-badge,
.season-badge {
  display: inline-block;
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
}

.provider-badge {
  background: rgba(99, 102, 241, 0.18);
  color: #c7d2fe;
  border: 1px solid rgba(99, 102, 241, 0.35);
}

.provider-badge-link {
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.provider-badge-link:hover {
  background: rgba(99, 102, 241, 0.32);
  border-color: rgba(129, 140, 248, 0.65);
  color: #e0e7ff;
}

.season-badge {
  background: rgba(148, 163, 184, 0.14);
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.25);
}

.card-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.card-annict-metrics {
  font-size: 11px;
  color: #a5b4fc;
}

.card-comment {
  margin: 2px 0 0;
  padding: 7px 9px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border);
  font-size: 12px;
  color: #e2e8f0;
  word-break: break-word;
  white-space: pre-wrap;
}

.card-episodes {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.card-episodes-scroll {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  padding: 2px 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
  cursor: grab;
}

.card-episodes-scroll::-webkit-scrollbar {
  display: none;
}

.card-episodes-scroll.dragging {
  cursor: grabbing;
  user-select: none;
}

.episode-chip {
  flex: 0 0 auto;
  min-width: 28px;
  height: 26px;
  padding: 0 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.75);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.episode-chip:hover {
  border-color: var(--accent);
  color: var(--text);
}

.episode-chip.watched {
  background: rgba(56, 189, 248, 0.18);
  border-color: rgba(56, 189, 248, 0.65);
  color: #7dd3fc;
}

.episode-chip.next-up {
  border-color: var(--accent);
  color: var(--text);
  box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.35);
}

.episode-sync-btn {
  flex: 0 0 auto;
  height: 26px;
  padding: 0 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
}

.episode-sync-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}

.episode-refresh-btn {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  padding: 0;
  margin-left: 2px;
  border-radius: 9999px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.episode-refresh-btn:hover {
  background: rgba(148, 163, 184, 0.16);
  color: var(--text);
}

.card-actions {
  margin-top: auto;
  padding-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.card-status-group {
  display: flex;
  flex: 1;
  min-width: 0;
  gap: 3px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.card-status-btn {
  flex: 1;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  padding: 5px 4px;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
  white-space: nowrap;
}

.card-status-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.card-status-btn.active[data-status="stock"] {
  background: var(--stock);
  color: #fff;
}

.card-status-btn.active[data-status="watching"] {
  background: var(--watching);
  color: #fff;
}

.card-status-btn.active[data-status="completed"] {
  background: var(--completed);
  color: #fff;
}

.card-actions .btn {
  padding: 6px 10px;
  font-size: 12px;
  white-space: nowrap;
}

/* Segmented buttons (modals) */
.segmented-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.seg-btn {
  flex: 1;
  min-width: 72px;
  background: var(--bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease;
}

.seg-btn:hover {
  border-color: #475569;
  color: var(--text);
}

.seg-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.segmented-rating .seg-btn {
  min-width: 48px;
  padding: 7px 6px;
}

.segmented-rating .seg-btn.active:not([data-value=""]) {
  background: rgba(245, 158, 11, 0.2);
  border-color: var(--amber);
  color: #fcd34d;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 7, 15, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}

.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 100%;
  max-width: 660px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  margin: 0;
  font-size: 17px;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.modal-body {
  padding: 20px;
}

.search-form-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.search-form {
  display: flex;
  gap: 10px;
}

.search-form .text-input {
  flex: 1;
}

.search-season-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.search-season-row label {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
}

.segmented-season {
  flex: 1;
  min-width: 240px;
}

.segmented-season .seg-btn {
  min-width: 44px;
  padding: 6px 8px;
  font-size: 12px;
}

.muted-text {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 12px;
}

.muted-text-inline {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 2px;
}

.quick-add-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.quick-add-label {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.segmented-quick-add {
  flex: 1;
  min-width: 210px;
}

.segmented-quick-add .seg-btn {
  min-width: 56px;
  padding: 5px 8px;
  font-size: 12px;
}

.search-item-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.btn-sm {
  padding: 6px 10px;
  font-size: 12px;
  white-space: nowrap;
}

.date-input-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.date-input-row .text-input {
  flex: 1;
  min-width: 0;
}

.search-results {
  display: grid;
  gap: 10px;
  max-height: 320px;
  overflow-y: auto;
}

.search-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
}

.search-item img {
  width: 72px;
  height: 46px;
  object-fit: cover;
  border-radius: 6px;
  flex-shrink: 0;
}

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

.search-item-title {
  font-size: 14px;
  font-weight: 600;
}

.search-item-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.selected-anime-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 16px;
}

.edit-title-label {
  font-weight: 700;
  margin-top: 0;
  margin-bottom: 16px;
}

.form-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-field label {
  font-size: 13px;
  color: var(--text-muted);
}

.label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.char-counter {
  font-size: 12px;
  color: var(--text-muted);
}

.modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.modal-footer-right {
  display: flex;
  gap: 10px;
  margin-left: auto;
}

.edit-header-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 16px;
}

.edit-header-meta .edit-title-label {
  margin: 0;
}

.official-site-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: #93c5fd;
  text-decoration: none;
}

.official-site-link:hover {
  text-decoration: underline;
  color: #bfdbfe;
}

.registered-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.16);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.35);
  white-space: nowrap;
}

.search-item-fallback {
  width: 72px;
  height: 46px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
}

.load-more-wrap {
  display: flex;
  justify-content: center;
  margin-top: 12px;
}

.toast-container {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 80;
  pointer-events: none;
}

.toast {
  background: #10b981;
  color: #052e16;
  font-size: 13px;
  font-weight: 700;
  padding: 10px 16px;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  animation: toast-in 0.18s ease-out;
}

.brand-link {
  text-decoration: none;
  color: inherit;
}

.site-footer {
  margin-top: 48px;
  padding: 20px 0 28px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.footer-links a {
  color: var(--text-muted);
  text-decoration: none;
}

.footer-links a:hover {
  color: var(--text);
  text-decoration: underline;
}

.legal-page {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px 24px;
  margin-top: 16px;
}

.legal-header h2 {
  margin: 12px 0 4px;
  font-size: 22px;
}

.legal-section {
  margin-top: 20px;
}

.legal-section h3 {
  margin: 0 0 8px;
  font-size: 15px;
  color: #e2e8f0;
}

.legal-section p,
.legal-section li {
  font-size: 14px;
  line-height: 1.7;
  color: #cbd5e1;
}

.legal-section ul {
  margin: 6px 0;
  padding-left: 20px;
}

.legal-section a {
  color: #93c5fd;
}

.account-danger-footer {
  margin-top: 32px;
  text-align: right;
}

.danger-link {
  color: #fca5a5;
  font-size: 12px;
}

.modal-card-sm {
  max-width: 460px;
}

.danger-notice {
  font-size: 14px;
  line-height: 1.6;
  color: #fecaca;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: 8px;
  padding: 12px;
  margin: 0;
}

.lp-container {
  display: flex;
  flex-direction: column;
  gap: 24px;
  margin-top: 24px;
}

.lp-hero {
  margin-top: 0;
  padding: 44px 24px;
}

.lp-eyebrow {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  color: #a5b4fc;
  background: rgba(99, 102, 241, 0.16);
  border: 1px solid rgba(99, 102, 241, 0.35);
  border-radius: 999px;
  padding: 4px 12px;
  margin-bottom: 14px;
}

.lp-subtitle {
  max-width: 680px;
  margin: 0 auto 24px;
  line-height: 1.7;
}

.lp-features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.lp-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
}

.lp-card-img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 10px;
  margin-bottom: 14px;
  border: 1px solid rgba(99, 102, 241, 0.2);
  display: block;
}

.lp-card h3 {
  margin: 0 0 8px;
  font-size: 16px;
  color: #e2e8f0;
}

.lp-card p {
  margin: 0;
  font-size: 13px;
  line-height: 1.65;
  color: var(--text-muted);
}

.lp-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 20px;
}

.lp-step {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.lp-step-num {
  font-size: 11px;
  font-weight: 700;
  color: #818cf8;
  letter-spacing: 0.05em;
}

.lp-step p {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
}

.dashboard-footer-actions {
  margin-top: 32px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.export-actions {
  display: flex;
  gap: 8px;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
