:root {
  --ink: #e5e7eb;
  --muted: #9ca3af;
  --bg-1: #020617;
  --bg-2: #020617;
  --glass: #020617d9;
  --glass-2: #020617bf;
  --surface: #020617;
  --surface-2: #020617;
  --accent: #2563eb;
  --accent-2: #60a5fa;
  --accent-soft: rgba(37, 99, 235, 0.12);
  --border: rgba(148, 163, 184, 0.35);
  --shadow: 0 14px 32px rgba(15, 23, 42, 0.7);
  --radius: 18px;

  --c-anger: #f97373;
  --c-disgust: #34d399;
  --c-fear: #60a5fa;
  --c-joy: #fde047;
  --c-sadness: #93c5fd;
  --c-passion: #fb7185;
  --c-surprise: #a78bfa;
  --bar-bg: rgba(15, 23, 42, 0.85);
}

[data-theme="light"] {
  --ink: #020617;
  --muted: #475569;
  --bg-1: #ecf2ff;
  --bg-2: #f3f5fb;
  --glass: #ffffffec;
  --glass-2: #ffffffd4;
  --surface: #ffffff;
  --surface-2: #e5edff;
  --accent: #2563eb;
  --accent-2: #60a5fa;
  --accent-soft: rgba(37, 99, 235, 0.08);
  --border: rgba(148, 163, 184, 0.45);
  --shadow: 0 12px 26px rgba(15, 23, 42, 0.18);
  --bar-bg: rgba(148, 163, 184, 0.18);
}

* {
  box-sizing: border-box;
}
html,
body {
  height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial,
    sans-serif;
  background: var(--bg-1);
  background-image:
    radial-gradient(1200px 800px at 0% 0%, #1d4ed833 0%, transparent 55%),
    radial-gradient(1200px 800px at 100% 100%, #6366f155 0%, transparent 60%);
  background-attachment: fixed;
}
[data-theme="light"] body {
  background: var(--bg-1);
  background-image:
    radial-gradient(1000px 700px at -10% -10%, #bfdbfe80 0%, transparent 55%),
    radial-gradient(1200px 900px at 120% 120%, #e0f2fe99 0%, transparent 55%);
  background-attachment: fixed;
}

/* Utility */

.hidden {
  display: none !important;
}

.wrap {
  max-width: 1160px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 2.6rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: transparent;
}

/* keep main content and footer vertically balanced */
.grid {
  display: grid;
  gap: 1.4rem;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.95fr);
  align-items: flex-start;
  flex: 1 0 auto;
}
@media (max-width: 980px) {
  .grid {
    grid-template-columns: 1fr;
  }
}

footer {
  margin-top: 2.4rem;
  color: var(--muted);
  text-align: center;
  font-size: 0.9rem;
  flex-shrink: 0;
}

/* Topbar and header */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
}
@media (max-width: 720px) {
  .topbar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
  }
  .topbar .brand {
    gap: 0.55rem;
    flex-shrink: 0;
  }
  .topbar .brand .logo {
    width: 32px;
    height: 32px;
    border-radius: 10px;
  }
  .topbar .brand .logo .mark {
    width: 14px;
    height: 14px;
  }
  .topbar .brand .title {
    font-size: 1.15rem;
  }
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  cursor: pointer;
}

.logo {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  background:
    radial-gradient(circle at 10% 0%, #e5e7eb 0, transparent 40%),
    conic-gradient(
      from 210deg,
      var(--accent),
      var(--accent-2),
      #a855f7,
      var(--accent)
    );
  display: grid;
  place-items: center;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.logo::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
    circle at 0% 0%,
    rgba(255, 255, 255, 0.55) 0,
    transparent 40%
  );
  opacity: 0.85;
  pointer-events: none;
}

.mark {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ffffff, #e5e7eb);
  position: relative;
  box-shadow:
    0 0 22px 6px rgba(255, 255, 255, 0.7),
    inset 0 0 10px rgba(148, 163, 184, 0.65);
}
[data-theme="light"] .mark {
  background: #020617;
  box-shadow:
    0 0 18px 3px rgba(15, 23, 42, 0.3),
    inset 0 0 8px rgba(255, 255, 255, 0.35);
}

.brandText {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.title {
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: 0.16px;
}

/* Old badge style kept for compatibility if needed */
.badge {
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.5);
  background: var(--accent-soft);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Notice banner */

.noticeBanner {
  width: 100%;
  margin-bottom: 1rem;
  padding: 0.7rem 1rem;
  border-radius: 12px;
  border: 1px solid rgba(250, 204, 21, 0.6);
  background:
    radial-gradient(circle at 0% 0%, rgba(250, 250, 210, 0.12), transparent 55%),
    rgba(15, 23, 42, 0.9);
  color: var(--ink);
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.noticeBanner::before {
  content: "⚠️";
  font-size: 1rem;
}

/* Actions area: help, settings, auth */

.actions {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}
@media (max-width: 720px) {
  .actions {
    align-self: center;
    justify-content: flex-end;
    gap: 0.4rem;
    flex-shrink: 0;
  }
  .actions .iconBtn,
  .actions .help,
  .actions .settingsBtn {
    width: 34px;
    height: 34px;
    border-radius: 10px;
  }
  .actions .loginBtn {
    padding: 0.45rem 0.9rem;
    font-size: 0.82rem;
    min-width: auto;
  }
  .actions .topbarDivider {
    height: 20px;
    margin-inline: 0;
  }
}

.topbarDivider {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin-inline: 0.1rem;
  align-self: stretch;
}

.iconBtn,
.help,
.settingsBtn {
  appearance: none;
  border: 1px solid var(--border);
  background:
    radial-gradient(
      circle at 0% 0%,
      rgba(248, 250, 252, 0.09),
      transparent 55%
    ),
    var(--surface);
  color: var(--ink);
  width: 38px;
  height: 38px;
  border-radius: 12px;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-weight: 800;
  padding: 0;
  box-shadow: var(--shadow);
  transition:
    transform 0.16s ease,
    box-shadow 0.16s ease,
    border-color 0.16s ease,
    background 0.16s ease;
}
.iconBtn:hover {
  transform: translateY(-1px);
  border-color: rgba(148, 163, 184, 0.7);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.9);
}
.iconBtn:active {
  transform: translateY(0);
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.8);
}
.helpIcon,
.settingsIcon {
  font-size: 1.1rem;
}

/* Home button in account area */

.homeBtn {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  font-size: 0.9rem;
  box-shadow: none;
}
.homeIcon {
  font-size: 1.05rem;
}

/* Login button in topbar */

.loginBtn {
  appearance: none;
  border-radius: 999px;
  border: 1px solid var(--border);
  background:
    radial-gradient(
      circle at 0% 0%,
      rgba(148, 163, 184, 0.18),
      transparent 45%
    ),
    var(--surface);
  color: var(--ink);
  padding: 0.55rem 1.25rem;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  height: auto;
  min-width: 104px;
  box-shadow: var(--shadow);
  white-space: nowrap;
  transition:
    transform 0.16s ease,
    box-shadow 0.16s ease,
    border-color 0.16s ease,
    background 0.16s ease,
    filter 0.16s ease;
}
.loginBtn:hover {
  border-color: rgba(148, 163, 184, 0.8);
  background:
    radial-gradient(
      circle at 0% 0%,
      rgba(148, 163, 184, 0.26),
      transparent 55%
    ),
    rgba(15, 23, 42, 0.96);
  transform: translateY(-1px);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.9);
  filter: brightness(1.03);
}
.loginBtn:active {
  transform: translateY(0);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.9);
}

/* Settings dropdown (guest only visible when logged out) */

.settingsControl {
  position: relative;
}

.settingsMenu {
  position: absolute;
  top: calc(100% + 0.6rem);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 0.8rem 0.9rem 0.85rem;
  width: min(270px, 82vw);
  opacity: 0;
  transform: translateY(-6px) scale(0.97);
  pointer-events: none;
  transition:
    opacity 0.18s ease,
    transform 0.2s ease;
  z-index: 40;
}
.settingsMenu.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.settingsSection {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}
.settingsSection:last-child {
  margin-bottom: 0;
}
.settingsLabel {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
}
.settingsRow {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.modeDot {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.45rem;
  width: 100%;
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
}
.modeDotLabel {
  flex: 0 0 auto;
}
.modeDotTrack {
  flex: 1;
  height: 18px;
  border-radius: 999px;
  background: var(--bar-bg);
  position: relative;
  overflow: hidden;
}
.modeDotThumb {
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: 2px;
  width: 50%;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 3px 8px rgba(15, 23, 42, 0.45);
  transition: transform 0.22s ease;
}
[data-theme="light"] .modeDotThumb {
  transform: translateX(100%);
}

.langControl {
  position: relative;
  width: 100%;
}
.langToggle {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--ink);
  height: 32px;
  border-radius: 999px;
  padding: 0 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
  box-shadow: var(--shadow);
  font-size: 0.8rem;
  font-weight: 600;
  width: 100%;
  justify-content: space-between;
  transition:
    transform 0.16s ease,
    box-shadow 0.16s ease,
    border-color 0.16s ease,
    background 0.16s ease;
}
.langToggle:hover {
  transform: translateY(-1px);
  border-color: rgba(148, 163, 184, 0.8);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.9);
}
.langIcon {
  font-size: 1rem;
}
.langCurrentLabel {
  font-variant: small-caps;
  letter-spacing: 0.08em;
}
.langMenu {
  position: absolute;
  top: calc(100% + 0.4rem);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 0.4rem 0;
  min-width: 190px;
  opacity: 0;
  transform: translateY(-4px) scale(0.98);
  pointer-events: none;
  transition:
    opacity 0.18s ease,
    transform 0.2s ease;
  z-index: 42;
}
.langMenu.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.langHeading {
  padding: 0.4rem 0.95rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
}
.langOption {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--ink);
  width: 100%;
  text-align: left;
  padding: 0.45rem 0.95rem;
  font-size: 0.86rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.langOption span {
  pointer-events: none;
}
.langOption[aria-checked="true"] {
  background: rgba(148, 163, 184, 0.22);
  font-weight: 700;
}
.langOption:hover {
  background: rgba(148, 163, 184, 0.3);
}

/* Headline and subtitle */

h1 {
  font-size: 2rem;
  margin: 0.35rem 0 0.9rem 0;
  letter-spacing: 0.18px;
}
.subtitle {
  margin: -0.6rem 0 1.6rem 0;
  color: var(--muted);
  font-size: 0.97rem;
  max-width: 620px;
}

.stack {
  display: grid;
  gap: 1.25rem;
}

/* Cards */

.card {
  position: relative;
  background:
    radial-gradient(
      circle at 0% 0%,
      rgba(148, 163, 184, 0.12) 0,
      transparent 50%
    ),
    linear-gradient(180deg, var(--glass), var(--glass-2));
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  padding: 1.35rem;
  overflow: hidden;
}
[data-theme="light"] .card {
  border-color: rgba(148, 163, 184, 0.18);
}
.card::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.08;
  background:
    radial-gradient(
      400px 400px at 0% 0%,
      rgba(96, 165, 250, 0.9),
      transparent 65%
    ),
    radial-gradient(
      420px 420px at 100% 100%,
      rgba(129, 140, 248, 0.9),
      transparent 70%
    );
  pointer-events: none;
  mix-blend-mode: soft-light;
}
.card > * {
  position: relative;
  z-index: 1;
}

/* Inputs */

label {
  display: block;
  font-weight: 700;
  margin-bottom: 0.6rem;
}

.inputShell {
  position: relative;
}

textarea {
  width: 100%;
  min-height: 220px;
  resize: vertical;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1rem 1rem 1.1rem;
  font-size: 1rem;
  line-height: 1.5;
  outline: none;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.25);
  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    background 0.16s ease;
}
.inputShell textarea {
  padding-bottom: 2rem;
}
textarea:focus {
  border-color: var(--accent);
  box-shadow:
    0 0 0 1px var(--accent),
    0 0 0 7px rgba(59, 130, 246, 0.22);
  background:
    radial-gradient(
      circle at 0% 0%,
      rgba(148, 163, 184, 0.14),
      transparent 55%
    ),
    var(--surface);
}

textarea.input-error {
  border-color: #f97373;
  box-shadow:
    0 0 0 1px #f97373,
    0 0 0 7px rgba(248, 113, 113, 0.5);
}

/* Word counter inside textarea */

#wordInfo,
.wordInfo {
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
  position: absolute;
  right: 1rem;
  bottom: 0.7rem;
  pointer-events: none;
}

/* Row under textarea */

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.7rem;
  margin-top: 1rem;
}

.row .status {
  flex: 1;
  min-width: 100px;
}

.row .emojiInline {
  margin-left: auto;
}

@media (max-width: 720px) {
  .row {
    gap: 0.5rem 0.7rem;
  }
  .row .status {
    flex-basis: 100%;
    order: 10;
  }
  #emojiTray {
    justify-content: flex-start;
  }
}

/* Buttons */

.btn {
  appearance: none;
  border: none;
  cursor: pointer;
  padding: 0.87rem 1.3rem;
  border-radius: 999px;
  font-weight: 800;
  background:
    radial-gradient(circle at 0% 0%, #2563eb 0, transparent 45%),
    linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #f9fafb;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.94rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.9);
  transition:
    transform 0.14s ease,
    box-shadow 0.14s ease,
    filter 0.12s ease;
}
.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 22px 55px rgba(15, 23, 42, 1);
  filter: brightness(1.05);
}
.btn:active {
  transform: translateY(0);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.9);
}

/* Explicit variants for clarity */

.primaryBtn {
  /* uses default .btn styling */
}

.secondaryBtn {
  background: var(--surface-2);
  color: var(--ink);
  border: 1px solid var(--border);
  text-transform: none;
  letter-spacing: 0.01em;
  box-shadow: var(--shadow);
}
.secondaryBtn:hover {
  filter: none;
  background: rgba(148, 163, 184, 0.12);
}

.dangerBtn {
  background:
    radial-gradient(circle at 0% 0%, #f97373 0, transparent 45%),
    linear-gradient(135deg, #ef4444, #fb7185);
  color: #fef2f2;
  box-shadow: 0 18px 40px rgba(127, 29, 29, 0.9);
}
.dangerBtn:hover {
  filter: brightness(1.04);
  box-shadow: 0 22px 55px rgba(127, 29, 29, 0.95);
}

.smallBtn {
  padding: 0.6rem 1rem;
  font-size: 0.82rem;
}

.primaryIconBtn {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: none;
  background:
    radial-gradient(circle at 0% 0%, #2563eb 0, transparent 45%),
    linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #f9fafb;
  box-shadow: 0 16px 32px rgba(15, 23, 42, 0.9);
  font-size: 1.6rem;
  font-weight: 500;
}

/* Back button in journal detail */

.backBtn {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.85);
  color: var(--ink);
  font-size: 1.1rem;
  margin-right: 0.4rem;
}

/* Danger text button inside menus */

.dangerTextButton {
  color: #f97373;
}

/* Focus states */

.btn:focus-visible,
.ghost:focus-visible,
.btnLink:focus-visible,
.ghostLink:focus-visible,
.help:focus-visible,
.settingsBtn:focus-visible,
.langToggle:focus-visible,
.modeDot:focus-visible,
.accountBtn:focus-visible,
.iconBtn:focus-visible,
.loginBtn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.status {
  grid-column: 1 / -1;
  font-size: 0.95rem;
  color: var(--muted);
  min-height: 1.1rem;
  transition: color 0.16s ease;
}
.status.err {
  color: #f43f5e;
}

.emojiInline {
  font-size: 1.7rem;
  display: flex;
  gap: 0.35rem;
  align-items: center;
  min-height: 1.7rem;
  justify-content: flex-end;
}
#emojiTray {
  min-width: 3.1rem;
}

.panelTitle {
  margin: 0.2rem 0 1rem 0;
  font-weight: 800;
  letter-spacing: 0.15px;
  font-size: 0.98rem;
  text-transform: uppercase;
  color: var(--muted);
}

.kv {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.6rem 1rem;
}
.pill {
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  font-weight: 700;
  font-size: 0.9rem;
}
.value {
  min-width: 4.7rem;
  text-align: right;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 0.55rem 0.75rem;
  border-radius: 14px;
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
}

.meta {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.6rem 1.1rem;
}
.metaPrimary {
  margin-bottom: 0.85rem;
}

/* Bar chart */

.chartCard {
  margin-top: 1.1rem;
}
.barRow {
  display: grid;
  grid-template-columns: 120px 1fr 64px;
  gap: 0.6rem;
  align-items: center;
  margin: 0.35rem 0;
}
@media (max-width: 720px) {
  .barRow {
    grid-template-columns: 100px 1fr 52px;
  }
}
.barLabel {
  font-weight: 700;
  color: var(--muted);
  font-size: 0.86rem;
}
.barTrack {
  height: 14px;
  border-radius: 999px;
  background: var(--bar-bg);
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
}
.barFill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  border-radius: 999px;
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.2);
  transition: width 0.6s cubic-bezier(0.18, 0.9, 0.16, 1.02);
  will-change: width;
}
.barValue {
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--ink);
  font-size: 0.86rem;
}

/* Generic overlay and modal */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.72);
  display: none;
  align-items: center;
  justify-content: center;

  /* Allow scrolling when modal content is taller than the viewport */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;

  /* Keep buttons reachable above iOS safe areas */
  padding-top: max(1rem, env(safe-area-inset-top));
  padding-right: 1rem;
  padding-bottom: max(1rem, env(safe-area-inset-bottom));
  padding-left: 1rem;

  z-index: 40;
}
.overlay.show {
  display: flex;
}
.modal {
  width: 100%;
  max-width: 520px;
  background: var(--surface);
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 1.35rem 1.35rem 1.1rem;

  /* Make the modal itself scroll if needed */
  max-height: calc(100vh - 2rem);
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
@media (min-width: 1200px) {
  .modal {
    max-width: 560px;
  }
}
.modal h2 {
  margin: 0.2rem 0 0.6rem 0;
  font-size: 1.2rem;
}
.modal p {
  color: var(--ink);
  line-height: 1.65;
  margin: 0.45rem 0;
}
.modal .muted {
  color: var(--muted);
}
.modal .actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 1rem;
}
.ghost {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  padding: 0.6rem 1rem;
  border-radius: 11px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
}

/* Crisis modal */

.alertRow {
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
}
.alertIcon {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(248, 113, 113, 0.12);
  color: #f97373;
  font-size: 1.4rem;
  flex-shrink: 0;
}
.crisisActions {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-top: 0.75rem;
}

/* Legacy link styles kept for compatibility but not used now */

.btnLink {
  text-decoration: none;
  text-align: center;
  padding: 0.8rem 1rem;
  border-radius: 12px;
  font-weight: 700;
  background: linear-gradient(135deg, #f97373, #fb7185);
  color: #020617;
  font-size: 0.92rem;
}
.ghostLink {
  text-decoration: none;
  text-align: center;
  padding: 0.78rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  font-size: 0.9rem;
}

.crisisNote {
  font-size: 0.9rem;
  color: var(--muted);
  margin-top: 0.4rem;
}

/* Maintenance shell */

.maintenanceShell {
  min-height: 80vh;
  display: none;
  align-items: center;
  justify-content: center;
}
.maintenanceShell:not(.hidden) {
  display: flex;
}
.maintenanceContent {
  max-width: 540px;
  width: 100%;
  padding: 1.8rem 1.7rem;
  border-radius: 18px;
  border: 1px solid var(--border);
  background:
    radial-gradient(
      circle at 0% 0%,
      rgba(96, 165, 250, 0.16),
      transparent 55%
    ),
    var(--surface);
  box-shadow: var(--shadow);
}
.maintenanceTitle {
  font-size: 1.35rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
}
.maintenanceMessage {
  font-size: 0.98rem;
  color: var(--ink);
  margin-bottom: 0.6rem;
}
.maintenanceNote {
  font-size: 0.88rem;
  color: var(--muted);
}

/* Account header */

.accountControl {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}
.accountBtn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background:
    radial-gradient(
      circle at 0% 0%,
      rgba(248, 250, 252, 0.12),
      transparent 55%
    ),
    var(--surface);
  color: var(--ink);
  cursor: pointer;
  box-shadow: var(--shadow);
  font-size: 0.86rem;
  font-weight: 600;
}
.accountAvatar {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.76rem;
  color: #020617;
}
.accountNameLabel {
  max-width: 110px;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}
.accountCaret {
  font-size: 0.72rem;
  color: var(--muted);
}

.accountMenu {
  position: absolute;
  top: calc(100% + 0.4rem);
  right: 0;
  background: var(--surface);
  border-radius: 14px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 0.35rem 0;
  min-width: 180px;
  z-index: 44;
  display: none;
}
.accountMenu.open {
  display: block;
}
.accountMenuItem {
  width: 100%;
  border: none;
  background: transparent;
  color: var(--ink);
  text-align: left;
  font-size: 0.9rem;
  padding: 0.5rem 0.95rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.accountMenuItem:hover {
  background: rgba(148, 163, 184, 0.25);
}

/* Auth modals (login, register, forgot) */

.authModal {
  max-width: 480px;
}

.authHeader {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.8rem;
}

.fieldLabel {
  display: block;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--muted);
  margin-top: 0.6rem;
  margin-bottom: 0.25rem;
}

.fieldInput {
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  padding: 0.6rem 0.9rem;
  font-size: 0.94rem;
  outline: none;
  width: 100%;
  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    background 0.16s ease;
}
.fieldInput:focus {
  border-color: var(--accent);
  box-shadow:
    0 0 0 1px var(--accent),
    0 0 0 5px rgba(59, 130, 246, 0.18);
}

.errorText {
  margin-top: 0.4rem;
  font-size: 0.86rem;
  color: #f97373;
}

.authLinksRow {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.75rem;
  margin-top: 0.8rem;
}

.authLinksRow .linkButton + .linkButton {
  position: relative;
  padding-left: 0.8rem;
}

.authLinksRow .linkButton + .linkButton::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 1px;
  height: 1rem;
  transform: translateY(-50%);
  background: var(--border);
}

.linkButton {
  appearance: none;
  border: none;
  background: none;
  color: var(--accent-2);
  cursor: pointer;
  padding: 0;
  font-size: 0.86rem;
  font-weight: 500;
  white-space: nowrap;
}
.linkButton:hover {
  text-decoration: underline;
}

.actionsRow {
  margin-top: 0.8rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* Account settings modal */

.accountSettingsBody {
  margin-top: 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.accountSettingsGroup {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.accountSettingsLabel {
  font-size: 0.9rem;
  color: var(--muted);
}

/* Journal overlay */

.journalModal {
  max-width: 900px;
}

.journalHeaderRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.65rem;
}

.journalLayout {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 1.2rem;
}
@media (max-width: 900px) {
  .journalLayout {
    grid-template-columns: 1fr;
  }
}

.journalListPane {
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid var(--border);
  padding: 0.85rem 0.85rem 0.9rem;
}

.journalSectionHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 0.2rem 0 0.4rem;
}

.journalList {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  max-height: 320px;
  overflow-y: auto;
  padding-right: 0.1rem;
}

/* Entries inserted via JS should use these */

.journalListItem {
  width: 100%;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  padding: 0.45rem 0.5rem;
  font-size: 0.88rem;
  cursor: pointer;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.2rem 0.3rem;
  align-items: center;
}
.journalListItem:hover {
  background: rgba(148, 163, 184, 0.18);
}
.journalListTitle {
  grid-column: 1 / 2;
  font-weight: 600;
}
.journalListMeta {
  grid-column: 1 / 2;
  font-size: 0.78rem;
  color: var(--muted);
}
.journalListFlag {
  grid-row: 1 / 3;
  justify-self: end;
}

.journalEmptyState {
  font-size: 0.9rem;
  color: var(--muted);
  margin-top: 0.4rem;
}

/* Journal detail */

.journalDetailPane {
  min-height: 260px;
}

.journalDetail {
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.96);
  padding: 0.9rem 0.95rem 0.95rem;
}

.journalDetailHeader {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  align-items: flex-start;
}

#journalDetailTitle {
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 0.1rem 0;
}

#journalDetailMeta,
.journalMeta {
  font-size: 0.8rem;
  color: var(--muted);
}

.journalMetaRow {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.7rem;
  margin-top: 0.35rem;
  font-size: 0.78rem;
}
.journalMetaLabel {
  color: var(--muted);
}
.journalMetaValue {
  font-weight: 600;
}

.journalDetailActions {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.warningIndicator {
  border-color: rgba(248, 113, 113, 0.9);
  background: rgba(248, 113, 113, 0.1);
  color: #fecaca;
}

.journalEditMenuDropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 0.4rem);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 0.25rem 0;
  z-index: 46;
}
.journalEditMenuDropdown.hidden {
  display: none;
}
.journalEditMenuDropdown button {
  padding: 0.35rem 0.8rem;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--ink);
  font-size: 0.85rem;
  text-align: left;
  cursor: pointer;
}
.journalEditMenuDropdown button:hover {
  background: rgba(148, 163, 184, 0.22);
}

.journalDetailContent {
  margin-top: 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.journalSourceBlock,
.journalAnalysisBlock,
.journalTextBlock {
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.96);
  padding: 0.55rem 0.65rem 0.65rem;
}
.journalSourceBlock h4,
.journalAnalysisBlock h4,
.journalTextBlock h4 {
  margin: 0 0 0.4rem 0;
  font-size: 0.86rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.journalSourceBlock p {
  margin: 0;
  font-size: 0.92rem;
}
.journalAnalysisBlock pre {
  margin: 0;
  font-size: 0.9rem;
  white-space: pre-wrap;
  font-family: ui-monospace, SFMonoRegular, Menlo, Monaco, Consolas,
    Liberation Mono, Courier New, monospace;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.journalEditArea {
  width: 100%;
  min-height: 120px;
  resize: vertical;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  padding: 0.6rem 0.7rem;
  font-size: 0.94rem;
}

#journalDetailActionsRow {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.7rem;
}

/* New journal content (from detection) */

.journalNewContent {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* Responsive tweaks */

@media (max-width: 720px) {
  .wrap {
    padding: 1.9rem 1.1rem 2.2rem;
  }
  textarea {
    min-height: 180px;
  }
  .modal {
    border-radius: 16px;
    padding: 1.1rem 1.1rem 0.9rem;
  }
  .journalLayout {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .barFill,
  .langMenu,
  .settingsMenu {
    transition: none !important;
  }
  .btn,
  .iconBtn,
  .langToggle {
    transition: none !important;
  }
}

/* Entry help container - divider and help button */

.entryHelpContainer {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.entryHelpDivider {
  width: 1px;
  height: 28px;
  background: var(--border);
}

.entryHelpBtn {
  padding: 0.55rem 0.9rem;
  font-size: 0.82rem;
  text-transform: none;
  letter-spacing: 0.02em;
}

/* Logged-in help button (icon style) */

.loggedInHelpBtn {
  appearance: none;
  border: 1px solid var(--border);
  background:
    radial-gradient(
      circle at 0% 0%,
      rgba(248, 250, 252, 0.09),
      transparent 55%
    ),
    var(--surface);
  color: var(--ink);
  width: 38px;
  height: 38px;
  border-radius: 999px;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 1rem;
  padding: 0;
  box-shadow: var(--shadow);
  transition:
    transform 0.16s ease,
    box-shadow 0.16s ease,
    border-color 0.16s ease,
    background 0.16s ease;
}

.loggedInHelpBtn:hover {
  transform: translateY(-1px);
  border-color: rgba(148, 163, 184, 0.7);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.9);
}

.loggedInHelpBtn:active {
  transform: translateY(0);
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.8);
}

/* Feedback popup modal */

.feedbackModal {
  max-width: 540px;
}

.feedbackHeader {
  margin-bottom: 0.5rem;
}

.feedbackHeader h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink);
}

.feedbackNotice {
  font-size: 0.88rem;
  color: var(--muted);
  margin: 0 0 1rem 0;
  padding: 0.6rem 0.8rem;
  background: rgba(37, 99, 235, 0.08);
  border: 1px solid rgba(37, 99, 235, 0.2);
  border-radius: 10px;
}

.feedbackContent {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.feedbackSection {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.feedbackReadonly {
  background: var(--surface-2);
  color: var(--muted);
  cursor: default;
  resize: none;
}

.requiredIndicator {
  color: #f97373;
  font-weight: 600;
}

.feedbackActionsRow {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 1.1rem;
}

/* Feedback analysis rating display */

.feedbackAnalysisRating {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.7rem 0.85rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.feedbackEmotionRow {
  display: grid;
  grid-template-columns: 90px 1fr 55px;
  gap: 0.55rem;
  align-items: center;
}

.feedbackEmotionLabel {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: capitalize;
}

.feedbackEmotionBarContainer {
  height: 10px;
  border-radius: 999px;
  background: var(--bar-bg);
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
}

.feedbackEmotionBar {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  border-radius: 999px;
  box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.15);
}

.feedbackEmotionValue {
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--ink);
}

.feedbackResultsSummary {
  margin-top: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.feedbackSummaryLabel {
  font-size: 0.8rem;
  color: var(--muted);
  margin-right: 0.35rem;
}

.feedbackSummaryValue {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
}

/* Admin feedback section */

.feedbackStatsRow {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.8rem;
}

.feedbackStatItem {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.feedbackStatLabel {
  font-size: 0.88rem;
  color: var(--muted);
}

.feedbackStatValue {
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
  padding: 0.2rem 0.6rem;
  background: var(--accent-soft);
  border-radius: 8px;
}

.feedbackActions {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 0.7rem;
}

/* Admin feedback view modal */

.feedbackViewModal {
  max-width: 680px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;

  /* Keep this modal controlled by its internal scroll area */
  overflow: hidden;
}

.feedbackViewHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.8rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
}

.feedbackViewHeader h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
}

.feedbackViewContent {
  flex: 1;
  overflow-y: auto;
  max-height: 50vh;
  padding-right: 0.3rem;
}

.noFeedback {
  font-size: 0.92rem;
  color: var(--muted);
  text-align: center;
  padding: 1.5rem 0;
}

.feedbackEntry {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  margin-bottom: 0.7rem;
}

.feedbackEntry:last-child {
  margin-bottom: 0;
}

.feedbackEntryHeader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.65rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.feedbackEntryNumber {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--accent-2);
}

.feedbackEntryDate {
  font-size: 0.78rem;
  color: var(--muted);
}

.feedbackEntrySection {
  margin-bottom: 0.6rem;
}

.feedbackEntrySection:last-child {
  margin-bottom: 0;
}

.feedbackEntrySectionLabel {
  display: block;
  font-size: 0.76rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.feedbackEntryText,
.feedbackEntryAnalysis,
.feedbackEntryUserFeedback {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.5;
}

.feedbackEntryText {
  color: var(--ink);
  padding: 0.45rem 0.6rem;
  background: var(--surface);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.feedbackEntryAnalysis {
  color: var(--ink);
  font-weight: 500;
}

.feedbackEntryMixture {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.35rem;
}

.feedbackMixtureItem {
  font-size: 0.78rem;
  padding: 0.2rem 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
}

.feedbackEntryFeedback {
  background: rgba(37, 99, 235, 0.06);
  padding: 0.6rem 0.7rem;
  border-radius: 8px;
  border: 1px solid rgba(37, 99, 235, 0.15);
}

.feedbackEntryUserFeedback {
  color: var(--ink);
}

.feedbackViewActions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 0.9rem;
  padding-top: 0.7rem;
  border-top: 1px solid var(--border);
}
