/* ═══════════════════════════════════════════════════
   Luminwell — Journal Write / New Entry
   Pure CSS · no JavaScript
═══════════════════════════════════════════════════ */

:root {
  --sb-bg:     #175d92;
  --sb-deep:   #134a75;
  --sb-hover:  rgba(255,255,255,.1);
  --sb-active: rgba(255,255,255,.18);
  --sb-line:   rgba(255,255,255,.12);
  --sb-text:   #f4f8fc;
  --sb-muted:  rgba(244,248,252,.58);
  --page-bg:   #f8f9fb;
  --surface:   #ffffff;
  --teal:      #2d9676;
  --teal-pale: #eaf5f1;
  --teal-deep: #1d6e55;
  --text:      #0c1929;
  --muted:     #64748b;
  --soft:      #94a3b8;
  --border:    rgba(12,25,41,.09);
  --shadow-sm: 0 1px 3px rgba(12,25,41,.06);
  --shadow:    0 2px 8px rgba(12,25,41,.07), 0 16px 40px rgba(12,25,41,.07);
  --r:         12px;
  --r-full:    9999px;
  --sb-width:  268px;
  --font:      "DM Sans", system-ui, -apple-system, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; font-family: var(--font); font-size: 14px; color: var(--text); background: var(--page-bg); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
p, h1, h2, h3 { margin: 0; }

/* Hidden state inputs */
.state-input { position: absolute; width: 0; height: 0; opacity: 0; pointer-events: none; }

.app { display: flex; min-height: 100vh; min-height: 100dvh; }

/* ══════════════════════════════════════════════════
   SIDEBAR
══════════════════════════════════════════════════ */
.sidebar { width: var(--sb-width); flex-shrink: 0; background: var(--sb-bg); color: var(--sb-text); display: flex; flex-direction: column; padding: 16px 14px 14px; overflow: hidden; }
.sidebar__head { display: flex; align-items: center; gap: 10px; padding: 0 6px 18px; margin-bottom: 4px; border-bottom: 1px solid var(--sb-line); }
.sidebar__logo-img { width: 30px; height: 30px; object-fit: contain; flex-shrink: 0; border-radius: 6px; }
.sidebar__logo { font-size: 11px; font-weight: 700; letter-spacing: .18em; flex: 1; min-width: 0; }
.sidebar__block { margin-bottom: 18px; }
.sidebar__block--fill { flex: 1; display: flex; flex-direction: column; min-height: 0; margin-bottom: 0; }
.sidebar__label { padding: 0 8px 8px; font-size: 10px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--sb-muted); }
.sidebar__new { display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; height: 36px; padding: 0 12px; border: 1px solid rgba(255,255,255,.22); border-radius: 10px; background: rgba(255,255,255,.06); color: var(--sb-text); font-size: 13px; font-weight: 600; font-family: var(--font); cursor: pointer; transition: background .15s; }
.sidebar__new:hover { background: rgba(255,255,255,.14); }
.sidebar__new svg { width: 16px; height: 16px; }
.sb-nav { display: flex; flex-direction: column; gap: 2px; }
.sb-nav__link { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--sb-text); font-size: 13px; font-weight: 500; transition: background .15s; }
.sb-nav__link:hover     { background: var(--sb-hover); }
.sb-nav__link.is-active { background: var(--sb-active); box-shadow: inset 0 0 0 1px rgba(255,255,255,.07); }
.sb-nav__icon { width: 17px; height: 17px; flex-shrink: 0; opacity: .92; }
.sb-recent { flex: 1; min-height: 60px; display: flex; flex-direction: column; gap: 1px; overflow-y: auto; margin: 0 -2px; padding: 0 2px 4px; }
.sb-recent__btn { width: 100%; padding: 8px 10px; border: none; border-radius: 8px; background: transparent; color: inherit; cursor: pointer; text-align: left; font-family: var(--font); transition: background .15s; }
.sb-recent__btn:hover { background: var(--sb-hover); }
.sb-recent__title { font-size: 12px; font-weight: 600; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sb-recent__meta { font-size: 11px; color: var(--sb-muted); margin-top: 2px; }
.sidebar__foot { padding-top: 12px; margin-top: auto; border-top: 1px solid var(--sb-line); display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.sidebar__avatar { width: 30px; height: 30px; border-radius: 50%; background: rgba(255,255,255,.15); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.sidebar__avatar svg { width: 17px; height: 17px; }
.sidebar__name { font-size: 13px; font-weight: 700; }
.sidebar__credits { display: flex; align-items: center; gap: 4px; font-size: 11px; color: var(--sb-muted); margin-top: 1px; }
.sidebar__credits svg { width: 12px; height: 12px; }

/* ══════════════════════════════════════════════════
   MAIN + TOPBAR
══════════════════════════════════════════════════ */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }
.topbar { height: 56px; padding: 0 24px; display: flex; align-items: center; justify-content: space-between; background: var(--surface); border-bottom: 1px solid var(--border); flex-shrink: 0; gap: 12px; }
.topbar__left  { display: flex; align-items: center; gap: 10px; }
.topbar__logo-img { width: 30px; height: 30px; object-fit: contain; border-radius: 6px; }
.topbar__title { font-size: 16px; font-weight: 700; letter-spacing: -0.02em; }
.topbar__right { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.topbar__crisis { padding: 5px 12px; border-radius: var(--r-full); background: rgba(239,68,68,.09); color: #b91c1c; font-size: 12px; font-weight: 700; transition: background .15s; }
.topbar__crisis:hover { background: rgba(239,68,68,.16); }
.topbar__icon-btn { width: 34px; height: 34px; border-radius: 8px; border: none; background: transparent; color: var(--muted); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background .15s, color .15s; }
.topbar__icon-btn:hover { background: rgba(12,25,41,.05); color: var(--text); }
.topbar__icon-btn svg { width: 18px; height: 18px; }

/* ══════════════════════════════════════════════════
   WRITE PAGE LAYOUT
══════════════════════════════════════════════════ */
.write-page {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 24px 48px;
  gap: 0;
}

/* Breadcrumb */
.breadcrumb {
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 24px; font-size: 13px; font-weight: 500; color: var(--muted);
  width: 100%; max-width: 800px;
}
.breadcrumb a { color: var(--muted); transition: color .15s; }
.breadcrumb a:hover { color: var(--sb-bg); }
.breadcrumb svg { width: 14px; height: 14px; flex-shrink: 0; }
.breadcrumb__sep { opacity: .4; }

/* Two-column write layout */
.write-layout {
  display: flex;
  gap: 20px;
  width: 100%;
  max-width: 1000px;
  align-items: flex-start;
}

/* ── Left: main editor ────────────────────────────── */
.write-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 16px; }

/* Editor card */
.editor-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* Editor header — changes colour per mood via :has() */
.editor-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, var(--sb-deep), var(--sb-bg));
  color: #fff;
  display: flex; flex-direction: column; gap: 0;
  transition: background .35s ease;
}
.editor-header__row { display: flex; align-items: center; gap: 14px; }
.editor-header__icon {
  width: 42px; height: 42px; border-radius: 11px;
  background: rgba(255,255,255,.18);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.editor-header__icon svg { width: 22px; height: 22px; }
.editor-header__title { font-size: 18px; font-weight: 700; letter-spacing: -0.02em; }
.editor-header__sub   { font-size: 12px; opacity: .72; margin-top: 2px; }

/* Mood-aware header colours */
html:has(#wr-great:checked) .editor-header { background: linear-gradient(135deg, #065f46, #10b981); }
html:has(#wr-good:checked)  .editor-header { background: linear-gradient(135deg, #1e3a8a, #3b82f6); }
html:has(#wr-okay:checked)  .editor-header { background: linear-gradient(135deg, #78350f, #f59e0b); }
html:has(#wr-low:checked)   .editor-header { background: linear-gradient(135deg, #881337, #f43f5e); }

/* Mood message strip inside header */
.editor-mood-message { display: none; margin-top: 12px; padding: 10px 14px; border-radius: 9px; background: rgba(255,255,255,.14); font-size: 12px; line-height: 1.55; font-weight: 500; }
html:has(#wr-great:checked) .editor-mood-message--great { display: block; }
html:has(#wr-good:checked)  .editor-mood-message--good  { display: block; }
html:has(#wr-okay:checked)  .editor-mood-message--okay  { display: block; }
html:has(#wr-low:checked)   .editor-mood-message--low   { display: block; }

/* Title input */
.editor-title-wrap { padding: 20px 24px 0; }
.editor-title {
  width: 100%; border: none; outline: none;
  font-family: var(--font);
  font-size: 22px; font-weight: 800; letter-spacing: -0.03em;
  color: var(--text); background: transparent;
  padding: 0; line-height: 1.3;
}
.editor-title::placeholder { color: #c0cdd8; }

/* Divider */
.editor-divider { height: 1px; background: var(--border); margin: 14px 24px 0; }

/* Main textarea */
.editor-body-wrap { padding: 16px 24px 20px; }
.editor-textarea {
  width: 100%; border: none; outline: none;
  font-family: var(--font);
  font-size: 15px; font-weight: 400; line-height: 1.8;
  color: var(--text); background: transparent;
  resize: none; min-height: 260px;
}
.editor-textarea::placeholder { color: #b8c4cc; font-style: italic; }

/* Editor toolbar (formatting hints - visual only) */
.editor-toolbar {
  padding: 10px 24px 12px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 2px;
  background: rgba(12,25,41,.018);
}
.toolbar-btn {
  width: 30px; height: 30px; border-radius: 7px;
  border: none; background: transparent; color: var(--soft);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background .14s, color .14s; font-size: 12px; font-weight: 700;
}
.toolbar-btn:hover { background: rgba(12,25,41,.06); color: var(--text); }
.toolbar-btn svg { width: 14px; height: 14px; }
.toolbar-sep { width: 1px; height: 18px; background: var(--border); margin: 0 4px; }
.toolbar-hint { margin-left: auto; font-size: 11px; font-weight: 500; color: var(--soft); }

/* ── Right: meta panel ────────────────────────────── */
.write-meta {
  width: 280px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: sticky;
  top: 0;
}

/* Meta section card */
.meta-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.meta-card__head {
  padding: 12px 16px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 11px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted);
  background: rgba(12,25,41,.02);
}
.meta-card__body { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }

/* Date display */
.meta-date {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600; color: var(--text);
}
.meta-date svg { width: 15px; height: 15px; color: var(--soft); flex-shrink: 0; }

/* Mood picker */
.mood-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}
.mood-radio { display: none; }
.mood-pill {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 11px 8px 9px; border-radius: 10px;
  border: 1.5px solid var(--border);
  background: var(--page-bg);
  cursor: pointer; transition: all .16s; text-align: center;
  user-select: none;
}
.mood-pill:hover { transform: translateY(-1px); box-shadow: 0 3px 10px rgba(12,25,41,.1); }
.mood-pill__emoji { font-size: 20px; line-height: 1; }
.mood-pill__label { font-size: 12px; font-weight: 700; color: var(--text); margin-top: 2px; }
.mood-pill__desc  { font-size: 10px; font-weight: 500; color: var(--soft); line-height: 1.3; }

/* Active mood pill — per-mood colour */
#wr-great:checked + .mood-pill { border-color: #10b981; background: rgba(16,185,129,.09); box-shadow: 0 0 0 3px rgba(16,185,129,.15); }
#wr-good:checked  + .mood-pill { border-color: #3b82f6; background: rgba(59,130,246,.09);  box-shadow: 0 0 0 3px rgba(59,130,246,.15);  }
#wr-okay:checked  + .mood-pill { border-color: #f59e0b; background: rgba(245,158,11,.09); box-shadow: 0 0 0 3px rgba(245,158,11,.15); }
#wr-low:checked   + .mood-pill { border-color: #f43f5e; background: rgba(244,63,94,.08);  box-shadow: 0 0 0 3px rgba(244,63,94,.12);  }

/* Tags */
.tag-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-checkbox { display: none; }
.tag-pill {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 5px 11px; border-radius: var(--r-full);
  border: 1.5px solid var(--border);
  background: var(--page-bg);
  font-size: 11px; font-weight: 700; color: var(--muted);
  cursor: pointer; transition: all .14s; user-select: none;
}
.tag-pill:hover { border-color: var(--sb-bg); color: var(--sb-bg); }
.tag-checkbox:checked + .tag-pill {
  background: var(--sb-bg);
  border-color: var(--sb-bg);
  color: #fff;
}

/* Writing prompts */
.prompt-list { display: flex; flex-direction: column; gap: 6px; }
.prompt-radio { display: none; }
.prompt-pill {
  display: block; padding: 10px 12px;
  border-radius: 9px; border: 1.5px solid var(--border);
  background: var(--page-bg);
  font-size: 12px; font-weight: 500; color: var(--muted);
  cursor: pointer; line-height: 1.45;
  transition: border-color .14s, background .14s, color .14s;
  user-select: none;
}
.prompt-pill:hover { border-color: var(--sb-bg); color: var(--sb-bg); background: rgba(23,93,146,.04); }
.prompt-radio:checked + .prompt-pill {
  border-color: var(--sb-bg);
  background: rgba(23,93,146,.07);
  color: var(--sb-bg);
  font-weight: 600;
}
.prompt-pill::before { content: '"'; opacity: .5; margin-right: 2px; }
.prompt-pill::after  { content: '"'; opacity: .5; margin-left: 2px; }

/* Privacy info card */
.privacy-card {
  padding: 14px 16px;
  background: rgba(45,150,118,.06);
  border: 1px solid rgba(45,150,118,.2);
  border-radius: 12px;
  display: flex; flex-direction: column; gap: 6px;
}
.privacy-card__row { display: flex; align-items: flex-start; gap: 8px; font-size: 12px; font-weight: 500; color: var(--teal-deep); line-height: 1.5; }
.privacy-card__row svg { width: 14px; height: 14px; flex-shrink: 0; margin-top: 1px; }

/* Action buttons */
.write-actions {
  display: flex; gap: 10px;
}
.btn-cancel {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 11px 20px; border-radius: 10px;
  border: 1.5px solid var(--border);
  background: var(--surface); color: var(--muted);
  font-size: 14px; font-weight: 600; font-family: var(--font);
  cursor: pointer; transition: background .14s; text-decoration: none;
}
.btn-cancel:hover { background: rgba(12,25,41,.04); color: var(--text); }
.btn-save {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  flex: 1; padding: 12px 20px; border-radius: 10px;
  border: none; background: var(--sb-bg); color: #fff;
  font-size: 14px; font-weight: 700; font-family: var(--font);
  cursor: pointer; transition: background .14s, box-shadow .14s; text-decoration: none;
}
.btn-save:hover { background: var(--sb-deep); box-shadow: 0 4px 16px rgba(23,93,146,.38); }
.btn-save svg { width: 15px; height: 15px; }
/* Mood-aware save button colour */
html:has(#wr-great:checked) .btn-save { background: #059669; }
html:has(#wr-great:checked) .btn-save:hover { background: #047857; box-shadow: 0 4px 16px rgba(5,150,105,.35); }
html:has(#wr-low:checked)   .btn-save { background: #be185d; }
html:has(#wr-low:checked)   .btn-save:hover { background: #9d174d; box-shadow: 0 4px 16px rgba(190,24,93,.3); }

/* ── Responsive ───────────────────────────────────── */
@media (max-width: 860px) {
  .write-layout { flex-direction: column; }
  .write-meta { width: 100%; position: static; flex-direction: row; flex-wrap: wrap; gap: 12px; }
  .meta-card { flex: 1; min-width: 220px; }
}
@media (max-width: 640px) {
  .write-page { padding: 16px 12px 40px; }
  .editor-header, .editor-title-wrap, .editor-body-wrap, .editor-toolbar { padding-left: 16px; padding-right: 16px; }
}
@media (max-width: 520px) { .sidebar { display: none; } }
