/* ZeeVelo — warm, calm, accessible */
:root {
  --bg: #faf5ee;
  --bg-card: #fffdf9;
  --bg-soft: #f3e9db;
  --ink: #3d3229;
  --ink-soft: #6b5d4f;
  --accent: #a64b2a;        /* terracotta — AA on cream for large text/buttons */
  --accent-strong: #8a3a1e;
  --accent-soft: #f6dfd3;
  --sage: #4e7357;
  --sage-soft: #e2ecdd;
  --gold: #b98a2e;
  --gold-soft: #f5ebd2;
  --focus: #2563eb;
  --danger: #9c3c3c;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 2px 12px rgba(90, 65, 40, 0.08);
  --font: "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
}
[data-theme="dark"] {
  --bg: #211b16;
  --bg-card: #2b241e;
  --bg-soft: #362d25;
  --ink: #f0e7dc;
  --ink-soft: #c4b5a4;
  --accent: #e8916b;
  --accent-strong: #f0a988;
  --accent-soft: #46302a;
  --sage: #9dc4a5;
  --sage-soft: #2d3a2f;
  --gold: #ddb469;
  --gold-soft: #3d3423;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font-size: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.6;
  min-height: 100vh;
}

.skip-link {
  position: absolute; left: -9999px; top: 0;
  background: var(--accent); color: #fff; padding: 0.6rem 1rem;
  border-radius: 0 0 var(--radius-sm) 0; z-index: 100;
}
.skip-link:focus { left: 0; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.7rem 1.2rem; gap: 1rem;
  background: var(--bg-card);
  box-shadow: var(--shadow);
  position: sticky; top: 0; z-index: 20;
  flex-wrap: wrap;
}
.brand {
  font-weight: 700; font-size: 1.25rem; text-decoration: none; color: var(--ink);
}
.mainnav { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.mainnav a {
  text-decoration: none; color: var(--ink-soft);
  padding: 0.45rem 0.85rem; border-radius: 999px; font-weight: 600;
}
.mainnav a:hover { background: var(--bg-soft); color: var(--ink); }
.mainnav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-strong); }
[data-theme="dark"] .mainnav a[aria-current="page"] { color: var(--accent); }

/* ---------- layout ---------- */
main { max-width: 880px; margin: 0 auto; padding: 1.4rem 1rem 4rem; }
.card {
  background: var(--bg-card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.3rem; margin-bottom: 1.1rem;
}
h1 { font-size: 1.7rem; margin: 0.4rem 0 0.8rem; }
h2 { font-size: 1.2rem; margin: 0 0 0.7rem; }
.muted { color: var(--ink-soft); }
.small { font-size: 0.88rem; }

/* ---------- forms ---------- */
label { display: block; font-weight: 600; margin: 0.8rem 0 0.25rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="date"],
select, textarea {
  width: 100%; padding: 0.65rem 0.8rem; font-size: 1rem; font-family: inherit;
  border: 2px solid var(--bg-soft); border-radius: var(--radius-sm);
  background: var(--bg-card); color: var(--ink);
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--focus); outline-offset: 1px;
}

.btn {
  display: inline-flex; align-items: center; gap: 0.45rem;
  background: var(--accent); color: #fff; border: none; cursor: pointer;
  padding: 0.65rem 1.25rem; font-size: 1rem; font-weight: 700; font-family: inherit;
  border-radius: 999px; text-decoration: none;
}
.btn:hover { background: var(--accent-strong); }
[data-theme="dark"] .btn { color: #211b16; }
.btn.secondary {
  background: var(--bg-soft); color: var(--ink);
}
.btn.secondary:hover { background: var(--accent-soft); }
.btn.subtle {
  background: transparent; color: var(--accent-strong); text-decoration: underline;
  padding: 0.4rem 0.6rem;
}
[data-theme="dark"] .btn.subtle { color: var(--accent); }
.btn.danger { background: var(--danger); color: #fff; }
.btn:disabled { opacity: 0.55; cursor: wait; }

.form-error {
  background: var(--accent-soft); color: var(--accent-strong);
  border-radius: var(--radius-sm); padding: 0.7rem 0.9rem; margin: 0.8rem 0;
  font-weight: 600;
}
[data-theme="dark"] .form-error { color: var(--accent); }

/* ---------- auth ---------- */
.auth-wrap { max-width: 420px; margin: 6vh auto 0; }
.auth-hero { text-align: center; margin-bottom: 1rem; }
.auth-hero .flower { font-size: 3rem; display: block; }

/* ---------- dashboard ---------- */
.dash-header { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.6rem; }
.rings { display: flex; gap: 1rem; flex-wrap: wrap; justify-content: space-between; }
.ring-item { text-align: center; flex: 1; min-width: 110px; }
.ring-item svg { width: 84px; height: 84px; }
.ring-label { font-weight: 700; margin-top: 0.2rem; }
.ring-count { font-size: 0.88rem; color: var(--ink-soft); }

.task-group h2 { display: flex; align-items: center; gap: 0.5rem; }
.task-list { list-style: none; margin: 0; padding: 0; }
.task-item {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.65rem 0.5rem; border-bottom: 1px solid var(--bg-soft);
}
.task-item:last-child { border-bottom: none; }
.task-check {
  width: 1.7rem; height: 1.7rem; flex-shrink: 0;
  accent-color: var(--sage); cursor: pointer;
}
.task-title { flex: 1; font-weight: 600; }
.task-done .task-title { color: var(--ink-soft); text-decoration: line-through; }
.task-status { font-size: 0.85rem; font-weight: 700; white-space: nowrap; }
.status-done { color: var(--sage); }
.status-open { color: var(--gold); }
.streak-chip {
  background: var(--gold-soft); color: #7a5a1c; border-radius: 999px;
  font-size: 0.8rem; font-weight: 700; padding: 0.15rem 0.6rem; white-space: nowrap;
}
[data-theme="dark"] .streak-chip { color: var(--gold); }
.task-del { background: none; border: none; cursor: pointer; font-size: 1rem; color: var(--ink-soft); padding: 0.3rem; border-radius: 6px; }
.task-del:hover { color: var(--danger); background: var(--bg-soft); }

.quick-actions { display: flex; gap: 0.7rem; flex-wrap: wrap; margin: 1rem 0; }

#banner:empty { display: none; }
#banner {
  max-width: 880px; margin: 0.8rem auto 0; padding: 0 1rem;
}
.banner-inner {
  background: var(--gold-soft); color: #6b4e14; border-radius: var(--radius);
  padding: 0.8rem 1.1rem; font-weight: 600; display: flex; gap: 0.6rem; align-items: center;
}
[data-theme="dark"] .banner-inner { color: var(--gold); }

/* ---------- mood ---------- */
.mood-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.mood-btn {
  border: 2px solid var(--bg-soft); background: var(--bg-card); cursor: pointer;
  border-radius: var(--radius-sm); padding: 0.5rem 0.7rem; font-size: 1rem; font-family: inherit;
  display: flex; flex-direction: column; align-items: center; min-width: 64px; color: var(--ink);
}
.mood-btn .m-emoji { font-size: 1.5rem; }
.mood-btn[aria-pressed="true"] { border-color: var(--sage); background: var(--sage-soft); font-weight: 700; }

/* ---------- journal ---------- */
.entry-card { cursor: pointer; transition: transform 0.1s ease; }
.entry-card:hover { transform: translateY(-2px); }
.entry-meta { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; color: var(--ink-soft); font-size: 0.9rem; }
.tag-chip {
  background: var(--sage-soft); color: #2f5237; border-radius: 999px;
  padding: 0.1rem 0.6rem; font-size: 0.8rem; font-weight: 700;
}
[data-theme="dark"] .tag-chip { color: var(--sage); }
.search-row { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 0.6rem; }
@media (max-width: 640px) { .search-row { grid-template-columns: 1fr; } }

.editor-toolbar { display: flex; gap: 0.3rem; margin-bottom: 0.4rem; flex-wrap: wrap; }
.editor-toolbar button {
  border: 2px solid var(--bg-soft); background: var(--bg-card); color: var(--ink);
  border-radius: 8px; min-width: 2.2rem; height: 2.2rem; cursor: pointer; font-size: 1rem; font-family: inherit;
}
.editor-toolbar button:hover { background: var(--bg-soft); }
.rich-editor {
  min-height: 180px; border: 2px solid var(--bg-soft); border-radius: var(--radius-sm);
  padding: 0.8rem; background: var(--bg-card);
}
.rich-editor:focus { border-color: var(--accent); outline: none; }

.reflection-box {
  background: var(--sage-soft); border-radius: var(--radius-sm); padding: 0.9rem 1.1rem;
  margin-top: 1rem;
}
.reflection-box .rb-label {
  font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  color: #2f5237; display: flex; align-items: center; gap: 0.4rem;
}
[data-theme="dark"] .reflection-box .rb-label { color: var(--sage); }

/* ---------- calendar ---------- */
.cal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.7rem; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { text-align: center; font-weight: 700; font-size: 0.8rem; color: var(--ink-soft); padding: 0.3rem 0; }
.cal-cell {
  aspect-ratio: 1; border-radius: var(--radius-sm); border: 2px solid transparent;
  background: var(--bg-soft); display: flex; flex-direction: column; align-items: center;
  justify-content: center; cursor: pointer; font-family: inherit; font-size: 0.95rem; color: var(--ink);
  padding: 0;
}
.cal-cell:hover { border-color: var(--accent); }
.cal-cell.has-entry { background: var(--sage-soft); font-weight: 700; }
.cal-cell.today { border-color: var(--accent); }
.cal-cell.empty { background: transparent; cursor: default; }
.cal-mood { font-size: 0.9rem; line-height: 1; }

/* ---------- settings ---------- */
.avatar-row { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.avatar-btn {
  font-size: 1.5rem; background: var(--bg-soft); border: 2px solid transparent;
  border-radius: var(--radius-sm); width: 3rem; height: 3rem; cursor: pointer;
}
.avatar-btn[aria-pressed="true"] { border-color: var(--sage); background: var(--sage-soft); }

/* ---------- toast ---------- */
#toast {
  position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%);
  z-index: 50; pointer-events: none;
}
.toast-msg {
  background: var(--ink); color: var(--bg); padding: 0.7rem 1.3rem;
  border-radius: 999px; font-weight: 600; box-shadow: var(--shadow);
  animation: toast-in 0.25s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; } }

@media (max-width: 560px) {
  .mainnav a span { display: none; }
  .mainnav a { font-size: 1.2rem; padding: 0.45rem 0.6rem; }
  h1 { font-size: 1.4rem; }
}
/* ============ 3D MOTION LAYER ============ */
:root {
  --glow: #2fbe8b;
  --glow-soft: rgba(47, 190, 139, 0.35);
  --bezel: #2e3b36;
  --bezel-edge: #1c2622;
}
[data-theme="dark"] {
  --glow: #3ddc9e;
  --glow-soft: rgba(61, 220, 158, 0.30);
  --bezel: #222d29;
  --bezel-edge: #131a17;
}

/* floating parallax background */
#bg3d {
  position: fixed; inset: 0; z-index: -1; overflow: hidden;
  perspective: 900px; pointer-events: none;
}
.orb {
  position: absolute; border-radius: 50%; filter: blur(70px); opacity: 0.5;
  will-change: transform; transition: transform 0.6s ease-out;
}
.o1 { width: 44vw; height: 44vw; left: -10vw; top: -12vh; background: var(--glow-soft); animation: drift1 19s ease-in-out infinite alternate; }
.o2 { width: 36vw; height: 36vw; right: -8vw; top: 30vh; background: rgba(166, 75, 42, 0.22); animation: drift2 23s ease-in-out infinite alternate; }
.o3 { width: 30vw; height: 30vw; left: 28vw; bottom: -14vh; background: rgba(185, 138, 46, 0.20); animation: drift3 27s ease-in-out infinite alternate; }
@keyframes drift1 { to { transform: translate3d(6vw, 5vh, 40px) scale(1.12); } }
@keyframes drift2 { to { transform: translate3d(-5vw, -6vh, 60px) scale(0.92); } }
@keyframes drift3 { to { transform: translate3d(4vw, -4vh, 30px) scale(1.08); } }

/* 3D page transitions */
main { perspective: 1200px; }
.page-enter { animation: pageIn 0.55s cubic-bezier(0.22, 1, 0.36, 1) both; }
@keyframes pageIn {
  from { opacity: 0; transform: perspective(1200px) rotateX(6deg) translateY(22px) scale(0.985); }
  to   { opacity: 1; transform: perspective(1200px) rotateX(0) translateY(0) scale(1); }
}

/* tilt-reactive cards */
.card {
  transform-style: preserve-3d;
  transition: transform 0.18s ease-out, box-shadow 0.18s ease-out;
}
.card.tilting { box-shadow: 0 18px 40px rgba(90, 65, 40, 0.16); }
[data-theme="dark"] .card.tilting { box-shadow: 0 18px 40px rgba(0, 0, 0, 0.5); }

/* logo spin */
.spin3d { display: inline-block; animation: coinspin 5s ease-in-out infinite; transform-style: preserve-3d; }
@keyframes coinspin {
  0%, 72% { transform: rotateY(0); }
  86% { transform: rotateY(180deg); }
  100% { transform: rotateY(360deg); }
}

/* ============ COMPANION (3D buddy) ============ */
.companion-card { overflow: visible; text-align: center; }
.companion-stage {
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  min-height: 230px; perspective: 800px; position: relative;
}
.speech {
  background: var(--bg-soft); border-radius: 999px; padding: 0.5rem 1.2rem;
  font-weight: 600; margin-bottom: 1.4rem; position: relative; max-width: 92%;
  box-shadow: 0 4px 14px rgba(90, 65, 40, 0.10);
  animation: speechIn 0.4s ease both;
}
.speech::after {
  content: ''; position: absolute; bottom: -6px; left: 50%;
  transform: translateX(-50%) rotate(45deg);
  width: 13px; height: 13px; background: var(--bg-soft);
}
@keyframes speechIn { from { opacity: 0; transform: translateY(-8px); } }
.companion {
  position: relative; transform-style: preserve-3d; cursor: pointer;
  border: none; background: none; padding: 0 1rem 30px; font-family: inherit;
}
.companion .char {
  display: block; font-size: 5.2rem; line-height: 1;
  transform: translateZ(40px);
  filter: drop-shadow(0 16px 12px rgba(60, 45, 25, 0.28));
  animation: floaty 3.6s ease-in-out infinite alternate;
}
@keyframes floaty {
  from { transform: translateZ(40px) translateY(0) rotate(-2deg); }
  to   { transform: translateZ(40px) translateY(-14px) rotate(2deg); }
}
.companion .pad {
  position: absolute; left: 50%; bottom: 8px; width: 130px; height: 36px; margin-left: -65px;
  border-radius: 50%;
  background: radial-gradient(ellipse at 50% 40%, var(--glow-soft), transparent 70%);
  transform: rotateX(60deg);
  animation: padPulse 3.6s ease-in-out infinite alternate;
}
@keyframes padPulse {
  from { opacity: 0.9; transform: rotateX(60deg) scale(1); }
  to   { opacity: 0.5; transform: rotateX(60deg) scale(0.8); }
}
.companion.party .char { animation: hop 0.5s cubic-bezier(0.3, 1.6, 0.5, 1) infinite alternate; }
@keyframes hop {
  from { transform: translateZ(40px) translateY(0) rotate(-4deg) scale(1); }
  to   { transform: translateZ(40px) translateY(-24px) rotate(4deg) scale(1.06); }
}
.companion.snooze .char { animation-duration: 6s; filter: drop-shadow(0 16px 12px rgba(60,45,25,0.28)) saturate(0.75); }
.sparkles { position: absolute; inset: 0; pointer-events: none; }
.sparkles span { position: absolute; font-size: 1.15rem; animation: spark 1.6s ease-in-out infinite; }
@keyframes spark {
  0%, 100% { opacity: 0; transform: translateY(0) scale(0.6); }
  50%      { opacity: 1; transform: translateY(-18px) scale(1.15); }
}
.companion-progress { font-weight: 700; color: var(--ink-soft); margin: 0.3rem 0 0; }

/* ============ INSIGHTS ============ */
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.9rem; margin-bottom: 1.1rem;
}
.stat { text-align: center; padding: 1rem 0.6rem; margin-bottom: 0; }
.stat-num { display: block; font-size: 1.9rem; font-weight: 800; }
.stat-label { display: block; color: var(--ink-soft); font-size: 0.85rem; font-weight: 600; }
.tmpl-row { display: flex; gap: 0.45rem; flex-wrap: wrap; align-items: center; margin: 0.3rem 0 0.6rem; }
.tmpl-row .btn { padding: 0.35rem 0.8rem; font-size: 0.88rem; }
kbd {
  background: var(--bg-soft); border-radius: 5px; padding: 0.1rem 0.4rem;
  font-family: ui-monospace, monospace; font-size: 0.85em; border: 1px solid rgba(0,0,0,0.1);
}

/* ============ PERSISTENT WIDGET DOCK ============ */
#widgets {
  position: fixed; right: 1.1rem; bottom: 1.1rem; z-index: 40;
  display: flex; flex-direction: column; align-items: flex-end; gap: 0.8rem;
  perspective: 600px;
}
#widgets[hidden] { display: none; }

.w-buddy {
  border: none; background: none; cursor: pointer; position: relative; padding: 0;
  font-size: 2.7rem; line-height: 1;
  filter: drop-shadow(0 9px 8px rgba(60, 45, 25, 0.3));
  animation: wfloat 3.2s ease-in-out infinite alternate;
  transform-style: preserve-3d;
}
@keyframes wfloat {
  from { transform: translateY(0) rotate(-3deg) translateZ(20px); }
  to   { transform: translateY(-9px) rotate(3deg) translateZ(20px); }
}
.w-buddy:hover { animation-play-state: paused; }
.w-bubble {
  position: absolute; bottom: 112%; right: 0;
  background: var(--bg-card); border: 2px solid var(--bg-soft); color: var(--ink);
  border-radius: 14px 14px 4px 14px; padding: 0.45rem 0.85rem;
  font-size: 0.85rem; font-weight: 600; width: max-content; max-width: 230px;
  box-shadow: var(--shadow); text-align: left;
  opacity: 0; transform: translateY(5px) scale(0.95);
  transition: opacity 0.25s, transform 0.25s; pointer-events: none;
}
.w-buddy:hover .w-bubble, .w-buddy:focus-visible .w-bubble, .w-bubble.show {
  opacity: 1; transform: none;
}

.w-ring {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--bg-card); box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: center; text-decoration: none;
  transform: rotateX(10deg); transition: transform 0.2s ease;
}
.w-ring:hover { transform: rotateX(0deg) scale(1.1); }
.w-ring svg { width: 56px; height: 56px; }

.w-fab { position: relative; }
.w-fab-main {
  width: 58px; height: 58px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--accent); color: #fff; font-size: 1.7rem; line-height: 1;
  box-shadow: 0 8px 20px rgba(138, 58, 30, 0.45), inset 0 2px 4px rgba(255,255,255,0.3);
  transition: transform 0.25s ease;
}
[data-theme="dark"] .w-fab-main { color: #211b16; }
.w-fab-main:hover { transform: scale(1.08); }
.w-fab.open .w-fab-main { transform: rotate(45deg); }
.w-fab-menu {
  position: absolute; bottom: 115%; right: 0;
  display: flex; flex-direction: column; gap: 0.5rem; align-items: flex-end;
  opacity: 0; pointer-events: none; transform: translateY(10px) rotateX(-14deg);
  transform-origin: bottom right;
  transition: opacity 0.25s, transform 0.25s;
}
.w-fab.open .w-fab-menu { opacity: 1; pointer-events: auto; transform: none; }
.w-fab-menu .btn { white-space: nowrap; box-shadow: var(--shadow); }

@media (max-width: 600px) {
  #widgets { right: 0.7rem; bottom: 0.7rem; gap: 0.6rem; }
  .w-ring { display: none; }
  .w-buddy { font-size: 2.3rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  .card { transform: none !important; }
  .orb { display: none; }
}
