/* ─── CSS CUSTOM PROPERTIES ─────────────────────────────────── */
:root {
  --bg: #0e0e12;
  --surface: #16161d;
  --surface2: #1e1e28;
  --border: rgba(255, 255, 255, 0.07);
  --text: #f0ede8;
  --muted: rgba(240, 237, 232, 0.45);
  --accent-anxious: #ff6b6b;
  --accent-burnt: #ffa94d;
  --accent-overwhelmed: #a78bfa;
  --accent-numb: #74c0fc;
  --accent: #a78bfa;
}

/* ─── RESET & BASE ───────────────────────────────────────────── */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'DM Mono', monospace;
  min-height: 100vh;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  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)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9999;
  opacity: 0.4;
}

/* ─── AMBIENT BACKGROUND BLOBS ───────────────────────────────── */
.ambient { position: fixed; border-radius: 50%; filter: blur(120px); pointer-events: none; z-index: 0; }
.ambient-1 { width: 600px; height: 600px; background: rgba(167, 139, 250, 0.08); top: -200px; right: -200px; }
.ambient-2 { width: 600px; height: 600px; background: rgba(116, 192, 252, 0.06); bottom: -200px; left: -200px; }

/* ─── SCREEN SYSTEM ──────────────────────────────────────────── */
.screen { display: none; min-height: 100vh; }
.screen.active { display: flex; flex-direction: column; animation: fadeUp 0.4s ease; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── SIGNUP ─────────────────────────────────────────────────── */
#signup { align-items: center; justify-content: center; padding: 40px 24px; position: relative; }
.signup-inner { max-width: 440px; width: 100%; text-align: center; position: relative; z-index: 1; }
.signup-logo { font-family: 'DM Serif Display', serif; font-size: clamp(40px, 8vw, 64px); line-height: .95; letter-spacing: -.02em; margin-bottom: 10px; }
.signup-logo em { font-style: italic; color: var(--accent); }
.signup-tag { font-size: 10px; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); margin-bottom: 40px; display: block; }
.signup-card { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 32px 28px; }
.signup-card h2 { font-family: 'DM Serif Display', serif; font-style: italic; font-size: 22px; margin-bottom: 6px; }
.signup-card p { font-size: 12px; color: var(--muted); line-height: 1.7; margin-bottom: 24px; }
.input-wrap { position: relative; margin-bottom: 14px; }
.input-wrap input {
  width: 100%; background: var(--surface2); border: 1px solid var(--border);
  border-radius: 12px; padding: 13px 16px; color: var(--text);
  font-family: 'DM Mono', monospace; font-size: 13px; outline: none; transition: border-color .2s;
}
.input-wrap input::placeholder { color: var(--muted); }
.input-wrap input:focus { border-color: rgba(167, 139, 250, .4); }
.input-wrap input.error { border-color: rgba(255, 107, 107, .5); }
.err-msg { font-size: 11px; color: var(--accent-anxious); margin-bottom: 10px; display: none; text-align: left; padding-left: 4px; }
.err-msg.show { display: block; }
.signup-btn {
  width: 100%; background: var(--accent); color: var(--bg); border: none;
  padding: 14px; border-radius: 12px; font-family: 'Syne', sans-serif;
  font-weight: 700; font-size: 14px; letter-spacing: .06em; cursor: pointer;
  transition: opacity .2s, transform .2s; margin-top: 4px;
}
.signup-btn:hover { opacity: .9; transform: scale(1.01); }
.anon-note { margin-top: 18px; font-size: 11px; color: var(--muted); line-height: 1.7; }
.anon-name-preview { display: inline-block; color: var(--accent); font-family: 'Syne', sans-serif; font-weight: 700; font-size: 13px; margin-top: 6px; }
.already-link { margin-top: 16px; font-size: 11px; color: var(--muted); }
.already-link span { color: var(--accent); cursor: pointer; text-decoration: underline; }
.privacy-note { margin-top: 20px; font-size: 10px; color: var(--muted); opacity: .6; line-height: 1.6; }

/* ─── LOGIN ──────────────────────────────────────────────────── */
#login { align-items: center; justify-content: center; padding: 40px 24px; }
.login-inner { max-width: 440px; width: 100%; text-align: center; z-index: 1; position: relative; }

/* ─── LANDING ────────────────────────────────────────────────── */
#landing { align-items: center; justify-content: center; padding: 40px 24px; position: relative; }
.landing-inner { max-width: 580px; width: 100%; text-align: center; position: relative; z-index: 1; }
.user-chip {
  display: inline-flex; align-items: center; gap: 8px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 100px; padding: 6px 14px 6px 10px;
  margin-bottom: 28px; font-size: 11px; color: var(--muted);
}
.user-chip strong { color: var(--accent); font-family: 'Syne', sans-serif; font-size: 12px; }
.user-chip .logout-x { cursor: pointer; opacity: .5; transition: opacity .2s; font-size: 14px; margin-left: 4px; }
.user-chip .logout-x:hover { opacity: 1; }
.tag { display: inline-block; font-size: 10px; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--border); padding: 6px 14px; border-radius: 100px; margin-bottom: 32px; }
h1 { font-family: 'DM Serif Display', serif; font-size: clamp(52px, 10vw, 88px); line-height: .95; letter-spacing: -.02em; margin-bottom: 20px; }
h1 em { font-style: italic; color: var(--accent); }
.subtitle { font-size: 13px; color: var(--muted); line-height: 1.7; max-width: 380px; margin: 0 auto 52px; }
.mood-label { font-size: 10px; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); margin-bottom: 20px; }
.moods { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mood-btn {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 24px 20px; cursor: pointer; transition: all .25s; text-align: left;
  position: relative; overflow: hidden;
}
.mood-btn::before { content: ''; position: absolute; inset: 0; opacity: 0; transition: opacity .3s; border-radius: inherit; }
.mood-btn:hover::before { opacity: 1; }
.mood-btn:hover { transform: translateY(-2px); }
.mood-btn[data-mood=anxious]::before     { background: radial-gradient(circle at 30% 50%, rgba(255, 107, 107, .12), transparent 70%); }
.mood-btn[data-mood=burnt]::before       { background: radial-gradient(circle at 30% 50%, rgba(255, 169, 77,  .12), transparent 70%); }
.mood-btn[data-mood=overwhelmed]::before { background: radial-gradient(circle at 30% 50%, rgba(167, 139, 250, .12), transparent 70%); }
.mood-btn[data-mood=numb]::before        { background: radial-gradient(circle at 30% 50%, rgba(116, 192, 252, .12), transparent 70%); }
.mood-btn[data-mood=anxious]:hover     { border-color: var(--accent-anxious); }
.mood-btn[data-mood=burnt]:hover       { border-color: var(--accent-burnt); }
.mood-btn[data-mood=overwhelmed]:hover { border-color: var(--accent-overwhelmed); }
.mood-btn[data-mood=numb]:hover        { border-color: var(--accent-numb); }
.mood-emoji { font-size: 28px; margin-bottom: 10px; display: block; }
.mood-name  { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 15px; color: var(--text); display: block; margin-bottom: 4px; }
.mood-desc  { font-size: 11px; color: var(--muted); line-height: 1.5; }

/* ─── TOOLS ──────────────────────────────────────────────────── */
#tools { align-items: center; justify-content: center; padding: 40px 24px; }
.tools-inner { max-width: 560px; width: 100%; position: relative; z-index: 1; }
.back-btn {
  background: none; border: none; color: var(--muted); font-family: 'DM Mono', monospace;
  font-size: 11px; cursor: pointer; letter-spacing: .1em; padding: 0; margin-bottom: 40px;
  display: flex; align-items: center; gap: 8px; transition: color .2s;
}
.back-btn:hover { color: var(--text); }
.tools-heading { font-family: 'DM Serif Display', serif; font-size: 38px; line-height: 1.1; margin-bottom: 8px; }
.tools-heading span { font-style: italic; }
.tools-sub { font-size: 12px; color: var(--muted); margin-bottom: 36px; }
.tool-cards { display: flex; flex-direction: column; gap: 10px; }
.tool-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 20px 22px; cursor: pointer; display: flex; align-items: center;
  gap: 18px; transition: all .2s;
}
.tool-card:hover { background: var(--surface2); transform: translateX(4px); }
.tool-icon { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.tool-info { flex: 1; }
.tool-name { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 14px; margin-bottom: 3px; }
.tool-time { font-size: 11px; color: var(--muted); }
.tool-arrow { color: var(--muted); font-size: 18px; }

/* ─── SHARED ACTIVITY LAYOUT ─────────────────────────────────── */
.activity-screen { align-items: center; justify-content: center; padding: 40px 24px; }
.activity-inner  { max-width: 500px; width: 100%; position: relative; z-index: 1; }
.activity-header { display: flex; align-items: center; gap: 12px; margin-bottom: 40px; }
.activity-title  { font-family: 'Syne', sans-serif; font-weight: 800; font-size: 18px; }
.timer-badge     { margin-left: auto; font-size: 11px; color: var(--muted); border: 1px solid var(--border); padding: 4px 12px; border-radius: 100px; }
.start-btn {
  background: var(--accent); color: var(--bg); border: none; padding: 14px 40px;
  border-radius: 100px; font-family: 'Syne', sans-serif; font-weight: 700; font-size: 13px;
  letter-spacing: .08em; cursor: pointer; transition: opacity .2s, transform .2s;
}
.start-btn:hover { opacity: .9; transform: scale(1.02); }
.done-btn {
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  padding: 14px 40px; border-radius: 100px; font-family: 'Syne', sans-serif;
  font-weight: 700; font-size: 13px; cursor: pointer; transition: all .2s;
}
.done-btn:hover { background: var(--surface2); }

/* ─── BREATHING ──────────────────────────────────────────────── */
#breathe .breath-container { display: flex; flex-direction: column; align-items: center; gap: 32px; }
.breath-circle-wrap { position: relative; width: 240px; height: 240px; }
.breath-ring   { position: absolute; inset: 0; border-radius: 50%; border: 1px solid rgba(167, 139, 250, .2); }
.breath-circle {
  position: absolute; inset: 20px; border-radius: 50%;
  background: radial-gradient(circle, rgba(167, 139, 250, .3), rgba(167, 139, 250, .05));
  border: 1px solid rgba(167, 139, 250, .4); transition: transform .3s ease;
  display: flex; align-items: center; justify-content: center;
}
.breath-text        { font-family: 'DM Serif Display', serif; font-style: italic; font-size: 16px; color: var(--accent); text-align: center; }
.breath-instruction { font-size: 13px; color: var(--muted); text-align: center; min-height: 20px; letter-spacing: .05em; }
.breath-counter     { font-size: 11px; color: var(--muted); letter-spacing: .1em; }
.progress-bar-wrap  { width: 100%; height: 2px; background: var(--border); border-radius: 2px; overflow: hidden; }
.progress-bar       { height: 100%; background: var(--accent); border-radius: 2px; width: 0%; transition: width .5s linear; }

/* ─── JOURNAL ────────────────────────────────────────────────── */
#journal .journal-container { display: flex; flex-direction: column; gap: 20px; }
.prompt-card   { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 20px; }
.prompt-label  { font-size: 10px; letter-spacing: .15em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.prompt-text   { font-family: 'DM Serif Display', serif; font-style: italic; font-size: 20px; line-height: 1.4; }
.journal-textarea {
  width: 100%; min-height: 180px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 18px; color: var(--text); font-family: 'DM Mono', monospace;
  font-size: 13px; line-height: 1.8; resize: none; outline: none; transition: border-color .2s;
}
.journal-textarea::placeholder { color: var(--muted); }
.journal-textarea:focus { border-color: rgba(167, 139, 250, .4); }
.journal-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.delete-note   { font-size: 11px; color: var(--muted); }
.btn-row       { display: flex; gap: 10px; }

/* ─── SOUND ──────────────────────────────────────────────────── */
#sound .sound-container { display: flex; flex-direction: column; gap: 20px; }
.soundscape-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sound-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 20px 16px; cursor: pointer; transition: all .2s; position: relative;
  overflow: hidden; text-align: center;
}
.sound-card.active { border-color: rgba(167, 139, 250, .5); background: var(--surface2); }
.sound-card:hover  { transform: translateY(-2px); }
.sound-emoji { font-size: 32px; margin-bottom: 8px; display: block; }
.sound-name  { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 13px; margin-bottom: 2px; }
.sound-desc  { font-size: 11px; color: var(--muted); }
.sound-playing-dot { position: absolute; top: 12px; right: 12px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); display: none; animation: pulse 1.5s infinite; }
.sound-card.active .sound-playing-dot { display: block; }
.volume-row { display: flex; align-items: center; gap: 12px; padding: 16px 20px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; }
.vol-label  { font-size: 11px; color: var(--muted); white-space: nowrap; }
input[type=range] { flex: 1; -webkit-appearance: none; height: 3px; background: var(--border); border-radius: 2px; outline: none; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: var(--accent); cursor: pointer; }

/* ─── SAND DRAWING ───────────────────────────────────────────── */
#sand .sand-container { display: flex; flex-direction: column; align-items: center; gap: 20px; width: 100%; }
#sandCanvas { border-radius: 16px; display: block; cursor: crosshair; max-width: 100%; touch-action: none; }
.sand-controls { display: flex; gap: 10px; align-items: center; width: 100%; flex-wrap: wrap; justify-content: center; }
.sand-color-btn { width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; transition: all .2s; flex-shrink: 0; }
.sand-color-btn.active { border-color: var(--text); transform: scale(1.15); }
.sand-hint  { font-size: 11px; color: var(--muted); text-align: center; opacity: .7; }
.clear-btn  { background: none; border: 1px solid var(--border); color: var(--muted); font-family: 'DM Mono', monospace; font-size: 11px; padding: 6px 16px; border-radius: 100px; cursor: pointer; transition: all .2s; }
.clear-btn:hover { color: var(--text); border-color: rgba(255, 255, 255, .2); }

/* ─── DONE ───────────────────────────────────────────────────── */
#done { align-items: center; justify-content: center; padding: 40px 24px; text-align: center; }
.done-inner   { max-width: 400px; z-index: 1; }
.done-emoji   { font-size: 64px; margin-bottom: 24px; display: block; animation: float 3s ease-in-out infinite; }
.done-h       { font-family: 'DM Serif Display', serif; font-size: 42px; margin-bottom: 12px; }
.done-h em    { font-style: italic; color: var(--accent); }
.done-sub     { font-size: 13px; color: var(--muted); line-height: 1.7; margin-bottom: 36px; }
.done-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.pill-btn     { border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 12px 24px; border-radius: 100px; font-family: 'DM Mono', monospace; font-size: 12px; cursor: pointer; transition: all .2s; }
.pill-btn:hover { background: var(--surface2); }
.pill-btn.primary { background: var(--accent); color: var(--bg); border-color: var(--accent); font-family: 'Syne', sans-serif; font-weight: 700; }

/* ─── MOOD ACCENT OVERRIDES ──────────────────────────────────── */
.mood-anxious     { --accent: var(--accent-anxious); }
.mood-burnt       { --accent: var(--accent-burnt); }
.mood-overwhelmed { --accent: var(--accent-overwhelmed); }
.mood-numb        { --accent: var(--accent-numb); }

/* ─── CHAT ───────────────────────────────────────────────────── */
#chat { padding: 0; }
#chat.screen.active { display: flex; }
.chat-layout    { display: flex; flex-direction: column; width: 100%; max-width: 560px; margin: 0 auto; height: 100vh; }
.chat-header    { padding: 18px 24px 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; flex-shrink: 0; background: var(--bg); }
.chat-room-badge { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.chat-room-emoji { font-size: 20px; flex-shrink: 0; }
.chat-room-name  { font-family: 'Syne', sans-serif; font-weight: 700; font-size: 14px; }
.chat-room-meta  { font-size: 10px; color: var(--muted); margin-top: 2px; }
.online-dot     { width: 6px; height: 6px; border-radius: 50%; background: #4ade80; display: inline-block; margin-right: 4px; animation: pulse 2s infinite; }
.leave-btn {
  background: var(--surface); border: 1px solid var(--border); color: var(--muted);
  font-family: 'DM Mono', monospace; font-size: 11px; padding: 7px 14px;
  border-radius: 100px; cursor: pointer; transition: all .2s; white-space: nowrap; flex-shrink: 0;
}
.leave-btn:hover { color: var(--text); border-color: rgba(255, 255, 255, .2); }
.chat-messages  { flex: 1; overflow-y: auto; padding: 16px 24px; display: flex; flex-direction: column; gap: 2px; scroll-behavior: smooth; }
.chat-messages::-webkit-scrollbar       { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.chat-msg { display: flex; flex-direction: column; gap: 3px; padding: 3px 0; animation: fadeUp .2s ease; }
.chat-msg.mine   { align-items: flex-end; }
.chat-msg.theirs { align-items: flex-start; }
.chat-msg.system { align-items: center; margin: 6px 0; }
.msg-name   { font-size: 10px; color: var(--muted); padding: 0 4px; }
.msg-bubble { max-width: 78%; padding: 10px 14px; border-radius: 16px; font-size: 13px; line-height: 1.6; word-break: break-word; }
.chat-msg.mine   .msg-bubble { background: var(--accent); color: var(--bg); border-bottom-right-radius: 4px; font-weight: 500; }
.chat-msg.theirs .msg-bubble { background: var(--surface2); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.chat-msg.system .msg-bubble { background: transparent; font-size: 11px; color: var(--muted); font-style: italic; padding: 4px 12px; border: 1px solid var(--border); border-radius: 100px; }
.autoclear-notice { text-align: center; font-size: 10px; color: var(--muted); opacity: .5; padding: 10px; letter-spacing: .06em; }
.chat-input-row { padding: 14px 20px 22px; border-top: 1px solid var(--border); display: flex; gap: 10px; align-items: flex-end; flex-shrink: 0; background: var(--bg); }
.chat-input {
  flex: 1; background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
  padding: 11px 18px; color: var(--text); font-family: 'DM Mono', monospace; font-size: 13px;
  outline: none; resize: none; line-height: 1.5; max-height: 120px; transition: border-color .2s; overflow-y: auto;
}
.chat-input::placeholder { color: var(--muted); }
.chat-input:focus { border-color: rgba(167, 139, 250, .35); }
.send-btn {
  width: 42px; height: 42px; border-radius: 50%; background: var(--accent); border: none;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700; color: var(--bg); transition: all .2s; flex-shrink: 0;
}
.send-btn:hover { opacity: .85; transform: scale(1.05); }

/* ─── KINDNESS MODAL ─────────────────────────────────────────── */
.kindness-overlay { position: fixed; inset: 0; background: rgba(14, 14, 18, .93); backdrop-filter: blur(8px); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 24px; animation: fadeUp .3s ease; }
.kindness-overlay.hidden { display: none; }
.kindness-card  { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 32px 28px; max-width: 400px; width: 100%; text-align: center; }
.kindness-icon  { font-size: 44px; margin-bottom: 14px; display: block; }
.kindness-title { font-family: 'DM Serif Display', serif; font-style: italic; font-size: 24px; margin-bottom: 18px; }
.kindness-rules { list-style: none; margin: 0 0 20px; display: flex; flex-direction: column; gap: 8px; }
.kindness-rules li { font-size: 12px; color: var(--muted); line-height: 1.6; padding: 10px 14px; background: var(--surface2); border-radius: 10px; text-align: left; }
.your-name-row  { font-size: 11px; color: var(--muted); margin-bottom: 20px; }
.your-name-row strong { color: var(--accent); font-family: 'Syne', sans-serif; letter-spacing: .03em; }

/* ─── ANIMATIONS ─────────────────────────────────────────────── */
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .5; transform: scale(1.3); } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }

/* ─── RESPONSIVE ─────────────────────────────────────────────── */
@media (max-width: 480px) {
  .moods, .soundscape-grid { grid-template-columns: 1fr; }
  .kindness-card { padding: 24px 20px; }
  .signup-card   { padding: 24px 18px; }
}
