@font-face { font-family: Nunito; src: url('/brand/nunito.woff2') format('woff2'); font-weight: 200 900; font-display: swap; }
:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-soft: #f9fbfc;
  --ink: #1f2933;
  --muted: #637083;
  --line: #d8e0e7;
  --primary: #087780;
  --primary-dark: #065e65;
  --accent: #2e6f95;
  --accent-soft: #e7f1f5;
  --warn-soft: #fff2dc;
  --danger: #b42318;
  --ok: #157347;
  --shadow: 0 16px 36px rgba(31, 41, 51, 0.08);
  font-family: Nunito, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

[hidden] { display: none !important; }
.account-link { color: var(--primary); font-weight: 700; padding: 10px; }
.panel-footer { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; padding: 24px; border-top: 1px solid var(--line); font-size: 14px; }
.panel-footer a { color: var(--primary); }
.help-live-banner { position: fixed; bottom: 0; left: 0; right: 0; z-index: 5; display: flex; align-items: center; gap: 16px; padding: 16px 24px; background: #fff2dc; border-top: 3px solid var(--danger); }
.help-live-banner strong { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.help-live-banner button { flex-shrink: 0; }
.has-help-alert { padding-bottom: 150px; }
.phone-health, .view-tabs, .care-view { width: min(1440px, 100%); margin: 0 auto; padding: 20px 24px; }
.phone-health { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; border-bottom: 1px solid var(--line); background: #fff; }
.phone-health div { display: grid; align-content: start; gap: 6px; min-width: 0; }
.phone-health span { color: var(--muted); font-size: 13px; }
.phone-health strong { font-size: 15px; overflow-wrap: anywhere; }
#health-warning { grid-column: 1 / -1; color: var(--danger); font-size: 14px; margin: 0; }
#health-warning:empty { display: none; }
.view-tabs { display: flex; flex-wrap: wrap; gap: 4px; padding-top: 8px; padding-bottom: 0; border-bottom: 1px solid var(--line); }
.view-tabs button { background: transparent; border: 0; border-bottom: 3px solid transparent; border-radius: 0; padding: 12px; }
.view-tabs button[aria-pressed="true"] { border-bottom-color: var(--primary); color: var(--primary); }
.care-view { min-height: 500px; }
.care-view .section-heading { margin: 16px 0; align-items: center; gap: 12px; flex-wrap: wrap; }
.care-view .section-heading button { display: inline-flex; align-items: center; gap: 8px; }
.care-toolbar { display: flex; align-items: end; gap: 20px; flex-wrap: wrap; margin-bottom: 20px; }
.care-toolbar select { min-height: 44px; max-width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 8px; background: white; }
.care-toolbar label { min-width: 0; max-width: 100%; }
.care-toolbar p { color: var(--muted); font-size: 14px; }
.escalation-field { max-width: 360px; margin: 16px 0; }
.care-item { display: grid; grid-template-columns: 24px minmax(0, 1fr) minmax(0, 1fr) auto; gap: 12px; align-items: center; border-bottom: 1px solid var(--line); padding: 14px 0; }
.care-item label, .reminder-fields label { min-width: 0; }
.care-item input, .reminder-item input { min-width: 0; }
.help-event { padding: 16px; background: white; border: 1px solid var(--line); border-left: 4px solid var(--danger); border-radius: 6px; }
.help-event.acknowledged { border-left-color: var(--primary); }
.help-event.resolved { border-left-color: var(--muted); }
.help-event strong { font-size: 18px; overflow-wrap: anywhere; }
.help-event p { font-size: 14px; color: var(--muted); }
.reminder-item { padding: 20px; background: white; border: 1px solid var(--line); border-radius: 6px; }
.reminder-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
.reminder-fields label:nth-child(3) { grid-column: 1 / -1; }
.reminder-media { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 12px 0; }
.reminder-media img { width: 100px; height: 100px; object-fit: cover; border-radius: 4px; }
.reminder-media audio { width: min(100%, 340px); }
.reminder-item .row-actions, .care-item .row-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.care-view .icon-button { width: 44px; height: 44px; display: inline-grid; place-items: center; flex: 0 0 44px; }
@media (max-width: 700px) {
  .phone-health { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .phone-health, .view-tabs, .care-view { padding-left: 14px; padding-right: 14px; }
  .view-tabs button { font-size: 14px; padding: 10px 8px; }
  .care-item { grid-template-columns: 20px minmax(0, 1fr); }
  .care-item label, .care-item .row-actions { grid-column: 2; }
  .reminder-fields { grid-template-columns: minmax(0, 1fr); }
  .reminder-fields label:nth-child(3) { grid-column: auto; }
  .reminder-item { padding: 14px; }
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, #eef5f1 0, transparent 280px),
    var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  min-height: 42px;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 700;
}

button:hover {
  border-color: #b8c5cf;
}

button:disabled {
  cursor: wait;
  opacity: 0.66;
}

button.primary,
.segmented button.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

button.primary:hover,
.segmented button.active:hover {
  background: var(--primary-dark);
}

button.danger {
  color: var(--danger);
}

.icon-button {
  min-width: 42px;
  padding: 0;
}

input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
}

input[readonly] {
  background: var(--panel-soft);
  color: var(--muted);
}

label {
  display: grid;
  gap: 6px;
  font-weight: 700;
}

h1,
h2 {
  margin: 0;
  line-height: 1.08;
}

h1 {
  font-size: 32px;
}

h2 {
  font-size: 22px;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px 18px;
  align-items: center;
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 3;
}

.brand {
  min-width: 0;
}

.brand-logo {
  display: block;
  width: 144px;
  max-width: 100%;
  height: auto;
  aspect-ratio: 1442 / 424;
  margin-bottom: 6px;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
}

.workspace {
  width: min(1440px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  gap: 18px;
  align-items: start;
  padding: 20px 24px 28px;
}

.editor-stack,
.preview-rail {
  display: grid;
  gap: 16px;
}

.preview-rail {
  position: sticky;
  top: calc(var(--topbar-height, 160px) + 16px);
}

.panel,
.preview-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.screen-panel {
  border-top: 4px solid var(--accent);
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.pill,
.connection-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 11px;
  color: var(--muted);
  background: #fff;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 750;
}

.connection-pill.ready {
  color: var(--ok);
  border-color: #b8dec8;
  background: #ecf8f0;
}

.status {
  grid-column: 1 / -1;
  margin: 0;
  line-height: 1.4;
  color: var(--muted);
}

.status.ok {
  color: var(--ok);
}

.status.error {
  color: var(--danger);
}

.button-row,
.segmented,
.row-actions,
.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.screen-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: end;
}

.control-block {
  display: grid;
  gap: 8px;
}

.profile-control { grid-column: 1 / -1; }
.avatar.palette-0 { background: #d7efe9; }
.avatar.palette-1 { background: #fbe4dd; }
.avatar.palette-2 { background: #dfeaf8; }
.avatar.palette-3 { background: #f5ecc8; }
.avatar img.default-icon { width: 60%; height: 60%; object-fit: contain; }
.night .avatar img.default-icon { filter: invert(1); }

.segmented button {
  min-width: 74px;
}

.switch-line,
.small-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
}

.switch-line {
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.switch-line input,
.small-toggle input {
  width: 22px;
  min-height: 22px;
  flex: 0 0 auto;
}

.list {
  display: grid;
  gap: 10px;
}

.item {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.item-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

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

.avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 22px;
  font-weight: 850;
}

.app-avatar {
  background: #edf7ef;
  color: var(--primary);
  font-size: 13px;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.phone-preview {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 16px;
  height: 640px;
  grid-template-rows: repeat(2, minmax(min-content, 1fr));
  overflow-y: auto;
  border-radius: 28px;
  background: #f7f9fc;
  border: 10px solid #222a35;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.65);
}

.phone-preview.count-6 { grid-template-rows: repeat(3, minmax(min-content, 1fr)); }
.phone-preview.count-8 { grid-template-rows: repeat(4, minmax(min-content, 1fr)); }

.page-navigation {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 48px;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  text-align: center;
  font-weight: 700;
}

.page-navigation .icon-button {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  font-size: 26px;
}

.page-navigation button:disabled img { opacity: 0.4; }

#page-dialog-message { margin: 0; line-height: 1.5; }

.phone-preview.night {
  background: #0e1116;
  border-color: #151b24;
  box-shadow: inset 0 0 0 1px rgba(203, 231, 255, 0.12);
}

.preview-tile {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  padding: 12px;
  border-radius: 8px;
  background: #fff;
  text-align: center;
  font-weight: 850;
  overflow-wrap: anywhere;
}

.preview-label {
  min-width: 0;
  width: 100%;
  min-height: 2.4em;
  line-height: 1.2;
  letter-spacing: 0;
}

.phone-preview.night .preview-tile {
  background: #18212b;
  color: #fff;
}

.phone-preview.night .avatar {
  background: #263849;
  color: #cbe7ff;
}

.phone-preview.size-Small .preview-tile {
  font-size: 18px;
}

.phone-preview.size-Medium .preview-tile {
  font-size: 20px;
}

.phone-preview.size-Large .preview-tile {
  font-size: 24px;
}

.phone-preview.size-Small .avatar {
  width: 56px;
  height: 56px;
}

.phone-preview.size-Medium .avatar {
  width: 70px;
  height: 70px;
}

.phone-preview.size-Large .avatar {
  width: 88px;
  height: 88px;
}

.phone-preview.count-8 .avatar { width: 60px; height: 60px; }
.phone-preview.count-8.size-Small .avatar { width: 40px; height: 40px; }
.phone-preview.count-8.size-Medium .avatar { width: 50px; height: 50px; }
.phone-preview.count-8 .preview-tile { padding: 8px; gap: 6px; }
.phone-preview.count-8.size-Large .preview-tile { font-size: 22px; }

.pin-row {
  display: grid;
  grid-template-columns: minmax(220px, 340px) minmax(0, 1fr);
  gap: 14px;
  align-items: end;
}

.security-toggle {
  margin-top: 14px;
}

.help-text {
  margin: 0;
  color: var(--muted);
  line-height: 1.4;
}

.audit-list {
  display: grid;
  gap: 10px;
}

.audit-entry {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.audit-entry p {
  margin: 0;
  color: var(--muted);
  line-height: 1.35;
}

.connection-dialog {
  width: min(520px, calc(100% - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  color: var(--ink);
  box-shadow: 0 24px 80px rgba(31, 41, 51, 0.28);
}

.connection-dialog::backdrop {
  background: rgba(31, 41, 51, 0.42);
}

.account-stack { display: grid; gap: 12px; min-width: 0; }
.account-stack[hidden], #legacy-connection[hidden], #account-login [hidden] { display: none; }
.account-stack h3 { font-size: 17px; margin: 10px 0 0; }
.account-stack strong, .access-member span, .account-status { overflow-wrap: anywhere; }
.access-member { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.access-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.pairing-code { font-size: 24px; font-weight: 700; letter-spacing: 0; }
.account-status { margin: 0; padding: 0 18px 16px; color: var(--muted); }
#legacy-connection { border-top: 1px solid var(--line); }
.connection-dialog summary { padding: 12px 0; cursor: pointer; }
#legacy-connection > summary { padding: 18px; }
#account-content input, #account-content select { min-width: 0; width: 100%; }
#account-content select { border: 1px solid var(--line); border-radius: 6px; padding: 10px; min-height: 44px; background: white; }
#open-connection, #account-pair { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.connection-dialog .icon-button { display: inline-grid; place-items: center; width: 44px; height: 44px; flex: 0 0 44px; }
.connection-dialog > .dialog-header { position: sticky; top: 0; z-index: 2; background: var(--panel); }
#account-user { font-size: 15px; }

.dialog-header,
.dialog-fields,
.dialog-actions {
  padding: 18px;
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  border-bottom: 1px solid var(--line);
}

.dialog-fields {
  display: grid;
  gap: 12px;
}

.dialog-actions {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  background: var(--panel-soft);
}

#clear-connection {
  margin-right: auto;
}

@media (max-width: 980px) {
  .topbar {
    position: static;
  }

  .topbar,
  .workspace {
    grid-template-columns: 1fr;
  }

  .top-actions {
    justify-content: flex-start;
  }

  .preview-rail {
    position: static;
  }
}

@media (max-width: 680px) {
  h1 {
    font-size: 28px;
  }

  h2 {
    font-size: 20px;
  }

  .topbar,
  .workspace {
    padding-left: 14px;
    padding-right: 14px;
  }

  .top-actions,
  .dialog-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .top-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .top-actions .connection-pill, .top-actions #save-device { grid-column: 1 / -1; }

  .top-actions button,
  .dialog-actions button {
    width: 100%;
  }

  #clear-connection {
    margin-right: 0;
  }

  .connection-pill {
    text-align: center;
  }

  .screen-controls,
  .item,
  .item-fields,
  .pin-row {
    grid-template-columns: 1fr;
  }

  .item {
    align-items: start;
  }

  .row-actions {
    justify-content: flex-start;
  }

  .phone-preview {
    padding: 12px;
  }
}
