/* Voluntary measurements and installation share the small, accessible notice. */
.hk-retention-notice {
  position: fixed; z-index: 1002; inset-inline: 12px; bottom: calc(108px + env(safe-area-inset-bottom, 0px));
  width: min(680px, calc(100% - 24px)); max-height: calc(100dvh - 140px); margin-inline: auto;
  display: flex; flex-wrap: wrap; gap: 12px 18px; align-items: center;
  padding: 15px 18px; border: 1px solid var(--line, #d6d6dc); border-radius:var(--ui-radius-card);
  background: var(--surface, #fff); color: var(--ink, #303139); box-shadow: 0 4px 18px rgb(20 18 31 / .12);
  overflow: auto; overscroll-behavior: contain; overflow-wrap: anywhere; font: inherit;
}
.hk-retention-notice[hidden], .hk-retention-dialog [hidden], .hk-retention-spacer[hidden] { display: none; }
.hk-retention-copy { flex: 1 1 290px; min-width: 0; }
.hk-retention-copy h2 { margin: 0 0 5px; font-size: .88rem; font-weight: 700; line-height: 1.5; }
.hk-retention-copy p { margin: 0; color: var(--muted, #62636d); font-size: .77rem; line-height: 1.65; }
.hk-retention-actions { display: flex; flex: 1 1 auto; flex-wrap: wrap; gap: 8px; }
.hk-retention-button {
  display: inline-flex; align-items: center; justify-content: center; min-width: 0; min-height: 44px; max-width: 100%;
  padding: 9px 13px; border: 1px solid var(--line, #d6d6dc); border-radius:var(--ui-radius-control);
  background: var(--surface, #fff); color: var(--ink, #303139); font: inherit; font-size: .77rem; line-height: 1.5;
  font-weight: 600; white-space: normal; overflow-wrap: anywhere; text-align: center; cursor: pointer;
}
.hk-retention-button:hover { background: var(--surface-2, #f4f4f6); }
.hk-retention-button:focus-visible, .hk-retention-dialog:focus-visible { outline: 3px solid var(--hk-focus, #c53b13); outline-offset: 3px; }
.hk-retention-button:disabled { cursor: not-allowed; opacity: .5; }
.hk-retention-dialog {
  width: min(600px, calc(100% - 24px)); max-width: calc(100% - 24px); max-height: calc(100dvh - 32px);
  margin: auto; padding: 24px; border: 1px solid var(--line, #d6d6dc); border-radius:var(--ui-radius-card);
  background: var(--surface, #fff); color: var(--ink, #303139); font: inherit; overflow: auto; overflow-wrap: anywhere;
}
.hk-retention-dialog::backdrop { background: rgb(10 12 17 / .48); -webkit-backdrop-filter: none; backdrop-filter: none; }
body.dark-mode .hk-retention-dialog::backdrop { background: rgb(8 10 15 / .7); }
.hk-retention-dialog h2 { margin: 0 0 14px; font-size: 1.15rem; line-height: 1.4; }
.hk-retention-dialog p { margin: 0 0 15px; font-size: .86rem; line-height: 1.8; }
.hk-retention-dialog .hk-retention-details { color: var(--muted, #62636d); }
.hk-retention-dialog .hk-retention-status { padding: 12px; border: 1px solid var(--line, #d6d6dc); border-radius:var(--ui-radius-control); }
.hk-retention-spacer { flex: 0 0 auto; }
.hk-telemetry-settings { margin: 8px; font-weight: 400; }
/* Measurements use the same opaque surface and simple scrim as other dialogs. */
.hk-telemetry-banner { box-shadow: 0 8px 30px rgb(20 18 31 / .14); }
#hk-telemetry-dialog {
  position: fixed; inset: 0; height: fit-content; width: min(600px, calc(100% - 24px)); max-width: calc(100% - 24px);
  max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); margin: auto; padding: 24px;
  border-radius:var(--ui-radius-panel); overflow: auto; overscroll-behavior: contain;
  background: var(--surface, #fff); box-shadow: 0 28px 90px -20px rgb(0 0 0 / .4);
  opacity: 0; transform: translateY(16px) scale(.96);
  transition: opacity 160ms ease-out, transform 220ms cubic-bezier(.2, .9, .25, 1);
}
#hk-telemetry-dialog[open] { display: block; }
#hk-telemetry-dialog.is-open { opacity: 1; transform: none; }
#hk-telemetry-dialog.is-closing {
  opacity: 0; pointer-events: none; transform: translateY(12px) scale(.97);
  transition-duration: 140ms, 180ms; transition-timing-function: ease-in;
}
#hk-telemetry-dialog::backdrop {
  background: rgb(10 12 17 / .48); opacity: 0; -webkit-backdrop-filter: none; backdrop-filter: none;
  transition: opacity 160ms ease-out;
}
#hk-telemetry-dialog.is-open::backdrop { opacity: 1; }
body.dark-mode #hk-telemetry-dialog::backdrop { background: rgb(8 10 15 / .7); }
.hk-telemetry-banner, #hk-telemetry-dialog { background: var(--surface, #fff); -webkit-backdrop-filter: none; backdrop-filter: none; }
html.reduce-motion #hk-telemetry-dialog, html.lite-mode #hk-telemetry-dialog { transform: none !important; transition: none !important; }
html.reduce-motion #hk-telemetry-dialog::backdrop, html.lite-mode #hk-telemetry-dialog::backdrop { transition: none; }
html.lite-mode .hk-telemetry-banner, html.lite-mode #hk-telemetry-dialog {
  background: var(--surface, #fff); -webkit-backdrop-filter: none !important; backdrop-filter: none !important;
  box-shadow: 0 1px 3px rgb(20 18 31 / .2);
}
html.lite-mode #hk-telemetry-dialog::backdrop { -webkit-backdrop-filter: none !important; backdrop-filter: none !important; }
@media (prefers-reduced-motion: reduce) {
  #hk-telemetry-dialog { transform: none !important; transition: none !important; }
  #hk-telemetry-dialog::backdrop { transition: none; }
}
@media (min-width: 768px) { .hk-retention-notice { bottom: 18px; max-height: calc(100dvh - 48px); } }
@media (max-width: 400px) {
  .hk-retention-notice { padding: 12px; gap: 10px; }
  .hk-retention-actions > .hk-retention-button { flex: 1 1 90px; }
  .hk-retention-dialog { padding: 18px; }
  #hk-telemetry-dialog { padding: 18px; }
}
@media (prefers-reduced-motion: reduce) { .hk-retention-notice, .hk-retention-dialog { scroll-behavior: auto; } }


/* Local work stays compact until the user opens its saved work and routines. */
.result-saved-shell {
  --saved-card:var(--bg-card,#fff); --saved-subtle:var(--surface-2,#f1f2f4);
  --saved-line:var(--border-color,#e0e2e6); --saved-text:var(--text-main,#303238);
  --saved-muted:var(--text-muted,#61656d); --saved-hover:var(--bg-hover,#edf0f3);
  width:100%; max-width:900px; min-width:0; margin:12px auto; text-align:start; color:var(--saved-text); color-scheme:light;
}
.result-saved-shell > .result-saved-home { margin:0; max-width:100%; }
.result-saved-shortcut { display:flex; align-items:center; flex-wrap:wrap; gap:8px 14px; padding:10px 14px; margin-bottom:6px; border:1px solid var(--line,#d9d9df); border-radius:var(--ui-radius-control); background:var(--surface-2,#f7f7f8); }
.result-saved-latest { flex:1 1 180px; min-width:0; margin:0; color:var(--muted,#62636d); font-size:.78rem; line-height:1.6; overflow-wrap:anywhere; }
.result-saved-shortcut .result-flow-button { flex:0 1 auto; min-height:44px; max-width:100%; white-space:normal; overflow-wrap:anywhere; }
.result-saved-shell button { scroll-margin-block:110px 140px; }
.result-saved-shell button:focus-visible { outline:3px solid var(--hk-focus,#c53b13); outline-offset:3px; }
.result-saved-home > summary > span:first-child { min-width:0; overflow-wrap:anywhere; }
.result-saved-count { display:inline-flex; align-items:center; justify-content:center; flex:0 0 auto; min-width:24px; min-height:24px; padding:2px 7px; border-radius:999px; background:var(--upload-soft,#fff0e9); color:var(--upload-accent,#a73613); font-size:.75rem; font-variant-numeric:tabular-nums; }
.result-preset-list { display:grid; gap:8px; min-width:0; }
.result-preset-row { padding:10px 12px; border:1px solid var(--line,#d9d9df); border-radius:var(--ui-radius-control); background:var(--surface-2,#f7f7f8); }
.result-preset-row .result-history-copy { display:grid; gap:4px; }
.result-preset-row > .result-flow-button { flex:0 1 auto; }
.result-followup > .result-next-actions { grid-template-columns:minmax(0,1fr); }
.result-next-primary { border-color:var(--upload-accent,#a73613); font-weight:650; }
.result-saved-shell [hidden] { display:none; }
/* Scoped surfaces override the older global charcoal defaults in both themes. */
body .result-saved-shell .result-saved-home {
  padding:6px 18px 12px; border-color:var(--saved-line); border-radius:var(--ui-radius-card);
  background:var(--saved-card); color:var(--saved-text);
  box-shadow:0 14px 34px -28px rgb(28 42 58 / .28);
}
body .result-saved-shell .result-saved-home > summary { min-height:54px; gap:12px; font-weight:650; color:var(--saved-text); }
.result-saved-shell .result-saved-home > summary::after {
  display:inline-flex; align-items:center; justify-content:center; flex:0 0 28px; height:28px;
  border:1px solid var(--saved-line); border-radius:50%; background:var(--saved-subtle); color:var(--saved-muted);
}
.result-saved-shell .result-saved-body { margin-top:0; padding:14px 0 4px; gap:12px; border-top:1px solid var(--saved-line); }
.result-saved-shell .result-saved-home h3 { margin:10px 0 0; color:var(--saved-text); font-size:.88rem; font-weight:650; }
.result-saved-shell .result-saved-home p,.result-saved-shell .result-history-copy span,.result-saved-shell .result-saved-latest { color:var(--saved-muted); }
.result-saved-shell .result-history-copy strong { color:var(--saved-text); font-weight:650; }
body .result-saved-shell .result-saved-shortcut,
body .result-saved-shell .result-saved-row,
body .result-saved-shell .result-recipe-builder {
  padding:13px 14px; border:1px solid var(--saved-line); border-radius:var(--ui-radius-control);
  background:var(--saved-subtle); color:var(--saved-text);
}
.result-saved-shell .result-saved-row { gap:12px; }
.result-saved-shell .result-history-actions { gap:8px; min-width:0; max-width:100%; }
.result-saved-shell .result-flow-button {
  border-color:var(--saved-line); background:var(--saved-card); color:var(--saved-text); border-radius:var(--ui-radius-control); font-weight:550;
}
.result-saved-shell .result-flow-button:hover:not(:disabled) { border-color:var(--border-hover,var(--saved-line)); background:var(--saved-hover); }
.result-saved-shell .result-saved-shortcut .result-flow-button,
.result-saved-shell .result-preset-row > .result-flow-button {
  border-color:var(--accent-line,var(--saved-line)); background:var(--accent-soft,var(--saved-card)); color:var(--accent-text,var(--saved-text));
}
.result-saved-shell .result-saved-count { background:var(--accent-soft,var(--saved-subtle)); color:var(--accent-text,var(--saved-text)); }
body .result-saved-shell .result-recipe-builder input,
body .result-saved-shell .result-recipe-builder select,
body .result-saved-shell .result-recipe-name,
body .result-saved-shell .result-history-actions select {
  box-sizing:border-box; min-width:0; max-width:100%; min-height:44px; padding:10px 12px;
  border:1px solid var(--saved-line); border-radius:var(--ui-radius-control); background:var(--saved-card); color:var(--saved-text);
  font:inherit; font-size:.8rem; line-height:1.5;
}
.result-saved-shell .result-history-actions select { flex:1 1 150px; width:100%; }
.result-saved-shell .result-recipe-builder label { gap:7px; color:var(--saved-muted); line-height:1.6; }
.result-saved-shell .result-recipe-builder > summary { color:var(--saved-text); font-weight:650; }
.result-saved-shell .result-recipe-steps { color:var(--saved-text); line-height:1.8; }
.result-saved-shell .result-flow-status { padding:12px 14px; border:1px solid var(--saved-line); border-radius:var(--ui-radius-control); background:var(--saved-subtle); color:var(--saved-text); }
.result-saved-shell :is(button,input,select,summary):focus-visible { outline:3px solid var(--hk-focus,#c53b13); outline-offset:3px; }
body.dark-mode .result-saved-shell { color-scheme:dark; }
html.lite-mode .result-saved-shell .result-saved-home { box-shadow:none; }
@media(max-width:420px) {
  body .result-saved-shell .result-saved-home { padding-inline:12px; border-radius:var(--ui-radius-card); }
  body .result-saved-shell .result-saved-row,body .result-saved-shell .result-recipe-builder { padding:12px; }
  .result-saved-shortcut { align-items:stretch; padding:10px 12px; }
  .result-saved-shortcut .result-flow-button, .result-preset-row > .result-flow-button { flex:1 1 100%; }
}
