/* @ekm-tags: style, misc, patient */
/* @ekm-tags+: patient */
/* Letter writer (js/ekm-letter-writer.js): one screen for a patient letter. It sits on EKM Sign's dark workspace tokens
   (.esgx-ws in css/ekm-esign.css: the accent is the person's own portal theme color), and the letter stays white paper.
   Owner 2026-11-18: "really ugly and the design need much improved". Every control is at least 44 px tall. */

.lw-root { position: fixed; inset: 0; z-index: 9100; display: flex; flex-direction: column; overflow: hidden;
  background: radial-gradient(900px 380px at 30% -120px, var(--esgx-acc-soft), transparent 70%), #09090B;
  font-family: var(--esg-font); color: var(--esg-ink); font-size: 14px; letter-spacing: -.005em; -webkit-font-smoothing: antialiased; }
.lw-host { flex: 1; min-height: 0; display: flex; }
.lw-root .lw-panel { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.lw-root :focus-visible { outline: 2px solid var(--esgx-accent); outline-offset: 2px; }
.lw-loading { padding: 48px; color: var(--esg-muted); }
.lw-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* top bar */
.lw-top { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 28px; border-bottom: 1px solid var(--esgx-hair); flex: none; }
.lw-crumb { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--esg-muted); min-width: 0; }
.lw-crumb b { color: var(--esg-ink); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lw-crumb [aria-hidden] { color: #52525B; }
.lw-root .lw-crumb-btn { min-height: 44px; padding: 0 4px; border: 0; background: none; color: var(--esg-muted); font: inherit; font-size: 13px; cursor: pointer; }
.lw-root .lw-crumb-btn:hover { color: var(--esg-ink); }
.lw-grow { flex: 1; }
.lw-root .lw-x { width: 44px; height: 44px; border: 0; border-radius: 10px; background: transparent; color: var(--esg-muted); cursor: pointer; display: grid; place-items: center; }
.lw-root .lw-x:hover { background: rgba(255, 255, 255, .08); color: var(--esg-ink); }

/* buttons */
.lw-root .lw-ghost { min-height: 44px; padding: 0 14px; border: 0; border-radius: 10px; background: rgba(255, 255, 255, .05); box-shadow: 0 0 0 1px rgba(255, 255, 255, .08) inset;
  color: var(--esg-ink2); font: inherit; font-size: 13.5px; font-weight: 500; cursor: pointer; }
.lw-root .lw-ghost:hover:not(:disabled) { background: rgba(255, 255, 255, .09); color: var(--esg-ink); }
.lw-root .lw-ghost:disabled { opacity: .45; cursor: not-allowed; }
.lw-root .lw-cta { min-height: 50px; width: 100%; border: 0; border-radius: 12px; padding: 0 16px; cursor: pointer; font: inherit; font-size: 15px; font-weight: 600;
  background: linear-gradient(180deg, var(--esgx-acc-hi), var(--esgx-acc)); color: var(--esgx-acc-ink);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .14) inset, 0 10px 24px -12px var(--esgx-acc-glow); }
.lw-root .lw-cta:hover:not(:disabled) { filter: brightness(1.06); }
.lw-root .lw-cta:disabled { background: rgba(255, 255, 255, .06); color: var(--esgx-faint); cursor: not-allowed; box-shadow: 0 0 0 1px rgba(255, 255, 255, .1) inset; filter: none; }
/* the portal's own disabled-button rule (html:not(#…) body :is(button…):disabled, !important) would paint it light grey on black */
html:not(#ekm-lw-a):not(#ekm-lw-b) body .lw-root .lw-cta:disabled, html:not(#ekm-lw-a):not(#ekm-lw-b) body .lw-root .lw-ghost:disabled {
  background: rgba(255, 255, 255, .05) !important; color: var(--esgx-faint) !important; box-shadow: 0 0 0 1px rgba(255, 255, 255, .1) inset !important; opacity: 1 !important; }
.lw-root .lw-linkbtn { min-height: 0; padding: 0; border: 0; background: none; color: var(--esgx-accent); font: inherit; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }

/* page */
.lw-root .lw-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 0; }
.lw-main { max-width: 1440px; margin: 0 auto; padding: 24px 28px 64px; box-sizing: border-box; }
.lw-intro { display: flex; flex-direction: column; gap: 6px; margin-bottom: 20px; }
.lw-intro h1 { margin: 0; font-size: 28px; font-weight: 600; letter-spacing: -.03em; line-height: 1.15; color: var(--esg-ink); }
.lw-intro p { margin: 0; color: var(--esg-muted); font-size: 14px; max-width: 70ch; }
.lw-eyebrow, .lw-label { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--esgx-faint); }
.lw-eyebrow, .lw-acc { color: var(--esgx-accent); }
.lw-grid { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.lw-left { flex: 1 1 320px; max-width: 400px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.lw-center { flex: 999 1 520px; min-width: 0; border-radius: 16px; background: rgba(17, 17, 20, .6); box-shadow: 0 0 0 1px rgba(255, 255, 255, .07) inset; padding: 20px; display: flex; flex-direction: column; gap: 12px; box-sizing: border-box; }
.lw-right { flex: 1 1 300px; max-width: 360px; display: flex; flex-direction: column; gap: 12px; position: sticky; top: 16px; min-width: 0; }
.lw-card { border-radius: 16px; background: rgba(17, 17, 20, .85); box-shadow: 0 0 0 1px rgba(255, 255, 255, .07) inset; padding: 16px; display: flex; flex-direction: column; gap: 12px; box-sizing: border-box; }
.lw-send { background: rgba(17, 17, 20, .92); box-shadow: 0 0 0 1px var(--esgx-acc-line) inset, 0 24px 48px -24px rgba(0, 0, 0, .8); padding: 18px; gap: 14px; }
.lw-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.lw-help { margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--esg-muted); }
.lw-err { margin: 0; font-size: 13px; line-height: 1.45; color: var(--esg-danger); background: var(--esg-danger-bg); border-radius: 10px; padding: 8px 12px; }
.lw-done { margin: 0; font-size: 13px; line-height: 1.45; color: var(--esg-ok); background: var(--esg-ok-bg); border-radius: 10px; padding: 10px 12px; }
.lw-note { margin: 0; padding: 12px 14px; border-radius: 12px; background: rgba(255, 255, 255, .03); color: var(--esg-muted); font-size: 12.5px; line-height: 1.5; }
.lw-note b { color: var(--esg-ink2); font-weight: 500; }
.lw-empty { color: var(--esg-muted); padding: 24px 0; }

/* patient */
.lw-pt { display: flex; align-items: center; gap: 12px; }
.lw-avatar { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; flex: none; background: var(--esgx-acc-soft); color: var(--esgx-accent); font-weight: 600; }
.lw-pt-t { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.lw-pt-t b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; }
.lw-pt-t small { font-size: 12.5px; color: var(--esg-muted); }

/* fields (Copy Toolkit's own inputs, restyled) */
.lw-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 10px; }
.lw-fields > .ctk-f:has(textarea), .lw-fields > .ctkl-date, .lw-fields > .ctk-f:only-child, .lw-fields > .ctk-f:has(.ctkl-phr) { grid-column: 1 / -1; }
.lw-root .ctk-f, .lw-root .lw-field { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--esg-muted); min-width: 0; }
.lw-root .ctk-f > span:first-child, .lw-root .lw-field > span { color: var(--esg-muted); font-size: 12.5px; }
.lw-root .ctk-hint { font-size: 11.5px; line-height: 1.4; color: var(--esgx-faint); }
.lw-root .ctk-clin { color: var(--esgx-accent); font-weight: 600; }
.lw-root .lw-panel input:not([type=checkbox]):not([type=radio]), .lw-root .lw-panel select, .lw-root .lw-panel textarea {
  font: inherit; font-size: 14px; min-height: 44px; box-sizing: border-box; width: 100%; padding: 0 12px; border: 0; border-radius: 10px;
  background: rgba(255, 255, 255, .04) !important; box-shadow: 0 0 0 1px rgba(255, 255, 255, .1) inset; color: var(--esg-ink) !important; -webkit-text-fill-color: currentColor; }
.lw-root .lw-panel textarea { padding: 10px 12px; min-height: 88px; resize: vertical; line-height: 1.45; }
.lw-root .lw-panel select { padding: 0 10px; }
.lw-root .lw-panel select option { background: #18181B; color: #FAFAFA; }
.lw-root .lw-panel input:focus, .lw-root .lw-panel select:focus, .lw-root .lw-panel textarea:focus { outline: none; box-shadow: 0 0 0 1px var(--esgx-acc-line) inset, 0 0 0 4px var(--esgx-acc-soft); }
.lw-root .lw-panel input::placeholder, .lw-root .lw-panel textarea::placeholder { color: #71717A; -webkit-text-fill-color: #71717A; }
.lw-root .lw-panel input[type=date], .lw-root .lw-panel input[type=month] { color-scheme: dark; }
.lw-root .ctk-f.lw-need input:not([type=checkbox]), .lw-root .ctk-f.lw-need select, .lw-root .ctk-f.lw-need textarea { box-shadow: 0 0 0 1px var(--esgx-acc-line) inset; }
.lw-root .ctk-f.lw-need > span:first-child::after { content: " · needed"; color: var(--esgx-accent); }
.lw-root .ctkl-dr { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.lw-root .ctkl-dr > input { flex: 1 1 150px; width: auto; }
.lw-root .ctkl-dr > select { flex: 0 1 132px; width: auto; }
.lw-root .ctk-link, .lw-root .ctkl-dr .ctk-link { min-height: 44px; padding: 0 8px; background: none; border: 0; color: var(--esgx-accent); font: inherit; font-size: 13px; cursor: pointer; text-decoration: none; }
.lw-root .ctk-link:hover { text-decoration: underline; }
.lw-root .ctkl-days { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.lw-root .ctkl-days label { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; color: var(--esg-ink2); font-size: 13px; }
.lw-check { display: flex; align-items: flex-start; gap: 10px; min-height: 44px; padding: 10px 0 0; box-sizing: border-box; font-size: 13.5px; color: var(--esg-ink2); cursor: pointer; line-height: 1.4; }
.lw-check input, .lw-root .ctkl-days input, .lw-root .lw-other input[type=checkbox] { width: 18px; height: 18px; flex: none; margin: 1px 0 0; accent-color: var(--esgx-acc); }
.lw-check small { display: block; color: var(--esgx-faint); font-size: 12px; }
.lw-check b { font-weight: 500; }
.lw-sub, .lw-opts { display: flex; flex-direction: column; gap: 10px; padding-top: 14px; border-top: 1px solid var(--esgx-hair); }
.lw-prog { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex: 1; max-width: 60%; }
.lw-count { font-size: 12px; color: var(--esg-muted); }
.lw-bar { height: 4px; width: 100%; border-radius: 2px; background: rgba(255, 255, 255, .06); overflow: hidden; }
.lw-bar i { display: block; height: 4px; border-radius: 2px; background: var(--esgx-acc); transition: width .2s; }
.lw-root .ctkl-sugg { background: rgba(255, 255, 255, .03); border: 1px dashed rgba(255, 255, 255, .1); border-radius: 12px; padding: 10px 12px; font-size: 12.5px; color: var(--esg-muted); display: flex; flex-direction: column; gap: 2px; }
.lw-root .ctk-sub { margin: 0; color: var(--esg-muted); font-size: 12.5px; }
.lw-root .ctk-warnline { color: var(--esg-wait); font-size: 12.5px; }

/* diagnosis picker */
.lw-dx { display: flex; flex-direction: column; gap: 10px; padding: 12px; border-radius: 12px; background: rgba(255, 255, 255, .025); box-shadow: 0 0 0 1px rgba(255, 255, 255, .06) inset; }
.lw-dx-h { display: flex; flex-direction: column; gap: 2px; }
.lw-dx-list { display: flex; flex-direction: column; gap: 6px; }
.lw-root .lw-dx-opt { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 4px 10px; min-height: 44px; padding: 8px 12px; border: 0; border-radius: 10px; text-align: left; cursor: pointer;
  background: rgba(255, 255, 255, .04); box-shadow: 0 0 0 1px rgba(255, 255, 255, .08) inset; color: var(--esg-ink); font: inherit; font-size: 13.5px; }
.lw-root .lw-dx-opt:hover { background: rgba(255, 255, 255, .08); }
.lw-root .lw-dx-opt b { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--esgx-accent); }
.lw-root .lw-dx-opt small { font-size: 11px; color: var(--esgx-faint); white-space: nowrap; }
.lw-root .lw-dx-opt.is-on { background: var(--esgx-acc-soft); box-shadow: 0 0 0 1px var(--esgx-acc-line) inset; }
.lw-root .lw-dx-opt.is-on small::before { content: "✓ "; color: var(--esgx-accent); }

/* the letter */
.lw-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--esg-muted); }
.lw-pill i { width: 6px; height: 6px; border-radius: 50%; background: var(--esg-wait); }
.lw-pill.is-ok i { background: #34D399; }
.lw-flag { margin: 0; font-size: 13px; border-radius: 10px; padding: 8px 12px; background: rgba(255, 255, 255, .04); color: var(--esg-ink2); }
.lw-flag.is-error { background: var(--esg-danger-bg); color: var(--esg-danger); }
.lw-flag.is-warn { background: var(--esg-wait-bg); color: var(--esg-wait); }
.lw-paper { background: #FFFFFF; color: #18181B; border-radius: 6px; padding: 48px 56px 56px; box-shadow: 0 30px 60px -28px rgba(0, 0, 0, .9);
  font-family: "Times New Roman", Tinos, Times, serif; font-size: 15px; line-height: 1.5; max-width: 760px; width: 100%; box-sizing: border-box; margin: 0 auto; color-scheme: light; overflow-wrap: anywhere; }
.lw-paper p { margin: 12px 0 0; }
.lw-lh { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding-bottom: 8px; border-bottom: 1px solid #B08D57; margin-bottom: 18px; font-family: var(--esg-font); }
.lw-lh-logo { width: 1.5in; max-width: 30%; height: auto; flex: none; margin-top: -8px; }
.lw-lh > div { display: flex; flex-direction: column; gap: 2px; font-size: 11.5px; color: #3F3F46; }
.lw-lh b { font-size: 14px; color: #18181B; }
.lw-paper .lw-meta { margin-top: 0; }
.lw-paper .lw-close { margin-top: 18px; }
.lw-sigspace { height: 48px; margin: 6px 0 4px; border-bottom: 1px dashed #D4D4D8; width: 260px; max-width: 100%; display: flex; align-items: flex-end; padding-bottom: 4px; box-sizing: border-box;
  font-family: var(--esg-font); font-size: 11px; color: #71717A; }
.lw-paper .lw-signer { margin-top: 6px; }
.lw-root .lw-blank { font: inherit; font-family: var(--esg-font); font-size: 12.5px; line-height: 1.3; padding: 1px 7px; margin: 0 1px; border: 1px dashed #B45309; border-radius: 5px;
  background: #FEF3C7; color: #78350F; cursor: pointer; vertical-align: baseline; }
.lw-root .lw-blank:hover { background: #FDE68A; }

/* signature checklist */
.lw-checks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; font-size: 13px; }
.lw-checks li { display: flex; gap: 10px; align-items: flex-start; color: var(--esg-ink2); line-height: 1.45; }
.lw-tick { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; flex: none; font-size: 11px; font-weight: 600; margin-top: 0; }
.lw-checks .is-ok .lw-tick { background: var(--esg-ok-bg); color: var(--esg-ok); }
.lw-checks .is-todo .lw-tick { background: var(--esgx-acc-soft); color: var(--esgx-accent); }
.lw-after { display: flex; flex-wrap: wrap; gap: 8px; }
.lw-after .lw-ghost { flex: 1 1 auto; }

/* other ways to send */
.lw-other { padding: 4px 16px; gap: 0; }
.lw-other summary { min-height: 44px; display: flex; align-items: center; gap: 8px; cursor: pointer; color: var(--esg-ink2); font-size: 13.5px; font-weight: 500; list-style: none; }
.lw-other summary::-webkit-details-marker { display: none; }
.lw-other summary::before { content: "▸"; color: var(--esgx-faint); font-size: 11px; }
.lw-other[open] summary::before { content: "▾"; }
.lw-other summary small { color: var(--esgx-faint); font-weight: 400; font-size: 12px; }
.lw-other-b { display: flex; flex-direction: column; gap: 10px; padding: 4px 0 14px; }
.lw-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.lw-btns .lw-ghost { flex: 1 1 120px; }
.lw-root .lw-other .ctkl-wf { background: rgba(255, 255, 255, .03); border: 0; border-radius: 12px; padding: 12px; color: var(--esg-ink2); font-size: 12.5px; display: flex; flex-direction: column; gap: 8px; }
.lw-root .lw-other .ctk-btn, .lw-root .lw-other .ctk-copy { min-height: 44px; border: 0; border-radius: 10px; background: rgba(255, 255, 255, .06); color: var(--esg-ink); font: inherit; font-size: 13px; padding: 0 12px; cursor: pointer; }
.lw-root .lw-other .ctk-btn.primary { background: var(--esgx-acc); color: var(--esgx-acc-ink); }
.lw-root .lw-other .ctk-ack { display: flex; gap: 8px; align-items: flex-start; font-size: 12.5px; line-height: 1.4; color: var(--esg-ink2); }
.lw-root .lw-other textarea { min-height: 120px; }

/* letter list */
.lw-pickmain { max-width: 1100px; }
.lw-search { display: flex; align-items: center; gap: 10px; padding: 0 14px; border-radius: 12px; background: rgba(255, 255, 255, .04); box-shadow: 0 0 0 1px rgba(255, 255, 255, .1) inset; color: var(--esg-muted); margin-bottom: 20px; }
.lw-root .lw-panel .lw-search input[type=search] { flex: 1; background: transparent !important; box-shadow: none; padding: 0; min-height: 50px; font-size: 15px; }
.lw-search:focus-within { box-shadow: 0 0 0 1px var(--esgx-acc-line) inset, 0 0 0 4px var(--esgx-acc-soft); }
.lw-pickgroup { margin: 0 0 20px; }
.lw-pickgroup h2 { margin: 0 0 8px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--esgx-faint); }
.lw-pickgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.lw-root .lw-pick { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; min-height: 76px; padding: 14px 16px; border: 0; border-radius: 14px; text-align: left; cursor: pointer;
  background: rgba(17, 17, 20, .85); box-shadow: 0 0 0 1px rgba(255, 255, 255, .07) inset; color: var(--esg-ink); font: inherit; transition: background-color .15s, box-shadow .15s; }
.lw-root .lw-pick:hover { background: rgba(255, 255, 255, .06); box-shadow: 0 0 0 1px var(--esgx-acc-line) inset; }
.lw-pick-t { font-size: 14.5px; font-weight: 500; line-height: 1.3; }
.lw-pick-s { font-size: 12px; color: var(--esgx-faint); }
.lw-pick-s.is-ok { color: var(--esg-ok); }

@media (max-width: 1100px) {
  .lw-right { position: static; max-width: none; flex-basis: 100%; }
  .lw-left { max-width: none; }
}
@media (max-width: 640px) {
  .lw-top { padding: 8px 16px; }
  .lw-main { padding: 16px 16px 48px; }
  .lw-intro h1 { font-size: 22px; }
  .lw-center { padding: 12px; }
  .lw-paper { padding: 24px 20px 32px; font-size: 14px; }
  .lw-lh { flex-direction: column; }
  .lw-fields { grid-template-columns: 1fr; }
  .lw-prog { max-width: none; }
}
@media (prefers-reduced-motion: reduce) { .lw-bar i, .lw-root .lw-pick { transition: none; } }

/* smart phrases (owner 2026-11-18: "add smart phrases to easily apply here"): chips that toggle on and off */
.lw-root .ctkl-phf { display: flex; flex-direction: column; gap: 8px; grid-column: 1 / -1; }
.lw-root .ctkl-ph { border: 0; padding: 0; }
.lw-root .ctkl-ph > summary { min-height: 32px; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; list-style: none; font-size: 12.5px; font-weight: 600; color: var(--esgx-accent); }
.lw-root .ctkl-ph > summary::-webkit-details-marker { display: none; }
.lw-root .ctkl-ph > summary::before { content: "✦"; font-size: 11px; }
.lw-root .ctkl-ph-l { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 6px; }
.lw-root .ctkl-ph-b { min-height: 36px; padding: 6px 12px; border: 0; border-radius: 999px; text-align: left; cursor: pointer; font: inherit; font-size: 13px; line-height: 1.3;
  color: var(--esg-ink2); background: rgba(255, 255, 255, .05); box-shadow: 0 0 0 1px rgba(255, 255, 255, .1) inset; transition: background-color .12s, box-shadow .12s; }
.lw-root .ctkl-ph-b:hover { background: rgba(255, 255, 255, .09); }
.lw-root .ctkl-ph-b.is-on { color: var(--esg-ink); background: var(--esgx-acc-soft); box-shadow: 0 0 0 1px var(--esgx-acc-line) inset; }
.lw-root .ctkl-ph-b.is-on::before { content: "✓ "; color: var(--esgx-accent); font-weight: 600; }
.lw-root .ctkl-ph .ctk-hint { display: block; }
