/* Cards & Layout */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.module-card {
  background: var(--color-card);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--duration-base) var(--ease-out), transform var(--duration-base) var(--ease-out);
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  gap: 20px;
  height: 100%;
}

.split-main {
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  padding-right: 4px;
}

.split-side {
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  padding-left: 4px;
}

.sticky-summary {
  position: sticky;
  top: 0;
}

.editor-card .textarea-field {
  min-height: 116px;
  max-height: 220px;
}

.module-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.section-subtitle {
  margin-top: -8px;
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

.stacked-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.segmented-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border-radius: var(--radius-md);
  background: var(--secondary);
  width: max-content;
  max-width: 100%;
  flex-wrap: wrap;
}

.profile-mode-bar,
.agent-mode-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-card);
}

.profile-mode-bar .primary-btn.active {
  box-shadow: 0 0 0 2px rgba(33, 32, 30, 0.12);
}

.ai-profile-card.prominent,

.agent-card {
  border-color: var(--color-border-strong);
}

.profile-fixed-side {
  align-self: start;
}

.profile-switch-list,
.compact-topic-list {
  max-height: 340px;
  overflow-y: auto;
}

.more-profile-button {
  align-self: flex-start;
}

.profile-workbench {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.profile-workbench-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
  gap: 14px;
  align-items: start;
  min-width: 0;
}

.profile-main-panel,
.profile-side-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.profile-side-panel {
  position: sticky;
  top: 0;
}

.ip-profile-form {
  gap: 14px;
}

.profile-form-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 2px;
}

.profile-form-section+.profile-form-section {
  border-top: 1px solid var(--color-border);
  padding-top: 12px;
}

.profile-form-section-title {
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0;
}

.profile-field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 12px;
}

.profile-field-grid .field {
  min-width: 0;
}

.profile-form-actions,
.profile-action-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.profile-action-grid .btn {
  flex: 1 1 140px;
}

.compact-heading {
  align-items: center;
}

.profile-summary-text {
  white-space: pre-line;
  color: var(--text-main);
  font-size: 0.84rem;
  line-height: 1.55;
}

.muted-pill {
  color: var(--text-muted);
  background: var(--secondary);
}

.profile-score {
  font-size: 0.9rem;
}

.completion-meter {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--secondary);
  border: 1px solid var(--color-border);
}

.completion-meter span {
  display: block;
  height: 100%;
  background: var(--primary);
  border-radius: inherit;
}

.profile-check-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.profile-check {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: var(--secondary);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.profile-check span {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  font-size: 0.72rem;
}

.profile-check.done {
  color: var(--text-main);
}

.profile-check.done span {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.profile-references {
  min-width: 0;
}

.profile-reference-table {
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow-x: auto;
}

.profile-reference-head,
.profile-reference-row {
  display: grid;
  grid-template-columns: 110px minmax(220px, 1fr) 110px 120px 76px;
  gap: 10px;
  align-items: center;
  min-width: 720px;
  padding: 9px 10px;
}

.profile-reference-head {
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 700;
  border-bottom: 1px solid var(--color-border);
}

.profile-reference-row {
  border-bottom: 1px solid var(--color-border);
  font-size: 0.84rem;
  transition: background 0.12s ease;
}

.profile-reference-row:hover {
  background: var(--secondary);
}

.profile-reference-row strong {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-reference-row span {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-muted);
}

.profile-reference-empty {
  padding: 18px 10px;
  color: var(--text-muted);
  font-size: 0.84rem;
}

body.profile-page .topbar {
  display: none;
}

body.profile-page .sidebar {
  width: var(--sidebar-width, 216px);
}

body.profile-page .view-container {
  width: 100%;
  max-width: none;
  padding: 12px 14px 16px;
  gap: 12px;
}

.nav-item.weak {
  margin-top: 2px;
  color: var(--nav-text);
  font-size: 0.82rem;
  opacity: 0.7;
}

.profile-workbench {
  min-height: calc(100vh - 28px);
}

body.profile-page {
  color-scheme: light;
}

.profile-topbar {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
}

.profile-title-block h2 {
  font-size: 1.12rem;
  font-weight: 700;
  line-height: 1.2;
}

.eyebrow {
  display: block;
  margin-bottom: 2px;
  color: #6e6b63;
  font-size: 0.72rem;
  font-weight: 700;
}

.profile-selector,
.profile-search {
  min-width: 0;
  height: 36px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--surface-muted);
  padding: 0 10px;
}

.profile-context-selector {
  height: auto;
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  margin-bottom: 12px;
  padding: 8px 10px;
}

.profile-context-selector span {
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.profile-selector select,
.profile-search input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text-main);
  font: inherit;
}

.profile-search span {
  color: var(--text-subtle);
}

.profile-toolbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.profile-toolbar-actions .primary-btn,
.profile-action-grid.vertical .primary-btn {
  background: var(--primary-accent);
  transition: opacity 0.15s ease;
}

.profile-toolbar-actions .primary-btn:hover:not(:disabled),
.profile-action-grid.vertical .primary-btn:hover:not(:disabled) {
  background: var(--primary-accent-hover);
}

.profile-toolbar-actions .primary-btn:disabled,
.profile-action-grid.vertical .primary-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.profile-workbench-grid {
  grid-template-columns: minmax(0, 1fr) minmax(400px, 430px);
  gap: 16px;
}

.profile-editor-panel,
.profile-context-card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
}

.profile-editor-panel {
  padding: 14px;
}

.profile-context-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: sticky;
  top: 14px;
  align-self: start;
}

.profile-occupancy-card {
  min-height: 0;
}

.profile-context-card {
  padding: 14px;
}

.profile-context-card.compact {
  padding-bottom: 10px;
}

.profile-editor-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(140px, 1fr)) auto;
  gap: 12px;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--color-border);
}

.profile-editor-meta span,
.profile-summary-list dt,
.profile-summary-chips>span,
.profile-row-field>span,
.profile-section-heading p,
.profile-help-text {
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 600;
}

.profile-editor-meta strong {
  display: block;
  margin-top: 3px;
  font-size: 0.88rem;
}

.profile-meta-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.icon-text-button {
  border: 0;
  background: transparent;
  color: var(--primary-accent);
  cursor: pointer;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
}

.profile-section {
  padding-top: 14px;
}

.profile-section+.profile-section {
  margin-top: 2px;
  border-top: 1px solid var(--color-border);
}

.profile-section-heading,
.profile-context-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.profile-section-heading h3,
.profile-context-head h3 {
  font-size: 0.95rem;
  font-weight: 700;
}

.profile-form-grid {
  display: grid;
  gap: 10px;
}

.profile-form-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.profile-row-field {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  min-width: 0;
}

.profile-row-field.full {
  grid-column: 1 / -1;
}

.profile-row-field-full {
  grid-column: 1 / -1;
}

.profile-section-heading-with-action {
  align-items: center;
}

.profile-section-heading-with-action>div {
  min-width: 0;
}

.profile-meta-story-btn {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 0 12px;
  white-space: nowrap;
}

.profile-origin-story-textarea {
  min-height: 160px;
}

.profile-input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-card);
  padding: 8px 10px;
  color: var(--text-main);
  font: inherit;
  line-height: 1.45;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.profile-input:hover {
  border-color: var(--color-border-strong);
}

.profile-input:focus {
  border-color: var(--primary-accent);
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary-accent) 18%, transparent);
}

.compact-textarea {
  min-height: 68px;
  resize: vertical;
}

.required-dot {
  display: inline-flex;
  margin-left: 5px;
  padding: 1px 5px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--primary-accent) 15%, transparent);
  color: var(--primary-accent);
  font-size: 0.68rem;
}

/* Tag field component — golden tags, forbidden zones */
.tag-field {
  min-height: 44px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 10px;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.tag-field:focus-within {
  border-color: #e08b6d;
  box-shadow: 0 0 0 3px rgba(201, 100, 66, 0.10);
}

.tag-list {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  width: 100%;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 28px;
  padding: 0 6px 0 10px;
  border-radius: 999px;
  background: #f0eee6;
  border: 1px solid #ede1dc;
  color: #44423c;
  font-size: 13px;
  line-height: 1;
  transition: border-color 0.12s ease;
  user-select: none;
}

.tag-chip:hover {
  border-color: #a8a59c;
}

.tag-chip-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.tag-chip-remove {
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: #a8a59c;
  cursor: pointer;
  display: inline-grid;
  place-items: center;
  font-size: 14px;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
  transition: background 0.12s ease, color 0.12s ease;
}

.tag-chip-remove:hover {
  background: #e8e6dc;
  color: #21201e;
}

.tag-add-button {
  height: 28px;
  padding: 0 10px;
  border: 1px dashed var(--color-border-strong);
  border-radius: 999px;
  background: #ffffff;
  color: #6e6b63;
  cursor: pointer;
  font-size: 13px;
  transition: border-color 0.12s ease, color 0.12s ease, background 0.12s ease;
}

.tag-add-button:hover {
  border-color: #e08b6d;
  color: #c96442;
  background: #faf0ea;
}

.tag-add-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tag-add-input {
  width: 160px;
  height: 28px;
  border: 1px solid #f0d3c4;
  border-radius: 999px;
  padding: 0 10px;
  outline: none;
  font-size: 13px;
  color: #21201e;
  background: #ffffff;
}

.tag-add-input::placeholder {
  color: #a8a59c;
}

.tag-add-confirm {
  height: 28px;
  padding: 0 12px;
  border: 1px solid #c96442;
  border-radius: 999px;
  background: #c96442;
  color: #ffffff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.12s ease;
}

.tag-add-confirm:hover {
  background: #b05730;
}

/* Legacy chip-editor — keep for any non-profile usages */
.chip-editor {
  min-width: 0;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-card);
  padding: 6px;
}

.chip-list {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.profile-chip,
.profile-summary-chips em {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--surface-strong);
  border: 1px solid var(--color-border);
  color: var(--text-main);
  font-size: 0.78rem;
  font-style: normal;
  transition: border-color 0.12s ease;
}

.profile-chip:hover {
  border-color: var(--color-border-strong);
}

.profile-chip button {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
}

.chip-inline-input {
  flex: 1 1 110px;
  min-width: 100px;
  border: 0;
  outline: 0;
  padding: 4px 2px;
  background: transparent;
  color: var(--text-main);
  font: inherit;
}

.profile-notice {
  padding: 9px 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--secondary);
  color: var(--primary-accent);
  font-size: 0.84rem;
  font-weight: 600;
}

.profile-ai-entry-card {
  border-color: var(--color-border);
  background: var(--color-card);
}

/* HAZ-192：AI 建档入口卡 heading 行容纳 [新建IP] [保存档案] [AI 帮我建档]
   三按钮，保持右对齐 + 不换行。 */
.profile-ai-entry-heading {
  align-items: center;
}

.profile-ai-entry-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.profile-ai-entry-actions .btn {
  white-space: nowrap;
}

.profile-ai-guide {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0 10px;
}

.profile-ai-entry-guide {
  gap: 0;
  overflow: hidden;
  padding: 3px;
  border: 1px solid color-mix(in srgb, var(--primary-accent) 14%, var(--color-border));
  border-radius: 10px;
  background: color-mix(in srgb, var(--color-card) 88%, var(--primary-soft));
}

.profile-ai-guide span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 7px 9px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--surface-muted);
  color: var(--text-main);
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}

.profile-ai-entry-guide span {
  justify-content: flex-start;
  padding: 7px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-muted);
  font-weight: 650;
}

.profile-ai-entry-guide span + span {
  border-left: 1px solid color-mix(in srgb, var(--color-border) 72%, transparent);
  border-radius: 0;
}

.profile-ai-guide b {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: var(--primary-accent);
  color: #fff;
  font-size: 0.68rem;
  line-height: 1;
}

.profile-ai-entry-guide b {
  flex-basis: 16px;
  width: 16px;
  height: 16px;
  background: color-mix(in srgb, var(--primary-accent) 14%, var(--color-card));
  color: var(--primary-accent);
  box-shadow: none;
}

.profile-ai-example {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  color: var(--text-muted);
  font-size: 0.84rem;
}

.profile-ai-starter {
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--secondary);
  color: var(--primary-accent);
  cursor: pointer;
  font-weight: 600;
  padding: 5px 10px;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.profile-ai-starter:hover {
  background: var(--secondary-hover);
  border-color: var(--color-border-strong);
}

.profile-ai-example em {
  min-width: 0;
  overflow: hidden;
  color: var(--text-muted);
  font-style: normal;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-ai-backdrop {
  position: fixed;
  inset: 0;
  z-index: 3000;
  width: 100vw;
  min-width: 100vw;
  height: 100dvh;
  min-height: 100dvh;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(33, 32, 30, 0.42);
}

.profile-ai-dialog {
  position: relative;
  width: min(760px, calc(100vw - 32px));
  max-height: min(780px, calc(100vh - 32px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: 14px;
  background: var(--color-card);
  box-shadow: 0 24px 72px rgba(33, 32, 30, 0.24);
}

.profile-ai-header {
  display: grid;
  gap: 8px;
  padding: 10px 14px 12px;
  border-bottom: 1px solid var(--color-border);
}

.profile-ai-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.profile-ai-header-top .eyebrow {
  color: var(--text-muted);
  font-size: 0.72rem;
  letter-spacing: 0;
}

.profile-ai-header-top .icon-btn {
  width: 26px;
  height: 26px;
  min-height: 26px;
  flex: 0 0 auto;
}

.profile-ai-header-cols {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(200px, 240px);
  align-items: stretch;
  gap: 10px;
}

.profile-ai-header-controls,
.profile-ai-header-status {
  min-width: 0;
}

.profile-ai-header-controls {
  display: grid;
  align-content: start;
  gap: 7px;
}

.profile-ai-header-status {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 5px;
  padding: 8px 9px;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface-muted) 78%, var(--color-card));
}

.profile-ai-header-status > span {
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.profile-ai-header-status strong {
  min-width: 0;
  color: var(--text-main);
  font-size: 0.68rem;
  font-weight: 650;
  line-height: 1.35;
}

.profile-ai-header-status-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
}

.profile-ai-save-draft-btn {
  width: 100%;
  min-height: 28px;
  padding: 0 10px;
  font-size: 0.74rem;
  white-space: nowrap;
}

.profile-ai-clear-draft-btn {
  height: 28px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.74rem;
  font-size: 0.76rem;
  font-weight: 700;
}

.profile-ai-clear-draft-btn:not(:disabled):hover {
  background: var(--ghost-hover-bg);
  color: var(--text-main);
}

.profile-ai-clear-draft-btn:disabled {
  color: var(--text-subtle);
  cursor: not-allowed;
}

.profile-ai-draft-selector {
  display: grid;
  gap: 7px;
  padding: 8px;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface-muted) 66%, var(--color-card));
}

.profile-ai-draft-fields,
.profile-ai-draft-actions {
  display: grid;
  gap: 7px;
}

.profile-ai-draft-fields {
  grid-template-columns: minmax(150px, 0.75fr) minmax(180px, 1fr);
}

.profile-ai-draft-actions {
  grid-template-columns: repeat(4, minmax(78px, 1fr));
}

.profile-ai-draft-selector select,
.profile-ai-draft-selector input,
.profile-ai-draft-selector button {
  min-width: 0;
  height: 30px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--surface-muted);
  color: var(--text-muted);
  font: inherit;
  font-size: 0.74rem;
}

.profile-ai-draft-selector select,
.profile-ai-draft-selector input {
  padding: 0 9px;
}

.profile-ai-draft-selector button {
  padding: 0 10px;
  font-weight: 720;
}

.profile-ai-draft-selector :disabled {
  opacity: 0.62;
  cursor: not-allowed;
}

.profile-ai-draft-hint {
  margin: 0;
  padding: 0 2px;
  font-size: 0.71rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.profile-ai-form {
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
}

.profile-ai-body {
  min-height: 0;
  overflow-y: auto;
  padding: 16px 18px;
  background: var(--surface-muted);
}

.profile-ai-draft-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  padding: 9px 11px;
  border: 1px solid color-mix(in srgb, var(--primary-accent) 18%, var(--color-border));
  border-radius: 10px;
  background: color-mix(in srgb, var(--primary-accent) 7%, var(--color-card));
  color: var(--text-muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.profile-ai-draft-strip span {
  min-width: 0;
}

.profile-ai-draft-strip button {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: var(--primary-accent);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.profile-ai-draft-strip button:disabled {
  color: var(--text-subtle);
  cursor: not-allowed;
}

.profile-ai-summary,
.profile-ai-guide {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.profile-ai-summary div,
.profile-ai-guide-step {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--color-border) 78%, var(--primary-accent));
  border-radius: 10px;
  background: color-mix(in srgb, var(--color-card) 92%, var(--primary-soft));
}

.profile-ai-guide-step {
  display: grid;
  gap: 5px;
}

.profile-ai-guide-step b {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #34322f;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.72);
}

.profile-ai-summary span {
  display: block;
  margin-bottom: 4px;
  color: var(--text-muted);
  font-size: 0.74rem;
}

.profile-ai-guide-step span {
  color: var(--text-main);
  font-size: 0.82rem;
  font-weight: 700;
}

.profile-ai-guide-step p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.75rem;
  line-height: 1.45;
}

.profile-ai-error {
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
  border-radius: 10px;
  background: color-mix(in srgb, var(--danger) 10%, transparent);
  color: var(--danger);
}

.profile-ai-error strong {
  display: block;
  margin-bottom: 4px;
  font-size: 0.86rem;
}

.profile-ai-error p {
  margin: 0;
  color: var(--danger);
  font-size: 0.82rem;
  line-height: 1.5;
}

.profile-ai-summary strong {
  display: block;
  overflow: hidden;
  color: var(--text-main);
  font-size: 0.86rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-ai-flow {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.profile-ai-flow span {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  background: var(--color-card);
  color: var(--text-muted);
  font-size: 0.82rem;
}

.profile-ai-flow b {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 20px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: #fff;
  font-size: 0.72rem;
}

.profile-ai-steps {
  display: grid;
  gap: 12px;
}

.profile-ai-step-block {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.profile-ai-step-index {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
  border-radius: 999px;
  background: var(--primary-accent-hover);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
}

.profile-ai-step {
  min-width: 0;
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: var(--color-card);
}

.profile-ai-step-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-main);
  font-weight: 700;
}

.profile-ai-step-badge em {
  padding: 2px 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  color: var(--danger);
  font-size: 0.7rem;
  font-style: normal;
  font-weight: 600;
}

.profile-ai-step-badge em.optional {
  background: var(--surface-strong);
  color: var(--text-muted);
}

.profile-ai-step p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.86rem;
  line-height: 1.55;
}

.profile-ai-step textarea {
  width: 100%;
  min-height: 94px;
  resize: vertical;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  outline: 0;
  padding: 11px 12px;
  color: var(--text-main);
  background: var(--surface-muted);
  line-height: 1.55;
}

.profile-ai-step textarea:focus {
  border-color: var(--color-border-strong);
  background: var(--color-card);
  box-shadow: 0 0 0 3px rgba(201, 100, 66, 0.12);
}

.profile-ai-step small {
  color: var(--text-muted);
  font-size: 0.76rem;
}

.profile-ai-save-status {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: var(--secondary);
  color: #843f24;
}

.profile-ai-save-status strong {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 0.88rem;
}

.profile-ai-save-status .phosphor-icon {
  font-size: 0.96rem;
  line-height: 1;
  animation: profile-ai-status-spin 1s linear infinite;
}

.profile-ai-save-status p {
  margin: 0;
  color: var(--primary-accent);
  font-size: 0.82rem;
  line-height: 1.5;
}

@keyframes profile-ai-status-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.profile-ai-chat {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.profile-ai-message {
  max-width: 82%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--color-border);
  background: var(--color-card);
  color: var(--text-main);
  line-height: 1.55;
}

.profile-ai-message.user {
  align-self: flex-end;
  border-color: var(--color-border);
  background: var(--secondary);
}

.profile-ai-message.streaming p::after {
  content: "...";
  display: inline-block;
  width: 0;
  overflow: hidden;
  vertical-align: bottom;
  animation: profile-ai-dots 1.2s steps(4, end) infinite;
}

@keyframes profile-ai-dots {
  to {
    width: 1.25em;
  }
}

.profile-ai-composer {
  display: grid;
  gap: 10px;
  padding: 14px 18px 16px;
  border-top: 1px solid var(--color-border);
  background: var(--color-card);
}

.profile-ai-composer textarea {
  width: 100%;
  resize: vertical;
  min-height: 92px;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  outline: 0;
  padding: 11px 12px;
  color: var(--text-main);
  background: var(--color-card);
}

.profile-ai-composer textarea:focus {
  border-color: var(--color-border-strong);
  box-shadow: 0 0 0 3px rgba(201, 100, 66, 0.12);
}

.profile-ai-composer-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.profile-ai-save-actions {
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
}

.profile-ai-save-actions > .btn,
.profile-ai-save-actions .ai-model-choice {
  min-height: 42px;
}

.profile-ai-save-actions > .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding-top: 0;
  padding-bottom: 0;
}

.profile-ai-save-actions .ai-model-choice {
  width: min(256px, 28vw);
  flex: 0 0 min(256px, 28vw);
}

.profile-ai-save-actions .ai-model-choice .aha-choice-trigger {
  height: 42px;
  min-height: 42px;
  padding-top: 7px;
  padding-bottom: 7px;
  border-radius: 10px;
}

.profile-ai-save-actions strong {
  display: block;
  margin-bottom: 3px;
  color: var(--text-main);
  font-size: 0.9rem;
}

.profile-ai-save-actions p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.profile-ai-exit-layer {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(33, 32, 30, 0.28);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.profile-ai-exit-card {
  width: min(420px, 100%);
  padding: 18px;
  border: 1px solid var(--color-border);
  border-radius: 14px;
  background: var(--color-card);
  box-shadow: 0 22px 56px rgba(33, 32, 30, 0.22);
}

.profile-ai-exit-card strong {
  display: block;
  color: var(--text-main);
  font-size: 1rem;
}

.profile-ai-exit-card p {
  margin: 8px 0 0;
  color: var(--text-muted);
  font-size: 0.84rem;
  line-height: 1.55;
}

.profile-ai-exit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

@media (max-width: 760px) {
  .profile-section-heading-with-action {
    align-items: stretch;
    flex-direction: column;
  }

  .profile-meta-story-btn {
    width: 100%;
  }

  .profile-ai-header-cols {
    grid-template-columns: 1fr;
  }

  .profile-ai-draft-fields,
  .profile-ai-draft-actions {
    grid-template-columns: 1fr 1fr;
  }

  .profile-ai-header-status-actions {
    grid-template-columns: 1fr;
  }

  .profile-ai-clear-draft-btn {
    width: 100%;
  }

  .profile-ai-exit-actions {
    flex-direction: column-reverse;
  }

  .profile-ai-exit-actions .btn {
    width: 100%;
  }
}

.profile-history-backdrop {
  position: fixed;
  inset: 0;
  z-index: 910;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(33, 32, 30, 0.42);
}

.profile-history-dialog {
  width: min(720px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 32px));
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: 14px;
  background: var(--color-card);
  box-shadow: 0 24px 72px rgba(33, 32, 30, 0.24);
}

.profile-history-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--color-border);
}

.profile-history-header h3 {
  margin-top: 2px;
  font-size: 1.05rem;
}

.profile-history-header p {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 0.84rem;
  line-height: 1.5;
}

.profile-history-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--color-border);
  background: var(--surface-muted);
}

.profile-history-toolbar span {
  color: var(--text-muted);
  font-size: 0.84rem;
  font-weight: 600;
}

.profile-history-body {
  min-height: 0;
  overflow-y: auto;
  padding: 14px 18px 18px;
  background: var(--surface-muted);
}

.profile-history-row {
  display: grid;
  grid-template-columns: 122px minmax(0, 1fr);
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--color-border);
}

.profile-history-row:last-child {
  border-bottom: 0;
}

.profile-history-time {
  display: grid;
  gap: 4px;
  align-content: start;
}

.profile-history-time strong {
  color: var(--text-main);
  font-size: 0.82rem;
}

.profile-history-time span {
  overflow: hidden;
  color: var(--text-muted);
  font-size: 0.74rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-history-content {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.profile-history-content>div {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.profile-history-content strong {
  max-width: 220px;
  overflow: hidden;
  color: var(--text-main);
  font-size: 0.9rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-history-content em {
  max-width: 180px;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 0.74rem;
  font-style: normal;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-history-content p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.84rem;
  line-height: 1.55;
}

.profile-history-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #f9ebe5;
  color: #4a4742;
  font-size: 0.72rem;
  font-weight: 700;
}

.profile-history-badge.create {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--accent);
}

.profile-history-badge.update {
  background: color-mix(in srgb, var(--primary-accent) 18%, transparent);
  color: var(--primary-accent);
}

.profile-history-badge.ai {
  background: color-mix(in srgb, var(--warning) 22%, transparent);
  color: var(--warning);
}

.profile-history-badge.switch {
  background: color-mix(in srgb, #de9274 18%, transparent);
  color: #de9274;
}

.profile-history-badge.archive,
.profile-history-badge.delete {
  background: color-mix(in srgb, var(--danger) 18%, transparent);
  color: var(--danger);
}

.profile-history-badge.restore {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--accent);
}

.profile-history-empty,
.profile-history-error {
  padding: 18px;
  border: 1px dashed var(--color-border);
  border-radius: 10px;
  background: var(--color-card);
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.55;
  text-align: center;
}

.profile-history-error {
  margin-bottom: 12px;
  border-style: solid;
  border-color: #fecaca;
  background: #fef2f2;
  color: #991b1b;
}

.profile-context-head {
  margin-bottom: 12px;
}

.profile-context-head p {
  margin: 3px 0 0;
  color: var(--text-muted);
  font-size: 0.76rem;
  line-height: 1.45;
}

.profile-person {
  display: block;
  padding: 6px 0 14px;
  border-bottom: 1px solid var(--color-border);
}

.profile-person strong {
  display: block;
  color: var(--text-main);
  font-size: 1.22rem;
  line-height: 1.25;
}

.profile-person p,
.profile-switch-row em {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-style: normal;
}

.profile-occupancy-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.profile-occupancy-grid div {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--surface-muted);
}

.profile-occupancy-grid span {
  display: block;
  color: var(--text-muted);
  font-size: 0.74rem;
}

.profile-occupancy-grid strong {
  display: block;
  margin-top: 3px;
  color: var(--text-main);
  font-size: 1rem;
}

.profile-summary-head {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--color-border);
}

.profile-summary-list {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}

.profile-summary-list div {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 8px;
}

.profile-summary-list dd {
  min-width: 0;
  color: var(--text-main);
  line-height: 1.45;
}

.profile-summary-chips {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.profile-summary-chips div {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.profile-summary-chips i {
  color: var(--text-subtle);
  font-style: normal;
  font-size: 0.82rem;
}

.profile-local-analysis {
  display: grid;
  gap: 10px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--color-border);
}

.profile-analysis-head {
  margin-bottom: 0;
}

.profile-analysis-head span {
  flex: 0 0 auto;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--accent-soft, color-mix(in srgb, var(--accent) 18%, transparent));
  color: var(--accent, #0f9f8f);
  font-size: 0.74rem;
  font-weight: 800;
  white-space: nowrap;
}

.profile-analysis-item {
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--surface-muted);
}

.profile-analysis-item strong {
  display: block;
  color: var(--text-main);
  font-size: 0.82rem;
}

.profile-analysis-item p {
  margin: 5px 0 0;
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.profile-analysis-item ul {
  display: grid;
  gap: 8px;
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.profile-analysis-item li {
  position: relative;
  margin: 0;
  padding-left: 14px;
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.profile-analysis-item li::before {
  content: "";
  position: absolute;
  top: 0.72em;
  left: 0;
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: var(--accent, #0f9f8f);
  transform: translateY(-50%);
}

.status-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: max-content;
  max-width: 100%;
  min-height: 22px;
  border-radius: 999px;
  padding: 0 8px;
  background: var(--secondary);
  color: var(--text-muted);
  font-size: 0.74rem;
  font-style: normal;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  vertical-align: middle;
}

.profile-current-status {
  flex: 0 0 auto;
  min-height: 24px;
  margin-top: 1px;
  padding-inline: 9px;
}

.profile-current-head {
  gap: 10px;
}

.profile-status-light,
.profile-row-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

.profile-status-light i,
.profile-row-state i {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--warning, #f59e0b);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--warning, #f59e0b) 20%, transparent);
}

.profile-status-light.ok i,
.profile-row-state.active i {
  background: var(--accent, #10b981);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent, #10b981) 20%, transparent);
}

.profile-status-light.ok {
  color: var(--accent, #047857);
}

.status-chip.ok {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--accent);
}

.status-chip.warn {
  background: color-mix(in srgb, var(--warning) 22%, transparent);
  color: var(--warning);
}

.status-chip.progress {
  background: var(--secondary);
  color: var(--primary-accent);
}

.status-chip.neutral {
  background: var(--secondary);
  color: var(--text-muted);
}

.profile-check-list {
  display: grid;
  gap: 7px;
}

.profile-check {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
}

.profile-check strong {
  min-width: 0;
  overflow: hidden;
  color: var(--text-main);
  font-size: 0.82rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-check em {
  color: var(--text-muted);
  font-style: normal;
  font-size: 0.76rem;
  white-space: nowrap;
}

.profile-check.missing span {
  background: #fef3c7;
  color: #92400e;
}

.profile-action-grid.vertical {
  display: grid;
  grid-template-columns: 1fr;
}

.profile-menu {
  position: relative;
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.profile-menu-trigger {
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 18px;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--color-card) 94%, #ffffff), var(--color-card));
  padding: 7px 10px;
  color: var(--text-main);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.profile-menu-trigger:hover,
.profile-menu-trigger[aria-expanded="true"] {
  border-color: color-mix(in srgb, var(--primary) 35%, var(--color-border));
  background: color-mix(in srgb, var(--primary) 7%, var(--color-card));
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.profile-menu-trigger:focus-visible {
  border-color: color-mix(in srgb, var(--primary) 35%, var(--color-border));
  outline: none;
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.profile-menu-trigger:disabled {
  cursor: not-allowed;
  opacity: 0.72;
}

.profile-menu-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.profile-row-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.profile-menu-copy strong,
.profile-row-copy strong {
  overflow: hidden;
  color: var(--text-main);
  font-size: 0.84rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-menu-copy em,
.profile-row-copy em {
  overflow: hidden;
  color: var(--text-muted);
  font-size: 0.74rem;
  font-style: normal;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-menu-caret {
  color: var(--text-muted);
  font-size: 1rem;
  text-align: center;
  transition: transform 0.16s ease;
}

.profile-menu-trigger[aria-expanded="true"] .profile-menu-caret {
  transform: rotate(180deg);
}

.profile-switch-menu,
.profile-switch-list {
  display: grid;
  gap: 6px;
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-card);
  padding: 6px;
  box-shadow: 0 18px 42px rgba(33, 32, 30, 0.12);
}

.profile-switch-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: stretch;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 4px;
}

.profile-switch-item.active,
.profile-switch-item:hover {
  background: var(--surface-muted);
  border: 1px solid var(--color-border);
}

.profile-switch-row {
  width: 100%;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  padding: 6px;
  text-align: left;
  cursor: pointer;
}

.profile-switch-row:disabled {
  cursor: default;
}

.profile-switch-row strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.82rem;
}

.profile-archive-icon {
  width: 32px;
  min-width: 32px;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.profile-archive-icon:hover {
  border-color: color-mix(in srgb, var(--danger) 30%, transparent);
  background: color-mix(in srgb, var(--danger) 10%, transparent);
  color: var(--danger);
}

.profile-archive-icon:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.profile-archive-icon svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.profile-archive-note,
.profile-delete-note {
  margin-top: 10px;
  padding: 8px 10px;
  border: 1px solid color-mix(in srgb, var(--warning) 30%, transparent);
  border-radius: 8px;
  background: color-mix(in srgb, var(--warning) 10%, transparent);
  color: var(--warning);
  font-size: 0.78rem;
  line-height: 1.45;
}

.profile-archived-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.profile-archived-row {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 9px;
  border: 1px solid var(--color-border, var(--color-border));
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.profile-archived-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.profile-archived-copy strong,
.profile-archived-copy em,
.profile-archived-copy small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-archived-copy strong {
  color: var(--text-main, #1f1e1d);
  font-size: 0.86rem;
  font-weight: 700;
}

.profile-archived-copy em,
.profile-archived-copy small {
  color: var(--text-muted, #6e6b63);
  font-size: 0.74rem;
  font-style: normal;
}

.profile-restore-btn {
  min-height: 30px;
  padding: 0 10px;
  white-space: nowrap;
}

.profile-archived-empty {
  margin-top: 10px;
  padding: 10px;
  border: 1px dashed var(--color-border, var(--color-border));
  border-radius: 8px;
  color: var(--text-muted, #6e6b63);
  font-size: 0.8rem;
}

@media (max-width: 520px) {
  .profile-archived-row {
    grid-template-columns: 32px minmax(0, 1fr);
  }

  .profile-restore-btn {
    grid-column: 1 / -1;
    width: 100%;
  }
}

.profile-reference-panel {
  overflow: hidden;
}

.profile-reference-head,
.profile-reference-row {
  grid-template-columns: minmax(190px, 1.5fr) 76px minmax(150px, 1fr) 112px 82px 84px 54px;
  min-width: 780px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.ai-mode-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
}

.ai-mode-grid h3 {
  font-size: 0.95rem;
}

.analysis-preview {
  min-height: 132px;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-md);
  padding: 14px;
  background: #fdfcf8;
}

.analysis-preview h3 {
  font-size: 0.95rem;
  margin-bottom: 8px;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0;
}
