/* groups.css — styles for groups.js, written against the role tokens in styles.css.

   The Selected panel and the two forms take only the roles `styles.css` declares on `:root`
   and again under `[data-theme="dark"]`, so there is no dark block for them here. The group
   preview is the exception, deliberately: it sits inside the device frame, whose light and
   dark are the built app's appearance (TechPlan.md § Light and dark), so it keeps Studio's
   device colours as literals and follows `.dark` on its own root, which groups.js sets from
   the look. The only values written from script are preview sizes, as `--grp-…` custom
   properties; everything else arrives as a class, `hidden`, `disabled` or `aria-disabled`. */

.grp-panel [hidden], .grp-preview [hidden], .grp-dialog [hidden], .grp-creation [hidden] { display: none !important; }

/* ------------------------------------------------------------- shared parts */

.grp-glyph { width: 14px; height: 14px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.grp-eyebrow { margin: 0; color: var(--muted); font: var(--type-eyebrow); letter-spacing: var(--eyebrow-tracking); text-transform: uppercase; }
.grp-caption { margin: 0; color: var(--muted); font: var(--type-caption); }
.grp-message { margin: 0; font: var(--type-caption); }
.grp-message.warning { color: var(--warn-ink); }
.grp-message.danger { color: var(--bad-ink); }
.grp-error, .grp-refusal { margin: 0; color: var(--bad-ink); font: var(--type-caption); }
.grp-spinner { width: 12px; height: 12px; flex: 0 0 12px; display: inline-block; border: 1.5px solid var(--line-strong); border-top-color: var(--loading); border-radius: 50%; animation: grp-spin .8s linear infinite; }
@keyframes grp-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .grp-spinner { animation: none; border-top-color: var(--line-strong); } }

/* Studio's status badge, as the rail draws it. */
.grp-badge { flex: 0 0 auto; padding: 4px 8px; color: var(--ink-soft); background: var(--chip); border-radius: var(--radius-badge); font: var(--type-caption-strong); white-space: nowrap; }
.grp-badge.approved { color: var(--ok-ink); background: var(--ok-bg); }
.grp-badge.warning { color: var(--warn-ink); background: var(--warn-bg); }

/* ------------------------------------------------------- the group's features */

.grp-panel { min-width: 0; display: grid; gap: 8px; }
.grp-panel-head { min-width: 0; display: flex; align-items: center; gap: 8px; }
.grp-panel-title { color: var(--ink); font: var(--type-label); }
.grp-capacity { color: var(--muted); font: var(--type-caption); }
.grp-spacer { flex: 1 1 auto; }
.grp-panel-extra:empty { display: none; }
.grp-panel-body { min-width: 0; display: grid; gap: 8px; }
.grp-add .menu-popover { left: auto; right: 0; }
/* Studio hides this menu's indicator: the button reads "+ Add feature" and nothing more. */
.grp-add .menu-chevron { display: none; }
.grp-add-label { display: inline-flex; align-items: center; gap: 4px; font: var(--type-caption-strong); }
.grp-add-label .grp-glyph { width: 12px; height: 12px; }
.grp-empty-note { margin: 0; color: var(--muted); font: var(--type-small); }

/* One row per feature: the number and its role, the feature, then move up, move down and
   remove — Studio's grid, so the controls line up down the list. */
.grp-members { margin: 0; padding: 0; display: grid; list-style: none; }
.grp-member { position: relative; min-width: 0; display: grid; grid-template-columns: minmax(28px, auto) minmax(0, 1fr) repeat(3, var(--icon-button)); align-items: center; gap: 4px; }
.grp-ordinal { min-width: 28px; display: flex; flex-direction: column; gap: 1px; color: var(--muted); }
.grp-ordinal b { font: var(--type-small-strong); }
.grp-ordinal small { font: var(--type-caption); white-space: nowrap; }
.grp-member-main { min-width: 0; min-height: calc(var(--control-height) + 16px); display: flex; align-items: center; gap: 8px; padding: 8px; color: var(--ink); background: transparent; border: 0; border-radius: var(--radius-row); text-align: left; }
button.grp-member-main { cursor: pointer; }
button.grp-member-main:hover { background: var(--hover); }
button.grp-member-main:active { background: var(--pressed); }
.grp-member-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.grp-member-text strong { overflow: hidden; color: var(--ink); font: var(--type-small-strong); white-space: nowrap; text-overflow: ellipsis; }
.grp-member-text small { overflow: hidden; color: var(--muted); font: var(--type-caption); white-space: nowrap; text-overflow: ellipsis; }
.grp-member-text small.warning { color: var(--warn-ink); }
.grp-member.unavailable .grp-member-name { flex: 1 1 auto; min-width: 0; overflow: hidden; color: var(--ink-soft); font: var(--type-small); white-space: nowrap; text-overflow: ellipsis; }
.grp-warning-mark { color: var(--warn-mark); }
/* A tab icon: a neutral glyph for a chosen SF Symbol (whose name is on the line beneath),
   or Studio's dashed placeholder. Browsers cannot draw SF Symbols. */
.grp-symbol { width: 20px; height: 20px; color: var(--ink); stroke-width: 1.6; }
.grp-symbol.placeholder { color: var(--muted); stroke-dasharray: 2.5 2.5; }
.grp-icon-button { width: var(--icon-button); height: var(--icon-button); display: grid; place-items: center; padding: 0; color: var(--ink); background: transparent; border: 0; border-radius: var(--radius-icon); cursor: pointer; }
.grp-icon-button:hover:not(:disabled):not([aria-disabled="true"]) { background: var(--hover); }
.grp-icon-button:active:not(:disabled):not([aria-disabled="true"]) { background: var(--pressed); }
.grp-icon-button:disabled, .grp-icon-button[aria-disabled="true"] { color: var(--muted); opacity: .48; cursor: not-allowed; }
.grp-icon-button:disabled { cursor: progress; }
/* A row's quick actions, when the shell does not draw them. */
.grp-context-menu { top: 100%; left: 32px; right: auto; }

/* Can be dismissed, and the workspace plan's toggles: the words, then a switch. */
.grp-sheet-settings { display: grid; gap: 4px; }
.grp-toggle { min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--ink); font: var(--type-small); cursor: pointer; }
.grp-toggle input[role="switch"] { appearance: none; width: 26px; height: 15px; flex: 0 0 26px; margin: 0; position: relative; background: var(--line-strong); border-radius: 8px; cursor: pointer; transition: background-color var(--motion-preview) ease; }
.grp-toggle input[role="switch"]::after { content: ""; width: 11px; height: 11px; position: absolute; top: 2px; left: 2px; background: var(--white); border-radius: 50%; box-shadow: 0 1px 2px var(--shadow-soft); transition: transform var(--motion-preview) ease; }
.grp-toggle input[role="switch"]:checked { background: var(--primary); }
.grp-toggle input[role="switch"]:checked::after { transform: translateX(11px); }
.grp-toggle input[role="switch"]:disabled { opacity: .48; cursor: not-allowed; }
.grp-toggle input[role="switch"]:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .grp-toggle input[role="switch"], .grp-toggle input[role="switch"]::after { transition: none; } }

/* The adaptive workspace's plan, inline under its four headings. */
.grp-plan { display: grid; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); }
.grp-plan-section { display: grid; gap: 8px; }
.grp-plan-section h4 { margin: 0; color: var(--ink); font: var(--type-h4); }
.grp-plan-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.grp-number { min-width: 0; display: grid; gap: 2px; color: var(--ink-soft); font: var(--type-caption); }
.grp-number-input { width: 100%; height: var(--control-height); padding: 0 8px; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-button); font: var(--type-body); font-variant-numeric: tabular-nums; }
.grp-number-input:focus { border-color: var(--selected-line-strong); }
.grp-number-input:disabled { color: var(--muted); background: var(--chip); }
.grp-choice-row { min-width: 0; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 8px; color: var(--ink); font: var(--type-small); }
.grp-segmented button { min-height: 20px; }
.grp-segmented button:disabled { opacity: .48; cursor: not-allowed; }
.grp-plan-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------------------------------------------------------------- forms */

/* A native modal `<dialog>`: Studio's form card — a hairline and a 12px radius on the panel
   surface, cross-faded in over a black scrim at 40%. */
.grp-dialog { width: min(480px, calc(100vw - 32px)); max-width: calc(100vw - 32px); max-height: calc(100vh - 32px); margin: auto; padding: 0; overflow: hidden; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-card); }
.grp-dialog[open] { display: flex; animation: grp-dialog-in .3s ease-in-out; }
.grp-dialog::backdrop { background: rgba(0, 0, 0, .4); }
@keyframes grp-dialog-in { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .grp-dialog[open] { animation: none; } }
.grp-dialog-frame { flex: 1 1 auto; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.grp-dialog-head { flex: 0 0 auto; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 24px 24px 0; }
.grp-dialog-head h2 { flex: 1 1 auto; min-width: 0; margin: 0; font: var(--type-h1); }
/* Studio's mark while the form works: in the header, between the title and Close. */
.grp-dialog-progress { align-self: center; }
.grp-dialog-close { width: var(--icon-button); height: var(--icon-button); flex: 0 0 var(--icon-button); display: grid; place-items: center; padding: 0; color: var(--ink); background: transparent; border: 0; border-radius: var(--radius-icon); font-size: 17px; line-height: 1; cursor: pointer; }
.grp-dialog-close:hover:not(:disabled) { background: var(--hover); }
.grp-dialog-close:disabled { color: var(--muted); cursor: progress; }
.grp-dialog-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: grid; align-content: start; gap: 12px; padding: 16px 24px; }
.grp-dialog-lead { margin: 0; color: var(--ink-soft); font: var(--type-body); }
.grp-dialog-foot { flex: 0 0 auto; display: grid; gap: 8px; padding: 0 24px 24px; }
.grp-dialog-messages:empty { display: none; }
.grp-dialog-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.grp-dialog-cancel, .grp-dialog-primary { height: 32px; padding: 0 12px; border-radius: var(--radius-button); font: var(--type-body); cursor: pointer; }
.grp-dialog-cancel { color: var(--ink); background: var(--selected-fill); border: 1px solid var(--selected-line); }
.grp-dialog-cancel:hover:not(:disabled) { background-image: linear-gradient(var(--hover), var(--hover)); }
.grp-dialog-primary { color: var(--on-primary); background: var(--primary); border: 1px solid transparent; }
.grp-dialog-primary:hover:not(:disabled) { background: var(--primary-hover); }
.grp-dialog-primary:active:not(:disabled) { background: var(--primary-pressed); }
.grp-dialog-cancel:disabled, .grp-dialog-primary:disabled { color: var(--muted); background: var(--chip); border-color: transparent; cursor: not-allowed; }
.grp-field-group { display: grid; gap: 4px; }
.grp-field { width: 100%; height: var(--control-height); padding: 0 12px; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-button); font: var(--type-body); }
.grp-field:focus { border-color: var(--selected-line-strong); }
.grp-field::placeholder { color: var(--muted); }

/* KIND and LAYOUT: Studio's choice rows, a refused layout dimmed to 48% with its reason on hover. */
.grp-shape, .grp-creation { display: grid; gap: 12px; }
.grp-shape-section { display: grid; gap: 8px; }
.grp-choices { display: grid; gap: 6px; }
.grp-choice { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr) 16px; align-items: center; gap: 12px; padding: 12px; color: var(--ink); text-align: left; background: var(--panel-muted); border: 1px solid transparent; border-radius: var(--radius-button); cursor: pointer; }
.grp-choice:hover:not([aria-disabled="true"]):not(:disabled) { background-image: linear-gradient(var(--hover), var(--hover)); }
.grp-choice.selected { background: var(--selected-fill); border-color: var(--selected-line-strong); }
.grp-choice.refused { opacity: .48; cursor: not-allowed; }
.grp-choice:disabled { cursor: progress; }
.grp-choice-copy { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.grp-choice-copy strong { color: var(--ink); font: var(--type-label); }
.grp-choice.selected .grp-choice-copy strong { color: var(--selected-ink); }
.grp-choice-copy small { color: var(--muted); font: var(--type-caption); }
.grp-choice.selected .grp-choice-copy small { color: var(--ink-soft); }
.grp-choice-mark { width: 14px; height: 14px; justify-self: end; border: 1.5px solid var(--muted); border-radius: 50%; }
.grp-choice.selected .grp-choice-mark { border: 4px solid var(--selected-ink); }

/* -------------------------------------------------------------- the preview */

/* Inside the device frame: the built app's palette, never the workspace's. */
.grp-preview { position: absolute; inset: 0; z-index: 7; display: flex; flex-direction: column; overflow: hidden; color: #18181b; background: #fbfbf7; }
.grp-preview.dark { color: #ededf0; background: #19221f; }
.grp-preview:empty { display: none; }
.grp-chrome-top, .grp-chrome-bottom { flex: 0 0 auto; display: flex; flex-direction: column; }
.grp-chrome-top:empty, .grp-chrome-bottom:empty { display: none; }
.grp-content { flex: 1 1 auto; }
/* With the host's chrome, the member fills the screen and the chrome lies over it, as Studio's
   StudioAppChromeView lays it; the plain strips stack above and below instead. */
.grp-preview[data-chrome="overlay"] .grp-content { position: absolute; inset: 0; }
.grp-member-slot { position: relative; min-width: 0; min-height: 0; overflow: hidden; }
.grp-member-host { position: absolute; inset: 0; }
.grp-member-missing .grp-member-host { visibility: hidden; }
.grp-placeholder { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 16px; text-align: center; }
.grp-placeholder strong { color: #18181b; font: 600 15px/20px var(--font-ui); }
.grp-placeholder small { max-width: 260px; color: #67676f; font: 400 12px/16px var(--font-ui); }
.grp-placeholder-mark { width: 28px; height: 28px; color: #67676f; stroke-width: 1.4; stroke-dasharray: 3 3; }
.grp-placeholder-text { max-width: 320px; margin: 0; color: #52525b; font: 400 13px/18px var(--font-ui); }
.grp-placeholder .grp-spinner { border-color: #d1d1d6; border-top-color: #67676f; }
.grp-preview.dark .grp-placeholder strong { color: #ededf0; }
.grp-preview.dark .grp-placeholder small, .grp-preview.dark .grp-placeholder-mark { color: #8e8e97; }
.grp-preview.dark .grp-placeholder-text { color: #b4b4bc; }
.grp-preview-empty { flex: 1 1 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 24px; text-align: center; }
.grp-preview-empty strong { font: 600 15px/20px var(--font-ui); }
.grp-preview-empty small { max-width: 280px; color: #67676f; font: 400 12px/16px var(--font-ui); }
.grp-preview.dark .grp-preview-empty small { color: #8e8e97; }
.grp-empty-mark { width: 30px; height: 30px; stroke-width: 1.5; }

/* The plain labelled strip that stands in when the host hands over no chrome. */
.grp-strip { display: flex; gap: 2px; padding: 4px 8px; background: #f4f4f2; border-color: rgba(0, 0, 0, .1); border-style: solid; border-width: 0; }
.grp-strip-top { overflow-x: auto; border-bottom-width: 1px; }
.grp-strip-bottom { justify-content: space-around; padding-bottom: 12px; border-top-width: 1px; }
.grp-strip-tab { min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 8px; color: #67676f; background: transparent; border: 0; border-radius: 6px; font: 500 10px/13px var(--font-ui); white-space: nowrap; cursor: pointer; }
.grp-strip-top .grp-strip-tab { flex-direction: row; font: 500 12px/16px var(--font-ui); }
.grp-strip-tab.selected { color: #18181b; }
.grp-strip-top .grp-strip-tab.selected { box-shadow: inset 0 -2px 0 currentColor; border-radius: 0; }
.grp-strip-tab .grp-symbol { width: 18px; height: 18px; color: currentColor; }
.grp-preview.dark .grp-strip { background: #1c1f1e; border-color: rgba(255, 255, 255, .1); }
.grp-preview.dark .grp-strip-tab { color: #8e8e97; }
.grp-preview.dark .grp-strip-tab.selected { color: #ededf0; }

/* A sheet container: the background keeps its full height under a bottom sheet; a split's top
   gives up the height its bottom takes. The share is the selected state's. */
.grp-sheet { position: relative; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.grp-sheet-bottom_sheet .grp-sheet-primary { position: absolute; inset: 0; }
.grp-sheet-bottom_sheet .grp-sheet-panel { position: absolute; left: 0; right: 0; bottom: 0; height: var(--grp-sheet-share, 50%); background: #ffffff; border-radius: 16px 16px 0 0; box-shadow: 0 -4px 16px rgba(0, 0, 0, .12); transition: height .25s ease; }
.grp-preview.dark .grp-sheet-bottom_sheet .grp-sheet-panel { background: #1f1f23; box-shadow: 0 -4px 16px rgba(0, 0, 0, .4); }
.grp-sheet-split .grp-sheet-primary { flex: 1 1 auto; }
.grp-sheet-split .grp-sheet-panel { flex: 0 0 var(--grp-sheet-share, 50%); transition: flex-basis .25s ease; }
@media (prefers-reduced-motion: reduce) { .grp-sheet-bottom_sheet .grp-sheet-panel, .grp-sheet-split .grp-sheet-panel { transition: none; } }

/* The adaptive workspace at the device's logical size: side panes at their saved widths as a
   share of it, the second pane filling the rest, and fixed hairlines between. */
.grp-workspace { flex: 1 1 auto; min-height: 0; display: flex; }
.grp-pane { flex: 0 0 var(--grp-pane-share, 30%); min-width: 0; display: flex; flex-direction: column; }
.grp-pane.fill { flex: 1 1 0; }
.grp-pane > .grp-member-slot { flex: 1 1 auto; }
.grp-divider { flex: 0 0 var(--grp-divider-share, 1px); min-width: 1px; background: rgba(0, 0, 0, .1); }
.grp-preview.dark .grp-divider { background: rgba(255, 255, 255, .1); }
