/* Dialogs share a scrollable sheet layout and native form controls. */
#modal {
  position:fixed;
  inset:0;
  margin:auto;
  width:min(720px,calc(100% - 48px));
  max-width:none;
  max-height:calc(100dvh - 64px);
  padding:0;
  border:1px solid var(--border,#d9dfd5);
  border-radius:18px;
  background:var(--surface,#fffefa);
  color:var(--ink,#233b32);
  box-shadow:0 24px 100px #132c3040;
  overflow:auto;
  overscroll-behavior:contain
}

#modal::backdrop {
  background:#172c276b;
  backdrop-filter:blur(3px)
}

#modal .modal-heading {
  position:sticky;
  top:0;
  z-index:2;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:20px;
  padding:20px 28px;
  background:var(--surface,#fffefa);
  border-bottom:1px solid var(--border,#d9dfd5)
}

#modal .modal-heading h2 {
  font-size:27px;
  line-height:1.2;
  margin:0
}

#modal .close {
  flex:0 0 44px;
  width:44px;
  height:44px;
  border:1px solid var(--border,#d9dfd5);
  border-radius:50%;
  display:grid;
  place-items:center;
  color:inherit;
  background:transparent
}

#modal .modal-body {
  padding:28px;
  min-width:0
}

#modal input,#modal textarea,#modal select {
  font-size:16px;
  max-width:100%;
  min-width:0
}

#modal button {
  min-height:44px
}

#modal .form-actions {
  display:flex;
  flex-wrap:wrap;
  justify-content:flex-end;
  gap:10px;
  margin-top:24px;
  padding-top:20px;
  border-top:1px solid var(--border,#d9dfd5)
}

#modal .form-actions .primary {
  margin-left:auto
}

.form-section {
  border:0;
  padding:0;
  margin:0 0 28px;
  min-width:0
}

.form-section legend {
  width:100%;
  font-size:16px;
  font-weight:650;
  margin:0 0 18px;
  padding:0 0 10px;
  border-bottom:1px solid var(--border,#d9dfd5)
}

#modal .assessment-description {
  font-size:16px;
  line-height:1.65;
  margin:16px 0 24px
}

#modal .assessment-step {
  font-size:14px;
  color:var(--muted,#52645b);
  margin:18px 0
}

#modal .step-dots {
  display:flex;
  gap:7px
}

#modal .step-dots i {
  height:5px;
  flex:1;
  border-radius:4px;
  background:var(--border,#d9dfd5)
}

#modal .step-dots i.current,#modal .step-dots i.done {
  background:var(--green,#275441)
}

#modal .assessment-icon {
  width:52px;
  height:52px;
  display:grid;
  place-items:center;
  border-radius:14px;
  background:#edf0e6;
  color:var(--ink,#233b32);
  margin-bottom:14px
}

#modal .assessment-icon svg {
  width:28px;
  height:28px
}

#modal .rating-row {
  display:grid;
  grid-template-columns:repeat(10,minmax(0,1fr));
  gap:6px;
  margin:12px 0 8px
}

#modal .rating-row button,#modal .importance-row button {
  font:inherit;
  border:1px solid var(--border,#d9dfd5);
  border-radius:8px;
  background:var(--surface,#fffefa);
  color:var(--ink,#233b32);
  padding:8px 3px;
  min-width:0
}

#modal .rating-row button.selected,#modal .importance-row button.selected {
  background:var(--green,#275441);
  border-color:var(--green,#275441);
  color:white;
  box-shadow:inset 0 0 0 1px white
}

#modal .rating-labels {
  display:flex;
  justify-content:space-between;
  gap:16px;
  margin:0 0 26px;
  font-size:12px;
  line-height:1.5;
  color:var(--muted,#52645b)
}

#modal .rating-labels span:last-child {
  text-align:right
}

#modal .importance-row {
  display:grid;
  grid-template-columns:repeat(5,minmax(0,1fr));
  gap:6px;
  margin:12px 0 24px
}

#modal .importance-row button {
  font-size:14px
}

#modal .assessment-nav {
  display:flex;
  flex-wrap:wrap;
  align-items:center;
  justify-content:space-between;
  gap:14px;
  border-top:1px solid var(--border,#d9dfd5);
  padding-top:22px;
  margin-top:22px
}

#modal .assessment-nav>div {
  display:flex;
  gap:10px
}

#modal .onboarding-intro {
  padding:0 0 22px;
  text-align:left;
  background:none
}

#modal .onboarding-intro h3 {
  font-size:24px;
  margin:10px 0
}

#modal .onboarding-intro p {
  font-size:16px;
  line-height:1.6
}

#modal .chips {
  gap:8px
}

#modal .chip {
  font-size:14px;
  padding:9px 13px
}

#modal [hidden] {
  display:none!important
}

#modal .detail-actions {
  display:flex;
  flex-wrap:wrap;
  gap:10px
}

#modal .goal-detail h3 {
  font-size:27px;
  line-height:1.3
}

@media(max-width:600px) {
  
 #modal {
  inset:0;
  width:100%;
  max-height:100dvh;
  height:100dvh;
  margin:0;
  border:0;
  border-radius:0;
  overflow:auto
}

 #modal .modal-heading {
  padding:12px 18px;
  padding-top:max(12px,env(safe-area-inset-top))
}

 #modal .modal-heading h2 {
  font-size:24px
}

 #modal .modal-body {
  padding:22px 18px calc(28px + env(safe-area-inset-bottom))
}

 #modal .rating-row {
  grid-template-columns:repeat(5,minmax(0,1fr));
  gap:8px
}

 #modal .rating-row button {
  min-height:48px
}

 #modal .importance-row {
  grid-template-columns:repeat(5,minmax(0,1fr));
  gap:5px
}

 #modal .importance-row button {
  font-size:12px;
  line-height:1.4;
  overflow-wrap:normal
}

 #modal .field-row,#modal .field-row.triple {
  grid-template-columns:1fr;
  display:grid;
  gap:0
}

 #modal .assessment-nav {
  align-items:stretch
}

 #modal .assessment-nav>div {
  width:100%
}

 #modal .assessment-nav>div button {
  flex:1
}

 #modal .form-actions {
  gap:8px
}

 #modal .form-actions .button {
  flex:1;
  white-space:normal
}


}

/* Feedback stays in the native dialog's visible, sticky header. */
#modal .modal-heading {
  flex-wrap: wrap;
}
#modal .modal-heading h2 {
  flex: 1;
}
#modal .modal-feedback {
  flex: 0 0 100%;
  padding: 12px 14px;
  border: 1px solid var(--border, #d9dfd5);
  border-radius: 8px;
  background: var(--sage, #edf0e6);
  font-size: 14px;
  line-height: 1.5;
}
#modal .assessment-nav .selected {
  background: var(--sage, #edf0e6);
  color: var(--ink, #233b32);
  box-shadow: inset 0 0 0 2px var(--green, #275441);
}
#modal .error-note {
  color: #923e2c;
  font-size: 14px;
  line-height: 1.5;
  scroll-margin: 160px;
}
#modal .error-note:not(:empty) {
  padding: 14px;
  border: 1px solid #c48a7a;
  background: #fff1eb;
  border-radius: 8px;
}
#modal .goal-detail .why {
  margin: 16px 0 24px;
  white-space: pre-wrap;
}
#modal .subheading {
  margin: 28px 0 12px;
  font-size: 16px;
  font-weight: 650;
}
#modal .milestone-list {
  display: grid;
  gap: 8px;
}
#modal .milestone-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
}
#modal .milestone-row span {
  min-width: 0;
  overflow-wrap: anywhere;
}
#modal .milestone-row.done span {
  text-decoration: line-through;
  color: var(--muted, #52645b);
}
#modal .log-row {
  border-top: 1px solid var(--border, #d9dfd5);
  padding: 18px 0;
  overflow-wrap: anywhere;
}
#modal .log-row p {
  white-space: pre-wrap;
  margin-top: 8px;
}
#modal .focus-card {
  padding: 20px;
  border: 1px solid var(--border, #d9dfd5);
  border-radius: 12px;
  background: var(--sage, #edf0e6);
}
#modal .focus-card h3 {
  margin: 10px 0 16px;
  font-size: 22px;
  line-height: 1.4;
}
#modal .review-row .review-title p {
  white-space: pre-wrap;
}
#modal .goal-detail, #modal .review-title, #modal .onboarding-intro {
  overflow-wrap: anywhere;
}

/* Dialog titles take focus so screen readers announce them; they are not controls, so no focus ring. */
#modal-title:focus, #assessment-area-title:focus, #ob-title:focus { outline: none; }
/* Dialogs never scroll sideways. */
#modal { overflow-x: hidden; }

/* First-run onboarding: a full-screen sheet over the app. */
#onboarding {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--paper);
  color: var(--ink);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}
#onboarding::backdrop { background: var(--paper); }
.ob {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 540px;
  margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top, 0px)) 24px calc(24px + env(safe-area-inset-bottom, 0px));
  animation: ob-in .35s ease both;
}
@keyframes ob-in { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) { .ob { animation: none; } }
.ob-top { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; min-height: 44px; }
.ob-top > :last-child { justify-self: end; }
.ob-link { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 4px; border: 0; background: none; color: var(--muted); font-size: 15px; font-weight: 500; }
.ob-link:hover { color: var(--green); }
.ob-dots { display: flex; gap: 6px; }
.ob-dots i { width: 22px; height: 4px; border-radius: 4px; background: var(--border); transition: background .25s; }
.ob-dots i.on { background: var(--green); }
.ob-hero { margin: 18px 0 0; border-radius: 22px; overflow: hidden; aspect-ratio: 16 / 10; background: var(--sage); }
.ob-hero img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ob-body { flex: 1; display: flex; flex-direction: column; justify-content: center; padding: 28px 0; min-width: 0; }
.ob-step-0 .ob-body { justify-content: flex-start; }
.ob-brand { font: 30px/1 var(--serif); letter-spacing: -1.3px; margin-bottom: 22px; }
.ob-brand > span { color: #9b6d53; }
.ob h1 { font-size: clamp(32px, 9vw, 42px); line-height: 1.12; margin-bottom: 14px; }
.ob .eyebrow { display: block; }
.ob-lead { font-size: 17px; line-height: 1.6; color: var(--muted); }
.ob-note { display: flex; gap: 9px; align-items: flex-start; margin-top: 22px; font-size: 14px; line-height: 1.55; color: var(--muted); }
.ob-note .icon { flex-shrink: 0; margin-top: 2px; }
.ob-note strong { color: var(--ink); font-weight: 600; }
.ob-pillars { list-style: none; margin: 18px 0 0; padding: 0; display: grid; gap: 14px; }
.ob-pillars li { display: flex; gap: 16px; align-items: flex-start; padding: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; }
.ob-pillars h3 { font-size: 17px; margin-bottom: 4px; }
.ob-pillars p { font-size: 15px; line-height: 1.55; color: var(--muted); }
.ob-pillar-icon { flex: 0 0 44px; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; background: var(--sage); color: var(--green); }
.ob-pillar-icon .icon { width: 22px; height: 22px; }
.ob .field { margin: 22px 0 0; }
.ob input { font-size: 16px; }
.ob .chips { gap: 8px; }
.ob .chip { font-size: 14px; padding: 9px 13px; }
.ob-choices { display: grid; gap: 12px; margin-top: 18px; }
.ob-choice { display: flex; align-items: center; gap: 16px; width: 100%; padding: 18px; text-align: left; font-family: var(--sans); color: var(--ink); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; min-height: 44px; }
.ob-choice:hover { border-color: #a9b8a5; background: #fbfcf8; }
.ob-choice > span:nth-child(2) { flex: 1; min-width: 0; display: grid; gap: 4px; }
.ob-choice strong { font-size: 17px; font-weight: 600; }
.ob-choice > span:nth-child(2) > span { font-size: 14px; line-height: 1.5; color: var(--muted); }
.ob-choice > .icon { flex-shrink: 0; color: var(--green); }
.ob-foot { display: flex; padding-top: 8px; }
.ob-foot .button { flex: 1; min-height: 54px; font-size: 16px; border-radius: 14px; }

/* Reminders: switches in Settings and in the introduction. */
input.switch { -webkit-appearance: none; appearance: none; flex: 0 0 51px; width: 51px; height: 31px; min-height: 0; padding: 0; margin: 0; border: 0; border-radius: 16px; background: #c9d1c7; position: relative; cursor: pointer; transition: background .2s; }
input.switch::before { content: ''; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px #1a2e2633; transition: transform .2s; }
input.switch:checked { background: var(--green); }
input.switch:checked::before { transform: translateX(20px); }
@media (prefers-reduced-motion: reduce) { input.switch, input.switch::before { transition: none; } }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; cursor: pointer; }
.switch-row > span { min-width: 0; display: grid; gap: 2px; }
.switch-row strong { font-weight: 600; }
.switch-row small { color: var(--muted); line-height: 1.5; }
.reminder-main { padding: 14px 16px; background: var(--sage); border-radius: 12px; }
.reminder-list { margin-top: 6px; }
.reminder-row { padding: 14px 0; border-bottom: 1px solid var(--border); }
.reminder-row:last-child { border-bottom: 0; }
.reminder-when { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.reminder-when input, .reminder-when select { width: auto; min-height: 40px; padding: 6px 10px; }
.ob-reminders li { padding: 14px 16px; }
.ob-remind { display: flex; align-items: center; gap: 14px; width: 100%; cursor: pointer; }
.ob-remind > span:nth-child(2) { flex: 1; min-width: 0; display: grid; gap: 3px; }
.ob-remind strong { font-size: 17px; font-weight: 600; }
.ob-remind > span:nth-child(2) > span { font-size: 14px; line-height: 1.5; color: var(--muted); }
.ob-foot-stack { flex-direction: column; align-items: stretch; gap: 4px; }
.ob-foot-stack .ob-link { justify-content: center; }
