/* Personal settings: visual values are scoped to the authenticated shell. */
body.owner-shell-v1 .settings-action-grid { align-items: stretch; }
body.owner-shell-v1 .settings-panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 16px; }
body.owner-shell-v1 .settings-panel-heading h3 { margin: 4px 0 5px; }
body.owner-shell-v1 .settings-panel-heading p { margin: 0; color: var(--cc-muted, #71808a); }
body.owner-shell-v1 .eyebrow { color: var(--cc-accent, #1c756d); font-size: 10px; letter-spacing: .08em; }
body.owner-shell-v1 .settings-action-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 14px 0; border-top: 1px solid color-mix(in srgb, var(--cc-border, #d5dedb) 70%, transparent); }
body.owner-shell-v1 .settings-action-row > span:first-child { display: grid; gap: 4px; min-width: 180px; }
body.owner-shell-v1 .settings-action-row small, body.owner-shell-v1 .settings-export-card small { color: var(--cc-muted, #71808a); }
body.owner-shell-v1 .settings-inline-form { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
body.owner-shell-v1 .settings-inline-form input, body.owner-shell-v1 .settings-preferences-form select { min-height: 38px; }
body.owner-shell-v1 .settings-password-inline input { max-width: 190px; }
body.owner-shell-v1 .settings-form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
body.owner-shell-v1 .settings-preferences-section-label { margin: 16px 0 8px; color: var(--cc-accent, #1c756d); font-size: 12px; font-weight: 700; }
body.owner-shell-v1 .settings-form-grid label:not(.settings-toggle) { display: grid; gap: 6px; }
body.owner-shell-v1 .settings-toggle { display: flex; align-items: center; gap: 10px; padding-top: 22px; }
body.owner-shell-v1 .settings-toggle span { display: grid; gap: 3px; }
body.owner-shell-v1 .settings-form-actions { display: flex; align-items: center; gap: 12px; margin-top: 18px; }
body.owner-shell-v1 .settings-inline-result { color: var(--cc-accent, #1c756d); min-height: 1.2em; }
body.owner-shell-v1 .settings-export-card { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px; border: 1px solid color-mix(in srgb, var(--cc-border, #d5dedb) 85%, transparent); background: color-mix(in srgb, var(--cc-panel, #fff) 82%, var(--cc-accent, #1c756d)); }
body.owner-shell-v1 .settings-export-card > span { display: grid; gap: 5px; }
@media (max-width: 760px) {
  body.owner-shell-v1 .settings-action-row, body.owner-shell-v1 .settings-export-card { align-items: stretch; flex-direction: column; }
  body.owner-shell-v1 .settings-inline-form { justify-content: stretch; }
  body.owner-shell-v1 .settings-inline-form input, body.owner-shell-v1 .settings-inline-form button, body.owner-shell-v1 .settings-export-card .mini-action { width: 100%; max-width: none; }
  body.owner-shell-v1 .settings-form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  body.owner-shell-v1 .settings-toggle { padding-top: 0; }
}
@media (max-width: 480px) { body.owner-shell-v1 .settings-form-grid { grid-template-columns: minmax(0, 1fr); } }
html[data-font-size="small"] body.owner-shell-v1 { font-size: 14px; }
html[data-font-size="medium"] body.owner-shell-v1 { font-size: 16px; }
html[data-font-size="large"] body.owner-shell-v1 { font-size: 18px; }

html[data-font-family="sans"] body.owner-shell-v1 { font-family: "Microsoft YaHei UI", "Noto Sans SC", sans-serif; }
html[data-font-family="serif"] body.owner-shell-v1 { font-family: "Noto Serif SC", "Songti SC", serif; }

html[data-density="compact"] body.owner-shell-v1 {
  --cc-density-row-gap: 6px;
  --cc-density-panel-padding: 12px;
}
html[data-density="comfortable"] body.owner-shell-v1 {
  --cc-density-row-gap: 12px;
  --cc-density-panel-padding: 18px;
}
html[data-density="compact"] body.owner-shell-v1 .panel { padding: var(--cc-density-panel-padding); }
html[data-density="compact"] body.owner-shell-v1 .list { gap: var(--cc-density-row-gap); }
html[data-reduce-motion="true"] body.owner-shell-v1 *,
html[data-reduce-motion="true"] body.owner-shell-v1 *::before,
html[data-reduce-motion="true"] body.owner-shell-v1 *::after {
  animation-duration: 1ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 1ms !important;
  scroll-behavior: auto !important;
}

@media (max-width: 600px) {
  body.owner-shell-v1 .tabs { padding-bottom: 3px; }
  body.owner-shell-v1 .tab { min-height: 40px; }
}

/* PEOPLE-MOBILE-EDITOR-BOUNDARY-R1: canvas resets must not expand editor cards. */
@media (max-width: 600px) {
  body.owner-shell-v1 #moduleStage .cc-people-v2 .people-contact-editor-canvas .people-canvas-editor-panel {
    height: min(62vh, 520px) !important;
    max-height: min(62vh, 520px) !important;
    overflow-y: auto !important;
  }
}

body.owner-shell-v1 .is-resizing-form-field,
body.owner-shell-v1 .is-resizing-form-field * {
  cursor: nwse-resize !important;
  user-select: none !important;
}

body.owner-shell-v1 #moduleStage :is(
  .cc-profile__field,
  [data-command-library="vault"] .vault-library-entry-form > .field,
  [data-reminders-v2] .reminder-v2-form > .field,
  [data-reminders-v2] .reminder-v2-form-row > .field,
  [data-reminders-v2] .reminder-v2-repeat-control > .field
) {
  position: relative;
}

body.owner-shell-v1 #moduleStage :is(
  [data-reminders-v2] .reminder-v2-form > .field,
  [data-reminders-v2] .reminder-v2-form-row > .field,
  [data-reminders-v2] .reminder-v2-repeat-control > .field
)::after {
  content: "";
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 11px;
  height: 11px;
  border-right: 2px solid color-mix(in srgb, var(--cc-accent, #1c756d) 72%, transparent);
  border-bottom: 2px solid color-mix(in srgb, var(--cc-accent, #1c756d) 72%, transparent);
  pointer-events: none;
}

@media (max-width: 760px) {
  body.owner-shell-v1 #moduleStage :is(
    .cc-profile__field,
    [data-command-library="vault"] .vault-library-entry-form > .field,
    [data-reminders-v2] .field
  )::after {
    display: none;
  }
}

/* Library dense editors keep their own bounded scroll range. Profile is an
   exception: its outer editor is the single scroll owner so collapsed groups
   below the first viewport can be reached by browser, keyboard and pointer. */
body.owner-shell-v1 .knowledge-v2__current-notes,
body.owner-shell-v1 .knowledge-v2__records,
body.owner-shell-v1 .knowledge-v2__capture-body {
  max-height: min(72vh, 860px);
  min-height: 0;
  overflow: auto;
  scrollbar-gutter: stable;
  overscroll-behavior: contain;
}

body.owner-shell-v1 .cc-profile__field textarea,
body.owner-shell-v1 .knowledge-v2__capture textarea,
body.owner-shell-v1 .knowledge-v2__custom-field-row textarea {
  min-width: min(100%, 16rem);
  min-height: 5.5rem;
  max-width: 100%;
  resize: vertical;
  overflow: auto;
}

body.owner-shell-v1 .cc-profile__field textarea {
  resize: none !important;
}

@media (min-width: 761px) {
  body.owner-shell-v1 #moduleStage .field:has(> input:not([type="checkbox"]):not([type="radio"])),
  body.owner-shell-v1 #moduleStage .field:has(> textarea) {
    box-sizing: border-box;
    max-width: 100%;
    resize: both;
    overflow: auto;
    align-content: start;
  }
}

@media (min-width: 601px) {
  body.owner-shell-v1 .knowledge-v2__capture .library-form:has(textarea:focus) {
    align-items: start;
  }

  body.owner-shell-v1 .knowledge-v2__capture .field:has(> textarea:focus) {
    grid-column: 1 / -1;
  }
}

@media (max-width: 600px) {
  body.owner-shell-v1 .knowledge-v2__current-notes,
  body.owner-shell-v1 .knowledge-v2__records,
  body.owner-shell-v1 .knowledge-v2__capture-body {
    max-height: 62vh;
    overscroll-behavior: auto;
  }

  body.owner-shell-v1 .cc-profile__field textarea,
  body.owner-shell-v1 .knowledge-v2__capture textarea,
  body.owner-shell-v1 .knowledge-v2__custom-field-row textarea {
    min-width: 0;
    width: 100%;
  }

  body.owner-shell-v1 #moduleStage .field:has(> input:not([type="checkbox"]):not([type="radio"])),
  body.owner-shell-v1 #moduleStage .field:has(> textarea) {
    width: 100%;
    max-width: 100%;
    resize: vertical;
    overflow: auto;
  }
}

/* Give dense editable grids a temporary full-row editor without changing their data model. */
@media (min-width: 601px) {
  body.owner-shell-v1 .form-grid:has(> label > input:not([type="checkbox"]):not([type="radio"]):not([type="date"]):not([type="datetime-local"]):focus),
  body.owner-shell-v1 .form-grid:has(> label > textarea:focus) {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }

  body.owner-shell-v1 .form-grid > label:has(> input:not([type="checkbox"]):not([type="radio"]):not([type="date"]):not([type="datetime-local"]):focus),
  body.owner-shell-v1 .form-grid > label:has(> textarea:focus),
  body.owner-shell-v1 .cc-people-v2 .people-form > .field:has(> input:not([type="checkbox"]):not([type="radio"]):not([type="date"]):not([type="datetime-local"]):focus),
  body.owner-shell-v1 .cc-people-v2 .people-form > .field:has(> textarea:focus),
  body.owner-shell-v1 .cc-custom-info__form-grid > label:has(> input:not([type="checkbox"]):not([type="radio"]):focus),
  body.owner-shell-v1 .cc-custom-info__form-grid > label:has(> textarea:focus),
  body.owner-shell-v1 .cc-people-v2 .people-full-edit-grid > [data-people-edit-field-row]:has(> input:not([type="checkbox"]):not([type="radio"]):focus),
  body.owner-shell-v1 .cc-people-v2 .people-full-edit-grid > [data-people-edit-field-row]:has(> textarea:focus),
  body.owner-shell-v1 [data-items-v2="true"] .items-v2__crud-form > .field:has(> input:not([type="checkbox"]):not([type="radio"]):not([type="date"]):focus),
  body.owner-shell-v1 [data-items-v2="true"] .items-v2__crud-form > .field:has(> textarea:focus) {
    grid-column: 1 / -1;
  }

}

/* Freeform values may grow vertically; structured controls stay stable and predictable. */
body.owner-shell-v1 .form-grid textarea,
body.owner-shell-v1 #moduleStage textarea,
body.owner-shell-v1 .cc-custom-info__form-grid textarea,
body.owner-shell-v1 .knowledge-v2__custom-field-row textarea,
body.owner-shell-v1 [data-items-v2="true"] .items-v2__crud-form textarea,
body.owner-shell-v1 .cc-people-v2 .people-full-edit-grid textarea,
body.owner-shell-v1 [data-reminders-v2] textarea {
  min-height: 5.5rem;
  max-width: 100%;
  resize: vertical !important;
  overflow: auto;
}

/* Wrapper resize owns these layouts. Do not let an inner textarea steal the drag handle. */
body.owner-shell-v1 #moduleStage .cc-profile__field textarea,
body.owner-shell-v1 #moduleStage [data-command-library="vault"] .vault-library-entry-form > .field > textarea {
  resize: none !important;
}

@media (max-width: 600px) {
  body.owner-shell-v1 #moduleStage [data-command-library="vault"] .vault-library-entry-form > .field::after {
    display: none;
  }
}

/* These panels already have bounded heights. Reserve the scrollbar instead of hiding records. */
body.owner-shell-v1 .cc-people-v2 .people-canvas-editor-panel,
body.owner-shell-v1 .cc-people-v2 .people-list,
body.owner-shell-v1 .cc-people-v2 .people-timeline,
body.owner-shell-v1 [data-reminders-v2] .reminder-v2-list,
body.owner-shell-v1 [data-items-v2="true"] .items-v2__list,
body.owner-shell-v1 .knowledge-v2__records {
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  overscroll-behavior: contain;
}

/* Dense record and editor surfaces keep their own vertical working area. */
body.owner-shell-v1 :is(
  .cc-profile__all-fields,
  .cc-profile__view-groups,
  .cc-profile__life-editor,
  .cc-profile__life-browser,
  .cc-profile__life-timeline,
  .knowledge-v2__capture-body,
  .knowledge-v2__category-form,
  .knowledge-v2__records,
  .knowledge-v2__category-results,
  [data-items-v2="true"] .items-v2__detail-pane,
  [data-items-v2="true"] .items-v2__crud-form,
  [data-items-v2="true"] .items-v2__history,
  .cc-people-v2 .people-full-edit-form,
  [data-reminders-v2] .reminder-v2-form,
  [data-reminders-v2] .reminder-v2-edit-fields,
  .cc-custom-info__records,
  .cc-custom-info__detail-shell,
  .cc-custom-info__form,
  .cc-custom-info__collection-form,
  .cc-custom-info__collection-list,
  [data-settings-activation-form],
  [data-settings-password-form],
  [data-settings-preferences-form],
  [data-admin-code-form],
  .ai-settings__connection-form,
  [data-ai-settings-permissions-form],
  [data-command-library="vault"] .library-editor-body,
  [data-command-library="vault"] .vault-library-list-panel,
  [data-command-library="vault"] .vault-library-secret-list
) {
  min-height: 0;
  max-height: min(72vh, 760px);
  overflow-y: scroll; /* overflow-y: auto remains the fallback contract for older renderers. */
  overflow-x: hidden;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  overscroll-behavior: contain;
}

body.owner-shell-v1 [data-reminders-v2] .reminder-v2-create-disclosure[open] .reminder-v2-form {
  overflow-y: scroll;
}

/* SETTINGS-PASSWORD-LAYOUT-R1: labels and password inputs stay in separate rows. */
body.owner-shell-v1 .settings-password-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
  gap: 12px;
}

body.owner-shell-v1 .settings-password-form > label {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}

body.owner-shell-v1 .settings-password-form > label > :is(span, input) {
  width: 100%;
  min-width: 0;
}

body.owner-shell-v1 .settings-password-form > .mini-action {
  justify-self: start;
}

@media (max-width: 600px) {
  body.owner-shell-v1 .cc-people-v2 .people-canvas-editor-panel,
  body.owner-shell-v1 .cc-people-v2 .people-list,
  body.owner-shell-v1 .cc-people-v2 .people-timeline,
  body.owner-shell-v1 [data-reminders-v2] .reminder-v2-list,
  body.owner-shell-v1 [data-items-v2="true"] .items-v2__list,
  body.owner-shell-v1 .knowledge-v2__records {
    overscroll-behavior: auto;
  }

  body.owner-shell-v1 :is(
    .cc-profile__all-fields,
    .cc-profile__view-groups,
    .cc-profile__life-editor,
    .cc-profile__life-browser,
    .cc-profile__life-timeline,
    .knowledge-v2__capture-body,
    .knowledge-v2__category-form,
    .knowledge-v2__records,
    .knowledge-v2__category-results,
    [data-items-v2="true"] .items-v2__detail-pane,
    [data-items-v2="true"] .items-v2__crud-form,
    [data-items-v2="true"] .items-v2__history,
    .cc-people-v2 .people-full-edit-form,
    [data-reminders-v2] .reminder-v2-form,
    [data-reminders-v2] .reminder-v2-edit-fields,
    .cc-custom-info__records,
    .cc-custom-info__detail-shell,
    .cc-custom-info__form,
    .cc-custom-info__collection-form,
    .cc-custom-info__collection-list,
    [data-settings-activation-form],
    [data-settings-password-form],
    [data-settings-preferences-form],
    [data-admin-code-form],
    .ai-settings__connection-form,
    [data-ai-settings-permissions-form],
    [data-command-library="vault"] .library-editor-body,
    [data-command-library="vault"] .vault-library-list-panel,
    [data-command-library="vault"] .vault-library-secret-list
  ) {
    max-height: 62vh;
    overscroll-behavior: auto;
  }
}
