/* Ahamoment profile workspace UI — full-width workbench & compact action row, 2026-08-06. */

.profile-screen {
  position: absolute;
  inset: 0;
  container-type: inline-size;
  container-name: profile-workspace;
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  padding: 8px 7px;
  background: var(--page);
  gap: 8px;
}

.profile-action-row,
.profile-toolbar {
  display: flex;
  min-height: 52px;
  height: 52px;
  max-height: 52px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 8px 16px;
  border-radius: var(--radius-lg);
  background: var(--surface-1);
  box-shadow: var(--shadow-card);
  flex: 0 0 auto;
  z-index: 3;
}

.profile-switcher-wrap {
  position: relative;
}

.profile-switcher-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  height: 32px;
  padding: 4px 10px;
  border: 0;
  border-radius: var(--radius-md);
  color: var(--text-primary);
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--duration-fast) var(--ease-standard);
}

.profile-switcher-trigger:hover,
.profile-switcher-trigger[aria-expanded="true"] {
  background: var(--surface-hover);
}

.profile-switcher-trigger:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.profile-switcher-avatar {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text-primary);
  font-size: 11px;
  font-weight: 600;
}

.profile-switcher-name {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-switcher-chevron {
  display: inline-flex;
  align-items: center;
  color: var(--text-muted);
  pointer-events: none;
}

.profile-switcher-menu {
  position: fixed;
  z-index: var(--z-popover);
  width: min(300px, calc(100vw - 24px));
  padding: 7px;
}

.profile-switcher-menu-heading {
  padding: 7px 9px 6px;
  color: var(--text-faint);
  font-size: 10px;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.profile-switcher-item { min-height: 44px; }
.profile-switcher-item .menu-label { min-width: 0; }
.profile-switcher-item .menu-label strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-switcher-item .menu-label small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.profile-current-badge,
.profile-version-badge {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  min-height: 20px;
  padding: 2px 7px;
  border-radius: 999px;
  color: var(--text-muted);
  background: var(--surface-2);
  font-size: 10px;
  font-weight: 600;
}

.profile-switcher-load-more {
  justify-content: center;
  width: 100%;
  min-height: 34px;
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 11px;
}

.profile-action-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.profile-action-group .button {
  border: 0 !important;
  box-shadow: none !important;
}

.profile-action-group .button--ghost,
.profile-action-group [data-action="open-profile-ai"] {
  border: 0 !important;
  background: transparent !important;
  color: var(--text-secondary);
  box-shadow: none !important;
}

.profile-action-group [data-action="open-profile-ai"]:hover {
  background: var(--surface-hover) !important;
  color: var(--text-primary);
}

.profile-action-group [data-action="save-profile"].button--saved,
.profile-action-group [data-action="save-profile"]:disabled {
  border: 0 !important;
  background: transparent !important;
  color: var(--text-faint) !important;
  opacity: .78;
  cursor: default;
  box-shadow: none !important;
}

.profile-action-group [data-action="save-profile"].button--primary {
  border: 0 !important;
  background: color-mix(in srgb, var(--surface-2) 80%, var(--surface-hover));
  color: var(--text-primary);
  font-weight: 500;
  box-shadow: none !important;
}

.profile-action-group [data-action="save-profile"].button--primary:hover {
  background: var(--surface-hover) !important;
}

.profile-action-group .profile-delete-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0 !important;
  background: transparent !important;
  color: var(--text-muted);
  box-shadow: none !important;
}

.profile-action-group .profile-delete-button:hover:not(:disabled) {
  background: var(--surface-hover) !important;
  color: var(--text-primary);
}

.profile-action-group .profile-delete-button:disabled {
  opacity: .35;
  cursor: default;
}

.profile-action-group .button:focus-visible {
  outline: none;
  box-shadow: var(--focus) !important;
}

.profile-action-group--cloud {
  min-width: 0;
}

.profile-action-group--cloud [data-action="open-profile-builder"] {
  color: var(--text-primary);
  background: var(--surface-2) !important;
}

.profile-action-group--cloud [data-action="open-profile-builder"]:hover {
  background: var(--surface-hover) !important;
}

/* Compact pane selector tablist */
.profile-compact-pane-selector {
  display: none;
  align-items: center;
  gap: 4px;
  padding: 2px;
  border-radius: var(--radius-md);
  background: var(--surface-2);
}

.profile-compact-pane-tab {
  padding: 4px 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease;
}

.profile-compact-pane-tab.is-active,
.profile-compact-pane-tab[aria-selected="true"] {
  background: var(--surface-1);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

/* Workbench Layout */
.profile-screen .profile-workbench {
  display: grid;
  grid-template-columns: clamp(260px, 22vw, 304px) minmax(0, 1fr);
  flex: 1;
  min-height: 0;
  min-width: 0;
  width: 100%;
  align-items: stretch;
}

.profile-summary-panel {
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 22px;
  border-right: .5px solid var(--border);
  background: color-mix(in srgb, var(--surface-1) 64%, var(--page));
}

.profile-summary-identity { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.profile-summary-account { display: flex; align-items: center; gap: 10px; min-width: 0; }
.profile-avatar-large { display: grid; flex: 0 0 auto; width: 36px; height: 36px; place-items: center; border-radius: 50%; color: var(--text-primary); background: var(--surface-2); font-size: 14px; font-weight: 600; }
.profile-summary-account h2 { margin: 0; overflow: hidden; color: var(--text-primary); font-size: 15px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.profile-summary-account p { margin: 3px 0 0; color: var(--text-faint); font-size: 11px; }
.profile-summary-identity .profile-version-badge { margin-top: 8px; }
.profile-summary-divider { height: 1px; margin: 20px 0; background: var(--border); }
.profile-summary-section h3 { margin: 0 0 12px; color: var(--text-secondary); font-size: 11px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; }
.profile-summary-list { margin: 0; }
.profile-summary-list > div { display: grid; grid-template-columns: 58px minmax(0, 1fr); gap: 10px; padding: 9px 0; border-bottom: .5px solid var(--border); }
.profile-summary-list dt { color: var(--text-faint); font-size: 11px; }
.profile-summary-list dd { margin: 0; color: var(--text-secondary); font-size: 12px; line-height: 1.55; }

.profile-editor-column {
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 24px 24px;
}

.profile-form-card { min-width: 0; }
.profile-form-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; padding: 0 0 14px; border-bottom: 1px solid var(--border); }
.profile-panel-kicker { color: var(--text-faint); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.profile-form-header h2 { margin: 6px 0 0; color: var(--text-primary); font-family: var(--font-serif); font-size: 22px; font-weight: 450; letter-spacing: -.02em; }
.profile-form-hint { color: var(--text-faint); font-size: 11px; }
.profile-cloud-state { max-width: 240px; color: var(--text-faint); font-size: 10px; line-height: 1.4; text-align: right; }

.profile-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 28px; }
.profile-field { display: grid; grid-template-columns: 88px minmax(0, 1fr); align-items: start; gap: 12px; min-width: 0; padding: 13px 0; border-bottom: .5px solid var(--border); }
.profile-field--wide { grid-column: 1 / -1; }
.profile-field-label { padding-top: 8px; color: var(--text-faint); font-size: 11px; line-height: 1.45; }
.profile-field-control { width: 100%; min-width: 0; min-height: 34px; padding: 7px 0; border: 0; border-bottom: 1px solid transparent; border-radius: 0; outline: 0; color: var(--text-primary); background: transparent; font: inherit; font-size: 13px; line-height: 1.45; transition: border-color 120ms ease, background 120ms ease; }
.profile-field-control::placeholder { color: var(--text-faint); opacity: .78; }
.profile-field-control:hover { border-bottom-color: var(--border-strong); }
.profile-field-control:focus { border-bottom-color: var(--border-strong); background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.profile-field-control:focus-visible { box-shadow: 0 2px 0 color-mix(in srgb, var(--clay) 48%, transparent); }
.profile-field-control--textarea { min-height: 88px; resize: none; }
.profile-field--wide .profile-field-control--textarea { min-height: 106px; }

.profile-form-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 16px; color: var(--text-faint); font-size: 11px; }
.profile-form-footer-state { color: var(--text-secondary); }

.profile-error-banner,
.profile-conflict-banner {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 8px 14px;
  border: 1px solid color-mix(in srgb, var(--danger) 20%, var(--border));
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  background: color-mix(in srgb, var(--danger) 5%, var(--surface-1));
  font-size: 12px;
}

.profile-error-banner > span:nth-child(2) { margin-right: auto; }

.profile-conflict-banner {
  align-items: flex-start;
  margin-bottom: 16px;
  border-color: color-mix(in srgb, var(--clay) 24%, var(--border));
  background: color-mix(in srgb, var(--clay) 7%, var(--surface-1));
}

.profile-conflict-banner > div:nth-child(2) { min-width: 0; margin-right: auto; }
.profile-conflict-banner strong { color: var(--text-primary); font-size: 12px; }
.profile-conflict-banner p { margin: 3px 0 0; color: var(--text-muted); font-size: 11px; line-height: 1.45; }
.profile-conflict-actions { display: flex; flex: 0 0 auto; align-items: center; gap: 6px; }

.profile-empty-state {
  display: grid;
  flex: 1;
  min-height: 0;
  place-content: center;
  justify-items: center;
  padding: 32px;
  color: var(--text-secondary);
  text-align: center;
}

.profile-empty-state > strong { margin-top: 12px; color: var(--text-primary); font-family: var(--font-serif); font-size: 24px; font-weight: 450; }
.profile-empty-state > p { max-width: 420px; margin: 8px 0 20px; color: var(--text-muted); font-size: 12px; line-height: 1.6; }
.profile-empty-state > div { display: flex; gap: 8px; }
.profile-empty-icon { display: grid; width: 48px; height: 48px; place-items: center; border-radius: 50%; color: var(--text-muted); background: var(--surface-2); }

/* Dialogs */
.profile-ai-dialog { position: relative; width: min(620px, calc(100vw - 32px)); max-height: min(760px, calc(100vh - 32px)); overflow: auto; padding: 28px; }
.profile-ai-dialog-kicker { color: var(--text-faint); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.profile-ai-dialog h2 { margin: 8px 0 6px; font-family: var(--font-serif); font-size: 28px; font-weight: 450; letter-spacing: -.03em; }
.profile-ai-subtitle { margin: 0 0 22px; color: var(--text-secondary); font-size: 13px; line-height: 1.6; }
.profile-ai-input-label { display: block; margin-bottom: 9px; color: var(--text-secondary); font-size: 12px; line-height: 1.5; }
.profile-ai-input { display: block; width: 100%; min-height: 240px; padding: 15px; border: 1px solid var(--border); border-radius: 12px; outline: 0; color: var(--text-primary); background: var(--surface-1); font: inherit; font-size: 13px; line-height: 1.7; resize: vertical; }
.profile-ai-input:focus { border-color: var(--border-strong); box-shadow: var(--focus); }
.profile-ai-draft-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 38px; color: var(--text-faint); font-size: 11px; }
.profile-ai-clear-confirm { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; color: var(--text-secondary); background: var(--surface-2); font-size: 11px; }
.profile-ai-clear-confirm strong { color: var(--text-primary); }
.profile-ai-clear-confirm span { margin-right: auto; }
.profile-ai-local-note { display: block; margin-top: 14px; color: var(--text-faint); font-size: 10px; }

.profile-create-dialog {
  position: relative;
  width: min(680px, calc(100vw - 32px));
  max-height: min(720px, calc(100vh - 32px));
  overflow: auto;
  padding: 28px;
}

.profile-create-dialog h2 { margin: 8px 0 6px; font-family: var(--font-serif); font-size: 28px; font-weight: 450; letter-spacing: -.03em; }
.profile-create-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 24px; }
.profile-create-grid .profile-field { grid-template-columns: 84px minmax(0, 1fr); }

.profile-dialog-error {
  display: flex;
  align-items: center;
  min-height: 38px;
  margin: 12px 0 0;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 7%, var(--surface-1));
  font-size: 11px;
}

.profile-builder-dialog {
  display: flex;
  width: min(1080px, calc(100vw - 32px));
  height: min(720px, calc(100vh - 32px));
  min-height: 540px;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
}

.profile-builder-header {
  display: flex;
  flex: 0 0 auto;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 24px 18px;
  border-bottom: .5px solid var(--border);
}

.profile-builder-header h2 { margin: 6px 0 4px; font-family: var(--font-serif); font-size: 26px; font-weight: 450; letter-spacing: -.03em; }
.profile-builder-header p { margin: 0; color: var(--text-muted); font-size: 11px; }

.profile-builder-recovered {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 7px 24px;
  color: var(--text-secondary);
  background: color-mix(in srgb, var(--clay) 6%, var(--surface-1));
  font-size: 11px;
}

.profile-builder-pass-required {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  margin: 16px 24px 0;
  padding: 14px 16px;
  border: 1px solid color-mix(in srgb, var(--clay) 25%, var(--border));
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--clay) 7%, var(--surface-1));
}

.profile-builder-pass-required strong { color: var(--text-primary); font-size: 12px; }
.profile-builder-pass-required p { margin: 3px 0 0; color: var(--text-muted); font-size: 11px; line-height: 1.45; }
.profile-builder-dialog > .profile-dialog-error { margin: 12px 24px 0; }
.profile-builder-loading { display: flex; flex: 1; align-items: center; justify-content: center; gap: 10px; color: var(--text-muted); font-size: 12px; }

.profile-builder-body {
  display: grid;
  grid-template-columns: minmax(280px, 34%) minmax(0, 1fr);
  flex: 1;
  min-height: 0;
}

.profile-builder-conversation {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  border-right: .5px solid var(--border);
  background: color-mix(in srgb, var(--surface-1) 65%, var(--page));
}

.profile-builder-progress,
.profile-builder-draft-heading {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 46px;
  padding: 12px 16px;
  border-bottom: .5px solid var(--border);
  color: var(--text-muted);
  font-size: 10px;
}

.profile-builder-progress strong,
.profile-builder-draft-heading strong { color: var(--text-secondary); font-size: 11px; }

.profile-builder-messages { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; }
.profile-builder-empty-copy { margin: 0; color: var(--text-faint); font-size: 11px; line-height: 1.6; }
.profile-builder-message { margin-bottom: 14px; }
.profile-builder-message > span { color: var(--text-faint); font-size: 10px; }
.profile-builder-message > p { margin: 4px 0 0; padding: 9px 10px; border-radius: 10px; color: var(--text-secondary); background: var(--surface-2); font-size: 11px; line-height: 1.55; }
.profile-builder-message[data-role="user"] > p { background: color-mix(in srgb, var(--clay) 7%, var(--surface-1)); }

.profile-builder-composer { display: grid; flex: 0 0 auto; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 8px; padding: 12px; border-top: .5px solid var(--border); }
.profile-builder-composer textarea { min-height: 74px; padding: 10px; border: 1px solid var(--border); border-radius: 10px; outline: 0; color: var(--text-primary); background: var(--surface-1); font: inherit; font-size: 11px; line-height: 1.5; resize: none; }
.profile-builder-composer textarea:focus { border-color: var(--border-strong); box-shadow: var(--focus); }

.profile-builder-draft { min-width: 0; min-height: 0; overflow-y: auto; padding: 0 20px 20px; }
.profile-builder-draft-heading { position: sticky; z-index: 1; top: 0; margin: 0 -20px; padding: 12px 20px; background: var(--surface-1); }
.profile-builder-draft-heading > div { display: flex; flex-direction: column; gap: 2px; }
.profile-builder-field-grid { column-gap: 20px; }
.profile-builder-field-grid .profile-field { grid-template-columns: 80px minmax(0, 1fr); padding: 10px 0; }
.profile-builder-field-grid .profile-field-control { font-size: 12px; }
.profile-builder-field-grid .profile-field-control--textarea { min-height: 72px; }

.profile-builder-footer {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 62px;
  padding: 10px 16px 10px 24px;
  border-top: .5px solid var(--border);
  color: var(--text-faint);
  font-size: 10px;
}

.profile-builder-footer > div { display: flex; align-items: center; gap: 7px; }

.profile-screen .dialog-actions { margin-top: 20px; }

/* The proposal review is a compact disclosure in the conversation stream. */
.profile-proposal-details { min-width: 0; margin: 0 0 6px; }
.profile-proposal-details > summary { min-height: 24px; padding: 2px 4px; border-radius: 5px; color: var(--text-secondary); font-size: 12px; }
.profile-proposal-details > summary:hover { background: var(--surface-hover); color: var(--text-primary); }
.profile-proposal-details > summary:focus-visible { outline: 2px solid var(--text-secondary); outline-offset: 2px; }
.profile-proposal-details > dl { display: grid; grid-template-columns: minmax(64px, auto) minmax(0, 1fr); gap: 4px 10px; margin: 6px 4px 8px 20px; padding: 8px 10px; border-left: 1px solid var(--border); color: var(--text-secondary); font-size: 11px; line-height: 1.55; }
.profile-proposal-details > dl dt { color: var(--text-faint); }
.profile-proposal-details > dl dd { min-width: 0; margin: 0; overflow-wrap: anywhere; }
.profile-proposal-details[open] > dl { animation: profile-proposal-reveal 180ms var(--ease-dialog, cubic-bezier(.2,.8,.2,1)) both; }
@keyframes profile-proposal-reveal { from { opacity: 0; clip-path: inset(0 0 100%); } to { opacity: 1; clip-path: inset(0); } }
@media (prefers-reduced-motion: reduce) { .profile-proposal-details[open] > dl { animation: none; } }
html[data-reduce-motion="true"] .profile-proposal-details[open] > dl { animation: none; }

/* Responsive Breakpoints */
@media (max-width: 1099px) and (min-width: 840px) {
  .profile-screen .profile-workbench {
    grid-template-columns: clamp(224px, 20vw, 248px) minmax(0, 1fr);
  }
  .profile-form-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .profile-field--wide {
    grid-column: auto;
  }
}

@media (max-width: 839px) {
  .profile-compact-pane-selector {
    display: flex;
  }
  .profile-screen .profile-workbench {
    grid-template-columns: minmax(0, 1fr);
  }
  .profile-form-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .profile-field--wide {
    grid-column: auto;
  }
  
  .profile-screen[data-profile-compact-pane="summary"] .profile-summary-panel {
    display: block;
    border-right: 0;
    width: 100%;
  }
  .profile-screen[data-profile-compact-pane="summary"] .profile-editor-column {
    display: none;
  }
  
  .profile-screen[data-profile-compact-pane="detail"] .profile-summary-panel {
    display: none;
  }
  .profile-screen[data-profile-compact-pane="detail"] .profile-editor-column {
    display: block;
    width: 100%;
  }

  .profile-action-group--cloud [data-action="activate-profile"],
  .profile-action-group--cloud [data-action="open-profile-create"] {
    display: none;
  }

  .profile-builder-dialog {
    height: calc(100vh - 24px);
  }

  .profile-builder-body {
    grid-template-columns: minmax(0, 1fr);
    overflow-y: auto;
  }

  .profile-builder-conversation {
    min-height: 320px;
    border-right: 0;
    border-bottom: .5px solid var(--border);
  }

  .profile-builder-draft {
    min-height: 420px;
    overflow: visible;
  }

  .profile-builder-footer {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (max-width: 560px) {
  .profile-action-row {
    gap: 6px;
  }
  .profile-switcher-name {
    max-width: 110px;
  }
  .profile-field {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .profile-field-label {
    padding-top: 0;
  }
  .profile-form-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .profile-action-group--cloud [data-action="open-profile-builder"] {
    max-width: 38px;
    overflow: hidden;
    white-space: nowrap;
  }

  .profile-conflict-banner,
  .profile-error-banner {
    align-items: flex-start;
    flex-direction: column;
  }

  .profile-conflict-actions {
    width: 100%;
  }

  .profile-create-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .profile-builder-pass-required {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .profile-builder-pass-required .button {
    grid-column: 1 / -1;
  }

  .profile-builder-footer > div {
    align-items: stretch;
    width: 100%;
    flex-direction: column;
  }
}
