/* ═══════════════════════════════════════════════
   Lust in DreamLand — Shared Styles
   ═══════════════════════════════════════════════ */

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --void: #0a0510;
  --abyss: #110a1a;
  --deep-violet: #1a0e2e;
  --bruise: #2d1b4e;
  --orchid: #9b4dca;
  --rose-gold: #e8a87c;
  --blush: #d4728c;
  --moon: #e6d5f3;
  --pearl: #f0e6f6;
  --ember: #ff6b8a;
  --honey: #ffb347;
  --whisper: rgba(155, 77, 202, 0.08);
  --card-bg: rgba(26,14,46,0.5);
  --card-border: rgba(155,77,202,0.15);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html, body {
  width: 100%;
  overflow-x: hidden;
  background: var(--void);
  color: var(--moon);
  font-family: 'Cormorant Garamond', 'Noto Serif JP', serif;
  -webkit-text-size-adjust: 100%;
}

/* ═══ AMBIENT ═══ */
.cosmos {
  position: fixed; inset: 0; z-index: 0; overflow: hidden;
}
.cosmos::before {
  content: '';
  position: absolute; width: 200%; height: 200%; top: -50%; left: -50%;
  background:
    radial-gradient(ellipse 600px 400px at 30% 20%, rgba(155,77,202,0.12) 0%, transparent 70%),
    radial-gradient(ellipse 500px 500px at 70% 60%, rgba(212,114,140,0.08) 0%, transparent 70%),
    radial-gradient(ellipse 400px 300px at 50% 80%, rgba(232,168,124,0.06) 0%, transparent 70%);
  animation: drift 30s ease-in-out infinite alternate;
}
@keyframes drift {
  0% { transform: translate(0,0) rotate(0deg); }
  100% { transform: translate(-5%,3%) rotate(2deg); }
}
.noise {
  position: fixed; inset: 0; z-index: 999; pointer-events: none; opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 128px;
}

/* ═══ PAGE LAYOUT ═══ */
.page {
  position: relative; z-index: 2;
  min-height: 100vh; min-height: 100dvh;
  padding: calc(1rem + var(--safe-top)) 1rem calc(5rem + var(--safe-bottom));
}

/* ═══ HEADER ═══ */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.5rem 0 1.5rem;
}
.back-btn {
  display: flex; align-items: center; gap: 0.3rem;
  color: var(--orchid); text-decoration: none;
  font-family: 'Cinzel Decorative', serif;
  font-size: 0.7rem; letter-spacing: 0.1em;
  opacity: 0.6; transition: opacity 0.3s;
  -webkit-tap-highlight-color: transparent;
}
.back-btn:active { opacity: 1; }
.page-gate-icon { font-size: 1.2rem; }

.page-title {
  font-family: 'Cinzel Decorative', serif;
  font-weight: 400;
  font-size: clamp(1.3rem, 5vw, 1.8rem);
  background: linear-gradient(135deg, var(--pearl), var(--rose-gold));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.3rem;
}
.page-subtitle {
  font-size: 0.75rem; letter-spacing: 0.3em;
  color: var(--orchid); opacity: 0.5;
  font-family: 'Cinzel Decorative', serif;
  text-transform: uppercase;
}

/* ═══ CARDS ═══ */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 1.2rem;
  margin-bottom: 0.8rem;
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  transition: all 0.3s;
  position: relative;
  overflow: hidden;
}
.card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--orchid), transparent);
  opacity: 0.3;
}
.card:active { transform: scale(0.98); }
.card a { text-decoration: none; color: inherit; display: block; }

.card-title {
  font-family: 'Cinzel Decorative', serif;
  font-size: 0.95rem; color: var(--pearl);
  margin-bottom: 0.4rem;
}
.card-meta {
  font-size: 0.75rem; color: rgba(155,77,202,0.5);
  margin-bottom: 0.5rem;
}
.card-excerpt {
  font-size: 0.85rem; color: rgba(230,213,243,0.5);
  line-height: 1.6; font-weight: 300;
}
.card-tags { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.6rem; }
.tag {
  font-size: 0.65rem; padding: 0.2rem 0.6rem;
  background: rgba(155,77,202,0.15);
  border: 1px solid rgba(155,77,202,0.2);
  border-radius: 20px; color: var(--orchid);
  letter-spacing: 0.05em;
}

/* ═══ STATUS BADGES ═══ */
.badge {
  display: inline-block; font-size: 0.6rem;
  padding: 0.15rem 0.5rem; border-radius: 20px;
  letter-spacing: 0.05em; text-transform: uppercase;
  font-family: 'Cinzel Decorative', serif;
}
.badge-draft { background: rgba(255,179,71,0.15); color: var(--honey); border: 1px solid rgba(255,179,71,0.3); }
.badge-complete { background: rgba(155,77,202,0.15); color: var(--orchid); border: 1px solid rgba(155,77,202,0.3); }

/* ═══ FORMS ═══ */
.form-group { margin-bottom: 1.2rem; }
.form-label {
  display: block; font-size: 0.7rem;
  letter-spacing: 0.15em; text-transform: uppercase;
  color: var(--orchid); opacity: 0.6;
  margin-bottom: 0.5rem;
  font-family: 'Cinzel Decorative', serif;
}
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 0.8rem 1rem;
  background: rgba(26,14,46,0.6);
  border: 1px solid rgba(155,77,202,0.2);
  border-radius: 10px; color: var(--pearl);
  font-family: 'Cormorant Garamond', 'Noto Serif JP', serif;
  font-size: 1rem; outline: none;
  transition: border-color 0.3s;
  -webkit-appearance: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--orchid);
}
.form-input::placeholder, .form-textarea::placeholder {
  color: rgba(155,77,202,0.25);
}
.form-textarea {
  min-height: 200px; resize: vertical;
  line-height: 1.8;
}
.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239b4dca' fill='none' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
}
.form-hint {
  font-size: 0.75rem; color: rgba(155,77,202,0.35);
  margin-top: 0.3rem;
}

/* ═══ BUTTONS ═══ */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 0.4rem; padding: 0.8rem 1.5rem;
  border: 1px solid rgba(155,77,202,0.3);
  border-radius: 10px; color: var(--pearl);
  font-family: 'Cinzel Decorative', serif;
  font-size: 0.8rem; letter-spacing: 0.08em;
  cursor: pointer; transition: all 0.3s;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  background: linear-gradient(135deg, rgba(155,77,202,0.2), rgba(212,114,140,0.2));
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: linear-gradient(135deg, rgba(155,77,202,0.35), rgba(212,114,140,0.35));
  border-color: rgba(155,77,202,0.4);
}
.btn-danger {
  background: rgba(255,107,138,0.15);
  border-color: rgba(255,107,138,0.3);
  color: var(--ember);
}
.btn-sm { padding: 0.5rem 1rem; font-size: 0.7rem; }
.btn-block { width: 100%; }

/* ═══ FAB (Floating Action Button) ═══ */
.fab {
  position: fixed;
  bottom: calc(1.5rem + var(--safe-bottom));
  right: 1.5rem;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--orchid), var(--blush));
  border: none; color: white;
  font-size: 1.5rem;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 20px rgba(155,77,202,0.4);
  cursor: pointer; z-index: 100;
  transition: all 0.3s;
  -webkit-tap-highlight-color: transparent;
  text-decoration: none;
}
.fab:active { transform: scale(0.9); }

/* ═══ EMPTY STATE ═══ */
.empty {
  text-align: center; padding: 3rem 1rem;
}
.empty-icon { font-size: 2.5rem; margin-bottom: 1rem; opacity: 0.3; }
.empty-text {
  font-size: 0.9rem; color: rgba(230,213,243,0.35);
  line-height: 1.8;
}

/* ═══ FLASH MESSAGES ═══ */
.flash {
  padding: 0.8rem 1rem; border-radius: 10px;
  margin-bottom: 1rem; font-size: 0.85rem;
  animation: flash-in 0.4s ease;
}
.flash-success { background: rgba(76,175,80,0.15); border: 1px solid rgba(76,175,80,0.3); color: #a5d6a7; }
.flash-error { background: rgba(255,107,138,0.15); border: 1px solid rgba(255,107,138,0.3); color: var(--ember); }
@keyframes flash-in { from { opacity: 0; transform: translateY(-10px); } }

/* ═══ FILTER BAR ═══ */
.filters {
  display: flex; gap: 0.5rem; overflow-x: auto;
  padding: 0.5rem 0 1rem;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.filters::-webkit-scrollbar { display: none; }
.filter-chip {
  flex-shrink: 0;
  padding: 0.4rem 0.9rem;
  border: 1px solid rgba(155,77,202,0.2);
  border-radius: 20px;
  font-size: 0.7rem; color: rgba(155,77,202,0.5);
  background: transparent;
  font-family: 'Cormorant Garamond', serif;
  cursor: pointer; transition: all 0.3s;
  -webkit-tap-highlight-color: transparent;
  text-decoration: none;
}
.filter-chip.active, .filter-chip:active {
  background: rgba(155,77,202,0.15);
  border-color: var(--orchid);
  color: var(--orchid);
}

/* ═══ CONFIRM DIALOG ═══ */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(10,5,16,0.85);
  z-index: 500;
  align-items: center; justify-content: center;
  padding: 1.5rem;
}
.modal-overlay.show { display: flex; }
.modal-box {
  background: var(--deep-violet);
  border: 1px solid rgba(155,77,202,0.3);
  border-radius: 16px;
  padding: 2rem 1.5rem;
  max-width: 320px; width: 100%;
  text-align: center;
}
.modal-text {
  font-size: 0.95rem; margin-bottom: 1.5rem;
  line-height: 1.7; color: var(--pearl);
}
.modal-actions { display: flex; gap: 0.8rem; }
.modal-actions .btn { flex: 1; }

/* ═══ NOVEL VIEW ═══ */
.novel-body {
  font-size: 1rem; line-height: 2.2;
  color: var(--pearl); font-weight: 300;
  white-space: pre-wrap; word-wrap: break-word;
  padding: 1rem 0;
}

/* ═══ GALLERY GRID ═══ */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
}
.gallery-item {
  aspect-ratio: 1;
  overflow: hidden;
  border-radius: 4px;
  position: relative;
  cursor: pointer;
}
.gallery-item img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform 0.3s;
}
.gallery-item:active img { transform: scale(1.05); }

/* ═══ DIVIDERS ═══ */
.section-divider {
  width: 40px; height: 1px;
  background: linear-gradient(90deg, transparent, var(--orchid), transparent);
  margin: 2rem auto;
}

/* ═══ UTILITY ═══ */
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 0.5rem; }
