/*
 * Shared look for every Bromley Law task pane (Merge Client Data, Irrevocable Trust, Amend Trust,
 * Insert Clause). Fluent 2 tokens as Word itself uses them: Segoe UI 14/20, 4 px grid, brand blue
 * #0f6cbd, 32 px controls with 4 px corners, neutral greys. Dark ribbon themes flip the tokens
 * through [data-theme="dark"], set by addin-theme.js from Office.context.officeTheme.
 *
 * Page skeleton (every pane):
 *   <header class="ad-title"><h1>Pane name</h1><p>One-line purpose</p></header>
 *   <main class="ad-page"> ... sections with <h2 class="ad-step"><span class="n">1</span>Step name</h2> ... </main>
 *   <footer class="ad-brand">Bromley Law Group</footer>
 * Messages:  <div class="msg ok|warn|error|info">text</div>      Log lines in #log use .ok .warn .error.
 * Buttons:   <button class="primary">Verb phrase</button>  <button class="secondary">...</button>  <button class="subtle">...</button>
 * Fields:    <label class="f" for=..>Label</label><input ...><div class="hint">One line of help</div>
 * Cards:     <div class="card">...</div>   (.card.good = suggested / positive, .card.trust = the main document)
 * Behaviour: addin-ui.js - adExplain(err) for every failure message (what happened, what to do next), adBusy(btn,
 *            "Saving...", job) for every button that waits. Wording: "Save draft to client folder", "Add from this
 *            computer", "Create the ...", results say where ("Saved X in New Client Intake/Client").
 * Controls:  drop-downs, tick boxes and radio buttons are drawn here (both themes); short, restrained motion that
 *            switches off with Windows' "show animations" setting.
 */
:root {
  --brand: #0f6cbd; --brand-hover: #115ea3; --brand-pressed: #0c3b5e; --brand-tint: #ebf3fc; --on-brand: #ffffff;
  --fg1: #242424; --fg2: #424242; --fg3: #616161; --fg-disabled: #bdbdbd;
  --bg1: #ffffff; --bg2: #fafafa; --bg3: #f5f5f5; --bg-disabled: #f0f0f0;
  --stroke1: #d1d1d1; --stroke2: #e0e0e0; --stroke-accessible: #616161;
  --ok-bg: #f1faf1; --ok-fg: #0e700e; --ok-stroke: #9fd89f;
  --warn-bg: #fff9f5; --warn-fg: #bc4b09; --warn-stroke: #f4bfab;
  --error-bg: #fdf3f4; --error-fg: #b10e1c; --error-stroke: #eeacb2;
  --info-bg: #f5f5f5; --info-fg: #242424; --info-stroke: #d1d1d1;
  --shadow: 0 1px 2px rgba(0, 0, 0, .12);
  --radius: 4px; --control: 32px;
  --font: "Segoe UI", "Segoe UI Web (West European)", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif;
  --mono: Consolas, "Cascadia Mono", monospace;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --brand: #479ef5; --brand-hover: #62abf5; --brand-pressed: #2886de; --brand-tint: #0b2b47; --on-brand: #0a0a0a;
  --fg1: #ffffff; --fg2: #d6d6d6; --fg3: #adadad; --fg-disabled: #5c5c5c;
  --bg1: #292929; --bg2: #1f1f1f; --bg3: #141414; --bg-disabled: #141414;
  --stroke1: #666666; --stroke2: #525252; --stroke-accessible: #adadad;
  --ok-bg: #052505; --ok-fg: #9fd89f; --ok-stroke: #0e700e;
  --warn-bg: #4a1e00; --warn-fg: #f7bfa0; --warn-stroke: #bc4b09;
  --error-bg: #3b0509; --error-fg: #f1a7ad; --error-stroke: #b10e1c;
  --info-bg: #1f1f1f; --info-fg: #ffffff; --info-stroke: #666666;
  --shadow: 0 1px 2px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

/* ---- page ---- */
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); font-size: 14px; line-height: 20px; color: var(--fg1); background: var(--bg1); min-width: 300px; }
*, *::before, *::after { box-sizing: border-box; }
.ad-title { padding: 12px 16px 8px; border-bottom: 1px solid var(--stroke2); }
.ad-title h1 { font-size: 16px; line-height: 22px; font-weight: 600; margin: 0; color: var(--fg1); }
.ad-title p { margin: 2px 0 0; font-size: 12px; line-height: 16px; color: var(--fg3); }
.ad-page { padding: 8px 16px 16px; }
.ad-brand { padding: 8px 16px; font-size: 12px; line-height: 16px; color: var(--fg3); border-top: 1px solid var(--stroke2); display: flex; align-items: center; gap: 8px; }
.ad-brand::before { content: ""; width: 3px; height: 14px; background: var(--brand); border-radius: 2px; }
h1, h2, h3 { font-family: inherit; }
h2, .ad-step { font-size: 14px; line-height: 20px; font-weight: 600; color: var(--fg1); margin: 20px 0 6px; display: flex; align-items: center; gap: 8px; }
.ad-page > section:first-child > h2, .ad-page > h2:first-child { margin-top: 8px; }
.ad-step .n { display: inline-flex; width: 20px; height: 20px; border-radius: 50%; background: var(--brand); color: var(--on-brand); font-size: 12px; font-weight: 600; align-items: center; justify-content: center; flex: 0 0 20px; }
.ad-step.done .n { background: var(--ok-fg); }
.ad-step.done .n::before { content: "\2713"; }
.ad-step.done .n span { display: none; }
h3 { font-size: 14px; line-height: 20px; font-weight: 600; margin: 12px 0 4px; }
p { margin: 0 0 8px; }
.hint, p.hint, .fhelp, .help { font-size: 12px; line-height: 16px; color: var(--fg3); margin: 2px 0 6px; }
a { color: var(--brand); } a:hover { color: var(--brand-hover); }
hr { border: 0; border-top: 1px solid var(--stroke2); margin: 12px 0; }
.locked { display: none; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; } .row > * { flex: 1 1 130px; min-width: 0; }
.row.stack > * { flex-basis: 100%; }
.actions { display: flex; flex-direction: column; gap: 8px; margin: 8px 0; } .actions button { width: 100%; margin: 0; }
.actions.inline { flex-direction: row; flex-wrap: wrap; } .actions.inline button { width: auto; flex: 1 1 auto; }

/* ---- controls ---- */
button, input, select, textarea { font-family: inherit; font-size: 14px; line-height: 20px; color: var(--fg1); }
button { min-height: var(--control); padding: 5px 12px; border-radius: var(--radius); border: 1px solid var(--stroke1); background: var(--bg1); color: var(--fg1); font-weight: 600; cursor: pointer; margin: 4px 0; white-space: normal; }
button:hover { background: var(--bg3); border-color: var(--stroke-accessible); }
button:active { background: var(--bg-disabled); }
button.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
button.primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
button.primary:active { background: var(--brand-pressed); border-color: var(--brand-pressed); }
button.secondary { background: var(--bg1); border-color: var(--stroke1); color: var(--fg1); }
button.subtle, button.link { background: none; border-color: transparent; color: var(--brand); font-weight: 600; padding-left: 4px; padding-right: 4px; }
button.subtle:hover, button.link:hover { background: var(--brand-tint); }
button:disabled, button.primary:disabled, button.secondary:disabled { background: var(--bg-disabled); border-color: var(--stroke2); color: var(--fg-disabled); cursor: default; }
button.primary.armed { background: var(--warn-fg); border-color: var(--warn-fg); color: #fff; }
button.x { min-height: 24px; padding: 0 6px; border: none; background: none; color: var(--error-fg); font-size: 14px; margin: 0; }
button.x:hover { background: var(--error-bg); }
button.small { min-height: 24px; padding: 1px 8px; font-size: 12px; line-height: 16px; }
input[type="text"], input[type="number"], input[type="date"], input[type="email"], select, textarea {
  width: 100%; min-height: var(--control); padding: 5px 8px; border: 1px solid var(--stroke1); border-bottom-color: var(--stroke-accessible); border-radius: var(--radius); background: var(--bg1); margin: 0;
}
textarea { min-height: 80px; resize: vertical; line-height: 20px; }
select { padding-right: 24px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--stroke1); border-bottom: 2px solid var(--brand); padding-bottom: 4px; }
textarea:focus { padding-bottom: 4px; }
input:disabled, select:disabled, textarea:disabled { background: var(--bg-disabled); color: var(--fg-disabled); border-color: var(--stroke2); }
input::placeholder, textarea::placeholder { color: var(--fg3); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible, a:focus-visible { outline: 2px solid var(--fg1); outline-offset: 1px; box-shadow: 0 0 0 4px var(--bg1); }
label.f, .label { display: block; font-size: 14px; line-height: 20px; font-weight: 600; margin: 10px 0 4px; color: var(--fg1); }
label.f:first-child { margin-top: 0; }
label.cb, label.rb, .check { display: flex; align-items: flex-start; gap: 8px; font-size: 14px; line-height: 20px; margin: 4px 0; cursor: pointer; }
label.cb input, label.rb input, .check input { margin: 2px 0 0; width: 16px; height: 16px; flex: 0 0 16px; accent-color: var(--brand); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--brand); }
.req { color: var(--error-fg); }
fieldset { border: 1px solid var(--stroke2); border-radius: var(--radius); margin: 12px 0; padding: 8px 12px 12px; background: var(--bg1); }
legend { font-size: 14px; line-height: 20px; font-weight: 600; color: var(--fg1); padding: 0 4px; }
details { margin: 8px 0; }
details > summary { cursor: pointer; font-weight: 600; font-size: 14px; line-height: 20px; color: var(--fg1); padding: 6px 0; list-style: none; display: flex; align-items: center; gap: 6px; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "\25B8"; color: var(--fg3); width: 12px; } details[open] > summary::before { content: "\25BE"; }
table { border-collapse: collapse; width: 100%; font-size: 13px; line-height: 18px; }
td, th { border-bottom: 1px solid var(--stroke2); padding: 3px 6px; vertical-align: top; text-align: left; }
th { font-weight: 600; color: var(--fg2); }
table.map td:first-child { font-weight: 600; width: 36%; color: var(--fg2); }
code, pre, .mono { font-family: var(--mono); font-size: 12px; }
pre { background: var(--bg3); padding: 8px; border-radius: var(--radius); overflow: auto; }

/* ---- cards and messages ---- */
.card, .doc, .item { border: 1px solid var(--stroke1); border-radius: var(--radius); padding: 8px 12px; margin: 8px 0; background: var(--bg1); box-shadow: var(--shadow); }
.card.good, .item.suggested { border-color: var(--ok-stroke); background: var(--ok-bg); }
.card.trust, .doc.trust { border-left: 3px solid var(--brand); }
.card .t, .doc .t { font-weight: 600; color: var(--fg1); } .card .k, .doc .k { color: var(--fg3); font-weight: 400; }
.msg, .note, .banner { font-size: 13px; line-height: 18px; padding: 8px 12px; margin: 6px 0; border: 1px solid var(--info-stroke); border-left-width: 4px; border-radius: var(--radius); background: var(--info-bg); color: var(--info-fg); }
.msg.ok, .note.ok { background: var(--ok-bg); border-color: var(--ok-stroke); border-left-color: var(--ok-fg); }
.msg.warn, .note.warn, .note:not(.ok):not(.info):not(.error), .banner { background: var(--warn-bg); border-color: var(--warn-stroke); border-left-color: var(--warn-fg); }
.msg.error, .note.error { background: var(--error-bg); border-color: var(--error-stroke); border-left-color: var(--error-fg); }
.msg.info, .note.info { background: var(--brand-tint); border-color: var(--stroke2); border-left-color: var(--brand); }
#log { font-size: 13px; line-height: 18px; }
#log div { margin: 2px 0; word-break: break-word; }
#log .ok, .ok { color: var(--ok-fg); } #log .warn, .warn { color: var(--warn-fg); } #log .error, .error { color: var(--error-fg); }
#log.sticky { position: sticky; bottom: 0; background: var(--bg1); border-top: 1px solid var(--stroke2); padding: 6px 16px; max-height: 30vh; overflow: auto; }
#log.sticky:empty { display: none; }
.progress { font-size: 12px; line-height: 16px; color: var(--fg3); }
.busy::after { content: ""; display: inline-block; width: 12px; height: 12px; margin-left: 8px; vertical-align: -1px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: ad-spin .8s linear infinite; }
@keyframes ad-spin { to { transform: rotate(360deg); } }
.tabs { display: flex; border-bottom: 1px solid var(--stroke2); margin: 0 -16px 8px; padding: 0 16px; gap: 4px; }
.tabs button { border: none; background: none; border-radius: 0; border-bottom: 2px solid transparent; margin: 0; padding: 6px 10px; color: var(--fg2); font-weight: 600; min-height: 36px; }
.tabs button:hover { background: var(--bg3); color: var(--fg1); }
.tabs button.active { color: var(--brand); border-bottom-color: var(--brand); }
.list { max-height: 220px; overflow: auto; border: 1px solid var(--stroke1); border-radius: var(--radius); padding: 4px 8px; font-size: 13px; line-height: 18px; background: var(--bg1); }
.list label { display: flex; gap: 6px; align-items: flex-start; margin: 2px 0; cursor: pointer; }
.list label input { margin-top: 2px; }
.muted { color: var(--fg3); }
.empty { color: var(--fg3); font-size: 13px; padding: 8px 0; }

/* ---- feel: crisp, quick, restrained (no blur, no bounce). Off when Windows asks for less motion. ---- */
:root { --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%23616161' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  --tick: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 6.2 5 8.6l4.6-5' fill='none' stroke='%23ffffff' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
:root[data-theme="dark"] { --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 4.5 6 8l3.5-3.5' fill='none' stroke='%23adadad' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  --tick: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2.5 6.2 5 8.6l4.6-5' fill='none' stroke='%230a0a0a' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
button { transition: background-color .12s ease, border-color .12s ease, color .12s ease, transform .08s ease; }
button:not(:disabled):active { transform: translateY(1px); }
input, select, textarea { transition: border-color .12s ease; }
/* drop-downs: one chevron, the same in every pane and both themes */
select:not([multiple]) { -webkit-appearance: none; appearance: none; background-image: var(--chevron); background-repeat: no-repeat; background-position: right 8px center; background-size: 12px; padding-right: 28px; cursor: pointer; }
select:disabled { cursor: default; }
/* tick boxes and radio buttons */
input[type="checkbox"], input[type="radio"] { -webkit-appearance: none; appearance: none; width: 16px; height: 16px; flex: 0 0 16px; margin: 2px 0 0; border: 1px solid var(--stroke-accessible); background: var(--bg1) center / 12px no-repeat; cursor: pointer; vertical-align: -3px;
  transition: background-color .12s ease, border-color .12s ease, box-shadow .12s ease; }
input[type="checkbox"] { border-radius: 3px; }
input[type="radio"] { border-radius: 50%; }
input[type="checkbox"]:hover, input[type="radio"]:hover { border-color: var(--brand); }
input[type="checkbox"]:checked { background-color: var(--brand); border-color: var(--brand); background-image: var(--tick); animation: ad-tick .14s ease-out; }
input[type="radio"]:checked { border-color: var(--brand); box-shadow: inset 0 0 0 4px var(--bg1); background-color: var(--brand); }
input[type="checkbox"]:disabled, input[type="radio"]:disabled { opacity: .5; cursor: default; }
input[type="checkbox"]:focus-visible, input[type="radio"]:focus-visible { outline: 2px solid var(--fg1); outline-offset: 2px; }
@keyframes ad-tick { from { background-size: 4px; } to { background-size: 12px; } }
/* a message or result arriving: a short slide, no fade through blur */
.msg, .note, #log > div, #log > * > div, #result > * { animation: ad-in .16s ease-out; }
@keyframes ad-in { from { opacity: 0; transform: translateY(-2px); } to { opacity: 1; transform: none; } }
.ad-step.done .n { animation: ad-done .22s ease-out; }
@keyframes ad-done { from { transform: scale(.6); } 60% { transform: scale(1.12); } to { transform: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 0s !important; transition-duration: 0s !important; } }
/* narrow panes (320 px): nothing wider than the pane */
@media (max-width: 340px) { .ad-page { padding-left: 12px; padding-right: 12px; } .ad-title, .ad-brand { padding-left: 12px; padding-right: 12px; } .row > * { flex-basis: 100%; } table { word-break: break-word; } }
