/* PERMA Lead — palette and type ported from et@'s prototype (e-dialog CI). */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --navy: #0A2564;
  --blue: #0045A5;
  --mid: #2A6CD0;
  --teal: #3EA5EB;
  --gold: #FBC105;
  --green: #1D9E75;
  --bg: #f4f6fb;
  --card: #fff;
  --border: #e2e6f0;
  --text: #1a2340;
  --muted: #7a8099;
  --radius: 12px;
  --radius-sm: 8px;
  --nav-h: 64px;
}

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  max-width: 420px;
  margin: 0 auto;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px);
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

/* ---------- sign-in ---------- */
.onboard {
  position: fixed; inset: 0; z-index: 300; background: var(--navy);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 32px 24px; text-align: center;
}
.ob-stripe { height: 3px; width: 50px; background: var(--gold); border-radius: 3px; margin-bottom: 24px; }
.ob-logo { font-family: 'DM Serif Display', serif; font-size: 40px; color: #fff; margin-bottom: 4px; }
.ob-logo em { color: var(--gold); font-style: italic; }
.ob-sub { font-size: 13px; color: rgba(255,255,255,.55); line-height: 1.7; margin-bottom: 32px; }
#gsi-button { display: flex; justify-content: center; min-height: 44px; }
.ob-fine { font-size: 12px; color: rgba(255,255,255,.4); margin-top: 20px; }

/* ---------- screens & chrome ---------- */
.screen { display: none; }
.screen.active { display: block; }

.top-bar { background: var(--navy); padding: calc(env(safe-area-inset-top) + 20px) 20px 28px; color: #fff; }
.top-bar h1 { font-family: 'DM Serif Display', serif; font-size: 22px; font-weight: 400; color: #fff; }
.top-bar h1 em { color: var(--gold); font-style: italic; }
.top-bar .sub { font-size: 12px; color: rgba(255,255,255,.55); margin-bottom: 2px; }
.top-inner { display: flex; align-items: flex-start; justify-content: space-between; }
.profile-btn {
  width: 34px; height: 34px; border-radius: 50%; border: none; cursor: pointer;
  background: rgba(255,255,255,.15); display: grid; place-items: center;
}
.profile-btn svg { width: 18px; height: 18px; stroke: #fff; stroke-width: 1.8; fill: none; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin: 0 16px 12px; }
.section-title {
  font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); padding: 14px 20px 6px;
}
.muted-txt { font-size: 13px; color: var(--muted); text-align: center; padding: 8px 0; }
.muted-txt.left { text-align: left; padding: 0 0 10px; }
.privacy-note { font-size: 12px; color: var(--muted); padding: 12px 20px 0; line-height: 1.6; }

/* ---------- buttons ---------- */
.btn-gold, .btn-ghost, .btn-navy {
  width: 100%; border: none; border-radius: var(--radius-sm); padding: 12px 18px;
  font-family: inherit; font-size: 13px; cursor: pointer;
}
.btn-gold { background: var(--gold); color: var(--navy); font-weight: 600; margin-bottom: 6px; }
.btn-ghost { background: rgba(255,255,255,.12); color: #fff; }
.btn-navy { background: var(--navy); color: #fff; font-weight: 500; margin-top: 8px; }
.btn-gold.is-done { background: var(--green); color: #fff; }
button:disabled { cursor: default; opacity: .95; }

/* ---------- streak & today ---------- */
.streak-row { display: flex; align-items: center; gap: 12px; padding: 14px 20px; }
.streak-flame { font-size: 28px; }
.streak-num { font-family: 'DM Serif Display', serif; font-size: 36px; font-style: italic; color: var(--gold); line-height: 1; }
.streak-label { font-size: 13px; color: var(--muted); }

.today-card { background: var(--navy); border-radius: var(--radius); margin: 0 16px 12px; padding: 18px; color: #fff; }
.today-dim-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.today-dim-name { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: rgba(255,255,255,.55); }
.today-text { font-size: 15px; line-height: 1.55; margin-bottom: 14px; }

.pdot {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  font-family: 'DM Serif Display', serif; font-size: 13px;
}
.pdot-P { background: var(--navy); color: var(--gold); }
.pdot-E { background: var(--blue); color: #fff; }
.pdot-R { background: var(--mid); color: #fff; }
.pdot-M { background: var(--teal); color: var(--text); }
.pdot-A { background: var(--gold); color: var(--text); }
.pdot-sm { width: 22px; height: 22px; font-size: 10px; }
/* P on a navy card needs a visible edge */
.today-card .pdot-P { box-shadow: inset 0 0 0 1px rgba(255,255,255,.35); }

/* ---------- dashboard & level ---------- */
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 0 16px 4px; }
.dash-kpi { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; text-align: center; }
.dash-num { font-family: 'DM Serif Display', serif; font-size: 28px; font-style: italic; color: var(--navy); line-height: 1; }
.dash-label { font-size: 11px; color: var(--muted); margin-top: 3px; }
.dash-hint { font-size: 10px; color: var(--muted); margin-top: 4px; }
.dash-kpi-click { cursor: pointer; }
.dash-kpi-click:active { background: var(--border); }

.level-card { background: var(--navy); border-radius: var(--radius); margin: 12px 16px; padding: 14px 16px; display: flex; align-items: center; gap: 12px; }
.level-icon { width: 42px; height: 42px; border-radius: 50%; background: rgba(255,255,255,.12); display: grid; place-items: center; font-size: 22px; flex-shrink: 0; }
.level-mid { flex: 1; }
.level-name { font-size: 15px; font-weight: 500; color: #fff; }
.level-sub { font-size: 11px; color: rgba(255,255,255,.5); margin-top: 2px; }
.level-bar { height: 5px; background: rgba(255,255,255,.15); border-radius: 3px; margin-top: 6px; overflow: hidden; }
.level-fill { height: 100%; width: 0; background: var(--gold); border-radius: 3px; transition: width .4s; }
.level-right { text-align: right; }
.level-right-label { font-size: 11px; color: rgba(255,255,255,.4); }
.level-num { font-family: 'DM Serif Display', serif; font-size: 22px; font-style: italic; color: var(--gold); }

/* ---------- team (aggregate only — no per-person rows) ---------- */
.team-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.team-tile { background: var(--bg); border-radius: var(--radius-sm); padding: 12px; text-align: center; }
.team-tile-num { font-family: 'DM Serif Display', serif; font-size: 28px; font-style: italic; color: var(--navy); }
.team-tile-label { font-size: 11px; color: var(--muted); margin-top: 2px; }
.team-strongest { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: var(--bg); border-radius: var(--radius-sm); margin-bottom: 12px; }
.team-strongest-label { font-size: 11px; color: var(--muted); }
.team-strongest-dim { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.team-strongest-name { font-size: 13px; font-weight: 500; }
.team-bar-row { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; }
.team-bar-row:last-child { margin-bottom: 0; }
.team-bar-track { flex: 1; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.team-bar-fill { height: 100%; border-radius: 3px; }
.team-bar-num { font-size: 11px; color: var(--muted); min-width: 18px; text-align: right; }

/* ---------- weekly reflection ---------- */
.rq-dim { display: inline-block; font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: 20px; margin-bottom: 8px; }
.rq-text { font-size: 14px; line-height: 1.7; margin-bottom: 12px; }
textarea {
  width: 100%; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px;
  font-family: inherit; font-size: 13px; color: var(--text); background: var(--card);
  resize: vertical; min-height: 80px; outline: none;
}
textarea:focus { border-color: var(--navy); }

/* ---------- library ---------- */
.lib-tabs { display: flex; gap: 6px; padding: 12px 16px 4px; overflow-x: auto; scrollbar-width: none; }
.lib-tabs::-webkit-scrollbar { display: none; }
.lib-tab {
  background: var(--card); border: 1px solid var(--border); border-radius: 20px;
  padding: 6px 14px; font-family: inherit; font-size: 12px; font-weight: 500;
  color: var(--muted); cursor: pointer; white-space: nowrap; flex-shrink: 0;
}
.lib-tab.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.lib-hero { border-radius: var(--radius); margin: 0 16px 12px; padding: 18px; color: #fff; }
.lib-hero.dark-ink, .lib-hero.dark-ink .lib-letter, .lib-hero.dark-ink .lib-kpi { color: var(--text); }
.lib-letter { font-family: 'DM Serif Display', serif; font-size: 48px; font-style: italic; color: var(--gold); line-height: 1; }
.lib-title { font-size: 16px; font-weight: 500; margin-top: 4px; }
.lib-kpi { font-size: 12px; margin-top: 4px; opacity: .75; }
.lib-what { font-size: 13px; color: var(--muted); line-height: 1.7; }
.strategy-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin: 0 16px 10px; }
.strategy-title { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.strategy-text { font-size: 12px; color: var(--muted); line-height: 1.6; }
.iv-pill {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 12px; margin: 0 16px 8px; font-size: 13px; line-height: 1.5;
  display: flex; align-items: flex-start; gap: 8px;
}
.iv-arrow { color: var(--gold); font-weight: 700; flex-shrink: 0; }

/* ---------- journal ---------- */
.j-new { padding: 0 16px 4px; }
.j-dim-row { display: flex; gap: 8px; margin-bottom: 10px; }
.j-dim-btn {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center;
  font-family: 'DM Serif Display', serif; font-size: 14px; cursor: pointer;
  border: 2px solid var(--border); background: var(--card); color: var(--muted);
  transition: all .15s;
}
.j-dim-btn.active { border-color: transparent; }
.j-entry { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin: 0 16px 10px; }
.j-date { font-size: 11px; color: var(--muted); margin-bottom: 6px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.j-badge { padding: 2px 8px; border-radius: 10px; font-size: 10px; font-weight: 600; }
.j-text { font-size: 13px; line-height: 1.6; white-space: pre-wrap; }
.j-empty { padding: 16px 20px; font-size: 13px; color: var(--muted); }

/* ---------- badges ---------- */
.badge-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 0 16px 12px; }
.badge-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
}
.badge-card.earned { border-color: var(--gold); }
.badge-card.locked { opacity: .4; filter: grayscale(1); }
.badge-icon { font-size: 30px; line-height: 1; }
.badge-name { font-size: 12px; font-weight: 600; }
.badge-desc { font-size: 11px; color: var(--muted); line-height: 1.4; }

/* ---------- buddy ---------- */
.buddy-name-card { background: var(--navy); border-radius: var(--radius); padding: 16px; margin: 12px 16px; display: flex; align-items: center; gap: 12px; }
.buddy-avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--gold); color: var(--navy); font-family: 'DM Serif Display', serif; font-size: 16px; display: grid; place-items: center; flex-shrink: 0; }
.buddy-name-txt { font-size: 15px; color: #fff; font-weight: 500; }
.buddy-name-sub { font-size: 12px; color: rgba(255,255,255,.55); margin-top: 2px; }
.buddy-edit-btn {
  margin-left: auto; background: rgba(255,255,255,.15); border: none; border-radius: var(--radius-sm);
  padding: 6px 12px; color: #fff; font-family: inherit; font-size: 12px; cursor: pointer; white-space: nowrap;
}
.buddy-q { font-size: 13px; line-height: 1.6; padding: 10px 0; border-bottom: 1px solid var(--border); display: flex; gap: 10px; align-items: flex-start; }
.buddy-q:last-child { border-bottom: none; padding-bottom: 0; }
.buddy-q-num { width: 22px; height: 22px; border-radius: 50%; background: var(--navy); color: #fff; font-size: 11px; font-weight: 600; display: grid; place-items: center; flex-shrink: 0; margin-top: 1px; }

/* ---------- pulse ---------- */
.pulse-date { font-size: 11px; color: rgba(255,255,255,.4); margin-top: 6px; }
.pulse-intro { padding: 12px 16px 4px; font-size: 13px; color: var(--muted); line-height: 1.6; }
.pulse-start { width: calc(100% - 32px); margin: 12px 16px; padding: 14px; font-size: 14px; }
.pulse-save-wrap { padding: 0 16px 16px; }
.pulse-dim { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); margin: 0 16px 12px; overflow: hidden; }
.pulse-dim-header { display: flex; align-items: center; gap: 12px; padding: 14px 16px; cursor: pointer; }
.pulse-dim-header:active { background: var(--bg); }
.pulse-dim-name { font-size: 14px; font-weight: 500; }
.pulse-dim-arrow { margin-left: auto; color: var(--muted); font-size: 14px; transition: transform .2s; }
.pulse-dim-arrow.open { transform: rotate(180deg); }
.pulse-dim-body { padding: 0 16px 14px; }
.pulse-leitfrage {
  font-size: 12px; color: var(--muted); line-height: 1.6; margin-bottom: 12px;
  padding: 10px 12px; background: var(--bg); border-radius: var(--radius-sm);
  border-left: 3px solid var(--gold);
}
.pulse-label { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 10px 0 6px; }
.pulse-ta { min-height: 70px; font-size: 13px; }

/* ---------- nav ---------- */
.nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 420px; z-index: 100;
  background: #fff; border-top: 1px solid var(--border);
  display: flex; padding: 6px 0 calc(10px + env(safe-area-inset-bottom));
}
.nav-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: none; border: none; cursor: pointer; font-family: inherit; font-size: 10px;
  color: var(--muted); padding: 4px 0;
}
.nav-btn.active { color: var(--navy); font-weight: 600; }
.nav-btn svg { width: 22px; height: 22px; stroke-width: 1.6; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- celebration ---------- */
.celebration {
  position: fixed; inset: 0; z-index: 600; background: rgba(10,37,100,.85);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  animation: fadeInOut 2.2s ease forwards;
}
@keyframes fadeInOut { 0% { opacity: 0 } 15% { opacity: 1 } 75% { opacity: 1 } 100% { opacity: 0 } }
.cel-emoji { font-size: 72px; animation: bounce .4s ease infinite alternate; }
@keyframes bounce { from { transform: scale(1) } to { transform: scale(1.15) } }
.cel-text { font-family: 'DM Serif Display', serif; font-size: 24px; color: #fff; margin-top: 16px; text-align: center; padding: 0 32px; }
.cel-sub { font-size: 14px; color: rgba(255,255,255,.65); margin-top: 8px; }

@media (prefers-reduced-motion: reduce) {
  .celebration, .cel-emoji { animation: none; }
  .level-fill { transition: none; }
}

/* ---------- modal ---------- */
.modal-overlay { position: fixed; inset: 0; z-index: 500; background: rgba(10,37,100,.5); display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal { background: #fff; border-radius: var(--radius); padding: 24px; width: 100%; max-width: 340px; box-shadow: 0 8px 32px rgba(10,37,100,.2); }
.modal-title { font-family: 'DM Serif Display', serif; font-size: 20px; color: var(--navy); margin-bottom: 8px; }
.modal-sub { font-size: 13px; color: var(--muted); margin-bottom: 16px; line-height: 1.5; }
.modal-input { width: 100%; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; font-family: inherit; font-size: 15px; color: var(--text); outline: none; margin-bottom: 12px; }
.modal-input:focus { border-color: var(--navy); }
.modal-btn-row { display: flex; gap: 8px; }
.modal-btn { flex: 1; padding: 12px; border-radius: var(--radius-sm); border: none; font-family: inherit; font-size: 14px; font-weight: 500; cursor: pointer; }
.modal-btn-primary { background: var(--navy); color: #fff; }
.modal-btn-secondary { background: var(--bg); color: var(--muted); }
.modal-extra { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.iv-log { max-height: 300px; overflow-y: auto; }
.iv-log-item { padding: 10px 0; border-bottom: 1px solid var(--border); display: flex; align-items: flex-start; gap: 10px; }
.iv-log-item:last-child { border-bottom: none; }
.iv-log-text { font-size: 13px; line-height: 1.5; flex: 1; }
.iv-log-date { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 12px); z-index: 700;
  background: var(--navy); color: #fff; padding: 10px 16px; border-radius: 999px;
  font-size: 13px; max-width: 90vw; box-shadow: 0 4px 16px rgba(10,37,100,.25);
}

/* ---------- wider screens ----------
   The prototype had two media queries whose opening lines were lost, leaving
   orphaned braces and dead rules. Restored as a single tablet/desktop breakpoint. */
@media (min-width: 700px) {
  body { max-width: 640px; }
  .nav { max-width: 640px; border-radius: var(--radius) var(--radius) 0 0; }
  .dash-grid, .badge-grid { grid-template-columns: repeat(4, 1fr); }
  .nav-btn { font-size: 12px; }
  .nav-btn svg { width: 24px; height: 24px; }
}
