:root {
  --night: #070b19;
  --navy: #0e1630;
  --violet: #2a214e;
  --rose: #ffb6c8;
  --gold: #ffd96f;
  --cyan: #8ff0ff;
  --mint: #a9f0c7;
  --cream: #fff8e8;
  --muted: rgba(255, 248, 232, 0.68);
  --line: rgba(255, 248, 232, 0.16);
  --shadow: rgba(0, 0, 0, 0.36);
  color-scheme: dark;
  font-family: "Geeza Pro", "Noto Sans Arabic", Tahoma, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--cream);
  background: linear-gradient(145deg, #070b19 0%, #101321 43%, #20152e 100%);
  overflow-x: hidden;
  text-align: right;
}

button,
textarea,
input {
  font: inherit;
}

button {
  touch-action: manipulation;
}

button:focus-visible,
a:focus-visible,
textarea:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(255, 217, 111, 0.95);
  outline-offset: 5px;
}

.site-shell {
  position: relative;
  isolation: isolate;
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
  padding-bottom: 4rem;
}

/* ===== الخلفية الحيّة ===== */
.atmosphere {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
}

.framer-gradient-bg {
  position: absolute;
  inset: -16%;
  background:
    radial-gradient(circle at 22% 18%, rgba(255, 143, 177, 0.2), transparent 30rem),
    radial-gradient(circle at 80% 26%, rgba(143, 240, 255, 0.16), transparent 28rem),
    radial-gradient(circle at 48% 70%, rgba(255, 216, 107, 0.14), transparent 34rem),
    conic-gradient(from 230deg at 52% 40%, rgba(255, 182, 200, 0.13), transparent 19%, rgba(255, 217, 111, 0.12), transparent 45%, rgba(169, 240, 199, 0.1), transparent 68%, rgba(214, 179, 255, 0.13), transparent 86%);
  opacity: 0.9;
  will-change: transform;
  transform: translateZ(0);
}

.gradient-sheet {
  position: absolute;
  width: min(42rem, 74vw);
  aspect-ratio: 1;
  pointer-events: none;
  opacity: 0.34;
  border-radius: 999px;
  will-change: transform;
  transform: translateZ(0);
}

.sheet-rose {
  right: -10rem;
  top: 2rem;
  background: radial-gradient(circle, rgba(255, 143, 177, 0.26), rgba(255, 143, 177, 0.08) 48%, transparent 72%);
}

.sheet-gold {
  left: -12rem;
  top: 16rem;
  background: radial-gradient(circle, rgba(255, 216, 107, 0.23), rgba(255, 216, 107, 0.07) 50%, transparent 74%);
}

.sheet-cyan {
  left: 28%;
  bottom: -12rem;
  background: radial-gradient(circle, rgba(143, 240, 255, 0.2), rgba(214, 179, 255, 0.07) 48%, transparent 74%);
}

.floating-glyph {
  position: absolute;
  left: var(--x);
  top: var(--y);
  color: var(--glyph-color);
  font-size: clamp(1.1rem, 2.4vw, 1.9rem);
  text-shadow: 0 0 18px var(--glyph-glow);
  will-change: transform, opacity;
}

.dust {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: 0.22rem;
  aspect-ratio: 1;
  border-radius: 999px;
  background: rgba(255, 248, 232, 0.72);
  box-shadow: 0 0 10px rgba(255, 217, 111, 0.42);
}

/* ===== عناوين ونصوص عامة ===== */
.eyebrow,
.kicker {
  display: inline-flex;
  width: fit-content;
  margin: 0 0 0.9rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 248, 232, 0.06);
  color: var(--muted);
  font-size: clamp(0.74rem, 1.7vw, 0.86rem);
  font-weight: 800;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  text-wrap: balance;
}

.lede {
  max-width: 44rem;
  color: rgba(255, 248, 232, 0.78);
  font-size: clamp(1.05rem, 2.4vw, 1.35rem);
  line-height: 1.75;
}

/* ===== الأزرار ===== */
.save-button,
.ghost-button {
  display: inline-flex;
  min-height: 3rem;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 0;
  cursor: pointer;
  text-decoration: none;
  font-weight: 900;
}

.save-button {
  padding: 0.9rem 1.4rem;
  color: #20172d;
  background: linear-gradient(135deg, var(--gold), var(--rose));
  box-shadow: 0 18px 42px rgba(255, 182, 200, 0.18);
}

.save-button:disabled {
  opacity: 0.6;
  cursor: default;
}

.ghost-button {
  padding: 0.8rem 1.1rem;
  color: var(--cream);
  border: 1px solid var(--line);
  background: rgba(255, 248, 232, 0.075);
}

/* ===== مودال الاسم ===== */
.onboarding {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(5, 8, 18, 0.84);
}

.onboarding-card {
  width: min(560px, 100%);
  max-height: 92vh;
  overflow: auto;
  padding: clamp(1.4rem, 4vw, 2.2rem);
  border: 1px solid var(--line);
  border-radius: 2rem;
  background: linear-gradient(145deg, rgba(255, 248, 232, 0.09), rgba(255, 248, 232, 0.035));
  box-shadow: 0 24px 60px var(--shadow);
}

.onboarding-card h2 {
  margin-bottom: 0.6rem;
  font-family: "Geeza Pro", "Noto Naskh Arabic", serif;
  font-size: clamp(2.4rem, 8vw, 3.8rem);
  line-height: 1;
}

.soft {
  margin-bottom: 1.25rem;
  color: rgba(255, 248, 232, 0.75);
  line-height: 1.7;
}

.name-input {
  width: 100%;
  margin-bottom: 1rem;
  padding: 0.95rem 1.1rem;
  border: 1px solid rgba(255, 248, 232, 0.16);
  border-radius: 1rem;
  color: var(--cream);
  background: rgba(7, 11, 25, 0.52);
}

.name-input::placeholder {
  color: rgba(255, 248, 232, 0.44);
}

/* ===== صفحة الكتابة ===== */
.composer-section {
  padding: clamp(3.5rem, 8vw, 6rem) 0 2rem;
}

.composer-hero {
  margin-bottom: 2rem;
}

.composer-hero h1 {
  margin: 0 0 1rem;
  font-family: "Geeza Pro", "Noto Naskh Arabic", serif;
  font-size: clamp(3rem, 11vw, 6.5rem);
  line-height: 0.98;
}

.letters-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.letter-card-write {
  display: flex;
  flex-direction: column;
  padding: clamp(1.1rem, 3vw, 1.5rem);
  border: 1px solid color-mix(in srgb, var(--tone) 32%, var(--line));
  border-radius: 1.6rem;
  background:
    radial-gradient(circle at 90% 0%, var(--glow), transparent 50%),
    linear-gradient(145deg, rgba(255, 248, 232, 0.09), rgba(255, 248, 232, 0.035));
  box-shadow: 0 18px 44px var(--shadow);
}

.letter-card-head {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 0.85rem;
}

.grad-emblem {
  display: grid;
  place-items: center;
  width: 2.8rem;
  aspect-ratio: 1;
  border-radius: 999px;
  color: var(--tone);
  background: color-mix(in srgb, var(--tone) 12%, rgba(7, 11, 25, 0.5));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tone) 38%, transparent), 0 0 26px var(--glow);
  font-size: 1.3rem;
}

.letter-card-head strong {
  display: block;
  font-size: 1.2rem;
}

.grad-subtitle {
  color: rgba(255, 248, 232, 0.6);
  font-size: 0.85rem;
}

textarea {
  width: 100%;
  min-height: 7.5rem;
  resize: vertical;
  border: 1px solid rgba(255, 248, 232, 0.16);
  border-radius: 1rem;
  padding: 0.9rem;
  color: var(--cream);
  background: rgba(7, 11, 25, 0.52);
  line-height: 1.7;
}

textarea::placeholder {
  color: rgba(255, 248, 232, 0.44);
}

.char-count {
  margin: 0.5rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.submit-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  align-items: center;
  justify-content: space-between;
  margin-top: 1.4rem;
  padding: 1.2rem 1.4rem;
  border: 1px solid var(--line);
  border-radius: 1.6rem;
  background: rgba(255, 248, 232, 0.05);
}

.submit-progress {
  margin: 0;
  color: var(--gold);
  font-weight: 800;
}

.submit-button {
  min-width: 12rem;
}

.submit-hint {
  margin: 0;
  width: 100%;
  color: rgba(255, 248, 232, 0.55);
  font-size: 0.85rem;
}

/* ===== شاشة الشكر ===== */
.thankyou {
  min-height: 78vh;
  display: grid;
  place-items: center;
  padding: 4rem 1rem;
  text-align: center;
}

.thankyou-card {
  width: min(560px, 100%);
  padding: clamp(1.6rem, 5vw, 2.8rem);
  border: 1px solid rgba(255, 242, 173, 0.18);
  border-radius: 1.8rem;
  background: rgba(12, 16, 32, 0.6);
  backdrop-filter: blur(10px);
  box-shadow: 0 24px 60px var(--shadow);
}

.thankyou-cap {
  font-size: clamp(3rem, 10vw, 4.4rem);
  margin-bottom: 0.4rem;
}

.thankyou-card h2 {
  margin: 0.2rem 0 0.8rem;
  font-family: "Geeza Pro", "Noto Naskh Arabic", serif;
  font-size: clamp(2.2rem, 7vw, 3.2rem);
  line-height: 1.1;
}

.thankyou-lede {
  color: rgba(255, 248, 232, 0.82);
  line-height: 1.9;
  margin-bottom: 1.6rem;
}

.thankyou-soft {
  margin: 1rem 0 0;
  font-size: 0.85rem;
  color: rgba(255, 248, 232, 0.55);
}

/* ===== بعد الإرسال: مراجعة الرسائل وتعديلها ===== */
.mine-section {
  padding: clamp(3rem, 7vw, 5rem) 0 2rem;
}

.mine-card {
  width: min(620px, 100%);
  margin: 0 auto 2rem;
  text-align: center;
}

.mine-hint {
  margin: 1rem 0 0;
  font-size: 0.9rem;
  line-height: 1.8;
  color: rgba(255, 248, 232, 0.6);
}

/* ===== صفحة العرض ===== */
.view-header {
  padding: clamp(3rem, 7vw, 5rem) 0 1.5rem;
}

.view-header h1 {
  margin: 0 0 1rem;
  font-family: "Geeza Pro", "Noto Naskh Arabic", serif;
  font-size: clamp(2.8rem, 10vw, 6rem);
  line-height: 1;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 1.5rem;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--cream);
  background: rgba(255, 248, 232, 0.05);
  cursor: pointer;
  font-weight: 800;
}

.tab.is-active {
  border-color: color-mix(in srgb, var(--tone) 60%, transparent);
  background: color-mix(in srgb, var(--tone) 14%, rgba(7, 11, 25, 0.5));
  box-shadow: 0 0 26px var(--glow);
}

.tab-emblem {
  color: var(--tone);
}

.tab-count {
  display: grid;
  place-items: center;
  min-width: 1.5rem;
  height: 1.5rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  color: #20172d;
  background: var(--tone);
  font-size: 0.78rem;
}

.view-loading {
  padding: 4rem 0;
  text-align: center;
  color: var(--muted);
}

.grad-page {
  padding: 1rem 0 1.5rem;
}

.grad-page-head {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1.4rem;
}

.grad-page-emblem {
  display: grid;
  place-items: center;
  width: 4rem;
  aspect-ratio: 1;
  border-radius: 999px;
  color: var(--tone);
  background: color-mix(in srgb, var(--tone) 12%, rgba(7, 11, 25, 0.5));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tone) 38%, transparent), 0 0 30px var(--glow);
  font-size: 1.9rem;
}

.grad-page-head h2 {
  margin: 0 0 0.2rem;
  font-family: "Geeza Pro", "Noto Naskh Arabic", serif;
  font-size: clamp(2.2rem, 7vw, 4rem);
  line-height: 1.04;
}

.grad-page-sub {
  margin: 0;
  color: rgba(255, 248, 232, 0.6);
  font-weight: 700;
}

.letters-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.letter-note {
  padding: 1.2rem;
  border: 1px solid color-mix(in srgb, var(--tone) 34%, var(--line));
  border-radius: 1.4rem;
  background:
    radial-gradient(circle at 12% 10%, var(--glow), transparent 44%),
    rgba(255, 248, 232, 0.055);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.16);
}

.letter-note-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.55rem;
}

.letter-note-head strong {
  color: var(--cream);
  font-size: 1.05rem;
}

.letter-note-head time {
  color: var(--muted);
  font-size: 0.8rem;
}

.letter-note p {
  margin: 0;
  color: rgba(255, 248, 232, 0.82);
  line-height: 1.8;
  white-space: pre-wrap;
}

.empty {
  padding: 2.5rem 1rem;
  text-align: center;
  color: rgba(255, 248, 232, 0.6);
}

.signature {
  margin: 1.6rem 0 0;
  color: var(--cream);
  font-family: "Geeza Pro", "Noto Naskh Arabic", serif;
  font-size: 1.3rem;
  text-align: left;
}

.view-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  justify-content: space-between;
  margin-top: 2rem;
}

/* ===== التنبيه ===== */
.toast {
  position: fixed;
  z-index: 30;
  right: 50%;
  bottom: 1rem;
  max-width: calc(100% - 2rem);
  padding: 0.85rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--cream);
  background: rgba(7, 11, 25, 0.94);
  box-shadow: 0 16px 40px var(--shadow);
}

noscript {
  display: block;
  padding: 2rem;
  color: var(--cream);
}

/* ===== استجابة الشاشات ===== */
@media (max-width: 760px) {
  .letters-grid,
  .letters-list {
    grid-template-columns: 1fr;
  }

  .view-nav {
    flex-direction: column;
  }

  .view-nav .ghost-button {
    width: 100%;
  }

  .submit-button {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}
