/* ============ Sahara.ai — desert, day & night ============ */
:root {
  --sand: #f7ecd9;
  --sand2: #f0dfc0;
  --card: #fffaf1;
  --card-glass: rgba(255, 250, 241, .82);
  --line: #e5d3b3;
  --ink: #33231a;
  --ink-soft: #6f5847;
  --dune: #c98a4b;
  --dune-dark: #7a3f23;
  --terracotta: #b3542d;
  --oasis: #1f6f5c;
  --sky1: #fdf3e0; --sky2: #f7ecd9;
  --glow1: rgba(255, 205, 130, .55); --glow2: rgba(255, 236, 200, 0);
  --dune-fill1: rgba(146, 84, 48, .30);
  --dune-fill2: rgba(120, 63, 35, .55);
  --star: transparent;
  --shadow: 0 14px 40px rgba(122, 63, 35, .14);
  --radius: 20px;
}
html[data-theme="night"] {
  --sand: #16121f;
  --sand2: #1d1830;
  --card: #221b33;
  --card-glass: rgba(34, 27, 51, .8);
  --line: #3b3155;
  --ink: #f2e7d8;
  --ink-soft: #b7a794;
  --dune: #e0a55e;
  --dune-dark: #ffd9a0;
  --terracotta: #ff9e6d;
  --oasis: #5fd3b3;
  --sky1: #0d0a18; --sky2: #16121f;
  --glow1: rgba(160, 120, 255, .25); --glow2: transparent;
  --dune-fill1: rgba(224, 165, 94, .18);
  --dune-fill2: rgba(224, 165, 94, .32);
  --star: rgba(255, 255, 255, .8);
  --shadow: 0 14px 40px rgba(0, 0, 0, .45);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: "Inter", "Segoe UI", system-ui, sans-serif;
  background: var(--sand);
  color: var(--ink);
  line-height: 1.6;
  transition: background .5s ease, color .5s ease;
}
::selection { background: var(--dune); color: #fff; }

/* ---------- sky, stars, glow ---------- */
.sky {
  position: relative; overflow: hidden;
  background: radial-gradient(1200px 500px at 70% -80%, var(--glow1) 0%, var(--glow2) 60%),
              linear-gradient(180deg, var(--sky1) 0%, var(--sky2) 100%);
  transition: background .5s ease;
}
.glow {
  position: absolute; inset: -40% -20% auto; height: 130%;
  background: radial-gradient(600px 300px at 50% 0%, var(--glow1), var(--glow2));
  animation: breathe 9s ease-in-out infinite;
  pointer-events: none;
}
@keyframes breathe { 0%,100% { opacity:.6; transform: translateY(0);} 50% { opacity:1; transform: translateY(12px);} }
.stars { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity 1s ease; }
html[data-theme="night"] .stars { opacity: 1; }
.stars i {
  position: absolute; width: 2px; height: 2px; border-radius: 50%;
  background: var(--star); animation: twinkle 3s ease-in-out infinite;
}
@keyframes twinkle { 0%,100% { opacity:.2; } 50% { opacity:1; } }

header {
  position: relative; z-index: 3;
  display: flex; align-items: center; gap: 1rem;
  padding: 1rem clamp(1rem, 4vw, 3rem); max-width: 1100px; margin: 0 auto;
}
.brand {
  font-family: "Fraunces", Georgia, serif; font-weight: 900; font-size: 1.3rem;
  color: var(--dune-dark); text-decoration: none; letter-spacing: .3px;
}
.brand .tld { color: var(--dune); }
nav { display: flex; gap: 1.1rem; margin-left: auto; }
nav a { color: var(--ink-soft); text-decoration: none; font-weight: 600; position: relative; }
nav a::after { content:""; position:absolute; left:0; bottom:-4px; width:0; height:2px; background: var(--terracotta); transition: width .2s; }
nav a:hover::after { width: 100%; }
.badge { font-size: .72rem; font-weight: 800; padding: .3rem .65rem; border-radius: 999px; background: var(--line); color: var(--dune-dark); cursor: help; }
.badge.demo { background: #f4e1c6; color: #8a5a1f; }
.badge.ai { background: #d9efe7; color: var(--oasis); }
html[data-theme="night"] .badge.demo { background: rgba(224,165,94,.2); color: var(--dune); }
.theme-btn {
  border: 1.5px solid var(--line); background: var(--card); color: var(--ink);
  width: 38px; height: 38px; border-radius: 50%; cursor: pointer; font-size: 1rem;
  transition: transform .3s ease;
}
.theme-btn:hover { transform: rotate(20deg) scale(1.1); }

/* ---------- hero ---------- */
.hero { text-align: center; padding: 2.4rem 1rem 0; position: relative; z-index: 2; }
.hero-title {
  font-family: "Fraunces", Georgia, serif;
  font-size: clamp(2.1rem, 6vw, 3.6rem); font-weight: 900;
  margin: 0 0 .5rem; color: var(--dune-dark); line-height: 1.1;
  animation: rise .7s ease both;
}
.shimmer {
  background: linear-gradient(110deg, var(--terracotta) 20%, #ffd9a0 40%, var(--terracotta) 60%);
  background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: shimmer 4s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
.hero p { max-width: 580px; margin: 0 auto 1.4rem; color: var(--ink-soft); font-size: 1.08rem; animation: rise .7s .12s ease both; }
.search { max-width: 460px; margin: 0 auto .9rem; animation: rise .7s .24s ease both; }
.search input {
  width: 100%; padding: .85rem 1.2rem; border-radius: 999px; border: 1.5px solid var(--line);
  background: var(--card-glass); backdrop-filter: blur(8px);
  font: inherit; font-size: 1rem; color: var(--ink); box-shadow: var(--shadow);
  transition: border-color .2s, box-shadow .2s;
}
.search input:focus { outline: none; border-color: var(--dune); box-shadow: 0 0 0 4px rgba(201,138,75,.18); }
.hero-chips { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; animation: rise .7s .36s ease both; }
.chip {
  padding: .45rem .95rem; border-radius: 999px; border: 1.5px solid var(--line);
  background: var(--card-glass); color: var(--ink-soft); text-decoration: none;
  font-size: .82rem; font-weight: 700; transition: all .18s ease;
}
.chip:hover { border-color: var(--dune); color: var(--dune-dark); transform: translateY(-2px); }

.dunes { display: block; width: 100%; height: clamp(70px, 12vw, 150px); margin-top: 1.2rem; }
.dunes path { fill: var(--dune-fill2); transition: fill .5s ease; }
.dunes-back { position: absolute; bottom: 0; left: 0; height: 120%; opacity: .55; }
.dunes-back path { fill: var(--dune-fill1); animation: drift 16s ease-in-out infinite alternate; }
@keyframes drift { from { transform: translateX(0); } to { transform: translateX(-3%); } }

/* ---------- grid ---------- */
main { max-width: 1100px; margin: 0 auto; padding: 2rem clamp(1rem, 4vw, 3rem) 3rem; }
.grid { display: grid; gap: 1.1rem; margin-top: 1rem; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); }
.tool {
  position: relative;
  background: var(--card-glass); backdrop-filter: blur(8px);
  border: 1.5px solid var(--line); border-radius: var(--radius);
  padding: 1.15rem 1.2rem; text-decoration: none; color: var(--ink);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s;
  display: flex; flex-direction: column; gap: .35rem; overflow: hidden;
  opacity: 0; transform: translateY(14px);
}
.tool.in { animation: rise .5s ease both; }
.tool::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(201,138,75,.12), transparent 55%);
  opacity: 0; transition: opacity .2s;
}
.tool:hover { transform: translateY(-4px); box-shadow: var(--shadow); border-color: var(--dune); }
.tool:hover::before { opacity: 1; }
.tool .ico {
  font-size: 1.65rem; width: 52px; height: 52px; display: grid; place-items: center;
  background: linear-gradient(135deg, rgba(201,138,75,.22), rgba(179,84,45,.18));
  border-radius: 16px; margin-bottom: .2rem;
  transition: transform .25s ease;
}
.tool:hover .ico { transform: scale(1.12) rotate(-6deg); }
.tool h3 { margin: 0; font-family: "Fraunces", serif; font-size: 1.08rem; color: var(--dune-dark); }
.tool p { margin: 0; font-size: .85rem; color: var(--ink-soft); }
.tool .cat {
  font-size: .66rem; text-transform: uppercase; letter-spacing: 1px;
  color: var(--terracotta); font-weight: 800; margin-top: auto; padding-top: .5rem;
}

/* ---------- tool view ---------- */
.toolview { max-width: 780px; margin: 0 auto; }
.back { color: var(--terracotta); text-decoration: none; font-weight: 700; font-size: .9rem; }
.toolview h2 { font-family: "Fraunces", serif; color: var(--dune-dark); margin: .4rem 0 .2rem; font-size: 1.7rem; }
.tagline { color: var(--ink-soft); margin-top: 0; }
.card {
  background: var(--card-glass); backdrop-filter: blur(8px);
  border: 1.5px solid var(--line); border-radius: var(--radius);
  padding: 1.3rem; box-shadow: var(--shadow); margin: 1.1rem 0;
}
label { display: block; font-weight: 700; font-size: .88rem; margin: .9rem 0 .3rem; color: var(--dune-dark); }
label:first-child { margin-top: 0; }
input[type="text"], input[type="number"], select, textarea {
  width: 100%; padding: .7rem .95rem; border-radius: 13px; border: 1.5px solid var(--line);
  background: var(--card); font: inherit; color: var(--ink); transition: border-color .2s, box-shadow .2s;
}
textarea { min-height: 100px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--dune); box-shadow: 0 0 0 4px rgba(201,138,75,.15); }
.hint { font-size: .75rem; color: var(--ink-soft); margin-top: .2rem; }
button.primary {
  margin-top: 1.2rem; width: 100%; padding: .9rem 1rem; border: none; border-radius: 999px;
  background: linear-gradient(135deg, var(--dune) 0%, var(--terracotta) 100%);
  background-size: 150% 100%;
  color: #fff; font: inherit; font-weight: 800; font-size: 1rem; cursor: pointer;
  transition: transform .15s ease, filter .15s, background-position .3s;
  box-shadow: 0 8px 24px rgba(179, 84, 45, .35);
}
button.primary:hover { filter: brightness(1.08); transform: translateY(-2px); background-position: 100% 0; }
button.primary:disabled { opacity: .6; cursor: wait; transform: none; }
.ghost { background: none; border: 1.5px solid var(--line); color: var(--ink-soft); border-radius: 999px; cursor: pointer; font: inherit; transition: all .15s; }
.ghost:hover { border-color: var(--dune); color: var(--dune-dark); }
.small { font-size: .75rem; padding: .32rem .85rem; }
.out-actions { display: flex; gap: .4rem; }

/* ---------- output ---------- */
.output { position: relative; }
.outhead { display: flex; justify-content: space-between; align-items: center; margin-bottom: .7rem; }
.outhead > span {
  font-weight: 800; font-size: .78rem; text-transform: uppercase; letter-spacing: 1.2px;
  color: var(--terracotta); display: flex; align-items: center; gap: .5rem;
}
.outhead > span::before { content: "•"; color: var(--dune); animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { opacity:.4; } 50% { opacity:1; } }
.md { white-space: pre-wrap; overflow-wrap: anywhere; font-size: .98rem; }
.loader { display: flex; gap: 6px; padding: .6rem 0; }
.loader span {
  width: 9px; height: 9px; border-radius: 50%; background: var(--dune);
  animation: bounce 1s ease-in-out infinite;
}
.loader span:nth-child(2) { animation-delay: .15s; }
.loader span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%,100% { transform: translateY(0); opacity:.5; } 50% { transform: translateY(-7px); opacity:1; } }
.choices { display: flex; flex-wrap: wrap; gap: .55rem; margin-top: 1.1rem; }
.choices button {
  flex: 1 1 30%; min-width: 190px; padding: .8rem .9rem; border-radius: 14px;
  border: 1.5px solid var(--dune); background: var(--card); color: var(--dune-dark);
  font: inherit; font-weight: 600; cursor: pointer; text-align: left;
  transition: all .16s ease; position: relative;
  opacity: 0; animation: rise .45s ease both;
}
.choices button:nth-child(2) { animation-delay: .1s; }
.choices button:nth-child(3) { animation-delay: .2s; }
.choices button::after { content: "→"; position: absolute; right: .9rem; opacity: 0; transition: all .16s; }
.choices button:hover { background: var(--dune); color: #fff; transform: translateY(-2px); padding-right: 2rem; }
.choices button:hover::after { opacity: 1; }
.error { background: rgba(229,160,128,.15); border: 1.5px solid #e5a080; color: #8c3d1a; border-radius: 12px; padding: .8rem 1rem; }
html[data-theme="night"] .error { color: #ffb59a; }
.hidden { display: none !important; }

/* ---------- dream journal ---------- */
.dream-history { margin: .9rem 0; }
.dream-history details { background: var(--card-glass); border: 1.5px solid var(--line); border-radius: 14px; padding: .7rem 1rem; }
.dream-history summary { cursor: pointer; font-weight: 700; color: var(--dune-dark); }
.dream-history ul { margin: .5rem 0; padding-left: 1.1rem; color: var(--ink-soft); font-size: .85rem; }
.dream-history li { margin: .18rem 0; }

/* ---------- about / footer ---------- */
.about { margin-top: 3.2rem; color: var(--ink-soft); }
.about h2 { font-family: "Fraunces", serif; color: var(--dune-dark); }
footer {
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem;
  max-width: 1100px; margin: 0 auto; padding: 1.4rem clamp(1rem, 4vw, 3rem) 2.2rem;
  color: var(--ink-soft); font-size: .85rem; border-top: 1.5px solid var(--line);
}
.dim { opacity: .65; }

.toast {
  position: fixed; bottom: 1.3rem; left: 50%; transform: translateX(-50%) translateY(150%);
  background: var(--dune-dark); color: #fff; padding: .65rem 1.3rem; border-radius: 999px;
  font-size: .85rem; transition: transform .3s ease; z-index: 50; box-shadow: var(--shadow);
}
.toast.show { transform: translateX(-50%) translateY(0); }

@media (max-width: 600px) {
  nav { display: none; }
  .choices button { flex-basis: 100%; }
  .hero-chips { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001s !important; transition-duration: .001s !important; }
}
