:root {
  --paper: #f7f5ef;
  --paper-strong: #fffdfa;
  --ink: #163b40;
  --ink-soft: #4d6668;
  --line: #d9ded8;
  --sky: #bfe4ed;
  --sky-deep: #1d6e82;
  --coral: #d85a4a;
  --coral-soft: #f9dfd8;
  --amber: #eebd55;
  --amber-soft: #fbefc9;
  --mint: #a8dfcf;
  --mint-deep: #267767;
  --focus: #113c86;
  --shadow: 0 20px 50px rgba(20, 54, 58, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 4px solid rgba(17, 60, 134, 0.28);
  outline-offset: 3px;
}

.martha-app {
  width: min(1420px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  padding: 22px clamp(16px, 3vw, 42px) 20px;
}

.app-header,
.header-actions,
.brand-lockup,
.message-surface,
.message-actions,
.section-heading,
.tool-heading,
.camera-actions,
.log-heading,
.app-footer,
.privacy-line,
.settings-heading {
  display: flex;
  align-items: center;
}

.app-header {
  justify-content: space-between;
  gap: 22px;
  padding-bottom: 19px;
  border-bottom: 1px solid var(--line);
}

.brand-lockup {
  min-width: 0;
  gap: 13px;
}

.brand-mark {
  width: 62px;
  height: 50px;
  object-fit: cover;
  object-position: 50% 42%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-strong);
}

.brand-name,
.brand-tagline,
.message-copy p,
.message-copy h1,
.message-copy span,
.section-heading p,
.section-heading h2,
.choice-group h2,
.tool-heading p,
.tool-heading h2,
.camera-status,
.care-note,
.empty-log,
.app-footer,
.settings-heading p,
.settings-heading span {
  margin: 0;
}

.brand-name {
  color: var(--ink);
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.brand-tagline {
  margin-top: 2px;
  color: var(--ink-soft);
  font-size: 0.86rem;
}

.header-actions {
  justify-content: flex-end;
  gap: 10px;
}

.camera-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-strong);
  color: var(--ink-soft);
  font-size: 0.84rem;
  font-weight: 700;
  white-space: nowrap;
}

.camera-indicator > span:first-child {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9ba9a5;
}

.camera-indicator.is-on > span:first-child {
  background: var(--mint-deep);
  box-shadow: 0 0 0 4px rgba(38, 119, 103, 0.15);
}

.camera-indicator.is-loading > span:first-child {
  background: var(--amber);
}

.camera-indicator.is-error > span:first-child {
  background: var(--coral);
}

.icon-button,
.voice-toggle,
.primary-action,
.scan-control,
.contrast-toggle {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.icon-button {
  display: inline-grid;
  width: 42px;
  place-items: center;
  padding: 0;
  border-color: var(--line);
  background: var(--paper-strong);
  color: var(--ink);
}

.icon-button:hover:not(:disabled),
.secondary-action:hover:not(:disabled) {
  border-color: var(--sky-deep);
  color: var(--sky-deep);
}

.icon-button:disabled,
.primary-action:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.message-surface {
  min-height: 136px;
  justify-content: space-between;
  gap: 18px;
  margin: 22px 0 18px;
  padding: 19px 21px;
  border: 1px solid #bfd4d0;
  border-left: 7px solid var(--mint-deep);
  border-radius: 8px;
  background: var(--paper-strong);
  box-shadow: var(--shadow);
}

.message-icon {
  display: grid;
  flex: 0 0 auto;
  width: 54px;
  height: 54px;
  place-items: center;
  border-radius: 50%;
  background: var(--mint);
  color: var(--ink);
}

.message-copy {
  min-width: 0;
  flex: 1;
}

.message-copy p,
.section-heading p,
.tool-heading p,
.settings-heading p {
  color: var(--ink-soft);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.message-copy h1 {
  margin-top: 3px;
  color: var(--ink);
  font-size: clamp(1.7rem, 3vw, 2.55rem);
  line-height: 1.08;
  letter-spacing: 0;
}

.message-copy > span {
  display: block;
  max-width: 760px;
  margin-top: 7px;
  color: var(--ink-soft);
  font-size: 0.96rem;
  line-height: 1.38;
}

.message-actions {
  align-self: flex-start;
  justify-content: flex-end;
  gap: 9px;
}

.message-action {
  background: var(--sky);
  border-color: var(--sky);
  color: var(--ink);
}

.voice-toggle,
.primary-action,
.scan-control {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 13px;
  font-weight: 800;
  white-space: nowrap;
}

.voice-toggle {
  border-color: var(--line);
  background: var(--paper-strong);
  color: var(--ink-soft);
}

.voice-toggle.is-on {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.settings-surface {
  display: grid;
  grid-template-columns: minmax(220px, 0.85fr) minmax(290px, 1.2fr) auto;
  align-items: center;
  gap: 22px;
  margin-bottom: 18px;
  padding: 17px 19px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #edf4f2;
}

.settings-heading {
  gap: 10px;
  color: var(--mint-deep);
}

.settings-heading span {
  display: block;
  margin-top: 4px;
  color: var(--ink-soft);
  font-size: 0.86rem;
  line-height: 1.3;
}

.range-control {
  display: grid;
  grid-template-columns: auto minmax(90px, 1fr) auto;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 700;
}

.range-control input {
  width: 100%;
  accent-color: var(--coral);
}

.range-control output {
  min-width: 62px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.contrast-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 150px;
  padding: 0 12px;
  border-color: var(--line);
  background: var(--paper-strong);
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 800;
}

.contrast-toggle > span:last-child {
  width: 29px;
  height: 16px;
  border-radius: 12px;
  background: #a7b0ae;
}

.contrast-toggle > span:last-child::after {
  display: block;
  width: 12px;
  height: 12px;
  margin: 2px;
  border-radius: 50%;
  background: #fff;
  content: "";
  transition: transform 160ms ease;
}

.contrast-toggle.is-on > span:last-child {
  background: var(--ink);
}

.contrast-toggle.is-on > span:last-child::after {
  transform: translateX(13px);
}

.access-switcher {
  padding: 3px 0 18px;
  border-bottom: 1px solid var(--line);
}

.section-heading,
.tool-heading,
.log-heading {
  justify-content: space-between;
  gap: 16px;
}

.section-heading h2,
.tool-heading h2 {
  margin-top: 4px;
  color: var(--ink);
  font-size: 1.12rem;
  line-height: 1.1;
}

.scan-control {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.mode-tabs button {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 0.94rem;
  font-weight: 800;
}

.mode-tabs button[aria-selected="true"] {
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.workspace-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(310px, 0.34fr);
  gap: clamp(22px, 3.4vw, 46px);
  padding-top: 26px;
}

.communication-board {
  min-width: 0;
}

.choice-group + .choice-group {
  margin-top: 25px;
}

.choice-group h2 {
  margin-bottom: 11px;
  color: var(--ink-soft);
  font-size: 0.84rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 11px;
}

.choice-card {
  position: relative;
  min-height: 143px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  overflow: hidden;
  padding: 17px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--paper-strong);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.choice-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 11px 24px rgba(17, 58, 61, 0.1);
}

.choice-card.is-selected {
  border-color: var(--ink);
  box-shadow: inset 0 0 0 2px var(--ink);
}

.choice-card.is-dwelling,
.choice-card.is-scanning {
  border-color: var(--focus);
  box-shadow: 0 0 0 4px rgba(17, 60, 134, 0.17);
}

.choice-card.tone-sky .choice-icon {
  background: var(--sky);
}

.choice-card.tone-coral .choice-icon {
  background: var(--coral-soft);
}

.choice-card.tone-amber .choice-icon {
  background: var(--amber-soft);
}

.choice-card.tone-mint .choice-icon {
  background: var(--mint);
}

.choice-card.tone-ink .choice-icon {
  background: #d9e5e1;
}

.choice-icon {
  display: grid;
  width: 49px;
  height: 49px;
  place-items: center;
  border-radius: 8px;
}

.choice-text {
  display: grid;
  gap: 4px;
  position: relative;
  z-index: 1;
}

.choice-text > span {
  font-size: clamp(1.1rem, 1.6vw, 1.36rem);
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1.08;
}

.choice-text small {
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 700;
}

.dwell-progress {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 7px;
  transform: scaleX(0);
  transform-origin: left;
  background: var(--coral);
}

.support-column {
  display: grid;
  align-content: start;
  gap: 16px;
}

.camera-tool,
.care-panel {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-strong);
}

.camera-tool {
  background: #f0f6f6;
}

.tool-heading > svg {
  flex: 0 0 auto;
  color: var(--sky-deep);
}

.camera-stage {
  position: relative;
  min-height: 206px;
  overflow: hidden;
  margin-top: 15px;
  border: 1px solid #bdd0d0;
  border-radius: 8px;
  background: #173c40;
}

.camera-stage video,
.camera-stage canvas,
.camera-placeholder {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.camera-stage video,
.camera-stage canvas {
  object-fit: cover;
  transform: scaleX(-1);
}

.camera-stage video,
.camera-stage canvas {
  opacity: 0;
  transition: opacity 180ms ease;
}

.camera-stage.is-on video,
.camera-stage.is-on canvas {
  opacity: 1;
}

.camera-stage.is-on .camera-placeholder {
  opacity: 0;
}

.camera-placeholder {
  display: grid;
  place-content: center;
  gap: 10px;
  color: #eaf0ed;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 800;
  transition: opacity 180ms ease;
}

.camera-status {
  min-height: 58px;
  margin-top: 13px;
  color: var(--ink-soft);
  font-size: 0.9rem;
  line-height: 1.42;
}

.camera-actions {
  gap: 9px;
}

.primary-action {
  flex: 1;
  border-color: var(--ink);
  background: var(--ink);
  color: #fff;
}

.primary-action:hover:not(:disabled),
.scan-control:hover {
  background: #23565b;
}

.secondary-action {
  flex: 0 0 auto;
}

.privacy-line {
  gap: 7px;
  margin-top: 14px;
  color: var(--mint-deep);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.25;
}

.care-panel {
  background: #fff9ec;
}

.care-note {
  margin-top: 14px;
  color: var(--ink-soft);
  font-size: 0.91rem;
  line-height: 1.45;
}

.note-input {
  display: grid;
  gap: 7px;
  margin-top: 15px;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 800;
}

.note-input textarea {
  width: 100%;
  resize: vertical;
  padding: 10px;
  border: 1px solid #d4cfbe;
  border-radius: 8px;
  background: #fffef9;
  color: var(--ink);
  line-height: 1.35;
}

.note-input textarea::placeholder {
  color: #7b8077;
}

.log-heading {
  margin-top: 17px;
  padding-top: 14px;
  border-top: 1px solid #e2ddcf;
  color: var(--ink-soft);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.icon-button.compact {
  width: 34px;
  min-height: 34px;
  background: transparent;
}

.signal-log {
  display: grid;
  gap: 7px;
  margin: 11px 0 0;
  padding: 0;
  list-style: none;
}

.signal-log li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 7px;
  border-bottom: 1px solid rgba(212, 207, 190, 0.7);
}

.signal-log li > span {
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 800;
}

.signal-log small {
  color: var(--ink-soft);
  font-size: 0.75rem;
  white-space: nowrap;
}

.empty-log {
  margin-top: 12px;
  color: var(--ink-soft);
  font-size: 0.86rem;
  line-height: 1.4;
}

.app-footer {
  justify-content: space-between;
  gap: 16px;
  margin-top: 28px;
  padding-top: 15px;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 0.78rem;
  line-height: 1.35;
}

.app-footer span:last-child {
  color: var(--ink);
  font-weight: 700;
  text-align: right;
}

.tracking-cursor {
  position: fixed;
  z-index: 20;
  width: 34px;
  height: 34px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: rgba(216, 90, 74, 0.43);
  box-shadow: 0 0 0 4px rgba(216, 90, 74, 0.2), 0 10px 26px rgba(19, 55, 60, 0.24);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%);
  transition: opacity 120ms ease;
}

.tracking-cursor.is-hand {
  background: rgba(38, 119, 103, 0.48);
  box-shadow: 0 0 0 4px rgba(38, 119, 103, 0.2), 0 10px 26px rgba(19, 55, 60, 0.24);
}

.tracking-cursor.is-visible {
  opacity: 1;
}

[data-contrast="high"] {
  --paper: #ffffff;
  --paper-strong: #ffffff;
  --ink: #061d20;
  --ink-soft: #1e3436;
  --line: #547073;
  --sky: #c8eff9;
  --coral: #b92013;
  --coral-soft: #ffe1dc;
  --amber: #a76a00;
  --amber-soft: #ffe8a6;
  --mint: #c9f4df;
  --mint-deep: #0d604f;
  --focus: #001e70;
}

[data-contrast="high"] .choice-card,
[data-contrast="high"] .camera-tool,
[data-contrast="high"] .care-panel,
[data-contrast="high"] .message-surface {
  border-width: 2px;
}

@media (max-width: 1080px) {
  .workspace-layout {
    grid-template-columns: minmax(0, 1fr) 310px;
    gap: 24px;
  }

  .choice-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .settings-surface {
    grid-template-columns: 1fr 1fr;
  }

  .contrast-toggle {
    width: max-content;
  }
}

@media (max-width: 820px) {
  .martha-app {
    padding: 16px 15px 18px;
  }

  .settings-surface,
  .workspace-layout {
    grid-template-columns: 1fr;
  }

  .support-column {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
  }

  .camera-tool,
  .care-panel {
    height: 100%;
  }
}

@media (max-width: 630px) {
  .app-header,
  .message-surface,
  .app-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-actions {
    width: 100%;
    justify-content: space-between;
  }

  .message-surface {
    min-height: 0;
    padding: 17px;
  }

  .message-actions {
    align-self: stretch;
    width: 100%;
  }

  .message-action {
    flex: 0 0 42px;
  }

  .voice-toggle {
    flex: 1;
  }

  .mode-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .choice-grid,
  .support-column {
    grid-template-columns: 1fr;
  }

  .choice-card {
    min-height: 116px;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
  }

  .choice-text > span {
    font-size: 1.28rem;
  }

  .settings-surface {
    gap: 16px;
    margin-inline: -15px;
    padding-inline: 15px;
  }

  .range-control {
    grid-template-columns: 1fr auto;
  }

  .range-control input {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .range-control output {
    text-align: right;
  }

  .app-footer span:last-child {
    text-align: left;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
