/* ═══════════════════════════════════════════════════════════════════
   CalmSignal Web-Companion · Stylesheet
   Visuelle Sprache stimmt mit Native-App (app-demo) überein.
   ═══════════════════════════════════════════════════════════════════ */

:root {
  /* Basis (synchron mit styles.css) */
  --ink: #17211f;
  --ink-strong: #0c1413;
  --muted: #55615d;
  --paper: #fbfaf7;
  --surface: #ffffff;
  --mist: #eef4f0;
  --line: rgba(23, 33, 31, 0.14);
  --line-strong: rgba(23, 33, 31, 0.22);
  --shadow-sm: 0 4px 12px rgba(13, 35, 33, 0.06);
  --shadow-md: 0 12px 32px rgba(13, 35, 33, 0.10);
  --shadow-lg: 0 24px 60px rgba(10, 28, 27, 0.18);

  /* Native-App-Farben (1:1 aus app-demo) */
  --teal: #2eb6a0;
  --teal-dark: #0f6b68;
  --teal-deep: #093f45;
  --coral: #d96550;
  --yellow: #f1c40f;
  --orange: #e67e22;
  --red: #e74c3c;
  --green: #2eb6a0;
  --gold: #c8a24a;

  /* Layout */
  --header-h: 64px;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
img { max-width: 100%; }

h1, h2, h3, p { overflow-wrap: anywhere; }

/* ═══ Demo-Banner ═══ */
.demo-banner {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 22px;
  background: linear-gradient(90deg, var(--coral), #e58a76);
  color: #fff;
  font-weight: 700;
  font-size: 0.92rem;
  letter-spacing: 0.01em;
}
.demo-banner strong { font-weight: 800; }
.demo-banner span { font-weight: 600; }
.demo-banner-cta {
  margin-left: auto;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.42);
  color: #fff;
  font-weight: 700;
}
.demo-banner-cta:hover { background: rgba(255, 255, 255, 0.28); }

/* ═══ Header ═══ */
.companion-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 24px;
  height: var(--header-h);
  padding: 0 clamp(18px, 3.5vw, 36px);
  border-bottom: 1px solid var(--line);
  background: rgba(251, 250, 247, 0.92);
  backdrop-filter: blur(18px);
}
.demo-banner:not([hidden]) + .companion-header { top: 0; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1rem;
}
.brand-mark {
  width: 20px; height: 20px; border-radius: 50%;
  background:
    radial-gradient(circle at 55% 45%, #fff 0 17%, transparent 18%),
    conic-gradient(from 210deg, var(--coral), var(--gold), var(--teal), var(--coral));
  box-shadow: 0 0 0 3px rgba(15, 107, 104, 0.12);
}
.brand-tag {
  margin-left: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(46, 182, 160, 0.14);
  color: var(--teal-dark);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.top-nav {
  display: flex;
  justify-content: center;
  gap: 4px;
  flex-wrap: wrap;
}
.nav-tab {
  min-height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease;
}
.nav-tab:hover { color: var(--ink); background: rgba(23, 33, 31, 0.04); }
.nav-tab.is-active {
  background: var(--ink);
  color: #fff;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.site-links {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding-right: 10px;
  border-right: 1px solid var(--line);
  margin-right: 4px;
}
.site-links .ghost-link {
  font-size: 0.82rem;
  padding: 0 10px;
  min-height: 32px;
}
.site-links .ghost-link span[aria-hidden] {
  margin-right: 2px;
  font-size: 0.78rem;
}
.brand { cursor: pointer; }
.brand:hover { opacity: 0.85; }
.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(46, 182, 160, 0.12);
  color: var(--teal-dark);
  font-weight: 700;
  font-size: 0.84rem;
}
.user-pill > span:first-child {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--teal);
  font-size: 0;
}
.ghost-link {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.6);
  color: var(--ink);
  font-weight: 700;
  font-size: 0.86rem;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.ghost-link:hover { border-color: var(--line-strong); }
.logout-form { margin: 0; }

/* ═══ Main ═══ */
.companion-main {
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(24px, 4vw, 48px) clamp(18px, 4vw, 36px) 96px;
}

.page-heading {
  max-width: 760px;
  margin-bottom: 28px;
}
.page-heading h1 {
  margin: 6px 0 12px;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.05;
  letter-spacing: -0.01em;
  font-weight: 850;
}
.page-lead {
  margin: 0;
  color: var(--muted);
  font-size: clamp(1rem, 1.6vw, 1.12rem);
  line-height: 1.55;
}
.eyebrow {
  margin: 0 0 4px;
  color: var(--coral);
  font-size: 0.74rem;
  font-weight: 850;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.plan-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  max-width: none;
}

/* ═══ Welcome ═══ */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 32px;
}
.qa-card {
  display: grid;
  gap: 6px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  text-align: left;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
  box-shadow: var(--shadow-sm);
}
.qa-card:hover {
  transform: translateY(-2px);
  border-color: var(--teal);
  box-shadow: var(--shadow-md);
}
.qa-icon {
  font-size: 1.8rem;
  margin-bottom: 4px;
}
.qa-card strong {
  font-size: 1.04rem;
  font-weight: 800;
}
.qa-card span {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}

.native-banner {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 28px;
  padding: 28px 32px;
  margin-bottom: 24px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(46, 182, 160, 0.12), rgba(15, 107, 104, 0.06));
  border: 1px solid rgba(46, 182, 160, 0.22);
}
.native-banner h2 {
  margin: 4px 0 8px;
  font-size: 1.4rem;
  line-height: 1.2;
}
.native-banner p { margin: 0; color: var(--muted); max-width: 560px; }
.native-banner-actions {
  display: grid;
  gap: 10px;
  justify-items: end;
  text-align: right;
}
.native-banner-note {
  color: var(--muted);
  font-size: 0.84rem;
}

.mood-inline {
  padding: 18px 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
}
.mood-note {
  margin: 10px 0 0;
  color: var(--teal-dark);
  font-weight: 700;
}

/* ═══ Mood-Pills ═══ */
.mood-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.mood-row-compact { gap: 6px; }
.mood-pill {
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-weight: 700;
  font-size: 0.94rem;
  cursor: pointer;
  transition: border-color 140ms, background 140ms;
}
.mood-pill:hover { border-color: var(--teal); }
.mood-pill.is-selected {
  border-color: var(--teal);
  background: rgba(46, 182, 160, 0.12);
  color: var(--teal-dark);
}

/* ═══ Check-in Form (CS-PARALLEL-C) ═══ */
.checkin-inline {
  margin-top: 18px;
  padding: 22px 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.checkin-inline h3 {
  margin: 4px 0 6px;
  font-size: 1.25rem;
}
.checkin-lead {
  color: var(--muted);
  font-size: 0.92rem;
  margin: 0 0 18px;
}
.checkin-field {
  margin-bottom: 16px;
}
.checkin-field-label {
  display: block;
  font-size: 0.88rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--ink);
}
.checkin-field input[type="range"] {
  width: 100%;
  accent-color: var(--teal);
}
.checkin-field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.94rem;
  resize: vertical;
  background: var(--bg);
}
.checkin-field textarea:focus {
  outline: none;
  border-color: var(--teal);
}
.checkin-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 12px;
}
.checkin-actions .primary-cta:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.checkin-status {
  margin: 10px 0 0;
  font-size: 0.88rem;
  min-height: 1.2em;
}
.checkin-status.is-ok { color: var(--teal-dark); font-weight: 700; }
.checkin-status.is-error { color: var(--red); font-weight: 700; }

/* History: Eigene Check-ins chart variants */
.chart .bar.mood-0 { background: var(--red); }
.chart .bar.mood-1 { background: var(--yellow); }
.chart .bar.mood-2 { background: #2ecc71; }
.chart .bar[title] { cursor: help; }
.checkin-empty {
  grid-column: 1 / -1;
  padding: 40px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.5;
}
.checkin-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  margin: 14px 4px 0;
  font-size: 0.84rem;
  color: var(--muted);
}
.checkin-legend i.dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}
.checkin-legend i.dot-green { background: #2ecc71; }
.checkin-legend i.dot-yellow { background: var(--yellow); }
.checkin-legend i.dot-red { background: var(--red); }
.checkin-legend .legend-hint {
  margin-left: auto;
  font-style: italic;
}

/* ═══ Dashboard ═══ */
.dash-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  grid-auto-rows: auto;
  gap: 16px;
  margin-bottom: 24px;
}
.dash-card {
  padding: 22px 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.risk-card { grid-row: span 2; }

.risk-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.risk-ball {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--teal);
  flex-shrink: 0;
}
.risk-card.risk-yellow .risk-ball { background: var(--yellow); }
.risk-card.risk-orange .risk-ball { background: var(--orange); }
.risk-card.risk-red .risk-ball { background: var(--red); }

.risk-card.risk-green { background: rgba(46, 182, 160, 0.07); }
.risk-card.risk-yellow { background: rgba(241, 196, 15, 0.08); }
.risk-card.risk-orange { background: rgba(230, 126, 34, 0.08); }
.risk-card.risk-red { background: rgba(231, 76, 60, 0.10); }

.risk-label {
  font-size: 1.4rem;
  font-weight: 850;
}
.risk-score {
  margin-left: auto;
  font-size: 0.86rem;
  color: var(--muted);
  font-weight: 700;
}
.risk-copy {
  margin: 8px 0 16px;
  color: var(--ink);
  font-size: 0.96rem;
}
.risk-signals {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  margin: 0 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--line);
  overflow: hidden;
}
.risk-signals > div {
  display: flex;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--surface);
  font-size: 0.86rem;
}
.risk-signals dt { color: var(--muted); }
.risk-signals dd { margin: 0; font-weight: 800; font-family: ui-monospace, "SF Mono", monospace; font-size: 0.84rem; }
.data-source-hint {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.card-head h3 {
  margin: 0;
  font-size: 1.04rem;
  font-weight: 800;
}
.card-icon { font-size: 1.1rem; }
.card-meta {
  margin: 0 0 12px;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.9rem;
}
.card-copy {
  margin: 12px 0 0;
  font-size: 0.86rem;
  color: var(--muted);
  line-height: 1.5;
}

.progress {
  height: 6px;
  background: rgba(23, 33, 31, 0.08);
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  display: block;
  height: 100%;
  background: var(--teal);
}

.source-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 4px;
}
.source-list li {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 4px;
  font-size: 0.9rem;
  border-bottom: 1px solid rgba(23, 33, 31, 0.06);
}
.source-list li:last-child { border-bottom: 0; }
.status-ok { color: var(--teal-dark); font-weight: 800; font-size: 0.78rem; }
.status-off { color: var(--muted); font-weight: 700; font-size: 0.78rem; }

.info-strip {
  display: flex;
  gap: 12px;
  padding: 14px 18px;
  border-left: 4px solid var(--coral);
  background: rgba(217, 101, 80, 0.08);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--ink);
  font-size: 0.9rem;
}
.info-strip strong { color: var(--coral); }

/* ═══ Plan ═══ */
.plan-overview {
  display: grid;
  gap: 14px;
  margin-bottom: 28px;
}
.plan-overview .contact-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
}
.avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: rgba(46, 182, 160, 0.16);
  display: grid; place-items: center;
  font-size: 1.2rem;
}
.contact-info { flex: 1; }
.contact-info strong { display: block; font-size: 1rem; }
.contact-info small { color: var(--muted); font-size: 0.82rem; }
.link-action {
  border: 0;
  background: transparent;
  color: var(--teal-dark);
  font-weight: 800;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dashed;
  text-underline-offset: 3px;
}
.link-action:hover { color: var(--teal); }

.stage-card {
  padding: 18px 22px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 6px solid currentColor;
}
.stage-yellow { color: var(--yellow); }
.stage-orange { color: var(--orange); }
.stage-red { color: var(--red); }

.stage-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  color: var(--ink);
}
.stage-head h3 {
  margin: 0;
  font-size: 1.06rem;
  font-weight: 800;
}
.stage-ball {
  width: 12px; height: 12px; border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.stage-yellow .stage-ball { background: var(--yellow); }
.stage-orange .stage-ball { background: var(--orange); }
.stage-red .stage-ball { background: var(--red); }
.stage-range {
  margin-left: auto;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 700;
}
.stage-desc {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.92rem;
}
.stage-actions {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}
.stage-actions li {
  position: relative;
  padding-left: 22px;
  font-size: 0.92rem;
  color: var(--ink);
}
.stage-actions li::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: var(--teal);
  font-weight: 800;
}
.stage-actions li.is-off {
  color: var(--muted);
  text-decoration: line-through;
}
.stage-actions li.is-off::before {
  color: rgba(23, 33, 31, 0.2);
  content: "○";
}
.auto-trigger-pill {
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.auto-trigger-pill.on { background: rgba(231, 76, 60, 0.14); color: #b54035; }
.auto-trigger-pill.off { background: rgba(23, 33, 31, 0.08); color: var(--muted); }

/* Plan-Editor */
.plan-editor {
  margin-bottom: 28px;
  padding: 22px 24px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}
.editor-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.editor-head h2 { margin: 0; font-size: 1.3rem; }

.editor-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: var(--radius-sm);
  background: rgba(23, 33, 31, 0.05);
  margin-bottom: 18px;
}
.editor-tab {
  flex: 1;
  min-height: 38px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.editor-tab.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.dot-yellow { background: var(--yellow); }
.dot-orange { background: var(--orange); }
.dot-red { background: var(--red); }

.editor-panel {
  display: grid;
  gap: 4px;
  padding-bottom: 6px;
}
.action-row {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid rgba(23, 33, 31, 0.06);
  cursor: pointer;
}
.action-row:last-child { border-bottom: 0; }
.action-row input[type="checkbox"] {
  width: 18px; height: 18px;
  margin-top: 2px;
  accent-color: var(--teal);
}
.action-row .action-text strong {
  display: block;
  font-size: 0.96rem;
  font-weight: 800;
}
.action-row .action-text small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.4;
}
.action-row .action-tag {
  margin-top: 4px;
  font-size: 0.7rem;
  color: var(--teal-dark);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.editor-red-extra {
  padding: 14px 0 4px;
  border-top: 1px solid var(--line);
  margin-top: 8px;
}
.danger-row {
  background: rgba(231, 76, 60, 0.06);
  border-color: rgba(231, 76, 60, 0.22) !important;
}

.editor-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 0;
  margin: 14px -24px 0;
  padding: 16px 24px;
  border-top: 1px solid var(--line);
  background: rgba(23, 33, 31, 0.03);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}
.save-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
}

/* Sub-views */
.subview {
  margin: 28px 0;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.subview-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.subview-head h2 { margin: 0; font-size: 1.3rem; }
.subview-lead { margin: 0 0 18px; color: var(--muted); }

.subview-form {
  display: grid;
  gap: 14px;
}
.subview-form label {
  display: grid;
  gap: 6px;
  font-weight: 700;
  font-size: 0.86rem;
  color: var(--ink);
}
.subview-form input {
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
}
.subview-form input:focus {
  outline: 3px solid rgba(46, 182, 160, 0.2);
  border-color: var(--teal);
}
.form-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
}
.form-hint strong { color: var(--ink); }
.form-actions {
  display: flex; align-items: center; gap: 10px;
  margin-top: 6px;
  flex-wrap: wrap;
}
.form-status {
  margin: 4px 0 0;
  min-height: 18px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}
.form-status.is-ok { color: var(--teal-dark); }
.form-status.is-error { color: var(--red); }

.block-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}
.block-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  font-weight: 700;
  font-size: 0.92rem;
}
.block-item input { accent-color: var(--teal); }
.block-item.is-on {
  border-color: var(--teal);
  background: rgba(46, 182, 160, 0.08);
  color: var(--teal-dark);
}

/* ═══ History ═══ */
.history-controls {
  display: flex; flex-wrap: wrap; justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.hist-tabs, .hist-range {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: var(--radius-sm);
  background: rgba(23, 33, 31, 0.05);
}
.hist-tab {
  min-height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
  font-size: 0.88rem;
}
.hist-tab.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}

.chart-wrap {
  position: relative;
  padding: 16px 16px 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  margin-bottom: 32px;
}
.chart {
  position: relative;
  display: grid;
  align-items: end;
  gap: 6px;
  min-height: 320px;
  padding-top: 12px;
}
.chart .bar {
  position: relative;
  min-height: 6px;
  border-radius: 6px 6px 2px 2px;
  background: var(--teal);
  transition: height 200ms ease;
}
.chart .bar.is-yellow { background: var(--yellow); }
.chart .bar.is-orange { background: var(--orange); }
.chart .bar.is-red { background: var(--red); }
.chart .bar > .lbl {
  position: absolute;
  left: 50%;
  bottom: -22px;
  transform: translateX(-50%);
  font-size: 0.74rem;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}
.chart-thresholds {
  position: absolute;
  left: 16px; right: 16px;
  top: 16px; bottom: 36px;
  pointer-events: none;
}
.thresh {
  position: absolute;
  left: 0; right: 0;
  border-top: 1px dashed rgba(23, 33, 31, 0.18);
  display: flex; justify-content: flex-end;
}
.thresh em {
  font-style: normal;
  margin-top: -10px;
  padding: 0 6px;
  background: var(--surface);
  font-size: 0.7rem;
  color: var(--muted);
  font-weight: 800;
}

.mood-journal {
  margin-top: 16px;
}
.mood-journal h3 { margin: 0 0 12px; font-size: 1.1rem; }
.journal-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.journal-table th, .journal-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid rgba(23, 33, 31, 0.06);
  font-size: 0.9rem;
}
.journal-table th {
  background: rgba(23, 33, 31, 0.04);
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.74rem;
}
.journal-table tr:last-child td { border-bottom: 0; }
.journal-table .episode-marker {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 800;
}
.episode-marker.manic { background: rgba(231, 76, 60, 0.14); color: #b54035; }
.episode-marker.hypomanic { background: rgba(230, 126, 34, 0.14); color: #a55818; }
.episode-marker.stable { background: rgba(46, 182, 160, 0.14); color: var(--teal-dark); }

/* ═══ Settings ═══ */
.settings-form {
  display: grid;
  gap: 22px;
  max-width: 720px;
}
.settings-section {
  margin: 0;
  padding: 22px 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.settings-section legend {
  padding: 0 6px;
  font-size: 0.8rem;
  font-weight: 850;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--coral);
}
.radio-row, .switch-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 8px;
  border-bottom: 1px solid rgba(23, 33, 31, 0.06);
  cursor: pointer;
}
.radio-row:last-of-type, .switch-row:last-of-type { border-bottom: 0; }
.radio-row input, .switch-row input { accent-color: var(--teal); }
.radio-row span, .switch-row > span {
  flex: 1;
}
.radio-row strong, .switch-row strong {
  display: block;
  font-size: 0.96rem;
  font-weight: 800;
}
.radio-row small, .switch-row small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.4;
}
.switch-row { justify-content: space-between; }
.switch-row input[type="checkbox"] {
  width: 36px; height: 22px; appearance: none;
  background: rgba(23, 33, 31, 0.15);
  border-radius: 12px;
  position: relative;
  cursor: pointer;
  transition: background 140ms;
}
.switch-row input[type="checkbox"]::after {
  content: ""; position: absolute;
  top: 3px; left: 3px;
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform 140ms;
}
.switch-row input[type="checkbox"]:checked { background: var(--teal); }
.switch-row input[type="checkbox"]:checked::after { transform: translateX(14px); }

.about-section ul { list-style: none; margin: 0; padding: 0; }
.about-section li {
  display: flex; justify-content: space-between;
  padding: 10px 4px;
  border-bottom: 1px solid rgba(23, 33, 31, 0.06);
  font-size: 0.92rem;
}
.about-section li:last-child { border-bottom: 0; }
.about-section li span { color: var(--muted); }

.danger-section { border-color: rgba(231, 76, 60, 0.3); }
.danger-section legend { color: var(--red); }
.danger-section p { margin: 0 0 12px; color: var(--muted); }
.danger-btn {
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--red);
  border-radius: var(--radius-sm);
  background: rgba(231, 76, 60, 0.06);
  color: var(--red);
  font-weight: 800;
  cursor: pointer;
}
.danger-btn:hover { background: rgba(231, 76, 60, 0.12); }

.settings-footer {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
}

/* ═══ Feedback ═══ */
.filter-row {
  display: flex; flex-wrap: wrap; gap: 8px;
  align-items: center;
  margin-bottom: 18px;
}
.filter-label {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.filter-label-second { margin-left: 14px; }
.chip {
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
  font-size: 0.86rem;
  cursor: pointer;
}
.chip:hover:not(.is-active) { border-color: var(--teal); }
.chip.is-active {
  background: var(--teal-dark);
  color: #fff;
  border-color: var(--teal-dark);
}

.ticket-list {
  display: grid;
  gap: 12px;
}
.ticket-card {
  padding: 16px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.ticket-card:hover { border-color: rgba(46, 182, 160, 0.5); }
.ticket-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 8px;
}
.ticket-title {
  font-size: 1rem; font-weight: 800; flex: 1; min-width: 0;
}
.ticket-status {
  flex-shrink: 0;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.ticket-status.open { background: #fef3c7; color: #92400e; }
.ticket-status.in_progress { background: rgba(46, 182, 160, 0.16); color: var(--teal-dark); }
.ticket-status.done { background: rgba(23, 33, 31, 0.08); color: var(--muted); }
.ticket-status.rejected { background: rgba(217, 101, 80, 0.15); color: #b54a3a; }
.ticket-desc { color: var(--muted); margin-bottom: 8px; font-size: 0.92rem; }
.ticket-meta {
  display: flex; flex-wrap: wrap;
  gap: 12px;
  font-size: 0.8rem; color: var(--muted);
}
.ticket-meta .type {
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(23, 33, 31, 0.06);
  font-weight: 700;
}
.ticket-meta .type.bug { color: #b54a3a; }
.ticket-meta .type.feature { color: var(--teal-dark); }

.empty-state, .error-state {
  text-align: center;
  padding: 36px 16px;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
}
.error-state { color: #b54a3a; border-color: rgba(217, 101, 80, 0.4); }

.filter-note {
  margin-top: 20px;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  background: rgba(23, 33, 31, 0.03);
  color: var(--muted);
  font-size: 0.9rem;
}

/* ═══ Footer ═══ */
.companion-footer {
  display: flex; justify-content: space-between; gap: 20px;
  flex-wrap: wrap;
  padding: 24px clamp(18px, 4vw, 36px);
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.86rem;
}
.companion-footer strong { display: block; color: var(--ink); margin-bottom: 4px; }
.footer-actions { display: flex; gap: 16px; align-items: center; }
.footer-actions a { color: var(--teal-dark); font-weight: 700; }
.footer-actions a:hover { color: var(--teal); }

/* ═══ Buttons ═══ */
.primary-cta {
  min-height: 44px;
  padding: 0 20px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--teal-dark);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
  text-decoration: none;
  transition: background 140ms, transform 140ms;
}
.primary-cta:hover { background: var(--teal-deep); transform: translateY(-1px); }
.primary-cta:disabled, .primary-cta[data-locked="true"] {
  background: rgba(23, 33, 31, 0.18);
  color: rgba(23, 33, 31, 0.42);
  cursor: not-allowed;
  transform: none;
}

/* Command Button */
.command-button {
  position: fixed;
  right: 22px; bottom: 22px;
  z-index: 20;
  min-height: 52px;
  padding: 0 22px;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
  box-shadow: 0 18px 44px rgba(7, 26, 25, 0.32);
  font-size: 0.94rem;
}
.command-button:hover { background: var(--ink-strong); transform: translateY(-1px); }
.command-button span { font-size: 1.2rem; line-height: 1; }

/* Dialogs */
.command-dialog, .confirm-dialog {
  width: min(100% - 32px, 540px);
  border: 0;
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  padding: 0;
}
.command-dialog::backdrop, .confirm-dialog::backdrop {
  background: rgba(7, 26, 25, 0.4);
  backdrop-filter: blur(4px);
}
.command-form, .confirm-card {
  display: grid;
  gap: 14px;
  padding: 24px;
}
.command-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
}
.command-header h2 { margin: 0; font-size: 1.4rem; }
.command-form label {
  display: grid;
  gap: 6px;
  font-weight: 700;
  font-size: 0.86rem;
}
.command-form input, .command-form select, .command-form textarea {
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.icon-close {
  width: 38px; height: 38px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink);
  font-size: 1.4rem;
  cursor: pointer;
}
.command-status {
  margin: 0;
  min-height: 18px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}
.command-status.is-ok { color: var(--teal-dark); }
.command-status.is-error { color: var(--red); }

.confirm-card h2 { margin: 0; font-size: 1.4rem; }
.confirm-card p { margin: 0; color: var(--muted); line-height: 1.5; }
.confirm-actions {
  display: flex; justify-content: flex-end; gap: 10px;
  margin-top: 4px;
}
.check-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(23, 33, 31, 0.03);
  font-size: 0.9rem;
  cursor: pointer;
}
.check-row input { accent-color: var(--teal); width: 18px; height: 18px; }

/* Toast */
.toast {
  position: fixed;
  bottom: 88px; right: 22px;
  z-index: 50;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: #fff;
  font-weight: 700;
  font-size: 0.92rem;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 200ms ease, transform 200ms ease;
  pointer-events: none;
}
.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}
.toast.is-error { background: var(--red); }
.toast.is-ok { background: var(--teal-dark); }

/* ═══ Demo-Mode: Save-Buttons disabled ═══ */
body.is-demo .primary-cta:not([data-allow-demo="true"]),
body.is-demo .danger-btn,
body.is-demo .qa-card[data-mood-prompt="true"] .mood-pill {
  pointer-events: none;
  opacity: 0.55;
  cursor: not-allowed;
  position: relative;
}
body.is-demo .primary-cta:not([data-allow-demo="true"])::after {
  content: " (Demo)";
  margin-left: 4px;
  font-size: 0.78rem;
}

/* ═══ Responsive ═══ */
@media (max-width: 960px) {
  .companion-header {
    grid-template-columns: 1fr;
    height: auto;
    padding: 12px 18px;
    gap: 12px;
    align-items: stretch;
  }
  .top-nav { justify-content: flex-start; overflow-x: auto; }
  .header-actions { justify-content: flex-end; flex-wrap: wrap; }
  .site-links { padding-right: 8px; }
  .dash-grid { grid-template-columns: 1fr; }
  .risk-card { grid-row: auto; }
  .native-banner { grid-template-columns: 1fr; }
  .native-banner-actions { justify-items: start; text-align: left; }
}

@media (max-width: 640px) {
  .demo-banner { flex-wrap: wrap; }
  .demo-banner-cta { margin-left: 0; }
  .nav-tab { font-size: 0.84rem; padding: 0 10px; }
  .top-nav { flex-wrap: nowrap; }
  .page-heading h1 { font-size: 1.7rem; }
  .quick-actions { grid-template-columns: 1fr; }
  .chart .bar > .lbl { font-size: 0.62rem; }
  .journal-table th, .journal-table td { padding: 8px 10px; font-size: 0.82rem; }
  .command-button { right: 14px; bottom: 14px; padding: 0 16px; min-height: 46px; }
  .editor-tabs { flex-direction: column; }
  .site-links {
    padding-right: 6px;
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding-bottom: 6px;
    margin-right: 0;
    width: 100%;
    justify-content: flex-end;
  }
}

@media (max-width: 375px) {
  .companion-main { padding: 16px 12px 80px; }
  .filter-row { gap: 6px; }
  .chip { font-size: 0.78rem; padding: 0 9px; }
}

/* ─── Devices Tab ────────────────────────────────────────── */
.device-rec-band {
  margin: 0 0 32px;
  padding: 24px 28px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(46, 182, 160, 0.10), rgba(15, 107, 104, 0.06));
  border: 1px solid rgba(46, 182, 160, 0.24);
}
.device-rec-band h2 {
  margin: 6px 0 12px;
  font-size: 1.32rem;
  line-height: 1.3;
  color: var(--teal-dark, #093f45);
}
.device-rec-band p {
  margin: 0;
  color: var(--ink);
  font-size: 0.96rem;
  line-height: 1.55;
}
.device-rec-band strong {
  color: var(--teal-dark, #093f45);
}

.device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.device-card {
  display: flex;
  flex-direction: column;
  padding: 22px 22px 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 6px 20px rgba(15, 37, 34, 0.04);
  transition: transform 160ms ease, box-shadow 160ms ease;
}
.device-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 32px rgba(15, 37, 34, 0.08);
}
.device-card.device-recommended {
  border-color: rgba(46, 182, 160, 0.6);
  background: linear-gradient(180deg, rgba(46, 182, 160, 0.04), #fff 30%);
}
.device-card.device-limited {
  background: linear-gradient(180deg, rgba(217, 101, 80, 0.03), #fff 30%);
}
.device-card.device-phone-only {
  background: rgba(255, 255, 255, 0.86);
  border-style: dashed;
}
.device-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}
.device-card h3 {
  margin: 0;
  font-size: 1.08rem;
  line-height: 1.2;
  color: var(--ink);
}
.device-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.device-badge.badge-green {
  background: rgba(46, 182, 160, 0.16);
  color: #0f6b68;
}
.device-badge.badge-yellow {
  background: rgba(200, 162, 74, 0.18);
  color: #8c6d20;
}
.device-badge.badge-orange {
  background: rgba(230, 126, 34, 0.16);
  color: #ad5500;
}
.device-badge.badge-gray {
  background: rgba(23, 33, 31, 0.08);
  color: var(--muted, #55615d);
}

.device-signals {
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}
.device-signals li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 0.88rem;
  color: var(--ink);
  line-height: 1.45;
}
.device-signals .dot {
  flex-shrink: 0;
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-top: 6px;
  border-radius: 50%;
}
.device-signals .dot-green { background: #2eb6a0; }
.device-signals .dot-yellow { background: #c8a24a; }
.device-signals .dot-red { background: #d96550; }

.device-setup {
  margin: 0 0 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(23, 33, 31, 0.035);
  font-size: 0.84rem;
  line-height: 1.5;
  color: var(--muted, #55615d);
}
.device-setup em {
  color: var(--ink);
  font-style: normal;
  font-weight: 600;
}
.device-models {
  margin: auto 0 0;
  padding-top: 8px;
  font-size: 0.84rem;
  color: var(--muted, #55615d);
  border-top: 1px dashed var(--line);
}
.device-models strong {
  color: var(--ink);
}

.device-status-band {
  padding: 22px 26px;
  border-radius: 14px;
  background: rgba(23, 33, 31, 0.03);
  border: 1px solid var(--line);
}
.device-status-band h3 {
  margin: 0 0 10px;
  font-size: 1.08rem;
}
.device-status-hint {
  margin: 0 0 14px;
  font-size: 0.92rem;
  color: var(--muted, #55615d);
  line-height: 1.55;
}
.device-evidence summary {
  cursor: pointer;
  padding: 10px 0;
  font-weight: 700;
  color: var(--teal-dark, #093f45);
  font-size: 0.92rem;
}
.device-evidence summary:hover {
  color: var(--teal, #0f6b68);
}
.device-evidence p {
  margin: 8px 0;
  font-size: 0.88rem;
  color: var(--ink);
  line-height: 1.6;
}
.device-evidence a {
  color: var(--teal, #0f6b68);
  text-decoration: underline;
}

@media (max-width: 640px) {
  .device-grid { grid-template-columns: 1fr; }
  .device-rec-band { padding: 18px 18px; }
}
