/* ===== Moodring — minimal, warm, notebook-like ===== */

:root {
  --bg: #faf6f0;
  --surface: #fffdfa;
  --surface-2: #f3ede4;
  --text: #2a2622;
  --text-soft: #6f6760;
  --border: #e7ded2;
  --accent: #e08a5b;
  --accent-soft: #f7e3d6;
  --danger: #c0573f;
  --shadow: 0 2px 12px rgba(60, 45, 30, 0.08);
  --radius: 18px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

[data-theme="dark"] {
  --bg: #131316;
  --surface: #1c1c21;
  --surface-2: #25252c;
  --text: #ece8e3;
  --text-soft: #9b938a;
  --border: #2e2e36;
  --accent: #e89b6e;
  --accent-soft: #3a2e26;
  --danger: #e07a63;
  --shadow: 0 2px 14px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s ease, color 0.3s ease;
}

#app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* ===== Topbar ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px 8px;
}
.brand {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}
.icon-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 42px; height: 42px;
  font-size: 1.1rem;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease;
}
.icon-btn:active { transform: scale(0.92); }

/* ===== Views ===== */
#views {
  flex: 1;
  padding: 8px 22px 100px;
  overflow-y: auto;
}
.view { display: none; animation: fade 0.25s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.section-title {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-soft);
  margin: 26px 0 12px;
}
.hint { font-size: 0.82rem; color: var(--text-soft); margin: 8px 0 14px; line-height: 1.5; }

/* ===== Log view ===== */
.prompt {
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 22px 0 20px;
  line-height: 1.3;
}
.emoji-row {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 6px 2px 16px;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}
.emoji-row::-webkit-scrollbar { height: 0; }
.emoji-btn {
  flex: 0 0 auto;
  width: 76px; height: 92px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  scroll-snap-align: center;
  box-shadow: var(--shadow);
  transition: transform 0.12s ease, background 0.2s ease;
}
.emoji-btn .e { font-size: 2.1rem; line-height: 1; }
.emoji-btn .l { font-size: 0.68rem; color: var(--text-soft); }
.emoji-btn:active { transform: scale(0.9); }
.emoji-btn.pop { animation: pop 0.4s ease; }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.18); background: var(--accent-soft); } 100% { transform: scale(1); } }

/* Note area */
.note-area {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-top: 6px;
  animation: fade 0.2s ease;
}
.note-selected { font-size: 1.8rem; margin-bottom: 10px; }
.note-actions { display: flex; gap: 10px; margin-top: 12px; justify-content: flex-end; }

input[type="text"],
input[type="email"],
input[type="password"] {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 1rem;
  outline: none;
  transition: border 0.2s ease, box-shadow 0.2s ease;
}
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder { color: var(--text-soft); opacity: 0.8; }

/* Buttons */
.btn {
  border: none;
  border-radius: 12px;
  padding: 11px 18px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.2s ease;
}
.btn:active { transform: scale(0.95); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.ghost { background: var(--surface-2); color: var(--text); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 200; /* above the auth overlay (100) so toasts are never hidden */
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Today's logs */
.today-logs { display: flex; flex-wrap: wrap; gap: 8px; }
.log-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 13px 7px 11px;
  font-size: 0.85rem;
  color: var(--text-soft);
  box-shadow: var(--shadow);
}
.log-chip .ce { font-size: 1.15rem; }
.log-chip .note { color: var(--text); font-style: italic; }
.log-chip .del {
  background: none; border: none; cursor: pointer;
  color: var(--text-soft); font-size: 0.9rem; margin-left: 2px;
}
.empty { color: var(--text-soft); font-size: 0.9rem; padding: 6px 0; }

/* Today's boost */
.boost-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: opacity 0.2s ease;
}
.boost-text { font-size: 1.4rem; font-weight: 700; line-height: 1.35; letter-spacing: -0.01em; }
.boost-actions { display: flex; gap: 8px; justify-content: flex-end; }
.boost-icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-soft);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s ease, background 0.2s ease, color 0.2s ease;
}
.boost-icon-btn:active { transform: scale(0.92); }
.boost-check.done {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.boost-card.done { border-color: var(--accent); }
.boost-card.done .boost-text {
  color: var(--text-soft);
  text-decoration: line-through;
  text-decoration-color: var(--accent);
}

/* ===== History ===== */
.trend {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}
.trend svg { width: 100%; height: 120px; display: block; }
.trend-label { font-size: 0.85rem; color: var(--text-soft); margin-top: 10px; }
.trend-label strong { color: var(--text); }

.summary-card {
  background: var(--accent-soft);
  border-radius: var(--radius);
  padding: 16px 18px;
  font-size: 0.92rem;
  line-height: 1.55;
  margin-bottom: 18px;
  color: var(--text);
}

.timeline { display: flex; flex-direction: column; gap: 14px; }
.day-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.day-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.day-name { font-weight: 600; font-size: 0.95rem; }
.day-count { font-size: 0.78rem; color: var(--text-soft); }
.day-entries { display: flex; flex-direction: column; gap: 8px; }
.entry { display: flex; align-items: center; gap: 10px; font-size: 0.88rem; }
.entry .ee { font-size: 1.3rem; }
.entry .et { color: var(--text-soft); width: 64px; flex: 0 0 auto; font-variant-numeric: tabular-nums; }
.entry .en { color: var(--text); font-style: italic; }

/* ===== Boosters ===== */
.suggestions { display: flex; flex-direction: column; gap: 12px; }
.suggestion-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  animation: fade 0.25s ease;
}
.suggestion-card .s-text { font-size: 0.95rem; margin-bottom: 10px; line-height: 1.45; }
.suggestion-card .s-actions { display: flex; gap: 8px; }
.suggestion-card .btn { padding: 8px 14px; font-size: 0.85rem; }

.booster-add { display: flex; gap: 8px; margin-bottom: 14px; }
.booster-add input { flex: 1; }
.booster-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.booster-item {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 13px 16px;
  box-shadow: var(--shadow);
  font-size: 0.95rem;
}
.booster-item .del { background: none; border: none; cursor: pointer; color: var(--text-soft); font-size: 1rem; }

/* ===== Settings emoji editor ===== */
.emoji-edit-list { list-style: none; display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.emoji-edit-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 11px 14px;
  box-shadow: var(--shadow);
  cursor: grab;
}
.emoji-edit-item.dragging { opacity: 0.4; }
.emoji-edit-item.drag-over { border-color: var(--accent); }
.emoji-edit-item .grip { color: var(--text-soft); cursor: grab; font-size: 1.1rem; }
.emoji-edit-item .ce { font-size: 1.6rem; }
.emoji-edit-item .lbl { flex: 1; font-size: 0.95rem; }
.emoji-edit-item .del { background: none; border: none; cursor: pointer; color: var(--text-soft); font-size: 1rem; }

.emoji-add { display: flex; gap: 8px; align-items: center; }
.emoji-char-input { width: 64px; flex: 0 0 auto; text-align: center; font-size: 1.3rem; }
.emoji-add input:not(.emoji-char-input) { flex: 1; }

.data-actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* ===== Tabbar ===== */
.tabbar {
  position: fixed;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 560px;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
  z-index: 40;
}
.tab {
  flex: 1;
  background: none;
  border: none;
  padding: 10px 0 12px;
  font-size: 1.3rem;
  color: var(--text-soft);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: color 0.2s ease;
}
.tab span { font-size: 0.66rem; font-weight: 600; }
.tab.active { color: var(--accent); }

/* ===== Topbar actions ===== */
.topbar-actions { display: flex; gap: 10px; }

/* ===== Auth overlay ===== */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fade 0.25s ease;
}
.auth-overlay[hidden] { display: none; }
.auth-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 30px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.auth-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: fade 0.2s ease;
}
.auth-panel[hidden] { display: none; }
.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 6px 0 2px;
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}
.auth-divider span {
  font-size: 0.78rem;
  color: var(--text-soft);
  white-space: nowrap;
}
.auth-nav { border: 1px solid var(--border); }
.auth-back {
  align-self: flex-start;
  text-decoration: none;
  padding: 2px 0;
}
.auth-logo {
  font-size: 2.8rem;
  line-height: 1;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.auth-logo.swap { opacity: 0; transform: translateY(-8px); }
.auth-title { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; }
.auth-sub { font-size: 0.9rem; color: var(--text-soft); margin-bottom: 6px; line-height: 1.5; }
.auth-card input { text-align: left; margin-top: 2px; }
.auth-btn { width: 100%; }
.auth-btn:disabled { opacity: 0.6; cursor: default; }
.auth-error {
  background: var(--accent-soft);
  color: var(--danger);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 0.85rem;
  text-align: left;
  line-height: 1.45;
}
.auth-error.success {
  background: var(--accent-soft);
  color: var(--accent);
}
.btn.link {
  background: none;
  color: var(--text-soft);
  font-weight: 500;
  font-size: 0.85rem;
  padding: 4px;
  text-decoration: underline;
}
.auth-config-warn {
  font-size: 0.78rem;
  color: var(--text-soft);
  line-height: 1.5;
  margin-top: 6px;
}
.auth-config-warn code {
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 5px;
  font-size: 0.95em;
}

/* ===== Standalone pages (privacy, contact) ===== */
.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 18px 22px 64px;
}
.page-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0 18px;
}
.page-back {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  text-decoration: none;
  color: var(--text-soft);
  font-size: 0.9rem;
  font-weight: 600;
}
.page-back:hover { color: var(--accent); }
.page h1 {
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 8px 0 6px;
}
.page .updated {
  font-size: 0.82rem;
  color: var(--text-soft);
  margin-bottom: 28px;
}
.page h2 {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 30px 0 10px;
  letter-spacing: -0.01em;
}
.page p,
.page li {
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--text);
}
.page p { margin: 0 0 14px; }
.page ul { margin: 0 0 14px; padding-left: 22px; }
.page li { margin-bottom: 6px; }
.page a { color: var(--accent); }
.page .lead {
  font-size: 1.05rem;
  color: var(--text-soft);
  line-height: 1.6;
  margin-bottom: 8px;
}
.page-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
  margin-bottom: 18px;
}
.page-card form { display: flex; flex-direction: column; gap: 12px; }
.page-card label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-soft);
  display: block;
  margin-bottom: 6px;
}
.page-card textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  resize: vertical;
  min-height: 120px;
  transition: border 0.2s ease, box-shadow 0.2s ease;
}
.page-card textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.page-card select {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 1rem;
  outline: none;
}
.email-direct {
  display: inline-block;
  margin-top: 4px;
  font-weight: 600;
  font-size: 1.05rem;
}
.page-footer {
  margin-top: 36px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-soft);
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.page-footer a { color: var(--text-soft); text-decoration: none; }
.page-footer a:hover { color: var(--accent); }

/* In-app legal links (settings footer) */
.app-legal {
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.app-legal a {
  font-size: 0.85rem;
  color: var(--text-soft);
  text-decoration: none;
  font-weight: 600;
}
.app-legal a:hover { color: var(--accent); }
