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

:root {
  --bg: #0f0e17;
  --surface: #1a1a2e;
  --surface2: #232340;
  --accent: #7f5af0;
  --accent-hover: #6b46d6;
  --text: #e0def4;
  --text-muted: #908caa;
  --border: #2e2e4a;
  --success: #3dd68c;
  --danger: #eb6f92;
  --warning: #f6c177;
  --radius: 10px;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* Login screen */
.login-screen[hidden] { display: none; }
#app[hidden] { display: none; }

.login-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.login-card {
  text-align: center;
  padding: 3rem;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  max-width: 400px;
  width: 90%;
}

.login-card h1 {
  font-size: 2.5rem;
  background: linear-gradient(135deg, #c4b5fd, #7f5af0, #a78bfa);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: 2px;
  margin-bottom: 0.5rem;
}

.login-subtitle {
  color: var(--text-muted);
  margin-bottom: 2rem;
  font-size: 0.95rem;
}

#google-signin-btn {
  display: flex;
  justify-content: center;
}

.login-legal {
  margin-top: 1.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.login-legal a {
  color: var(--accent);
  text-decoration: none;
}

.login-legal a:hover {
  text-decoration: underline;
}

/* Header */
header {
  background: linear-gradient(135deg, #1a1a2e 0%, #2d1b69 50%, #1a1a2e 100%);
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 800px;
  margin: 0 auto;
}

.header-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

header h1 {
  font-size: 1.8rem;
  background: linear-gradient(135deg, #c4b5fd, #7f5af0, #a78bfa);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: 2px;
}

/* Nav tabs */
.nav-tabs {
  display: flex;
  gap: 0.25rem;
}

.nav-tab {
  padding: 0.5rem 1rem;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.nav-tab:hover {
  color: var(--text);
  background: rgba(127, 90, 240, 0.1);
}

.nav-tab.active {
  color: white;
  background: var(--accent);
  border-color: var(--accent);
}

.user-info {
  display: flex;
  align-items: center;
}

.user-menu-wrapper {
  position: relative;
}

.user-menu-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.6rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s;
}

.user-menu-btn:hover {
  background: rgba(127, 90, 240, 0.1);
  border-color: var(--border);
}

.dropdown-arrow {
  font-size: 0.65rem;
}

.avatar {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 50%;
  border: 2px solid var(--border);
  object-fit: cover;
}

.user-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 180px;
  padding: 0.4rem 0;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.user-menu[hidden] { display: none; }

.user-menu-item {
  display: block;
  width: 100%;
  padding: 0.5rem 1rem;
  background: none;
  border: none;
  color: var(--text);
  font-size: 0.85rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.1s;
}

.user-menu-item:hover {
  background: rgba(127, 90, 240, 0.15);
}

.user-menu-item-danger {
  color: var(--danger);
}

.user-menu-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0.3rem 0;
}

/* Pages */
main {
  max-width: 800px;
  margin: 0 auto;
  padding: 1.5rem;
}

.page[hidden] { display: none; }

/* ======================== */
/* Journal Page              */
/* ======================== */

.journal-header {
  margin-bottom: 1.5rem;
}

.journal-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.journal-title-row h2 {
  font-size: 1.3rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}


/* Search */
.search-section {
  margin-bottom: 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.search-section summary {
  padding: 0.65rem 1rem;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: color 0.15s;
  background: var(--surface);
}

.search-section summary::-webkit-details-marker { display: none; }

.search-section summary::before {
  content: '\25B6';
  font-size: 0.6rem;
  transition: transform 0.15s;
}

.search-section[open] summary::before {
  transform: rotate(90deg);
}

.search-section summary:hover {
  color: var(--text);
}

.search-section-content {
  padding: 0.75rem 1rem 1rem;
}

.tags-section[open] {
  flex-basis: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.tags-section summary {
  padding: 0.4rem 0.6rem;
  cursor: pointer;
  color: var(--text-muted);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
}

.tags-section summary::-webkit-details-marker { display: none; }

.tags-section summary::before {
  content: '\25B6';
  font-size: 0.55rem;
  transition: transform 0.15s;
}

.tags-section[open] summary::before {
  transform: rotate(90deg);
}

.tags-section summary:hover {
  color: var(--text);
  border-color: var(--accent);
}

.tags-section .tag-cloud {
  padding: 0.5rem 0.75rem 0.75rem;
}

.clear-filters-btn {
  margin-top: 0.75rem;
}

.active-tag-label {
  color: var(--accent);
  font-weight: 400;
  font-size: 0.75rem;
}

.search-row {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.search-row input[type="text"] {
  flex: 1;
}

.tag-search-input {
  max-width: 200px;
}

.search-bar input[type="text"] {
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1rem;
}

.empty-tags {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-style: italic;
}

.search-bar input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(127, 90, 240, 0.15);
}

.filter-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.tag-cloud {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  flex: 1;
  min-width: 200px;
}

.tag-cloud .tag {
  cursor: pointer;
  transition: all 0.15s;
}

.tag-cloud .tag:hover, .tag-cloud .tag.active {
  background: var(--accent);
  color: white;
}

select {
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.85rem;
}

.lucid-toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
}

.dreams-section {
  margin-top: 1.5rem;
}

.dreams-section h3 {
  font-size: 1rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

/* Dream list */
.dream-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.dream-list::-webkit-scrollbar { width: 6px; }
.dream-list::-webkit-scrollbar-track { background: transparent; }
.dream-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.dream-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  cursor: pointer;
  transition: all 0.15s;
}

.dream-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.dream-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.4rem;
}

.dream-card h3 {
  font-size: 0.95rem;
  font-weight: 600;
}

.dream-card .date {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.dream-card .preview {
  font-size: 0.85rem;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.dream-card .card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 0.6rem;
}

.dream-card .tags {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
}

.tag {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  background: rgba(127, 90, 240, 0.15);
  color: #a78bfa;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 500;
}

.mood-badge {
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: 20px;
  background: rgba(246, 193, 119, 0.15);
  color: var(--warning);
}

.lucid-badge {
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: 20px;
  background: rgba(61, 214, 140, 0.15);
  color: var(--success);
}

.fragment-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 400;
  font-style: italic;
}

.analyzed-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  display: inline-block;
  margin-left: 0.3rem;
}

.count-badge {
  font-size: 0.75rem;
  background: var(--surface2);
  padding: 0.15rem 0.5rem;
  border-radius: 20px;
  color: var(--text-muted);
  font-weight: 400;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem;
  font-style: italic;
}

/* ======================== */
/* Editor Page               */
/* ======================== */

.editor-single {
  max-width: 800px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.panel h2 {
  font-size: 1.2rem;
  margin-bottom: 1rem;
  color: var(--text);
}

.editor-form-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.editor-form-header h2 {
  margin-bottom: 0;
}

/* Save status */
.save-status {
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
}

.save-status.saved {
  color: var(--success);
}

.save-status.saving {
  color: var(--warning);
}

.save-status.unsaved {
  color: var(--text-muted);
}

.save-status.error {
  color: var(--danger);
}

.editor-form-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

/* Form */
label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
  margin-top: 0.8rem;
}

label:first-of-type { margin-top: 0; }

input[type="text"], input[type="date"], textarea, .editor-form-panel select {
  width: 100%;
  padding: 0.6rem 0.8rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(127, 90, 240, 0.15);
}

textarea { resize: vertical; }

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  margin-top: 1rem;
  color: var(--text);
  font-size: 0.9rem;
}

/* Form details (collapsible) */
.form-details {
  margin-top: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.form-details summary {
  padding: 0.65rem 1rem;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: color 0.15s;
}

.form-details summary::-webkit-details-marker { display: none; }

.form-details summary::before {
  content: '\25B6';
  font-size: 0.6rem;
  transition: transform 0.15s;
}

.form-details[open] summary::before {
  transform: rotate(90deg);
}

.form-details summary:hover {
  color: var(--text);
}

.form-details-content {
  padding: 0 1rem 1rem;
}

.optional-hint {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* Mood chips */
.mood-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.3rem;
}

.mood-chip {
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface2);
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
}

.mood-chip:hover {
  border-color: var(--accent);
  color: var(--text);
}

.mood-chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

/* Buttons */
.btn {
  padding: 0.6rem 1.2rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface2);
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.15s;
}

.btn:hover { border-color: var(--accent); }

.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  font-weight: 600;
}

.btn-primary:hover { background: var(--accent-hover); }

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-analyze {
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
}

.btn-analyze:hover {
  background: var(--accent);
  color: white;
}

.btn-analyze-cta {
  padding: 0.75rem 2rem;
  font-size: 0.95rem;
  font-weight: 600;
}

.btn-danger {
  color: var(--danger);
  border-color: transparent;
  background: transparent;
  font-size: 0.8rem;
}

.btn-danger:hover { border-color: var(--danger); }

/* Analysis inline section */
.analysis-section-inline {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.analysis-section-inline h3 {
  color: var(--accent);
  font-size: 1rem;
  margin-bottom: 0.75rem;
}

/* Analysis */
.analysis-body {
  margin-top: 0.5rem;
}

.analysis-results {
  margin-top: 0;
}

.analysis-textarea {
  width: 100%;
  min-height: 200px;
  padding: 0.8rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.85rem;
  font-family: inherit;
  line-height: 1.7;
  resize: vertical;
  cursor: default;
}

.btn-analyze-cta {
  padding: 0.6rem 1.5rem;
  font-size: 0.9rem;
  font-weight: 600;
}

/* Form action buttons */
.form-action-buttons {
  display: flex;
  gap: 0.75rem;
}

.form-action-buttons[hidden] {
  display: none;
}

.analysis-section h3 {
  color: var(--accent);
  font-size: 1rem;
  margin-bottom: 0.75rem;
}

.analysis-content {
  font-size: 0.9rem;
  line-height: 1.8;
}

.analysis-content strong {
  color: #c4b5fd;
}

.analysis-content p {
  margin-bottom: 0.5rem;
}

.analysis-content ul, .analysis-content ol {
  margin-left: 1.2rem;
  margin-bottom: 0.5rem;
}

.analysis-content li {
  margin-bottom: 0.25rem;
}

.analysis-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.75rem 0;
  font-size: 0.85rem;
}

.analysis-content th,
.analysis-content td {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  text-align: left;
}

.analysis-content th {
  background: var(--surface2);
  color: #c4b5fd;
  font-weight: 600;
}

.analysis-content td {
  color: var(--text);
}

.analysis-actions {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.analysis-disclaimer {
  margin-top: 1rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Suggested tags */
.suggested-tags {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.suggested-tags h4 {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.suggested-tags-list {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.tag-add {
  cursor: pointer;
  border: 1px dashed var(--accent);
  background: transparent;
  color: var(--accent);
  transition: all 0.15s;
}

.tag-add:hover {
  background: var(--accent);
  color: white;
  border-style: solid;
}

.tag-accepted {
  cursor: default;
  border: 1px solid var(--success);
  background: rgba(61, 214, 140, 0.15);
  color: var(--success);
}

/* Loading spinner */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 0.4rem;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Modal */
.modal[hidden] { display: none; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  max-width: 700px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
}

.modal-close:hover { color: var(--text); }

/* Themed dialog */
#dialog-modal[hidden] { display: none; }

.dialog-box {
  max-width: 420px;
  text-align: center;
  padding: 2rem 2.5rem;
}

.dialog-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  line-height: 1;
}

.dialog-box h2 {
  font-size: 1.1rem;
  margin-bottom: 0.75rem;
}

.dialog-message {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 1.5rem;
  white-space: pre-line;
}

.dialog-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}

.dialog-actions .btn {
  min-width: 100px;
}

/* Consent dialog */
.consent-text {
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.consent-text a {
  color: var(--accent);
}

.consent-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

/* Legal pages */
.legal-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.legal-page h1 {
  font-size: 1.8rem;
  margin-bottom: 0.25rem;
  background: linear-gradient(135deg, #c4b5fd, #7f5af0, #a78bfa);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.legal-page h2 {
  font-size: 1.15rem;
  margin-top: 2rem;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.legal-page h3 {
  font-size: 0.95rem;
  margin-top: 1rem;
  margin-bottom: 0.3rem;
  color: var(--text-muted);
}

.legal-page p, .legal-page li {
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.legal-page ul {
  margin-left: 1.2rem;
  margin-bottom: 0.75rem;
}

.legal-page a {
  color: var(--accent);
  text-decoration: none;
}

.legal-page a:hover {
  text-decoration: underline;
}

.legal-back {
  display: inline-block;
  margin-bottom: 1.5rem;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.85rem;
}

.legal-updated {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  font-style: italic;
}

/* Footer */
.app-footer {
  text-align: center;
  padding: 1.5rem;
  margin-top: 2rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.app-footer a {
  color: var(--text-muted);
  text-decoration: none;
  margin: 0 0.75rem;
}

.app-footer a:hover {
  color: var(--accent);
}

.btn-export {
  background: transparent;
  border: 1px solid var(--success);
  color: var(--success);
}

.btn-export:hover {
  background: var(--success);
  color: var(--bg);
}

.btn-delete-account {
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
}

.btn-delete-account:hover {
  background: var(--danger);
  color: white;
}

/* ======================== */
/* Trends Page               */
/* ======================== */

.trends-container {
  max-width: 800px;
}

.trends-container h2 {
  font-size: 1.3rem;
  margin-bottom: 1.5rem;
}

.trends-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent);
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.trends-section {
  margin-bottom: 1.5rem;
}

.trends-section h3 {
  font-size: 1rem;
  margin-bottom: 0.75rem;
  color: var(--text);
}

.trends-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.mood-bars {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.mood-bar-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.mood-bar-label {
  width: 80px;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: capitalize;
}

.mood-bar-track {
  flex: 1;
  height: 8px;
  background: var(--surface2);
  border-radius: 4px;
  overflow: hidden;
}

.mood-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.3s;
}

.mood-bar-count {
  width: 30px;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: right;
}

/* ======================== */
/* Admin                     */
/* ======================== */

.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.admin-menu-wrapper {
  position: relative;
}

.admin-menu-wrapper[hidden] { display: none; }

.admin-menu-btn {
  border-color: var(--warning);
  color: var(--warning);
}

.admin-menu-btn:hover {
  background: rgba(246, 193, 119, 0.15);
}

.admin-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 160px;
  padding: 0.4rem 0;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.admin-menu[hidden] { display: none; }

.admin-menu-item {
  display: block;
  width: 100%;
  padding: 0.5rem 1rem;
  background: none;
  border: none;
  color: var(--text);
  font-size: 0.85rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.1s;
}

.admin-menu-item:hover {
  background: rgba(246, 193, 119, 0.15);
}

.admin-page {
  max-width: 800px;
}

.admin-page h2 {
  font-size: 1.3rem;
  margin-bottom: 1rem;
}

.admin-range-selector {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.admin-range.active {
  background: var(--warning);
  border-color: var(--warning);
  color: var(--bg);
}

.admin-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.admin-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
}

.admin-stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--warning);
}

.admin-stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.admin-section {
  margin-bottom: 1.5rem;
}

.admin-section h3 {
  font-size: 1rem;
  margin-bottom: 0.75rem;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.admin-table th,
.admin-table td {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  text-align: left;
}

.admin-table th {
  background: var(--surface2);
  color: var(--warning);
  font-weight: 600;
}

.admin-table td {
  color: var(--text);
}

.admin-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.admin-gran-label {
  font-weight: 400;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.timeline-wrapper {
  display: flex;
  height: 160px;
}

.timeline-yaxis {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-end;
  padding-right: 0.5rem;
  padding-bottom: 2.5rem;
  min-width: 28px;
}

.timeline-yaxis-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.timeline-chart {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  flex: 1;
  height: 100%;
  padding-bottom: 2.5rem;
  overflow-x: auto;
  border-left: 1px solid var(--border);
}

.timeline-bar-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  min-width: 20px;
  max-width: 40px;
  height: 100%;
  position: relative;
}

.timeline-bar-wrap {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: flex-end;
}

.timeline-bar {
  width: 100%;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
  min-height: 4px;
  transition: height 0.3s;
}

.timeline-bar-group:hover .timeline-bar {
  background: var(--warning);
}

.timeline-label {
  font-size: 0.6rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  white-space: nowrap;
  transform: rotate(-45deg);
  transform-origin: top center;
}

.timeline-count {
  position: absolute;
  top: -1rem;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text);
}

.admin-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.admin-user-count {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

.admin-user-cell {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.admin-user-avatar {
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 50%;
  object-fit: cover;
}

.admin-user-name {
  font-weight: 500;
  font-size: 0.85rem;
}

.admin-user-email {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Admin: Screenshots */
.admin-page-wide { max-width: 1100px; }

.screenshots-folder-title {
  text-transform: capitalize;
  margin-bottom: 0.75rem;
}

.screenshots-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.screenshot-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 0.85rem;
  cursor: pointer;
  transition: border-color 0.15s;
  min-width: 200px;
}

.screenshot-card:hover {
  border-color: var(--accent);
}

.screenshot-card-expanded {
  width: 100%;
  flex-basis: 100%;
  border-color: var(--accent);
}

.screenshot-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.screenshot-filename {
  font-size: 0.85rem;
  color: var(--text);
  text-transform: capitalize;
}

.screenshot-type-badge {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-html {
  background: rgba(127, 90, 240, 0.2);
  color: var(--accent);
}

.badge-json {
  background: rgba(61, 214, 140, 0.2);
  color: var(--success);
}

.screenshot-preview {
  margin-top: 0.75rem;
  width: 100%;
}

.screenshot-iframe {
  width: 100%;
  height: 600px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
}

.screenshot-json {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  overflow-x: auto;
  font-size: 0.8rem;
  max-height: 500px;
  overflow-y: auto;
  margin: 0;
}

.screenshot-json code {
  color: var(--text);
  white-space: pre;
}

/* Responsive */
@media (max-width: 700px) {
  .header-top-row {
    margin-bottom: 0.5rem;
  }

  header h1 {
    font-size: 1.4rem;
  }

  .nav-tab {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
  }

  .user-info {
    gap: 0.5rem;
  }

  #user-name {
    display: none;
  }

  .search-row {
    flex-direction: column;
  }

  .tag-search-input {
    max-width: none;
  }

  .journal-title-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
}
