/* Auth + Profile — matches editor-ui (same chrome, cards, buttons) */

:root {
  --auth-bg: #0b0d12;
  --auth-card: rgba(18, 20, 28, 0.72);
  --auth-border: rgba(255, 255, 255, 0.1);
  --auth-text: #eee;
  --auth-muted: #9aa0ab;
  --auth-accent: #d4c4ff;
  --auth-radius: 14px;
  --touch: 44px;
}

* {
  box-sizing: border-box;
}

.auth-body {
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  color: var(--auth-text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    sans-serif;
  background: #03050b;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
  max-width: 100%;
  width: 100%;
}

.auth-star-field {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  perspective: 600px;
  pointer-events: none;
}

.auth-star-layer {
  position: absolute;
  inset: -50%;
  opacity: 0;
  background-image:
    radial-gradient(1px 1px at 5% 10%, #fff 98%, transparent),
    radial-gradient(1px 1px at 15% 75%, #d4d4d4 98%, transparent),
    radial-gradient(2px 2px at 27% 35%, #f7f7f7 98%, transparent),
    radial-gradient(1px 1px at 39% 85%, #ccc 98%, transparent),
    radial-gradient(1px 1px at 48% 18%, #ededed 98%, transparent),
    radial-gradient(2px 2px at 62% 58%, #f0f0f0 98%, transparent),
    radial-gradient(1px 1px at 73% 8%, #d4d4d4 98%, transparent),
    radial-gradient(1px 1px at 84% 44%, #fcfcfc 98%, transparent),
    radial-gradient(2px 2px at 94% 91%, #cfcfcf 98%, transparent);
  background-size: 100% 100%;
  animation: auth-star-fly 7s linear infinite;
}

.auth-star-layer:nth-child(2) {
  animation-delay: -2.3s;
}

.auth-star-layer:nth-child(3) {
  animation-delay: -4.6s;
}

@keyframes auth-star-fly {
  from {
    opacity: 0;
    transform: scale(0.45);
  }
  15%,
  85% {
    opacity: 0.55;
  }
  to {
    opacity: 0;
    transform: scale(1.6);
  }
}

.auth-body .editor-topbar,
.auth-body main {
  position: relative;
  z-index: 1;
}

.auth-body .editor-topbar {
  z-index: 2;
}

html[data-theme='light'] .auth-star-field {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .auth-star-layer {
    animation: none;
    opacity: 0.45;
    transform: scale(1);
  }
}

.auth-body.editor-shell {
  display: block;
  padding: 0 !important;
  max-width: none;
}

.auth-wrap {
  width: min(480px, 100%);
  margin: 0 auto;
  padding: 20px max(14px, env(safe-area-inset-left)) 32px
    max(14px, env(safe-area-inset-right));
}

.auth-panel h1 {
  margin: 0 0 8px;
  font-size: clamp(1.35rem, 4vw, 1.65rem);
  font-weight: 650;
  color: #f0ecff;
}

.auth-panel .hint {
  margin-bottom: 4px;
}

.auth-brand {
  color: var(--auth-accent);
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0.03em;
  font-size: 1.05rem;
}

.auth-sub,
.auth-foot,
.muted {
  color: var(--auth-muted);
  line-height: 1.5;
  margin: 0;
}

.auth-foot {
  margin-top: 18px;
  font-size: 0.82rem;
}

.auth-error {
  background: #3a1515;
  border: 1px solid #7a3030;
  color: #ffb4b4;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 0.9rem;
  margin: 12px 0 0;
}

.auth-warn {
  background: #2a2410;
  border: 1px solid #665520;
  color: #f0e0a8;
  padding: 12px;
  border-radius: 10px;
  font-size: 0.86rem;
  line-height: 1.45;
  margin: 12px 0 0;
}

.auth-warn code {
  font-size: 0.78rem;
  word-break: break-all;
}

.google-btn,
.dev-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: var(--touch);
  margin-top: 18px;
  padding: 12px 16px;
  border-radius: 10px;
  border: none;
  background: #eee;
  color: #111;
  font-weight: 650;
  font-size: 0.95rem;
  text-decoration: none;
  cursor: pointer;
  transition: filter 0.12s ease;
}

.google-btn:hover,
.dev-btn:hover {
  filter: brightness(1.05);
}

.google-btn.secondary {
  background: transparent;
  color: var(--auth-text);
  border: 1px solid rgba(255, 255, 255, 0.22);
}

.dev-btn {
  background: #2a3a55;
  color: #eee;
  margin-top: 12px;
}

.inline-form {
  display: inline;
  margin: 0;
}

.editor-topbar .linkish {
  background: none;
  border: 1px solid transparent;
  cursor: pointer;
  font: inherit;
}

/* Profile */
.profile-body {
  display: block;
  padding: 0 !important;
}

/* You (left half) · Refer & earn (right half) · Library full width below */
.profile-layout.auth-wrap {
  width: min(1040px, 100%);
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: stretch;
  gap: 16px;
  padding-top: 20px;
}

.profile-layout .library-card {
  grid-column: 1 / -1;
}

@media (max-width: 800px) {
  .profile-layout.auth-wrap {
    grid-template-columns: 1fr;
  }

  .profile-card {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-areas:
      'label label'
      'avatar title'
      'avatar meta'
      'cta cta';
    column-gap: 14px;
    align-items: center;
  }

  .profile-card .editor-step-label {
    grid-area: label;
  }

  .profile-avatar-wrap {
    grid-area: avatar;
    margin: 0;
  }

  .profile-card h1 {
    grid-area: title;
    margin: 0;
    font-size: 1.2rem;
  }

  .profile-card .muted {
    grid-area: meta;
  }

  .profile-card .editor-btn {
    grid-area: cta;
  }

  .profile-card .muted.small {
    display: none;
  }
}

.profile-card,
.library-card {
  margin: 0;
}

.profile-avatar-wrap {
  margin-bottom: 12px;
}

.profile-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.14);
}

.profile-avatar.placeholder {
  display: grid;
  place-items: center;
  background: #3a2a55;
  font-size: 1.6rem;
  font-weight: 700;
}

.profile-card h1 {
  margin: 0 0 4px;
  font-size: 1.35rem;
  color: #f0ecff;
}

.library-card h2 {
  margin: 0 0 12px;
  font-size: 1.1rem;
  font-weight: 650;
  color: #f0ecff;
}

.small {
  font-size: 0.82rem;
}

.spaced {
  margin-top: 24px;
}

.library-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.library-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

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

.library-row strong {
  display: block;
  font-size: 0.95rem;
  line-height: 1.3;
  word-break: break-word;
}

.row-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 6px 12px;
  border-radius: 10px;
  background: #eee;
  color: #111;
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 600;
  white-space: nowrap;
}

.pill.ghost {
  background: transparent;
  color: #ddd;
  border: 1px solid rgba(255, 255, 255, 0.22);
}

@media (max-width: 520px) {
  .library-row {
    flex-direction: column;
    align-items: stretch;
  }

  .row-actions {
    justify-content: stretch;
  }

  .row-actions .pill {
    flex: 1;
  }
}

/* Referral code on sign-in */
.google-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ref-label {
  font-size: 0.85rem;
  font-weight: 600;
  opacity: 0.85;
}

.ref-label span {
  font-weight: 400;
  opacity: 0.7;
}

.ref-input {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
  color: inherit;
  font-size: 1rem;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.ref-note {
  margin: 0;
  font-size: 0.85rem;
  color: #ffb4a8;
}

.ref-note.ok {
  color: #7ee2a8;
}

button.google-btn {
  width: 100%;
  border: none;
  cursor: pointer;
  font: inherit;
  margin-top: 4px;
}

/* Refer & earn on the profile page */
.profile-ref-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 10px 0;
}

.profile-ref-code {
  padding: 8px 14px;
  border-radius: 10px;
  background: rgba(212, 196, 255, 0.16);
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 2px;
}

.profile-ref-copy {
  min-height: 38px;
  padding: 6px 14px;
  border: none;
  border-radius: 999px;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  background: linear-gradient(90deg, #ff7a6b, #d94fb0 50%, #8437fd);
}

.profile-ref-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  opacity: 0.9;
}

/* Library table */
.library-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.library-head h2 {
  margin: 0;
}

.library-table-wrap {
  overflow-x: auto;
  margin-top: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
}

.library-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.library-table th,
.library-table td {
  padding: 10px 14px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.library-table thead th {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #9aa0ab;
  background: rgba(255, 255, 255, 0.03);
}

.library-table tbody tr:last-child td {
  border-bottom: none;
}

.library-table tbody tr:hover {
  background: rgba(212, 196, 255, 0.06);
}

.library-table .col-num {
  width: 48px;
  color: #9aa0ab;
  font-variant-numeric: tabular-nums;
}

.library-table .col-title {
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.library-table .col-pages {
  width: 70px;
  font-variant-numeric: tabular-nums;
}

.library-table .col-date {
  width: 170px;
  white-space: nowrap;
  color: #c8ccd6;
}

.library-table .col-actions {
  width: 1%;
  white-space: nowrap;
  text-align: right;
}

.library-table .col-actions .pill + .pill {
  margin-left: 6px;
}

.library-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}

.pager-btn {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 6px 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #eee;
  font-weight: 650;
  text-decoration: none;
  transition: background 0.15s ease;
}

.pager-btn:hover:not(.disabled) {
  background: rgba(212, 196, 255, 0.14);
}

.pager-btn.disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.pager-info {
  font-size: 0.86rem;
  color: #9aa0ab;
  text-align: center;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
