/* Shared editor design. Notes retain their separate black writing canvas. */
#modal {
  background: #101215;
  border: 1px solid #5e5136;
  border-radius: 20px;
  box-shadow: 0 24px 90px #000b, 0 0 30px #e3b34a0d;
}
#modal .sheet { padding: 24px; }
#modal .sheet > header {
  margin: -24px -24px 24px;
  padding: 18px 24px;
  background: #1b1e22;
  border-bottom: 1px solid #74603a;
}
#modal .sheet > header h2 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
#modal .sheet > header .icon-btn { background: #30353b; border: 1px solid #656b73; border-radius: 50%; }
#modal form { margin: 0; }
#modal :is(.field, form > label:not(.tick):not(.btn):not(.member-permission)) {
  display: flex; flex-direction: column; gap: 8px; margin: 0 0 18px; min-width: 0;
  font-size: 14px; color: #e2e0d8; line-height: 1.4;
}
#modal .field > span { color: #e2e0d8; font-size: 14px; font-weight: 550; }
#modal :is(input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=range]), textarea, select) {
  background: #30353c; border: 1px solid #626b76; color: #fffaf0;
  border-radius: 10px; padding: 12px; min-height: 48px; width: 100%;
  font-size: 16px; line-height: 1.4; box-shadow: inset 0 1px 2px #0003;
}
#modal :is(input,textarea)::placeholder { color: #b9bec6; opacity: 1; }
#modal :is(input,textarea,select):focus-visible { outline: 2px solid #ffcf61; outline-offset: 3px; border-color: #ffcf61; }
#modal textarea { min-height: 90px; }
#modal select option { background: #30353c; color: #fffaf0; }
#modal .fields { gap: 14px; margin-bottom: 18px; }
#modal .fields > .field { margin-bottom: 0; }
#modal .form-section {
  min-width: 0; margin: 0 0 24px; padding: 18px;
  border: 1px solid #424951; border-radius: 14px; background: #1c2025;
}
#modal .form-section > legend { padding: 0 8px; color: #ffda87; font-size: 15px; font-weight: 650; }
#modal .form-section > :last-child { margin-bottom: 0; }
#modal :is(.small-note,.subtle) { color: #bdc3cb; font-size: 14px; line-height: 1.5; }
#modal .small-note { margin: 10px 0 16px; }
#modal .date-hint { margin: -8px 0 16px; font-size: 13px; }
#modal form > details, #modal .task-extras > details {
  background: #1b2025; border: 1px solid #48515c; border-radius: 12px;
  padding: 0 14px; margin: 0 0 14px;
}
#modal :is(form > details,.task-extras > details) > summary {
  min-height: 48px; display: flex; align-items: center; gap: 8px;
  color: #f6e8c7; font-size: 15px; font-weight: 550; padding: 10px 0;
}
#modal :is(form > details,.task-extras > details)[open] > summary { margin-bottom: 12px; border-bottom: 1px solid #434a53; }
#modal .task-extras { background: transparent; border: 0; padding: 0; margin: 0; }
#modal .task-extras > details + details { border-top: 1px solid #48515c; }
#modal .btn { background: #171b20; border: 1px solid #687380; color: #ede9df; min-height: 46px; padding: 11px 16px; font-size: 15px; box-shadow: none; }
#modal .btn.gold { background: linear-gradient(135deg,#ffe7a1,#ffd05c); border: 1px solid #ffe9ae; color: #251b08; font-weight: 700; box-shadow: 0 3px 14px #f9bd3326; }
#modal .btn.danger { color: #ffc2b6; border-color: #966256; background: #281d1c; }
#modal .btn:hover:not(:disabled) { border-color: #ffd77a; }
#modal .btn:disabled { opacity: .5; }
#modal .form-actions { gap: 12px; margin: 22px 0 0; padding-top: 18px; border-top: 1px solid #444a52; }
#modal .form-actions .gold { flex: 1; max-width: 280px; }
#modal form > .btn[type=submit] { margin-top: 8px; min-width: 150px; }
#modal .form-error:empty { display: none; }
#modal .form-error:not(:empty) { background: #3b2324; border: 1px solid #a86c62; border-radius: 10px; padding: 12px; color: #ffe0d7; margin: 14px 0 0; }
#modal .member-permission { padding: 12px 0; margin: 0; border-top: 1px solid #4a525c; font-size: 15px; }
#modal .member-permission select { max-width: 160px; width: 47%; }
#modal .selected-access { margin-top: 18px; }
#modal .shared-list-toolbar { margin-bottom: 16px; }
#modal .access-badge { margin: 0 0 20px; background: #30291b; border: 1px solid #81652f; color: #ffe1a0; }
#modal [data-shared-view] > form { padding: 16px; border-radius: 14px; border: 1px solid #49515c; background: #1c2025; margin-bottom: 24px; }
#modal .shared-items { margin-top: 18px; }
#modal .shared-item { background: #252a31; padding: 12px 8px; margin: 8px 0; border: 1px solid #4a535e; border-radius: 12px; }
#modal .shared-item strong { font-size: 16px; font-weight: 550; }
#modal .shared-item small { font-size: 13px; color: #c2c8cf; margin-top: 5px; }
#modal .step-edit-row { background: #20262c; border: 1px solid #535d67; border-radius: 12px; padding: 12px; margin: 12px 0; }
#modal .step-title-row { gap: 8px; }
#modal .step-edit-row textarea { margin-top: 10px; min-height: 70px; }
#modal .step-order { margin-top: 8px; }
#modal .step-order button { border: 1px solid #697581; border-radius: 8px; min-width: 44px; min-height: 44px; }
#modal .tick { min-height: 44px; font-size: 15px; gap: 10px; align-items: center; }
#modal .work-fields:not(.hidden) { padding: 16px; margin: 18px 0; border-left: 3px solid #d4ad5b; background: #1c2025; border-radius: 0 12px 12px 0; }
#modal [data-feature=capture-review] .capture-schedule { gap: 12px; grid-template-columns: minmax(0,1.1fr) minmax(0,1fr); }
#modal [data-feature=capture-review] .capture-schedule input { font-size: 16px; padding: 10px 8px; }
#modal #link-preview:empty { display: none; }
.optional-household { border-top: 1px solid #444; padding-top: 14px; margin: 24px 0; }
.optional-household summary { color: #d2b779; font-size: 14px; min-height: 44px; }
@media(max-width:540px) {
  #modal .sheet { padding: 18px; }
  #modal .sheet > header { margin: -18px -18px 22px; padding: 16px 18px; }
  #modal .sheet > header h2 { font-size: 21px; }
  #modal .form-section { padding: 14px; }
  #modal .form-actions { flex-wrap: wrap; }
  #modal .form-actions .gold { max-width: none; min-width: 130px; }
}
@media(prefers-reduced-motion:reduce) { #modal *, #modal *::before, #modal *::after { scroll-behavior: auto; transition: none; } }

/* Fit editors to the visible viewport, including the iPhone keyboard. */
#modal[open] { position:fixed; inset:auto 0 auto; top:calc(var(--viewport-top,0px) + 10px); margin:0 auto; max-height:calc(var(--visible-height) - 20px); overflow-y:auto; overscroll-behavior:contain; scroll-padding:20px 0 95px; }
#note-screen[open] { position:fixed; top:var(--viewport-top,0px); bottom:auto; }
#modal :is(input,textarea,select) { scroll-margin:24px 0 100px; }
#modal .form-section { padding:14px; margin-bottom:16px; }
#modal .field { margin-bottom:14px; }
#modal .form-actions { position:sticky; bottom:-1px; z-index:3; background:#101215; padding:12px 0 max(8px,env(safe-area-inset-bottom)); margin-top:16px; }
#modal .routine-instructions { padding:14px; border-left:3px solid #edc55f; background:#24231f; border-radius:8px; margin:14px 0 20px; }
#modal .routine-instructions small { color:#f6d884; font-size:12px; letter-spacing:.06em; }
#modal .routine-instructions p { margin:8px 0 0; font-size:16px; }
#modal .routine-reflection { margin-top:18px; }
#modal .routine-reflection summary { min-height:44px; color:#c9c2b4; }
.routine-priority-preview { display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; font-size:14px; line-height:1.45; color:#d7d0c1; margin-top:5px; }
.routine-score-chip { background:transparent; border:0; box-shadow:none; font-size:14px; color:#ddc681; }
.score-period-label { font-size:12px; color:#b5ad99; font-weight:400; }
.today-block .task-meta:empty { display:none; }
.today-shell .rhythm-card.is-relevant { border-color:#d3ab52; box-shadow:0 0 16px #dfb44c18; }
.goals-in-motion { max-width:1060px; margin:24px auto; }
.goals-in-motion .goal-grid { grid-template-columns:repeat(auto-fit,minmax(min(260px,100%),1fr)); }
.board-card .task-content { -webkit-touch-callout:none; user-select:none; touch-action:pan-x pan-y; }
@media(max-width:540px){.score-period-label { max-width:62px; text-align:right; }.today-columns .section-heading { gap:8px; }}

/* Record recovery: make competing copies easy to compare before choosing. */
.record-compare-grid{display:grid;gap:12px;margin:14px 0}
.record-compare-card{padding:14px 15px;border:1px solid #59616b;border-radius:16px;background:#15181c}
.record-compare-card h3{margin:0 0 7px;color:#f7d978;font-size:16px}
.record-compare-card p{margin:0 0 6px;line-height:1.45}
.record-compare-card small{display:block;color:#adb3bb;line-height:1.45}
