* {
  box-sizing: border-box;
}

:root {
  --bg: #08111f;
  --bg-soft: #101b31;
  --panel: rgba(11, 18, 33, 0.78);
  --panel-strong: rgba(17, 28, 50, 0.92);
  --border: rgba(255, 255, 255, 0.1);
  --text: #f4f7fb;
  --muted: #b8c3d9;
  --accent: #f4b942;
  --accent-strong: #ffcb6b;
  --danger: #ff6b6b;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
}

html, body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: 'Manrope', sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(244, 185, 66, 0.18), transparent 25%),
    radial-gradient(circle at right 10%, rgba(113, 198, 255, 0.18), transparent 30%),
    linear-gradient(135deg, #06101d, #0e1a31 55%, #08111f);
}

a {
  color: inherit;
  text-decoration: none;
}

h1, h2, h3 {
  margin: 0 0 0.5rem;
  font-family: 'Fraunces', serif;
  letter-spacing: 0.01em;
}

p {
  margin: 0;
  line-height: 1.6;
}

img {
  display: block;
  max-width: 100%;
}

input, textarea, select, button {
  font: inherit;
}

.background-orb {
  position: fixed;
  z-index: 0;
  pointer-events: none;
  filter: blur(10px);
  opacity: 0.5;
}

.background-orb-a {
  top: -120px;
  left: -100px;
  width: 260px;
  height: 260px;
  border-radius: 50%;
  background: rgba(244, 185, 66, 0.2);
}

.background-orb-b {
  bottom: -140px;
  right: -90px;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  background: rgba(104, 177, 255, 0.18);
}

.noise-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.04;
  background-image: linear-gradient(rgba(255, 255, 255, 0.95) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, 0.95) 1px, transparent 1px);
  background-size: 36px 36px;
}

.auth-page,
.app-page {
  position: relative;
  z-index: 1;
}

.topbar,
.page-shell,
.auth-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 24px 0 10px;
}

.brand {
  font-family: 'Fraunces', serif;
  font-size: 1.7rem;
  letter-spacing: 0.02em;
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
}

.brand-sub {
  font-family: 'Manrope', sans-serif;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  opacity: 0.5;
}

.hero-sub {
  font-size: 0.9rem;
  opacity: 0.5;
  margin-top: 0.25rem;
  font-style: italic;
}

.eyebrow {
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-size: 0.72rem;
  color: var(--accent-strong);
}

.topbar-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.page-shell {
  display: grid;
  gap: 1.25rem;
  padding: 1rem 0 3rem;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.2rem;
  align-items: center;
  justify-items: center;
  padding: 3rem 0;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.hero,
.auth-hero,
.auth-card,
.section-card,
.stat-card {
  padding: 1.5rem;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem 1.2rem;
  align-items: center;
}

.hero-art {
  margin: 0;
  width: min(260px, 34vw);
  flex: 0 0 auto;
  justify-self: end;
}

.hero-art img {
  width: 100%;
  height: auto;
  display: block;
  filter: drop-shadow(0 18px 28px rgba(0, 0, 0, 0.25));
}

.hero h1,
.auth-hero h1 {
  font-size: clamp(2.3rem, 4vw, 4rem);
  line-height: 0.95;
}

.hero-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  grid-column: 1 / -1;
}

.feature-grid,
.stats-grid,
.card-grid,
.detail-grid,
.settings-grid {
  display: grid;
  gap: 1rem;
}

.feature-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 1.6rem;
}

.feature-grid div,
.setting-card,
.relationship-card,
.photo-card,
.character-card,
.stat-card {
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(255, 255, 255, 0.04);
}

.feature-grid div {
  border-radius: 18px;
  padding: 1rem;
}

.feature-grid strong,
.stat-card strong {
  display: block;
  font-size: 1.2rem;
  margin-bottom: 0.25rem;
}

.feature-grid span,
.muted,
.card-meta,
.setting-card p,
.relationship-card p,
.info-list span {
  color: var(--muted);
}

.stats-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stat-card span {
  display: block;
  color: var(--muted);
  margin-bottom: 0.45rem;
}

.card-grid {
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  margin-top: 1rem;
}

.character-card {
  display: grid;
  gap: 0.8rem;
  border-radius: 22px;
  padding: 1.2rem;
  transition: transform 160ms ease, border-color 160ms ease;
}

.character-card:hover {
  transform: translateY(-4px);
  border-color: rgba(244, 185, 66, 0.45);
}

.character-avatar {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(244, 185, 66, 0.32), rgba(113, 198, 255, 0.24));
  font-weight: 800;
}

.character-cover {
  width: 100px;
  height: 100px;
  object-fit: cover;
  border-radius: 14px;
  display: block;
}

.character-cover-wrap {
  position: relative;
  display: inline-block;
}

.owner-card {
  border-color: rgba(244, 185, 66, 0.6) !important;
  background: linear-gradient(135deg, rgba(244, 185, 66, 0.08), rgba(255, 200, 80, 0.04));
}

.owner-avatar {
  background: linear-gradient(135deg, rgba(244, 185, 66, 0.5), rgba(255, 160, 20, 0.35));
  font-size: 1.4rem;
}

.owner-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  font-size: 1.1rem;
  line-height: 1;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,0.5));
}

.owner-label {
  font-size: 0.7rem;
  font-weight: 700;
  background: rgba(244, 185, 66, 0.25);
  color: rgb(244, 185, 66);
  border-radius: 6px;
  padding: 1px 6px;
  vertical-align: middle;
  margin-left: 4px;
}

.owner-banner {
  background: linear-gradient(90deg, rgba(244, 185, 66, 0.15), rgba(255, 160, 20, 0.08));
  border: 1px solid rgba(244, 185, 66, 0.35);
  border-radius: 16px;
  padding: 0.85rem 1.2rem;
  font-weight: 600;
  color: rgb(244, 200, 80);
  margin-bottom: 0.5rem;
}

.card-meta {
  font-size: 0.9rem;
}

.section-card h2 {
  margin-bottom: 1.2rem;
}

.section-card h3 {
  margin-top: 1.6rem;
  margin-bottom: 0.9rem;
}

.section-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.search-form,
.inline-form {
  display: flex;
  gap: 0.65rem;
}

.search-form input,
.stack-form input,
.stack-form textarea,
.stack-form select,
.form-grid input,
.form-grid textarea,
.form-grid select {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  background: rgba(6, 12, 22, 0.72);
  color: var(--text);
  padding: 0.9rem 1rem;
}

.search-form input::placeholder,
.stack-form input::placeholder,
.stack-form textarea::placeholder,
.form-grid input::placeholder,
.form-grid textarea::placeholder {
  color: rgba(244, 247, 251, 0.45);
}

.stack-form,
.form-grid {
  display: grid;
  gap: 1rem;
}

.form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.compact-grid {
  margin-bottom: 1rem;
}

.full-width {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 0.4rem;
  color: var(--text);
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(6, 12, 22, 0.72);
}

.checkbox-field input {
  width: 18px;
  height: 18px;
}

.slider-field,
.slider-display {
  gap: 0.65rem;
}

.slider-field input[type='range'],
.slider-display input[type='range'] {
  width: 100%;
  accent-color: var(--accent-strong);
}

.slider-labels {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.slider-labels strong {
  color: var(--text);
}

.slider-display {
  display: grid;
}

.slider-display strong {
  display: inline;
  margin-top: 0;
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 46px;
  padding: 0.8rem 1.15rem;
  border: 0;
  border-radius: 14px;
  cursor: pointer;
  transition: transform 160ms ease, opacity 160ms ease, background 160ms ease;
}

.small {
  min-height: 38px;
  padding-inline: 0.9rem;
}

.primary-button {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #241800;
  font-weight: 800;
}

.secondary-button,
.ghost-button {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.danger-button {
  background: rgba(255, 107, 107, 0.14);
  color: #ffd3d3;
  border: 1px solid rgba(255, 107, 107, 0.34);
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.danger-button:hover,
.character-card:hover {
  transform: translateY(-1px);
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.empty-state {
  border: 1px dashed rgba(255, 255, 255, 0.16);
  border-radius: 18px;
  padding: 2rem;
  text-align: center;
}

.detail-grid {
  grid-template-columns: 1.1fr 0.9fr;
}

.detail-hero {
  align-items: center;
}

.info-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.2rem;
}

.info-list div,
.setting-card,
.relationship-card,
.photo-card {
  border-radius: 18px;
  padding: 0.9rem 1rem;
}

.info-list strong {
  display: block;
  margin-top: 0.25rem;
}

.traits-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.2rem;
}

.trait-card {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 16px;
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.trait-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: 600;
}

.trait-value {
  font-size: 1rem;
  font-weight: 700;
}

.trait-pill {
  display: inline-flex;
  align-items: center;
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: 99px;
  padding: 0.2rem 0.7rem;
  align-self: flex-start;
}

.trait-pill-yes {
  background: rgba(84, 200, 120, 0.15);
  color: rgb(84, 200, 120);
}

.trait-pill-no {
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
}

.trait-dots {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.trait-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  flex-shrink: 0;
}

.trait-dot.filled {
  background: var(--accent-strong);
}

.trait-dot-num {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent-strong);
  margin-left: 4px;
}

.text-block {
  padding: 1rem;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  color: #e7edf8;
}

.photo-grid,
.relationship-list,
.vibe-list,
.settings-list {
  display: grid;
  gap: 0.75rem;
}

.vibe-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  border-radius: 18px;
  padding: 0.9rem 1rem;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(255, 255, 255, 0.04);
}

.vibe-emoji {
  font-size: 1.6rem;
  flex-shrink: 0;
  line-height: 1;
}

.vibe-body {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 1;
  min-width: 0;
}

.vibe-name {
  font-size: 1rem;
  font-weight: 700;
}

.vibe-tag {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: 600;
}

.vibe-note {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.1rem;
}

.hof-new-form {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.hof-new-form input {
  flex: 1;
}

.small-button {
  padding: 0.45rem 1rem;
  font-size: 0.85rem;
  white-space: nowrap;
}

.hof-card-open {
  border-color: rgba(113, 198, 255, 0.2);
  background: linear-gradient(135deg, rgba(113, 198, 255, 0.05), rgba(255,255,255,0.02));
}

.hof-decide-form {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  margin-top: 0.4rem;
}

.hof-decide-form select {
  flex: 1;
  font-size: 0.85rem;
  padding: 0.35rem 0.6rem;
}

.hof-list {
  display: grid;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.hof-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  border-radius: 18px;
  padding: 1rem 1.1rem;
  border: 1px solid rgba(244, 185, 66, 0.2);
  background: linear-gradient(135deg, rgba(244, 185, 66, 0.06), rgba(255,255,255,0.02));
}

.hof-trophy {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.hof-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.hof-thesis {
  font-weight: 600;
  font-size: 0.95rem;
}

.hof-winner {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.hof-avatar {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}

.hof-initials {
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, rgba(244, 185, 66, 0.32), rgba(113, 198, 255, 0.24));
  font-size: 0.65rem;
  font-weight: 800;
}

.hof-winner strong {
  font-size: 0.85rem;
  color: var(--accent-strong);
}

@media (max-width: 720px) {
  .hof-layout {
    grid-template-columns: 1fr;
  }
}

.vibe-delete {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  opacity: 0.3;
  padding: 0.2rem;
  line-height: 1;
  transition: opacity 0.15s;
  flex-shrink: 0;
  align-self: flex-start;
}

.vibe-delete:hover {
  opacity: 0.8;
}

.photo-grid {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.photo-card {
  overflow: hidden;
  padding: 0;
}

.photo-card img {
  aspect-ratio: 4 / 4;
  width: 100%;
  object-fit: cover;
  cursor: zoom-in;
  transition: opacity 0.15s;
}

.photo-card img:hover {
  opacity: 0.85;
}

/* Lightbox */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(0, 0, 0, 0.88);
  align-items: center;
  justify-content: center;
}

.lightbox.open {
  display: flex;
}

.lightbox-inner {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: min(96vw, 1200px);
  max-height: 92vh;
  width: 100%;
}

.lightbox-img {
  max-width: 100%;
  max-height: 88vh;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: 0 8px 48px rgba(0,0,0,0.6);
}

.lightbox-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255,255,255,0.12);
  border: none;
  color: #fff;
  font-size: 1.6rem;
  line-height: 1;
  padding: 0.6rem 0.9rem;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.15s;
  z-index: 1;
}

.lightbox-btn:hover {
  background: rgba(255,255,255,0.25);
}

.lightbox-prev { left: -3.2rem; }
.lightbox-next { right: -3.2rem; }

.lightbox-close {
  position: absolute;
  top: -2.6rem;
  right: 0;
  background: none;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  opacity: 0.7;
  line-height: 1;
}

.lightbox-close:hover { opacity: 1; }

.lightbox-counter {
  position: absolute;
  bottom: -2rem;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255,255,255,0.55);
  font-size: 0.82rem;
}

.photo-card {
  position: relative;
}

.photo-delete-form {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
}

.photo-focal-btn {
  position: absolute;
  top: 0.4rem;
  left: 0.4rem;
  background: rgba(0, 0, 0, 0.5);
  border: none;
  cursor: pointer;
  font-size: 1rem;
  opacity: 0;
  padding: 0.3rem 0.4rem;
  line-height: 1;
  border-radius: 8px;
  transition: opacity 0.15s;
}

.photo-card:hover .photo-focal-btn {
  opacity: 1;
}

/* Focal point modal */
.focal-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 950;
  background: rgba(0, 0, 0, 0.9);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1rem;
}

.focal-modal.open {
  display: flex;
}

.focal-modal-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  max-width: min(94vw, 700px);
}

.focal-hint {
  color: rgba(255,255,255,0.7);
  font-size: 0.9rem;
}

.focal-img-wrap {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  line-height: 0;
  user-select: none;
}

.focal-img-wrap img {
  max-width: min(90vw, 680px);
  max-height: 65vh;
  object-fit: contain;
  display: block;
  pointer-events: none;
}

.focal-circle {
  position: absolute;
  border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,0.9);
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.62);
  transform: translate(-50%, -50%);
  cursor: grab;
  touch-action: none;
}

.focal-circle:active {
  cursor: grabbing;
}

.focal-actions {
  display: flex;
  gap: 0.75rem;
}

.photo-delete {
  background: rgba(0, 0, 0, 0.5);
  border: none;
  cursor: pointer;
  font-size: 1rem;
  opacity: 0;
  padding: 0.3rem 0.4rem;
  line-height: 1;
  border-radius: 8px;
  transition: opacity 0.15s;
}

.photo-card:hover .photo-delete {
  opacity: 1;
}

.relationship-card,
.setting-card {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
}

.settings-grid {
  grid-template-columns: 0.7fr 1fr;
}

.settings-form,
.inner-panel {
  min-height: 100%;
}

.inner-panel {
  padding: 1.5rem;
}

.flash {
  margin: 0 0 0.5rem;
  padding: 1rem 1.1rem;
  border-radius: 16px;
  border: 1px solid transparent;
}

.flash-success {
  background: rgba(84, 200, 120, 0.12);
  border-color: rgba(84, 200, 120, 0.24);
}

.flash-error {
  background: rgba(255, 107, 107, 0.12);
  border-color: rgba(255, 107, 107, 0.24);
}

.compact-form {
  margin-bottom: 1rem;
}

.single-panel {
  min-height: calc(100vh - 110px);
  display: grid;
  place-items: center;
}

.auth-card {
  width: 100%;
  max-width: 520px;
}

@media (max-width: 980px) {
  .detail-grid,
  .settings-grid,
  .hero,
  .section-header,
  .topbar {
    grid-template-columns: 1fr;
    display: grid;
  }

  .topbar,
  .section-header,
  .hero {
    align-items: stretch;
  }

  .hero,
  .section-header {
    gap: 1rem;
  }

  .hero {
    grid-template-columns: 1fr;
  }

  .hero-art {
    width: min(220px, 60vw);
    justify-self: start;
  }

  .feature-grid,
  .stats-grid,
  .info-list,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .auth-shell {
    justify-items: stretch;
  }

  .topbar-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  .topbar,
  .page-shell,
  .auth-shell {
    width: min(100% - 20px, 1180px);
  }

  .hero,
  .auth-hero,
  .auth-card,
  .section-card,
  .stat-card,
  .inner-panel {
    padding: 1.1rem;
  }

  .topbar-actions,
  .hero-actions,
  .search-form,
  .inline-form,
  .relationship-card,
  .setting-card {
    flex-direction: column;
    align-items: stretch;
  }

  .hero-art {
    width: min(180px, 70vw);
  }
}