/* ============================================================
   AniJar — profile, anime lists, login and profile editor
   ============================================================ */

.profile-hero {
  margin-bottom: 26px;
}

.profile-banner {
  position: relative;
  height: 220px;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 20%, color-mix(in srgb, var(--accent-primary) 38%, transparent), transparent 45%),
    radial-gradient(circle at 85% 80%, color-mix(in srgb, var(--accent-cyan) 22%, transparent), transparent 45%),
    linear-gradient(135deg, var(--bg-card), var(--bg-elevated));
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
}

.profile-banner::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, transparent 45%, rgba(0, 0, 0, 0.35) 100%);
}

.profile-banner-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-banner-img.hidden {
  display: none;
}

.profile-head {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: flex-end;
  gap: 18px;
  margin-top: -52px;
  padding: 0 24px;
}

.profile-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 126px;
  height: 126px;
  overflow: hidden;
  background: var(--bg-card);
  border: 4px solid var(--bg-main);
  border-radius: 50%;
  color: var(--accent-primary);
  box-shadow: var(--shadow-md);
}

.profile-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-avatar-icon {
  width: 52px;
  height: 52px;
}

.profile-avatar-img.hidden,
.profile-avatar-icon.hidden {
  display: none;
}

.profile-identity {
  flex: 1;
  min-width: 0;
  padding-bottom: 10px;
}

.profile-identity h1 {
  overflow: hidden;
  margin-bottom: 3px;
  color: var(--text-main);
  font-size: 27px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-identity span {
  overflow: hidden;
  display: block;
  color: var(--text-muted);
  font-size: 12.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-edit-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 12px;
  white-space: nowrap;
}

.profile-lists-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.profile-lists-header h2 {
  font-size: 19px;
  font-weight: 800;
}

.profile-lists-header .btn-ctrl {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
}

.profile-lists {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.profile-list {
  overflow: hidden;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.profile-list-head {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease;
}

.profile-list-head:hover {
  background: var(--bg-card-hover);
}

.profile-list-title {
  flex: 1;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.2px;
}

.profile-list-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 46px;
  height: 24px;
  padding: 0 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  letter-spacing: 0;
  box-sizing: border-box;
}

.profile-list-chevron {
  width: 17px;
  height: 17px;
  color: var(--text-dim);
  transition: transform 0.2s ease;
}

.profile-list.open .profile-list-chevron {
  transform: rotate(180deg);
}

.profile-list-body {
  border-top: 1px solid var(--border-subtle);
}

.profile-list-body.hidden {
  display: none;
}

.profile-rows {
  padding: 4px 0;
}

.profile-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 64px 96px 90px 46px;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 5px 16px;
  border-bottom: 1px solid color-mix(in srgb, var(--border-subtle) 55%, transparent);
  font-size: 12.5px;
}

.profile-row:last-child {
  border-bottom: none;
}

.profile-row:hover {
  background: var(--bg-card-hover);
}

.profile-row-num {
  color: var(--text-dim);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  text-align: right;
}

.profile-row-title {
  overflow: hidden;
  background: transparent;
  border: none;
  color: var(--accent-cyan);
  font-family: inherit;
  font-size: 12.5px;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.profile-row-title:hover {
  color: var(--accent-primary);
  text-decoration: underline;
}

.profile-row-score,
.profile-row-eps,
.profile-row-type {
  color: var(--text-muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  text-align: right;
  white-space: nowrap;
}

.profile-row-score {
  color: var(--text-main);
  font-weight: 700;
}

.profile-row-rewatch {
  color: var(--accent-amber);
  font-size: 10.5px;
  font-weight: 700;
  text-align: right;
}

.profile-row-empty {
  padding: 18px 16px;
  color: var(--text-muted);
  font-size: 12.5px;
}

.profile-stats {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
  margin: 22px 0 8px;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 12px;
}

.profile-stats strong {
  color: var(--text-main);
}

.profile-stats .profile-stat-sep {
  color: var(--text-dim);
}

.profile-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 22px;
  color: var(--text-muted);
  font-size: 12.5px;
}

.profile-loading.hidden {
  display: none;
}

/* Login */
.login-card {
  max-width: 400px;
}

.login-fields {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-bottom: 12px;
}

.login-fields input,
.profile-form-row input {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: inherit;
  font-size: 12.5px;
  outline: none;
}

.login-fields input:focus,
.profile-form-row input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px var(--border-focus);
}

.login-error {
  margin-bottom: 10px;
  padding: 8px 10px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-sm);
  color: #fca5a5;
  font-size: 12px;
}

.login-error.hidden {
  display: none;
}

.login-forgot-btn {
  display: block;
  margin: -2px 0 10px auto;
  padding: 4px 0;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 11.5px;
  text-decoration: underline;
  cursor: pointer;
}

.login-forgot-btn:hover {
  color: var(--text-main);
}

.login-submit {
  width: 100%;
}

.login-create-btn {
  width: 100%;
  margin-top: 8px;
}

.login-guest-btn {
  width: 100%;
  margin-top: 10px;
  padding: 8px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 11.5px;
  text-decoration: underline;
  cursor: pointer;
}

.login-guest-btn:hover {
  color: var(--text-main);
}

.profile-guest-menu {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 8px 0 20px;
  padding: 18px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.profile-guest-menu.hidden {
  display: none;
}

.profile-guest-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 54px;
  height: 54px;
  background: var(--bg-elevated);
  border-radius: 50%;
  color: var(--accent-primary);
}

.profile-guest-copy {
  flex: 1;
  min-width: 0;
}

.profile-guest-copy h2 {
  margin-bottom: 3px;
  font-size: 16px;
  font-weight: 800;
}

.profile-guest-copy p {
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1.45;
}

.profile-guest-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.profile-connect-hint {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0 16px;
  padding: 12px 14px;
  background: color-mix(in srgb, var(--accent-primary) 9%, var(--bg-card));
  border: 1px solid color-mix(in srgb, var(--accent-primary) 25%, transparent);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 12px;
}

.profile-connect-hint.hidden {
  display: none;
}

.login-hint {
  margin-top: 12px;
  color: var(--text-dim);
  font-size: 11px;
  line-height: 1.5;
}

.login-hint strong {
  color: var(--text-muted);
}

/* Recovery code */
.recovery-code-card {
  max-width: 420px;
}

.recovery-code-value {
  margin: 14px 0;
  padding: 14px;
  background: var(--bg-input);
  border: 1px dashed var(--accent-primary);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 2px;
  text-align: center;
  user-select: all;
  word-break: break-all;
}

.profile-recovery-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 14px;
  padding: 12px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.profile-recovery-row strong {
  display: block;
  margin-bottom: 4px;
  font-size: 13px;
}

.profile-recovery-row .settings-hint {
  margin: 0;
}

.profile-recovery-row .btn-ctrl {
  flex: 0 0 auto;
}

/* Profile editor */
.profile-edit-modal-card {
  max-width: 560px;
}

.profile-edit-footer {
  justify-content: space-between;
}

.profile-edit-footer .btn-ctrl {
  margin-right: auto;
}

.profile-edit-banner {
  position: relative;
  height: 140px;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 20%, color-mix(in srgb, var(--accent-primary) 35%, transparent), transparent 45%),
    linear-gradient(135deg, var(--bg-card), var(--bg-elevated));
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}

.profile-edit-banner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-edit-banner img.hidden {
  display: none;
}

.profile-upload-banner {
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 5px 9px;
  background: rgba(9, 12, 21, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 11px;
  cursor: pointer;
}

.profile-edit-avatar-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 14px 0 18px;
}

.profile-edit-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  overflow: hidden;
  flex: 0 0 auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 50%;
  color: var(--accent-primary);
}

.profile-edit-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-edit-avatar img.hidden {
  display: none;
}

.profile-edit-avatar svg {
  width: 30px;
  height: 30px;
}

.profile-edit-avatar.has-image svg {
  display: none;
}

.profile-upload-avatar {
  font-size: 12px;
  cursor: pointer;
}

.profile-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.profile-form-row-wide {
  grid-template-columns: 1fr;
}

.profile-form-row label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 600;
}

.profile-form-row input {
  color: var(--text-main);
}

/* Light theme */
html[data-theme="light"] .profile-banner,
html[data-theme="light"] .profile-edit-banner {
  border-color: rgba(15, 23, 42, 0.12);
}

html[data-theme="light"] .profile-avatar {
  border-color: var(--bg-main);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.16);
}

html[data-theme="light"] .profile-list,
html[data-theme="light"] .profile-stats,
html[data-theme="light"] .profile-guest-menu {
  background: #ffffff;
  border-color: rgba(15, 23, 42, 0.1);
}

html[data-theme="light"] .profile-row:hover {
  background: #f8fafc;
}

html[data-theme="light"] .profile-upload-banner {
  background: rgba(255, 255, 255, 0.85);
  border-color: rgba(15, 23, 42, 0.15);
  color: var(--text-main);
}

@media (max-width: 760px) {
  .profile-banner {
    height: 160px;
  }
  .profile-head {
    gap: 12px;
    margin-top: -42px;
    padding: 0 12px;
    flex-wrap: wrap;
  }
  .profile-avatar {
    width: 92px;
    height: 92px;
    border-width: 3px;
  }
  .profile-avatar-icon {
    width: 38px;
    height: 38px;
  }
  .profile-identity h1 {
    font-size: 22px;
  }
  .profile-edit-btn {
    width: 100%;
    justify-content: center;
    margin: 0 0 10px;
  }
  .profile-row {
    grid-template-columns: 28px minmax(0, 1fr) 62px 60px;
  }
  .profile-row-type,
  .profile-row-rewatch {
    display: none;
  }
  .profile-form-row {
    grid-template-columns: 1fr;
  }
  .profile-guest-menu {
    flex-wrap: wrap;
  }
  .profile-guest-actions {
    width: 100%;
  }
  .profile-connect-hint {
    align-items: flex-start;
    flex-direction: column;
  }
}
