/* Pieces used by the tracker, journal, analysis, chat, map, stats, activities and settings. */

.grow {
  flex: 1 1 auto;
  min-width: 0;
}

.row-end {
  justify-content: flex-end;
}

.plain-fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.plain-fieldset legend {
  margin-bottom: 8px;
  padding: 0;
}

.split {
  display: grid;
  gap: 16px;
  align-items: start;
}

@media (min-width: 900px) {
  .split {
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  }

  .split-wide {
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  }
}

.notice {
  margin-bottom: 16px;
  padding: 12px 16px;
  border-radius: 18px;
  background: var(--grad-reflection);
  color: var(--ink-soft);
  font-size: 14px;
}

/* ---------- inputs ---------- */

.input-short {
  min-height: 90px;
}

.input-date,
.input-time {
  width: auto;
  min-height: 44px;
  padding: 6px 12px;
}

.color-input {
  width: 56px;
  height: 44px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-solid);
  cursor: pointer;
}

.range {
  width: 100%;
  min-height: 32px;
  accent-color: var(--emo, var(--accent));
}

.slider-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px 12px;
  align-items: center;
}

.slider-row label {
  font-size: 14px;
  color: var(--ink-soft);
}

@media (min-width: 640px) {
  .slider-row {
    grid-template-columns: minmax(0, 14rem) 1fr 2ch;
  }
}

.disclosure > summary {
  display: flex;
  align-items: center;
  min-height: 44px;
  color: var(--accent-strong);
  font-weight: 600;
  cursor: pointer;
}

.disclosure[open] > summary {
  margin-bottom: 12px;
}

.chip-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  margin-right: -6px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgb(0 0 0 / 0.08);
  color: inherit;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

.chip-x:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.chip-tone {
  background: var(--grad-mint);
}

.chip-muted {
  background: var(--well);
  color: var(--muted);
}

.chip-crisis {
  background: var(--danger-soft);
  color: var(--danger);
}

.filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
}

.filters-search,
.filters-actions {
  grid-column: 1 / -1;
}

@media (min-width: 900px) {
  .filters {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }

  .filters-search {
    grid-column: span 2;
  }

  .filters-actions {
    grid-column: auto;
  }
}

.segmented {
  display: inline-flex;
  padding: 3px;
  border-radius: var(--radius-pill);
  background: var(--well);
}

.segmented button,
.segmented a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  text-decoration: none;
  padding: 0 16px;
  border: 0;
  border-radius: var(--radius-pill);
  background: none;
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
}

.segmented [aria-pressed="true"] {
  background: var(--surface-solid);
  color: var(--ink);
  box-shadow: 0 2px 6px rgb(37 35 74 / 0.12);
}

/* a switch made from a checkbox */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.switch {
  appearance: none;
  position: relative;
  flex: none;
  width: 52px;
  height: 30px;
  margin: 0;
  border-radius: var(--radius-pill);
  background: var(--line);
  cursor: pointer;
  transition: background-color 0.2s;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--surface-solid);
  box-shadow: 0 1px 4px rgb(0 0 0 / 0.2);
  transition: transform 0.2s;
}

.switch:checked {
  background: var(--accent);
}

.switch:checked::after {
  transform: translateX(22px);
}

.switch:disabled,
fieldset:disabled .switch,
fieldset:disabled .input {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---------- dialog and tour ---------- */

.dialog {
  width: min(460px, calc(100vw - 32px));
  padding: 24px;
  border: 1px solid var(--surface-edge);
  border-radius: var(--radius-card);
  background: var(--surface-solid);
  color: var(--ink);
  box-shadow: var(--shadow-lift);
  animation: pop 0.3s ease-out backwards;
}

.dialog::backdrop {
  background: rgb(20 19 43 / 0.45);
  backdrop-filter: blur(3px);
}

.tour {
  text-align: center;
}

.tour .row-between {
  flex-wrap: wrap;
}

.tour-logo {
  width: 64px;
  height: 64px;
  margin: 0 auto;
  border-radius: 50%;
  background: var(--grad-logo);
}

.tour-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
}

.tour-dots i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--line);
  transition:
    background-color 0.2s,
    width 0.2s;
}

.tour-dots i.on {
  width: 22px;
  border-radius: 4px;
  background: var(--accent);
}

/* ---------- calendar ---------- */

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.cal-head {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
}

.cal-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  border-radius: 12px;
  background: var(--well);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.cal-blank {
  background: none;
}

.cal-has {
  background: color-mix(in srgb, var(--accent) calc(var(--level, 3) * 18%), var(--surface-solid));
  color: var(--ink);
}

.cal-has.cal-strong {
  color: var(--on-accent);
}

.cal-today {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.history-item {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ---------- journal ---------- */

.entry-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 800;
}

.entry-body {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 1.05rem;
  line-height: 1.7;
}

/* ---------- analysis ---------- */

.analysis h3 {
  font-size: 1rem;
}

.dots {
  display: flex;
  gap: 3px;
}

.dots i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--ink) 18%, transparent);
}

.dots i.on {
  background: var(--ink-soft);
}

.suggestions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.suggestions li {
  display: flex;
  gap: 12px;
}

.suggestion-dot {
  flex: none;
  width: 12px;
  height: 12px;
  margin-top: 7px;
  border-radius: 50%;
  background: var(--grad-primary);
}

.confirm {
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.summary-text {
  font-size: 1.05rem;
  line-height: 1.7;
}

/* ---------- assistant ---------- */

.chat-layout {
  display: grid;
  gap: 16px;
}

@media (min-width: 900px) {
  .chat-layout {
    grid-template-columns: 280px minmax(0, 1fr);
    align-items: start;
  }
}

.chat-list .crisis a {
  color: var(--ink);
  font-weight: 600;
}

.convo-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.convo {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  min-height: 44px;
  padding: 8px 12px;
  border: 0;
  border-radius: 14px;
  background: none;
  text-align: left;
  cursor: pointer;
}

.convo:hover {
  background: var(--well);
}

.convo[aria-current="true"] {
  background: var(--accent-soft);
}

.chat {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 60vh;
}

.messages {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 10px;
  max-height: 60vh;
  overflow-y: auto;
  padding: 4px;
}

.msg {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 20px;
}

.msg-user {
  align-self: flex-end;
  border-bottom-right-radius: 6px;
  background: var(--grad-primary);
  color: var(--on-accent);
}

.msg-bot {
  align-self: flex-start;
  border-bottom-left-radius: 6px;
  background: var(--well);
}

.msg-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.msg-time {
  font-size: 11px;
  opacity: 0.75;
}

.msg-card {
  max-width: 100%;
}

.typing {
  display: flex;
  gap: 5px;
  padding: 10px 14px;
}

.typing .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  animation: pulse 1.2s ease-in-out infinite;
}

.typing .dot:nth-child(2) {
  animation-delay: 0.2s;
}

.typing .dot:nth-child(3) {
  animation-delay: 0.4s;
}

.chat-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.chat-form textarea {
  min-height: 52px;
  resize: none;
}

/* ---------- mood map ---------- */

.wheel-wrap {
  display: flex;
  justify-content: center;
}

.wheel {
  width: 100%;
  max-width: 340px;
  height: auto;
}

.wheel-skeleton {
  width: 280px;
  height: 280px;
  border-radius: 50%;
}

.wheel-ring {
  fill: none;
  stroke: var(--line);
  stroke-dasharray: 2 5;
}

.wheel-slice {
  stroke: var(--surface-solid);
  stroke-width: 2;
  cursor: pointer;
  transform-box: view-box;
  transform-origin: 50% 50%;
  transition:
    transform 0.2s,
    opacity 0.2s;
  animation: pop 0.6s cubic-bezier(0.2, 0.8, 0.3, 1) backwards;
}

.wheel-slice:hover,
.wheel-slice:focus-visible,
.wheel-slice[aria-pressed="true"] {
  transform: scale(1.05);
}

.wheel:has([aria-pressed="true"]) .wheel-slice:not([aria-pressed="true"]) {
  opacity: 0.55;
}

.wheel-slice:focus-visible {
  outline: none;
  stroke: var(--ink);
  stroke-width: 3;
}

.wheel-center {
  fill: var(--ink-soft);
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 800;
}

.freq {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.freq-row {
  display: grid;
  grid-template-columns: 28px minmax(0, 7rem) 1fr 3ch;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 44px;
  padding: 4px 8px;
  border: 0;
  border-radius: 14px;
  background: none;
  text-align: left;
  cursor: pointer;
}

.freq-row:hover,
.freq-row[aria-pressed="true"] {
  background: var(--accent-soft);
}

.freq-name {
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.freq-bar,
.bar {
  height: 10px;
  overflow: hidden;
  border-radius: 6px;
  background: var(--well);
}

.freq-bar i,
.bar i {
  display: block;
  height: 100%;
  border-radius: 6px;
  background: var(--grad-primary);
  transition: width 0.6s ease;
}

.freq-count,
.bar-value {
  font-weight: 700;
  text-align: right;
}

.bars {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(0, 6.5rem) 1fr 3ch;
  gap: 10px;
  align-items: center;
  font-size: 14px;
}

.delta {
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 700;
}

.delta-up {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.delta-down {
  background: var(--success-soft);
  color: var(--success);
}

.chart-box {
  position: relative;
  height: 240px;
}

/* ---------- stats ---------- */

.kpis {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
}

@media (min-width: 900px) {
  .kpis {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.kpi dt {
  color: var(--muted);
  font-size: 13px;
}

.kpi dd {
  margin: 4px 0 0;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 800;
}

.corr-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
}

@media (min-width: 640px) {
  .corr-row {
    grid-template-columns: minmax(0, 10rem) 6rem 1fr;
    align-items: center;
    gap: 12px;
  }
}

.corr-meter {
  height: 8px;
  overflow: hidden;
  border-radius: 4px;
  background: var(--well);
}

.corr-meter i {
  display: block;
  height: 100%;
  background: var(--emo-calm);
}

.corr-meter i.neg {
  background: var(--emo-stress);
}

/* ---------- activities ---------- */

.scale {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.scale-option {
  position: relative;
}

.scale-option input {
  position: absolute;
  opacity: 0;
}

.scale-option span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border-radius: 14px;
  background: var(--well);
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.2s;
}

.scale-option input:checked + span {
  background: var(--grad-primary);
  color: var(--on-accent);
}

.scale-option input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.breath {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
}

.breath-circle {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: var(--grad-mint);
  box-shadow: 0 0 0 12px color-mix(in srgb, var(--emo-calm) 20%, transparent);
  transform: scale(0.6);
  transition: transform var(--breath-ms, 4000ms) ease-in-out;
}

.breath-circle[data-phase="inhale"],
.breath-circle[data-phase="hold"] {
  transform: scale(1);
}

.breath-circle[data-phase="exhale"] {
  transform: scale(0.6);
}

.breath-label {
  min-height: 1.6em;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 800;
}

@media (prefers-reduced-motion: reduce) {
  .breath-circle,
  .breath-circle[data-phase="exhale"] {
    transform: scale(0.8);
  }

  .breath-circle[data-phase="inhale"],
  .breath-circle[data-phase="hold"] {
    transform: scale(0.8);
    box-shadow: 0 0 0 24px color-mix(in srgb, var(--emo-calm) 45%, transparent);
  }
}

.goal {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
}

.goal input {
  flex: none;
  width: 22px;
  height: 22px;
  accent-color: var(--accent);
}

.goal label {
  flex: 1;
}

.goal-done label {
  color: var(--muted);
  text-decoration: line-through;
}

.timer-face {
  display: flex;
  align-items: center;
  gap: 12px;
}

#timer-time {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.prompt {
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.prompt:last-child {
  border-bottom: 0;
}

/* ---------- settings ---------- */

.settings-nav {
  margin-bottom: 16px;
}

.settings-nav a {
  text-decoration: none;
}

#settings > section,
#breathe {
  scroll-margin-top: 112px;
}

.inbox-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--well);
}

.inbox-item.unread {
  background: var(--accent-soft);
  font-weight: 600;
}

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

.error-page {
  max-width: 560px;
  margin: 32px auto;
}

/* ---------- emotional weather and the chat log card ---------- */

.weather {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.05rem;
}

.weather .label {
  color: var(--ink-soft);
}

.weather-icon {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

.weather-sunny {
  background: radial-gradient(circle, #ffd25e 0 45%, rgb(255 210 94 / 0.35) 46% 100%);
}

.weather-partly {
  background:
    radial-gradient(circle at 70% 70%, #ffffff 0 30%, transparent 31%),
    radial-gradient(circle at 35% 35%, #ffd25e 0 38%, rgb(255 210 94 / 0.3) 39% 100%);
}

.weather-cloudy {
  background:
    radial-gradient(circle at 35% 60%, #c9cfdd 0 30%, transparent 31%),
    radial-gradient(circle at 65% 50%, #b5bccc 0 34%, transparent 35%);
}

.weather-rainy {
  background:
    radial-gradient(circle at 50% 40%, #9aa6bd 0 36%, transparent 37%),
    repeating-linear-gradient(110deg, transparent 0 7px, #6c8fd6 7px 9px) bottom / 100% 40% no-repeat;
}

.weather-none {
  background: var(--well);
}

.log-card {
  align-self: stretch;
  max-width: 100%;
  border: 1px dashed var(--line);
  background: var(--surface-solid);
  box-shadow: none;
}

.log-card dl {
  display: grid;
  gap: 6px;
  margin: 0;
}

.log-card dt {
  color: var(--muted);
  font-size: 13px;
}

.log-card dd {
  margin: 0;
}

/* ---------- quick check-in ---------- */

.quick-fab {
  position: fixed;
  right: 16px;
  bottom: calc(88px + env(safe-area-inset-bottom, 0px));
  z-index: 21;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  padding: 0 18px;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--grad-primary);
  color: var(--on-accent);
  font: 700 0.95rem var(--font-body);
  box-shadow: var(--shadow-lift);
  cursor: pointer;
}

.quick-fab:focus-visible {
  outline: 3px solid var(--accent-strong);
  outline-offset: 3px;
}

@media (min-width: 1100px) {
  .quick-fab {
    bottom: 24px;
    right: 24px;
  }
}

.quick-dialog .moodrow {
  flex-wrap: nowrap;
}

.quick-dialog .chips .chip[aria-pressed="true"] {
  background: color-mix(in srgb, var(--emo) 30%, var(--surface-solid));
  outline: 2px solid var(--emo);
}

.quick-actions .btn {
  flex: 1;
  min-height: 48px;
}

.streak {
  margin: 0;
}

/* ---------- install offer ---------- */

.install-offer {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(150px + env(safe-area-inset-bottom, 0px));
  z-index: 22;
  max-width: 420px;
  margin: 0 auto;
  padding: 14px 16px;
}

@media (min-width: 1100px) {
  .install-offer {
    bottom: 90px;
    left: auto;
  }
}

/* ---------- insights ---------- */

.insight-text {
  font-weight: 600;
}

.confidence-low {
  background: var(--well);
}

.confidence-ok {
  background: var(--accent-soft);
}

.confidence-good {
  background: var(--success-soft);
}

.evidence {
  display: grid;
  gap: 6px;
}

.evidence-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(60px, 1.2fr) auto;
  gap: 8px;
  align-items: center;
}

.evidence .bar {
  display: block;
  height: 8px;
  border-radius: var(--radius-pill);
  background: var(--well);
  overflow: hidden;
}

.evidence .bar-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--grad-primary);
}

/* ---------- experiments ---------- */

.suggestion {
  align-items: center;
  flex-wrap: wrap;
}

.suggestion.is-wanted {
  outline: 2px solid var(--accent);
  outline-offset: 6px;
  border-radius: 8px;
}

.days {
  border: 0;
  margin: 0;
  padding: 0;
}

.day-checks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 6px;
  margin-top: 6px;
}

.day-check {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-height: 56px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: var(--radius-field);
  font-size: 0.85rem;
  cursor: pointer;
}

.day-check input {
  width: 22px;
  height: 22px;
  accent-color: var(--accent);
}

.day-check:has(input:checked) {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.day-check.is-future {
  opacity: 0.5;
  cursor: default;
}

.result {
  padding: 12px;
  border-radius: var(--radius-field);
  background: var(--well);
}

/* ---------- school events ---------- */

.cal-event {
  position: relative;
}

.cal-event::after {
  content: "";
  position: absolute;
  top: 3px;
  right: 3px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--event, var(--accent));
}

.cal-event-exam,
.cal-key.cal-event-exam {
  --event: var(--danger);
}

.cal-event-test,
.cal-key.cal-event-test {
  --event: var(--accent-strong);
}

.cal-event-matura,
.cal-key.cal-event-matura {
  --event: var(--emo-anger);
}

.cal-event-deadline,
.cal-key.cal-event-deadline {
  --event: var(--emo-excitement);
}

.cal-event-other,
.cal-key.cal-event-other {
  --event: var(--muted);
}

.cal-key {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-left: 8px;
  border-radius: 50%;
  background: var(--event);
  vertical-align: middle;
}

.school summary {
  cursor: pointer;
  padding: 6px 0;
}

.school-form {
  display: grid;
  gap: 10px;
}

@media (min-width: 560px) {
  .school-form {
    grid-template-columns: auto auto minmax(0, 1fr) auto;
    align-items: end;
  }
}

.switch-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  cursor: pointer;
}

/* plain checkboxes only: the .switch size must not be overridden */
.switch-row input[type="checkbox"]:not(.switch) {
  width: 22px;
  height: 22px;
  margin-top: 2px;
  accent-color: var(--accent);
}

/* ---------- share image ---------- */

.share-dialog {
  max-width: min(520px, calc(100vw - 32px));
}

.share-canvas {
  width: 100%;
  height: auto;
  border-radius: var(--radius-field);
  box-shadow: var(--shadow-card);
}

/* ---------- offline ---------- */

.offline-card {
  max-width: 520px;
  margin: 10vh auto;
}

/* ---------- app lock ---------- */

.lock-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 16px;
  background: var(--bg);
}

.lock-form {
  width: min(360px, 100%);
}

.pin-input {
  max-width: 220px;
  font-size: 1.4rem;
  letter-spacing: 0.4em;
}

body.is-locked {
  overflow: hidden;
}

.why {
  margin-top: 4px;
}
