.home-nav {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.home-nav-section {
  display: block;
  padding: 12px 12px 5px;
  color: var(--faint);
  font-size: 10px;
  font-weight: 650;
}

.home-nav button small {
  flex: 0 0 auto;
  padding: 3px 5px;
  border-radius: 5px;
  background: var(--surface-hover);
  color: var(--faint);
  font-size: 8px;
  font-weight: 650;
}

.home-nav button[data-unavailable="true"] {
  color: var(--muted);
}

.portal-page {
  min-height: calc(100vh - 58px);
  padding: 30px 34px 52px;
  overscroll-behavior: contain;
}

.portal-page[hidden] {
  display: none;
}

.portal-page-shell {
  width: min(1240px, 100%);
  margin: 0 auto;
}

.portal-page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.portal-page-heading h1 {
  margin: 0;
  color: var(--ink);
  font-size: 24px;
  line-height: 1.25;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.portal-page-heading p {
  max-width: 68ch;
  margin: 7px 0 0;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.6;
}

.portal-heading-actions,
.portal-filter-row,
.portal-action-button,
.portal-mode-switch,
.portal-project-actions,
.portal-asset-actions,
.portal-template-actions {
  display: flex;
  align-items: center;
}

.portal-heading-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.portal-action-button {
  min-height: 38px;
  justify-content: center;
  gap: 7px;
  padding: 0 13px;
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: var(--surface-hover);
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 700;
  transition: background 160ms ease-out, color 160ms ease-out, transform 160ms ease-out;
}

.portal-action-button:hover {
  background: var(--surface-active);
  color: var(--ink);
}

.portal-action-button.primary {
  background: var(--primary);
  color: oklch(0.13 0.03 145);
}

.portal-action-button.primary:hover {
  background: oklch(0.73 0.16 145);
}

.portal-action-button:active {
  transform: translateY(1px);
}

.portal-action-button svg {
  width: 15px;
  height: 15px;
}

.portal-action-button svg,
.portal-action-button svg * {
  pointer-events: none;
}

.portal-hermes-shell {
  max-width: 1180px;
}

.portal-page.portal-hermes-active {
  height: calc(100dvh - 58px);
  min-height: 0;
  padding: 18px 22px;
  overflow: hidden;
  overscroll-behavior: none;
}

.portal-page.portal-hermes-active > .portal-hermes-shell {
  width: 100%;
  max-width: none;
  height: 100%;
  margin: 0;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  gap: 12px;
  overscroll-behavior: none;
}

.portal-page.portal-hermes-active > .portal-hermes-entry-shell {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  padding-top: 4px;
}

.portal-page.portal-hermes-active > .portal-hermes-agent-shell {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) 280px;
  grid-template-rows: minmax(0, 1fr);
  gap: 14px;
  min-height: 0;
  overscroll-behavior: none;
}

.portal-page.portal-hermes-active > .portal-hermes-agent-shell.preview-open {
  grid-template-columns: 200px minmax(520px, 1fr) minmax(500px, 0.9fr);
}

.portal-page.portal-hermes-active > .portal-hermes-agent-shell.asset-board-open {
  grid-template-columns: 200px minmax(0, 1fr);
}

/* Asset board: fill width when history column is hidden */
.portal-hermes-asset-board {
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 14px 16px 16px;
}
.portal-hermes-asset-board-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.portal-hermes-asset-board-bar > div {
  min-width: 0;
  display: grid;
  gap: 2px;
}
.portal-hermes-asset-board-bar strong {
  color: var(--ink);
  font-size: 14px;
}
.portal-hermes-asset-board-bar small {
  color: var(--ink-soft);
  font-size: 11px;
  line-height: 1.45;
}
.portal-hermes-asset-board .portal-hermes-workflow {
  margin-bottom: 0;
}
.portal-hermes-asset-board .portal-hermes-main,
.portal-hermes-asset-board .portal-hermes-assets-stage {
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}
.portal-hermes-assets-stage.portal-hermes-main,
.portal-hermes-asset-board .portal-hermes-grid {
  height: 100%;
  min-height: 0;
}
.portal-hermes-asset-board .portal-hermes-grid {
  display: grid;
  grid-template-columns: minmax(280px, 1.05fr) minmax(360px, 1fr);
  gap: 14px;
  align-items: stretch;
}


.portal-page.portal-hermes-active .portal-page-heading {
  margin-bottom: 0;
}

.portal-page.portal-hermes-active .portal-hermes-status,
.portal-page.portal-hermes-active .portal-hermes-workflow {
  margin-bottom: 0;
}

.portal-page.portal-hermes-active .portal-hermes-studio,
.portal-page.portal-hermes-active .portal-hermes-main,
.portal-page.portal-hermes-active .portal-hermes-canvas,
.portal-page.portal-hermes-active .portal-hermes-side-panel,
.portal-page.portal-hermes-active .portal-hermes-asset-detail {
  min-height: 0;
}

.portal-page.portal-hermes-active .portal-hermes-studio {
  height: 100%;
}

.portal-page.portal-hermes-active .portal-hermes-main {
  height: 100%;
}

.portal-page.portal-hermes-active .portal-hermes-canvas,
.portal-page.portal-hermes-active .portal-hermes-side-panel,
.portal-page.portal-hermes-active .portal-hermes-asset-detail {
  overflow: hidden;
}

.portal-page.portal-hermes-active .portal-hermes-canvas {
  align-content: normal;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
}

.portal-page.portal-hermes-active .portal-hermes-document,
.portal-page.portal-hermes-active .portal-hermes-storyboard-document {
  min-height: 0;
  height: 100%;
}

.portal-page.portal-hermes-active .portal-hermes-document pre {
  height: 100%;
  max-height: none;
}

.portal-page.portal-hermes-active .portal-hermes-side-panel,
.portal-page.portal-hermes-active .portal-hermes-asset-detail,
.portal-page.portal-hermes-active .portal-hermes-asset-grid,
.portal-page.portal-hermes-active .portal-hermes-file-card pre,
.portal-page.portal-hermes-active .portal-hermes-script-box textarea {
  overflow: auto;
  overscroll-behavior: contain;
}

.portal-hermes-status,
.portal-hermes-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.portal-hermes-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
  padding: 12px 14px;
}

.portal-hermes-status span,
.portal-hermes-meta dd {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
}

.portal-hermes-status span i {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--muted);
}

.portal-hermes-entry-card {
  display: grid;
  gap: 14px;
  align-content: start;
  min-height: 388px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.portal-hermes-entry-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: var(--primary);
}

.portal-hermes-entry-mark svg {
  width: 34px;
  height: 34px;
}

.portal-hermes-entry-card h1 {
  margin: 12px 0 6px;
  color: var(--ink);
  font-size: 24px;
  line-height: 1.2;
}

.portal-hermes-entry-card .portal-action-button {
  width: 100%;
  min-height: 50px;
  font-size: 14px;
}

.portal-hermes-entry-card p {
  margin: 18px 0 4px;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.8;
}

.portal-hermes-entry-card > span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: auto;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 750;
}

.portal-hermes-entry-card > span i {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--muted);
}

.portal-hermes-entry-card > span.ready i {
  background: var(--success);
}

.portal-hermes-entry-card > span.error i {
  background: var(--danger);
}

.portal-hermes-entry-history {
  min-width: 0;
  min-height: 388px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 14px;
}

.portal-hermes-entry-history header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.portal-hermes-entry-history h2 {
  margin: 0;
  color: var(--ink);
  font-size: 18px;
}

.portal-hermes-entry-history p,
.portal-hermes-entry-history footer {
  margin: 5px 0 0;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.6;
}

.portal-hermes-history-list {
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  align-content: start;
  gap: 10px;
  overflow: auto;
  padding-right: 4px;
}

.portal-hermes-history-list article {
  min-width: 0;
}

.portal-hermes-history-list [data-hermes-history-open] {
  width: 100%;
  min-height: 112px;
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink-soft);
  text-align: left;
}

.portal-hermes-history-list [data-hermes-history-open]:hover {
  border-color: color-mix(in oklch, var(--primary) 56%, var(--line));
  background: color-mix(in oklch, var(--primary) 7%, var(--surface));
}

.portal-hermes-history-list strong {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.portal-hermes-history-list small,
.portal-hermes-history-list span,
.portal-hermes-history-list time {
  min-width: 0;
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.portal-hermes-history-list span {
  color: var(--primary);
  font-weight: 750;
}

.portal-hermes-history-list time {
  color: var(--faint);
}

.portal-hermes-history-empty {
  display: grid;
  place-items: center;
  align-content: center;
  min-height: 260px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--ink-soft);
  text-align: center;
}

.portal-hermes-history-empty strong {
  color: var(--ink);
  font-size: 16px;
}

.portal-hermes-agent-sidebar,
.portal-hermes-chat,
.portal-hermes-agent-history,
.portal-hermes-preview-panel {
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.portal-hermes-agent-sidebar {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 18px;
}

.portal-hermes-agent-sidebar h1 {
  margin: 4px 0 0;
  color: var(--ink);
  font-size: 20px;
  line-height: 1.2;
}

.portal-hermes-agent-sidebar p {
  margin: 0 0 8px;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.55;
}

.portal-hermes-agent-sidebar .portal-action-button {
  width: 100%;
  min-height: 40px;
}

.portal-hermes-agent-sidebar section {
  display: grid;
  gap: 8px;
  margin-top: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.portal-hermes-agent-sidebar section strong {
  color: var(--ink);
  font-size: 13px;
}

.portal-hermes-agent-sidebar section span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 750;
}

.portal-hermes-agent-sidebar section span i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
}

.portal-hermes-agent-sidebar section span.ready i {
  background: var(--success);
}

.portal-hermes-agent-sidebar section span.error i {
  background: var(--danger);
}

.portal-hermes-agent-sidebar code {
  overflow: hidden;
  color: var(--faint);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.portal-hermes-chat {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.portal-hermes-chat > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.portal-hermes-chat h2,
.portal-hermes-agent-history h2 {
  margin: 0;
  color: var(--ink);
  font-size: 16px;
}

.portal-hermes-chat p,
.portal-hermes-agent-history p {
  margin: 4px 0 0;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.5;
}

.portal-hermes-chat-thread {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 12px;
  overflow: auto;
  overscroll-behavior: contain;
  overflow-anchor: none;
  scrollbar-gutter: stable;
  padding: 20px 22px;
}

.portal-hermes-chat-thread article {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  max-width: min(920px, 92%);
}

.portal-hermes-chat-thread article.user {
  justify-self: end;
  grid-template-columns: minmax(0, 1fr) 34px;
}

.portal-hermes-chat-thread article.user > span {
  grid-column: 2;
  grid-row: 1;
}

.portal-hermes-chat-thread article.user > div {
  grid-column: 1;
  grid-row: 1;
  background: color-mix(in oklch, var(--primary) 16%, var(--surface-soft));
}

.portal-hermes-chat-thread article > span {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--surface-soft);
  color: var(--primary);
}

.portal-hermes-chat-thread article svg {
  width: 17px;
  height: 17px;
}

.portal-hermes-chat-thread article > div {
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.portal-hermes-chat-thread article p {
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.7;
}

.portal-hermes-message-files {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.portal-hermes-embedded-previews {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.portal-hermes-embedded-preview {
  min-width: 0;
  overflow: hidden;
  border: 1px solid color-mix(in oklch, var(--primary) 32%, var(--line));
  border-radius: var(--radius-sm);
  background: color-mix(in oklch, var(--surface) 86%, var(--primary) 6%);
}

.portal-hermes-embedded-preview header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
}

.portal-hermes-embedded-preview header span,
.portal-hermes-embedded-preview header div {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.portal-hermes-embedded-preview header strong {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.portal-hermes-embedded-preview header button {
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-hover);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.portal-hermes-embedded-preview pre {
  max-height: 360px;
  margin: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 12px;
  color: var(--ink);
  font: 12px/1.72 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
}

.portal-hermes-message-file {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  gap: 8px;
  align-items: center;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: color-mix(in oklch, var(--surface) 70%, var(--surface-soft));
}

.portal-hermes-message-file > span {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 2px 7px;
  align-items: center;
}

.portal-hermes-message-file svg {
  grid-row: 1 / span 2;
  width: 15px;
  height: 15px;
  color: var(--primary);
}

.portal-hermes-message-file strong,
.portal-hermes-message-file small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.portal-hermes-message-file strong {
  color: var(--ink);
  font-size: 12px;
}

.portal-hermes-message-file small {
  color: var(--faint);
  font-size: 10px;
}

.portal-hermes-message-file button {
  min-height: 30px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-hover);
  color: var(--ink-soft);
  cursor: pointer;
  font: inherit;
  font-size: 11px;
  font-weight: 750;
}

.portal-hermes-message-file button:hover {
  border-color: color-mix(in oklch, var(--primary) 55%, var(--line));
  color: var(--ink);
}

.portal-hermes-chat-thread article.loading p {
  display: inline-flex;
  gap: 4px;
  margin-top: 6px;
}

.portal-hermes-chat-thread article.loading i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--primary);
  animation: portalHermesSpin 900ms linear infinite;
}

.portal-hermes-chat-thread article.pending blockquote {
  margin: 10px 0 0;
  padding: 10px 12px;
  border: 1px solid color-mix(in oklch, var(--primary) 34%, var(--line));
  border-radius: var(--radius-sm);
  background: color-mix(in oklch, var(--primary) 9%, var(--surface-soft));
  color: var(--ink);
  font-size: 12px;
  line-height: 1.65;
}

.portal-hermes-chat-thread article.pending footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.portal-hermes-chat-thread article.pending button {
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-hover);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
}

.portal-hermes-chat-thread article.pending button:first-child {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
}

.portal-hermes-chat-files {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  padding: 10px 18px 0;
}

.portal-hermes-chat-files span {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 220px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  font-size: 11px;
}

.portal-hermes-chat-files svg {
  width: 13px;
  height: 13px;
  color: var(--primary);
}

.portal-hermes-chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 48px 48px;
  gap: 8px;
  padding: 14px 22px 18px;
}

.portal-hermes-chat-form > label {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-size: 12px;
}

.portal-hermes-chat-form select {
  max-width: 100%;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--ink);
}

.portal-hermes-chat-form textarea {
  min-height: 56px;
  max-height: 160px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  line-height: 1.5;
  padding: 12px;
  outline: none;
}

.portal-hermes-chat-form textarea:focus {
  border-color: color-mix(in oklch, var(--primary) 72%, var(--line));
}

.portal-hermes-chat-form button {
  width: 48px;
  min-height: 56px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--surface-hover);
  color: var(--ink-soft);
}

.portal-hermes-chat-form button.primary {
  background: var(--primary);
  color: oklch(0.13 0.03 145);
}

.portal-hermes-chat-form button svg {
  width: 16px;
  height: 16px;
}

.portal-hermes-agent-history {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  padding: 16px;
  overflow: hidden;
}

.portal-hermes-agent-history > div {
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 8px;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.portal-hermes-agent-history button {
  width: 100%;
  display: grid;
  gap: 5px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--ink-soft);
  text-align: left;
}

.portal-hermes-agent-history button:hover {
  border-color: color-mix(in oklch, var(--primary) 56%, var(--line));
}

.portal-hermes-agent-history strong {
  color: var(--ink);
  font-size: 12px;
}

.portal-hermes-agent-history small {
  overflow: hidden;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.portal-hermes-preview-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  overflow: hidden;
}

.portal-hermes-preview-panel > header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  gap: 10px;
  align-items: start;
  padding: 15px 16px 12px;
  border-bottom: 1px solid var(--line);
}

.portal-hermes-preview-panel h2 {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.portal-hermes-preview-panel header p {
  margin: 4px 0 0;
  overflow: hidden;
  color: var(--faint);
  font-size: 11px;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.portal-hermes-preview-panel header button {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--ink-soft);
  cursor: pointer;
}

.portal-hermes-preview-panel header button:hover {
  border-color: color-mix(in oklch, var(--primary) 55%, var(--line));
  color: var(--ink);
}

.portal-hermes-preview-panel header svg {
  width: 15px;
  height: 15px;
}

.portal-hermes-preview-toolbar {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
}

.portal-hermes-preview-toolbar button {
  min-height: 32px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--ink-soft);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 750;
}

.portal-hermes-preview-toolbar button:hover {
  border-color: color-mix(in oklch, var(--primary) 55%, var(--line));
  color: var(--ink);
}

.portal-hermes-preview-toolbar button:disabled {
  cursor: not-allowed;
  opacity: .55;
}

.portal-hermes-preview-document {
  min-height: 0;
  margin: 0;
  overflow: auto;
  overscroll-behavior: contain;
  overflow-anchor: none;
  scrollbar-gutter: stable;
  padding: 24px 28px 42px;
  background: oklch(0.985 0.006 230);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.75;
}

.portal-hermes-preview-document h2,
.portal-hermes-preview-document h3,
.portal-hermes-preview-document h4,
.portal-hermes-preview-document p,
.portal-hermes-preview-document ul,
.portal-hermes-preview-document ol,
.portal-hermes-preview-document blockquote,
.portal-hermes-preview-document table {
  max-width: 880px;
}

.portal-hermes-preview-document h2,
.portal-hermes-preview-document h3,
.portal-hermes-preview-document h4 {
  margin: 22px 0 10px;
  color: oklch(0.22 0.025 245);
  line-height: 1.35;
}

.portal-hermes-preview-document h2 {
  font-size: 24px;
}

.portal-hermes-preview-document h3 {
  font-size: 19px;
}

.portal-hermes-preview-document h4 {
  font-size: 16px;
}

.portal-hermes-preview-document p {
  margin: 8px 0;
  color: oklch(0.27 0.022 245);
}

.portal-hermes-preview-document ul,
.portal-hermes-preview-document ol {
  margin: 10px 0 14px;
  padding-left: 24px;
}

.portal-hermes-preview-document li {
  margin: 5px 0;
}

.portal-hermes-preview-document code {
  padding: 2px 5px;
  border-radius: 5px;
  background: oklch(0.93 0.014 230);
  color: oklch(0.31 0.09 230);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: .92em;
}

.portal-hermes-preview-document blockquote {
  margin: 14px 0;
  padding: 10px 14px;
  border-left: 3px solid var(--primary);
  background: oklch(0.95 0.012 230);
  color: oklch(0.31 0.026 245);
}

.portal-hermes-preview-document hr {
  margin: 22px 0;
  border: 0;
  border-top: 1px solid oklch(0.86 0.01 230);
}

.portal-hermes-preview-document table {
  width: 100%;
  margin: 14px 0 18px;
  border-collapse: collapse;
  border: 1px solid oklch(0.84 0.012 230);
  background: white;
  font-size: 13px;
}

.portal-hermes-preview-document th,
.portal-hermes-preview-document td {
  padding: 9px 10px;
  border: 1px solid oklch(0.86 0.01 230);
  text-align: left;
  vertical-align: top;
}

.portal-hermes-preview-document th {
  background: oklch(0.95 0.01 230);
  color: oklch(0.24 0.03 245);
  font-weight: 800;
}

.portal-hermes-preview-panel footer {
  padding: 9px 16px;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 11px;
}

.portal-hermes-preview-state,
.portal-hermes-preview-error {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 9px;
  min-height: 260px;
  color: var(--ink-soft);
  text-align: center;
}

.portal-hermes-preview-state i {
  width: 18px;
  height: 18px;
  border: 2px solid color-mix(in oklch, var(--primary) 22%, transparent);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: portalHermesSpin 900ms linear infinite;
}

.portal-hermes-preview-state strong {
  color: var(--ink);
  font-size: 13px;
}

.portal-hermes-preview-error {
  margin: 16px;
  min-height: 180px;
  border: 1px dashed color-mix(in oklch, var(--danger) 45%, var(--line));
  border-radius: var(--radius-sm);
  color: color-mix(in oklch, var(--danger) 88%, white);
  font-size: 12px;
  line-height: 1.6;
}

.portal-hermes-status span.ready i {
  background: var(--success);
}

.portal-hermes-status span.error i {
  background: var(--danger);
}

.portal-hermes-status code {
  max-width: min(100%, 560px);
  overflow: hidden;
  color: var(--faint);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.portal-hermes-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, .92fr);
  gap: 16px;
  align-items: start;
}

.portal-hermes-workflow {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.portal-hermes-workflow button {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 3px 9px;
  min-width: 0;
  min-height: 62px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: var(--surface);
  color: var(--ink-soft);
  text-align: left;
}

.portal-hermes-workflow button:disabled {
  cursor: not-allowed;
  opacity: .56;
}

.portal-hermes-workflow button.active {
  border-color: color-mix(in oklch, var(--primary) 72%, var(--line));
  background: color-mix(in oklch, var(--primary) 9%, var(--surface));
  color: var(--ink);
}

.portal-hermes-workflow button.done {
  border-color: color-mix(in oklch, var(--success) 52%, var(--line));
}

.portal-hermes-workflow button > span {
  grid-row: 1 / span 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--ink);
  font-size: 11px;
  font-weight: 850;
}

.portal-hermes-workflow button.done > span {
  background: var(--success);
  color: oklch(0.13 0.03 145);
}

.portal-hermes-workflow svg {
  width: 14px;
  height: 14px;
}

.portal-hermes-workflow strong {
  min-width: 0;
  overflow: hidden;
  color: inherit;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.portal-hermes-workflow small {
  color: var(--faint);
  font-size: 10px;
  font-weight: 700;
}

.portal-hermes-panel {
  min-width: 0;
  padding: 16px;
}

.portal-hermes-panel header {
  margin-bottom: 14px;
}

.portal-hermes-panel h2 {
  margin: 0;
  color: var(--ink);
  font-size: 16px;
}

.portal-hermes-panel header p,
.portal-hermes-empty p {
  margin: 5px 0 0;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.55;
}

.portal-hermes-panel label {
  display: grid;
  gap: 7px;
  margin-top: 12px;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
}

.portal-hermes-panel textarea,
.portal-hermes-panel input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  line-height: 1.5;
  outline: none;
}

.portal-hermes-panel textarea {
  min-height: 116px;
  resize: vertical;
  padding: 10px 11px;
}

.portal-hermes-panel textarea[name="params"] {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

.portal-hermes-panel input {
  min-height: 40px;
  padding: 0 11px;
}

.portal-hermes-panel input[readonly] {
  color: var(--ink-soft);
  background: color-mix(in oklch, var(--surface-soft) 76%, var(--surface-hover));
}

.portal-hermes-panel textarea:focus,
.portal-hermes-panel input:focus {
  border-color: color-mix(in oklch, var(--primary) 72%, var(--line));
}

.portal-hermes-upload {
  position: relative;
  grid-template-columns: minmax(0, auto) minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 10px;
  border: 1px dashed color-mix(in oklch, var(--primary) 55%, var(--line));
  border-radius: var(--radius-sm);
  background: color-mix(in oklch, var(--primary) 8%, var(--surface-soft));
}

.portal-hermes-upload input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.portal-hermes-upload span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 11px;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: oklch(0.13 0.03 145);
  font-size: 11px;
  font-weight: 800;
}

.portal-hermes-upload span svg {
  width: 14px;
  height: 14px;
}

.portal-hermes-upload small {
  min-width: 0;
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.portal-hermes-file-card {
  display: grid;
  gap: 7px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.portal-hermes-file-card strong {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--ink);
  font-size: 13px;
}

.portal-hermes-file-card strong svg {
  width: 15px;
  height: 15px;
  color: var(--primary);
}

.portal-hermes-file-card small {
  min-width: 0;
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 11px;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.portal-hermes-file-card pre {
  max-height: 150px;
  margin: 4px 0 0;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink-soft);
  font: 11px/1.6 ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  white-space: pre-wrap;
}

.portal-hermes-row {
  display: grid;
  grid-template-columns: minmax(0, .75fr) minmax(0, 1.25fr);
  gap: 10px;
}

.portal-hermes-upload-stage .portal-hermes-row {
  grid-template-columns: minmax(220px, .8fr) minmax(220px, .8fr) minmax(0, 1fr);
  align-items: end;
}

.portal-hermes-upload-stage .portal-hermes-row label {
  max-width: 360px;
}

.portal-hermes-upload-stage .portal-hermes-row input {
  background: color-mix(in oklch, var(--surface-soft) 84%, black);
  color: var(--ink);
  font-weight: 750;
}

.portal-hermes-defaults {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.portal-hermes-defaults span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 750;
}

.portal-hermes-stage-summary {
  display: grid;
  gap: 8px;
  margin: 0 0 12px;
}

.portal-hermes-stage-summary div,
.portal-hermes-context-note {
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.portal-hermes-stage-summary dt {
  color: var(--faint);
  font-size: 10px;
}

.portal-hermes-stage-summary dd {
  margin: 3px 0 0;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 750;
}

.portal-hermes-source {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.portal-hermes-source summary {
  cursor: pointer;
  padding: 10px 11px;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 750;
}

.portal-hermes-source pre {
  max-height: 220px;
  margin: 0;
  overflow: auto;
  padding: 0 11px 11px;
  color: var(--ink-soft);
  font: 11px/1.6 ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  white-space: pre-wrap;
}

.portal-hermes-context-note {
  margin-bottom: 12px;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.5;
}

.portal-hermes-confirmed {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 11px;
  color: var(--success);
  font-size: 12px;
  font-weight: 800;
}

.portal-hermes-confirmed svg {
  width: 15px;
  height: 15px;
}

.portal-hermes-panel footer {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 14px;
}

.portal-hermes-result {
  position: sticky;
  top: 18px;
}

.portal-hermes-deliverables {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.portal-hermes-deliverables article {
  display: grid;
  gap: 3px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.portal-hermes-deliverables strong {
  color: var(--ink);
  font-size: 12px;
}

.portal-hermes-deliverables span {
  color: var(--ink-soft);
  font-size: 11px;
  line-height: 1.45;
}

.portal-hermes-running,
.portal-hermes-empty,
.portal-hermes-error {
  display: grid;
  place-items: center;
  min-height: 180px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  color: var(--ink-soft);
  text-align: center;
}

.portal-hermes-running i {
  width: 22px;
  height: 22px;
  border: 2px solid var(--line);
  border-top-color: var(--primary);
  border-radius: 999px;
  animation: portalHermesSpin 900ms linear infinite;
}

.portal-hermes-running strong,
.portal-hermes-empty strong {
  margin-top: 8px;
  color: var(--ink);
  font-size: 14px;
}

.portal-hermes-empty svg {
  width: 28px;
  height: 28px;
  color: var(--primary);
}

.portal-hermes-empty.compact {
  min-height: 112px;
}

.portal-hermes-error {
  grid-template-columns: auto minmax(0, 1fr);
  place-items: center start;
  min-height: auto;
  margin-bottom: 12px;
  padding: 12px;
  border-color: color-mix(in oklch, var(--danger) 55%, var(--line));
  color: var(--danger);
  text-align: left;
}

.portal-hermes-error svg {
  width: 18px;
  height: 18px;
}

.portal-hermes-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 12px;
}

.portal-hermes-meta div {
  min-width: 0;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.portal-hermes-meta dt {
  color: var(--faint);
  font-size: 10px;
}

.portal-hermes-meta dd {
  min-width: 0;
  margin: 3px 0 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.portal-hermes-result pre {
  max-height: 460px;
  margin: 0 0 12px;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--ink);
  font: 12px/1.65 ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  white-space: pre-wrap;
}

.portal-hermes-studio {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
}

.portal-hermes-rail {
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 10px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in oklch, var(--surface) 82%, black);
}

.portal-hermes-rail button {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 850;
}

.portal-hermes-rail button.active {
  border-color: color-mix(in oklch, var(--primary) 62%, var(--line));
  background: var(--primary-soft);
  color: var(--primary);
}

.portal-hermes-rail button.done {
  color: var(--success);
}

.portal-hermes-rail button:disabled {
  cursor: not-allowed;
  opacity: .46;
}

.portal-hermes-rail svg {
  width: 15px;
  height: 15px;
}

.portal-hermes-main {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 16px;
  align-items: stretch;
}

.portal-hermes-canvas,
.portal-hermes-side-panel,
.portal-hermes-asset-detail {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.portal-hermes-canvas {
  display: grid;
  align-content: start;
  gap: 14px;
  min-height: 560px;
  padding: 18px;
}

.portal-hermes-canvas label {
  min-width: 0;
  display: grid;
  gap: 7px;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 750;
}

.portal-hermes-canvas input,
.portal-hermes-canvas textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  line-height: 1.5;
  outline: none;
}

.portal-hermes-canvas input {
  min-height: 40px;
  padding: 0 11px;
}

.portal-hermes-canvas textarea {
  min-height: 220px;
  resize: vertical;
  padding: 12px;
}

.portal-hermes-canvas input:focus,
.portal-hermes-canvas textarea:focus {
  border-color: color-mix(in oklch, var(--primary) 72%, var(--line));
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--primary) 16%, transparent);
}

.portal-hermes-stage-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.portal-hermes-stage-head h2 {
  margin: 0;
  color: var(--ink);
  font-size: 16px;
}

.portal-hermes-stage-head span {
  color: var(--faint);
  font-size: 11px;
  font-weight: 750;
}

.portal-hermes-script-box textarea {
  min-height: 360px;
}

.portal-page.portal-hermes-active .portal-hermes-script-box,
.portal-page.portal-hermes-active .portal-hermes-file-card {
  min-height: 0;
  height: 100%;
}

.portal-page.portal-hermes-active .portal-hermes-script-box textarea {
  min-height: 0;
  height: 100%;
  resize: none;
}

.portal-page.portal-hermes-active .portal-hermes-file-card {
  grid-template-rows: auto auto auto minmax(0, 1fr);
}

.portal-page.portal-hermes-active .portal-hermes-file-card pre {
  width: 100%;
  max-height: none;
  min-height: 0;
  height: 100%;
}

.portal-hermes-side-panel,
.portal-hermes-asset-detail {
  align-self: stretch;
  padding: 16px;
}

.portal-hermes-side-panel h3,
.portal-hermes-asset-detail h3 {
  margin: 0;
  color: var(--ink);
  font-size: 15px;
}

.portal-hermes-side-panel p {
  margin: 7px 0 14px;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.55;
}

.portal-hermes-side-panel dl {
  display: grid;
  gap: 8px;
  margin: 0 0 14px;
}

.portal-hermes-side-panel dl div {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.portal-hermes-side-panel dt {
  color: var(--faint);
  font-size: 10px;
}

.portal-hermes-side-panel dd {
  margin: 4px 0 0;
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.portal-hermes-ratio-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.portal-hermes-ratio-grid button {
  min-height: 48px;
  display: grid;
  place-items: center;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 800;
}

.portal-hermes-ratio-grid button.active {
  border-color: color-mix(in oklch, var(--primary) 62%, var(--line));
  background: color-mix(in oklch, var(--primary) 12%, var(--surface-soft));
  color: var(--ink);
}

.portal-hermes-ratio-grid i {
  width: 14px;
  height: 18px;
  border: 1px solid currentColor;
  border-radius: 2px;
}

.portal-hermes-document {
  min-height: 420px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: color-mix(in oklch, var(--surface-soft) 72%, black);
}

.portal-hermes-document pre {
  max-height: 560px;
  margin: 0;
  overflow: auto;
  padding: 18px;
  color: var(--ink);
  font: 12px/1.72 ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  white-space: pre-wrap;
}

.portal-hermes-stage-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: auto;
  padding-top: 4px;
}

.portal-hermes-upload-stage .portal-hermes-stage-actions {
  align-items: center;
  min-height: 44px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.portal-hermes-asset-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.portal-hermes-asset-toolbar div {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}

.portal-hermes-asset-toolbar strong {
  color: var(--primary);
  font-size: 18px;
}

.portal-hermes-asset-toolbar span,
.portal-hermes-asset-toolbar small {
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 750;
}

.portal-hermes-asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.portal-hermes-asset-grid button {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  min-height: 248px;
  height: auto;
  padding: 11px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--ink-soft);
  text-align: left;
}

.portal-hermes-asset-grid button.active,
.portal-hermes-asset-grid button:hover {
  border-color: color-mix(in oklch, var(--primary) 62%, var(--line));
  background: color-mix(in oklch, var(--primary) 8%, var(--surface-soft));
}

.portal-hermes-asset-grid button > span {
  width: max-content;
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--primary);
  font-size: 10px;
  font-weight: 850;
}

.portal-hermes-asset-grid i {
  display: grid;
  place-items: center;
  min-height: 62px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  color: var(--primary);
}

.portal-hermes-asset-grid svg {
  width: 24px;
  height: 24px;
}

.portal-hermes-asset-grid strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.portal-hermes-asset-grid small {
  min-height: 34px;
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 11px;
  line-height: 1.45;
}

.portal-hermes-asset-preview {
  min-height: 280px;
  display: grid;
  place-items: center;
  gap: 8px;
  margin-bottom: 14px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  background: color-mix(in oklch, var(--surface-soft) 72%, black);
  color: var(--ink-soft);
  text-align: center;
}

.portal-hermes-asset-preview svg {
  width: 34px;
  height: 34px;
  color: var(--primary);
}

.portal-hermes-asset-detail section {
  display: grid;
  gap: 3px;
  margin-bottom: 12px;
}

.portal-hermes-asset-detail small {
  color: var(--primary);
  font-size: 11px;
  font-weight: 800;
}

.portal-hermes-asset-detail label {
  display: grid;
  gap: 7px;
  margin-top: 12px;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 750;
}

.portal-hermes-asset-detail textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--ink);
  font: 11px/1.6 ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  padding: 10px;
}

.portal-hermes-cut-panel {
  display: grid;
  align-content: start;
}

.portal-hermes-storyboard-document {
  min-height: 480px;
}

@keyframes portalHermesSpin {
  to { transform: rotate(360deg); }
}

.portal-filter-row {
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 15px;
}

.portal-search {
  width: min(320px, 100%);
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 11px;
  border: 1px solid var(--home-line);
  border-radius: var(--radius-sm);
  background: var(--home-surface);
  color: var(--muted);
}

.portal-search:focus-within {
  border-color: var(--primary);
}

.portal-search svg {
  width: 15px;
  height: 15px;
}

.portal-search input {
  min-width: 0;
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 11px;
}

.portal-search input::placeholder {
  color: var(--ink-soft);
}

.portal-filter-button {
  min-height: 34px;
  padding: 0 11px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-soft);
  font-size: 10px;
}

.portal-filter-button:hover,
.portal-filter-button.active {
  background: var(--surface-hover);
  color: var(--ink);
}

.portal-project-table {
  overflow: hidden;
  border: 1px solid var(--home-line);
  border-radius: var(--radius-md);
  background: var(--home-surface);
}

.portal-project-row {
  width: 100%;
  min-height: 84px;
  display: grid;
  grid-template-columns: 76px minmax(170px, 1.4fr) minmax(120px, 0.8fr) minmax(100px, 0.7fr) auto;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  border: 0;
  border-bottom: 1px solid var(--home-line);
  background: transparent;
  color: var(--ink-soft);
  text-align: left;
}

.portal-project-row:last-child {
  border-bottom: 0;
}

.portal-project-row:hover {
  background: var(--home-surface-raised);
}

.portal-project-thumb {
  position: relative;
  width: 76px;
  height: 56px;
  overflow: hidden;
  border-radius: 7px;
  background: oklch(0.12 0.01 150);
}

.portal-project-thumb.canvas::before,
.portal-project-thumb.canvas::after {
  content: "";
  position: absolute;
  top: 14px;
  width: 20px;
  height: 14px;
  border-radius: 4px;
  background: var(--surface-active);
}

.portal-project-thumb.canvas::before { left: 8px; }
.portal-project-thumb.canvas::after { right: 8px; }

.portal-project-thumb.canvas i {
  position: absolute;
  top: 22px;
  left: 26px;
  width: 25px;
  height: 1px;
  background: var(--primary);
}

.portal-project-thumb.flow {
  background: linear-gradient(135deg, oklch(0.27 0.07 205), oklch(0.1 0.02 245));
}

.portal-project-thumb.flow::before {
  content: "";
  position: absolute;
  top: 12px;
  right: 18px;
  width: 20px;
  height: 34px;
  border-radius: 50% 50% 20% 20%;
  background: oklch(0.07 0.01 230 / 0.86);
}

.portal-project-thumb.script {
  border: 1px solid oklch(0.44 0.07 220);
  background: oklch(0.15 0.018 225);
}

.portal-project-thumb.script::before,
.portal-project-thumb.script::after,
.portal-project-thumb.script i {
  content: "";
  position: absolute;
  top: 8px;
  bottom: 8px;
  width: 15px;
  border-radius: 3px;
  background: oklch(0.23 0.025 225);
}

.portal-project-thumb.script::before { left: 7px; }
.portal-project-thumb.script i { left: 27px; width: 34px; background: oklch(0.19 0.02 225); }
.portal-project-thumb.script::after { right: 7px; border-bottom: 2px solid oklch(0.72 0.13 220); }

.portal-project-main,
.portal-project-cell {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.portal-project-main strong,
.portal-project-cell strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.portal-project-main small,
.portal-project-cell small {
  color: var(--muted);
  font-size: 9px;
}

.portal-project-status {
  display: inline-flex;
  width: max-content;
  align-items: center;
  gap: 6px;
  padding: 5px 7px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 9px;
}

.portal-project-status i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.portal-project-actions {
  gap: 4px;
}

.portal-icon-button {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
}

.portal-icon-button:hover {
  background: var(--surface-hover);
  color: var(--ink);
}

.portal-icon-button svg {
  width: 15px;
  height: 15px;
}

.portal-empty-search {
  padding: 54px 20px;
  color: var(--ink-soft);
  text-align: center;
}

.portal-asset-upload {
  min-height: 128px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
  padding: 22px 24px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--home-surface);
}

.portal-asset-upload.dragging {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.portal-asset-upload > div {
  display: flex;
  align-items: center;
  gap: 14px;
}

.portal-asset-upload .upload-mark {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  color: var(--primary);
}

.portal-asset-upload .upload-copy {
  display: grid;
  gap: 4px;
}

.portal-asset-upload strong {
  color: var(--ink);
  font-size: 13px;
}

.portal-asset-upload small {
  color: var(--ink-soft);
  font-size: 10px;
  line-height: 1.5;
}

.portal-asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}

.portal-asset-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--home-line);
  border-radius: var(--radius-md);
  background: var(--home-surface);
}

.portal-asset-preview {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: oklch(0.1 0.005 150);
}

.portal-asset-preview a,
.portal-asset-preview video,
.portal-asset-preview img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.portal-asset-actions a { color: inherit; font-size: 12px; align-self: center; }

.portal-asset-preview > span {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 4px 6px;
  border-radius: 5px;
  background: oklch(0.08 0.01 150 / 0.84);
  color: var(--white);
  font-size: 8px;
}

.portal-asset-meta {
  display: grid;
  gap: 4px;
  padding: 10px 11px 7px;
}

.portal-asset-meta strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.portal-asset-meta small {
  color: var(--muted);
  font-size: 9px;
}

.portal-asset-actions {
  gap: 4px;
  padding: 0 7px 8px;
}

.portal-asset-actions button {
  min-height: 30px;
  flex: 1;
  border: 0;
  border-radius: 6px;
  background: var(--surface-hover);
  color: var(--ink-soft);
  font-size: 9px;
}

.portal-asset-actions button:hover {
  background: var(--surface-active);
  color: var(--ink);
}

.portal-asset-actions .danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.portal-asset-empty {
  grid-column: 1 / -1;
  min-height: 260px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 9px;
  color: var(--ink-soft);
  text-align: center;
}

.portal-asset-empty svg {
  width: 34px;
  height: 34px;
  color: var(--primary);
}

.portal-asset-empty strong {
  color: var(--ink);
  font-size: 13px;
}

.portal-asset-empty small {
  max-width: 42ch;
  color: var(--ink-soft);
  font-size: 10px;
  line-height: 1.6;
}

.portal-template-featured {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(260px, 0.6fr);
  gap: 14px;
  margin-bottom: 20px;
}

.portal-template-lead,
.portal-template-side {
  min-height: 200px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 22px;
  border: 0;
  border-radius: var(--radius-md);
  color: var(--ink);
  text-align: left;
}

.portal-template-lead {
  background:
    radial-gradient(circle at 72% 32%, oklch(0.68 0.14 145 / 0.28), transparent 26%),
    oklch(0.18 0.035 155);
}

.portal-template-side {
  background:
    radial-gradient(circle at 70% 25%, oklch(0.7 0.13 305 / 0.24), transparent 30%),
    var(--home-surface-raised);
}

.portal-template-lead:hover,
.portal-template-side:hover {
  filter: brightness(1.08);
}

.portal-template-lead span,
.portal-template-side span {
  width: max-content;
  margin-bottom: auto;
  padding: 5px 7px;
  border-radius: 6px;
  background: oklch(0.1 0.01 150 / 0.52);
  color: var(--ink-soft);
  font-size: 9px;
}

.portal-template-lead strong,
.portal-template-side strong {
  margin-bottom: 6px;
  font-size: 18px;
}

.portal-template-lead small,
.portal-template-side small {
  color: var(--ink-soft);
  font-size: 10px;
}

.portal-template-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.portal-template-row {
  min-height: 92px;
  display: grid;
  grid-template-columns: 54px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--home-line);
  border-radius: var(--radius-md);
  background: var(--home-surface);
  color: var(--ink-soft);
  text-align: left;
}

.portal-template-row:hover {
  background: var(--home-surface-raised);
}

.portal-template-row > span:first-child {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--surface-hover);
  color: var(--primary);
}

.portal-template-row > span:nth-child(2) {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.portal-template-row strong {
  color: var(--ink);
  font-size: 11px;
}

.portal-template-row small,
.portal-template-row em {
  color: var(--muted);
  font-size: 9px;
  font-style: normal;
}

.portal-template-row > svg {
  width: 15px;
  height: 15px;
}

.portal-community-shell {
  --community-accent: oklch(0.74 0.14 292);
}

.portal-community-hero {
  min-height: 168px;
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  align-items: center;
  gap: 20px;
  padding: 24px 4px;
  border-block: 1px solid var(--line);
}

.portal-community-mark {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border: 1px solid color-mix(in oklch, var(--community-accent) 38%, var(--line));
  border-radius: 14px;
  background: color-mix(in oklch, var(--community-accent) 12%, var(--surface-hover));
  color: var(--community-accent);
}

.portal-community-mark svg {
  width: 27px;
  height: 27px;
}

.portal-community-hero > div:nth-child(2) {
  min-width: 0;
}

.portal-community-hero > div:nth-child(2) > span {
  color: var(--community-accent);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.portal-community-hero h2 {
  margin: 6px 0 0;
  color: var(--ink);
  font-size: clamp(22px, 2vw, 30px);
  line-height: 1.15;
}

.portal-community-hero p {
  max-width: 68ch;
  margin: 8px 0 0;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.65;
}

.portal-community-status {
  padding: 7px 10px;
  border: 1px solid color-mix(in oklch, var(--community-accent) 28%, var(--line));
  border-radius: 999px;
  color: var(--community-accent);
  font-size: 10px;
  font-weight: 750;
  white-space: nowrap;
}

.portal-community-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
}

.portal-community-grid article {
  min-height: 146px;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) 16px;
  align-items: start;
  gap: 12px;
  padding: 24px 20px;
  border-right: 1px solid var(--line);
}

.portal-community-grid article:last-child {
  border-right: 0;
}

.portal-community-grid article > span {
  color: var(--community-accent);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.portal-community-grid h3 {
  margin: 0;
  color: var(--ink);
  font-size: 13px;
}

.portal-community-grid p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.55;
}

.portal-community-grid article > svg {
  width: 16px;
  height: 16px;
  color: var(--faint);
}

.portal-community-activity {
  margin-top: 30px;
  border-top: 1px solid var(--line);
}

.portal-community-activity > header {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
}

.portal-community-activity h2 {
  margin: 0;
  color: var(--ink);
  font-size: 14px;
}

.portal-community-activity header p,
.portal-community-empty p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
}

.portal-community-activity header > span {
  color: var(--faint);
  font-size: 10px;
}

.portal-community-empty {
  min-height: 250px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  color: var(--muted);
  text-align: center;
}

.portal-community-empty > svg {
  width: 34px;
  height: 34px;
  margin-bottom: 4px;
  color: var(--community-accent);
}

.portal-community-empty strong {
  color: var(--ink-soft);
  font-size: 12px;
}

.portal-unavailable {
  min-height: 520px;
  display: grid;
  place-items: center;
}

.portal-unavailable-inner {
  width: min(760px, 100%);
  text-align: center;
}

.portal-unavailable-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  margin: 0 auto 14px;
  border-radius: var(--radius-md);
  background: var(--surface-hover);
  color: var(--muted);
}

.portal-unavailable-mark svg {
  width: 24px;
  height: 24px;
}

.portal-unavailable h1 {
  margin: 0;
  color: var(--ink);
  font-size: 24px;
}

.portal-unavailable > div > p {
  max-width: 60ch;
  margin: 8px auto 22px;
  color: var(--ink-soft);
  font-size: 11px;
  line-height: 1.6;
}

.portal-planned-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  text-align: left;
}

.portal-planned-list div {
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--home-surface);
}

.portal-planned-list strong,
.portal-planned-list small {
  display: block;
}

.portal-planned-list strong {
  color: var(--ink-soft);
  font-size: 10px;
}

.portal-planned-list small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.45;
}

.portal-unavailable-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 18px;
  padding: 7px 10px;
  border-radius: 999px;
  background: var(--surface-hover);
  color: var(--ink-soft);
  font-size: 9px;
}

/* Account and points */
.portal-account-shell { max-width: 1180px; }
.portal-account-loading,
.portal-account-empty { min-height: 240px; display: grid; place-items: center; align-content: center; gap: 12px; color: var(--muted); border-top: 1px solid var(--line); }
.portal-account-loading span { width: 24px; height: 24px; border: 2px solid var(--line); border-top-color: var(--primary); border-radius: 50%; animation: portal-account-spin .8s linear infinite; }
.portal-account-empty.error { color: var(--danger); }
.portal-account-hero { display: grid; grid-template-columns: minmax(250px, .72fr) minmax(480px, 1.28fr); align-items: stretch; border-block: 1px solid var(--line); }
.portal-account-hero > div { display: grid; align-content: center; min-height: 178px; padding: 24px 28px; border-right: 1px solid var(--line); }
.portal-account-hero > div span,
.portal-account-hero dt { color: var(--muted); font-size: 11px; }
.portal-account-hero > div strong { margin-top: 5px; color: var(--ink); font-size: clamp(42px, 6vw, 72px); line-height: 1; letter-spacing: -.06em; font-variant-numeric: tabular-nums; }
.portal-account-hero > div small { margin-top: 10px; color: var(--faint); font-size: 10px; }
.portal-account-hero dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0; }
.portal-account-hero dl div { display: grid; align-content: center; gap: 8px; min-height: 88px; padding: 18px 24px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.portal-account-hero dl div:nth-child(even) { border-right: 0; }
.portal-account-hero dl div:nth-last-child(-n+2) { border-bottom: 0; }
.portal-account-hero dd { margin: 0; color: var(--ink); font-size: 22px; font-weight: 720; font-variant-numeric: tabular-nums; }
.portal-account-profile { min-height: 76px; display: flex; align-items: center; gap: 13px; padding-block: 16px; border-bottom: 1px solid var(--line); }
.portal-account-avatar { width: 42px; height: 42px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; color: var(--ink); background: var(--primary-soft); font-weight: 800; }
.portal-account-profile > div:nth-child(2) { display: grid; min-width: 180px; gap: 3px; }
.portal-account-profile strong { font-size: 13px; }
.portal-account-profile small,
.portal-account-profile > span { color: var(--muted); font-size: 10px; }
.portal-account-profile > span { margin-right: auto; padding: 5px 8px; border-radius: 999px; background: var(--surface-hover); }
.portal-action-button.danger { color: var(--danger); }

.portal-recharge-shell { width: min(920px, 100%); }
.portal-recharge-page { margin-top: 8px; }
.portal-recharge-page > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.portal-recharge-balance { display: grid; gap: 4px; min-width: 120px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-hover); text-align: right; }
.portal-recharge-balance span { color: var(--muted); font-size: 10px; }
.portal-recharge-balance strong { color: var(--primary); font-size: 22px; font-variant-numeric: tabular-nums; }
.portal-recharge-option:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.portal-recharge-option[disabled] { opacity: 0.55; cursor: not-allowed; }
.portal-recharge-error { color: var(--danger) !important; }
.portal-heading-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.portal-recharge { margin-top: 30px; padding: 22px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); }
.portal-recharge header h2 { margin: 0; font-size: 18px; }
.portal-recharge header p { margin: 6px 0 0; color: var(--muted); font-size: 10px; }
.portal-recharge-options { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 18px; }
.portal-recharge-option { display: grid; gap: 6px; padding: 15px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-hover); color: var(--ink); text-align: left; cursor: pointer; }
.portal-recharge-option:hover { border-color: var(--primary); }
.portal-recharge-option strong { font-size: 17px; }
.portal-recharge-option span, .portal-recharge-custom, .portal-recharge-result { color: var(--muted); font-size: 11px; }
.portal-recharge-custom { display: flex; align-items: end; gap: 12px; margin-top: 16px; }
.portal-recharge-custom label { display: grid; gap: 6px; min-width: 230px; }
.portal-recharge-custom input { min-height: 38px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-hover); color: var(--ink); }
.portal-recharge-custom span { margin-right: auto; padding-bottom: 10px; }
.portal-recharge-result { display: grid; gap: 7px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.portal-recharge-result strong { color: var(--ink); }
.portal-recharge-result code { overflow-wrap: anywhere; color: var(--primary); font-size: 10px; }
.portal-payment-qr { width: 260px; height: 260px; padding: 8px; border-radius: 8px; background: #fff; object-fit: contain; }
.portal-account-ledger { margin-top: 30px; }
.portal-account-ledger > header { display: flex; align-items: end; justify-content: space-between; gap: 18px; padding-bottom: 14px; }
.portal-account-ledger h2 { margin: 0; font-size: 18px; }
.portal-account-ledger p,
.portal-account-ledger > header > span { margin: 5px 0 0; color: var(--muted); font-size: 10px; }
.portal-account-table { overflow-x: auto; border-top: 1px solid var(--line); }
.portal-account-table table { width: 100%; border-collapse: collapse; min-width: 780px; }
.portal-account-table th,
.portal-account-table td { padding: 14px 12px; border-bottom: 1px solid var(--line); color: var(--ink-soft); font-size: 11px; text-align: left; }
.portal-account-table th { color: var(--muted); font-size: 9px; font-weight: 650; }
.portal-account-table td strong,
.portal-account-table td small { display: block; }
.portal-account-table td small { margin-top: 3px; color: var(--faint); font-size: 9px; }
.portal-account-table .numeric { text-align: right; font-variant-numeric: tabular-nums; }
.portal-account-table .positive { color: var(--success); }
.portal-account-table .negative { color: var(--danger); }
@keyframes portal-account-spin { to { transform: rotate(1turn); } }

@media (max-width: 760px) {
  .portal-account-hero { grid-template-columns: 1fr; }
  .portal-account-hero > div { border-right: 0; border-bottom: 1px solid var(--line); }
  .portal-account-profile { align-items: flex-start; flex-wrap: wrap; }
  .portal-account-profile > span { margin-right: 0; }
  .portal-account-profile .portal-action-button { flex: 1 1 150px; }
  .portal-recharge-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .portal-recharge-custom { align-items: stretch; flex-direction: column; }
  .portal-recharge-custom span { margin-right: 0; }
}

.portal-model-plaza-shell { width: min(1460px, 100%); }

.portal-model-summary {
  min-height: 64px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid color-mix(in oklch, var(--success) 34%, var(--line));
  border-radius: var(--radius-md);
  background: color-mix(in oklch, var(--success) 7%, var(--home-surface));
}

.portal-model-summary.warning {
  border-color: color-mix(in oklch, var(--warning) 34%, var(--line));
  background: color-mix(in oklch, var(--warning) 7%, var(--home-surface));
}

.portal-model-summary > svg { width: 20px; height: 20px; color: var(--success); flex: 0 0 auto; }
.portal-model-summary.warning > svg { color: var(--warning); }
.portal-model-summary > div { min-width: 0; flex: 1; }
.portal-model-summary strong, .portal-model-summary p { display: block; margin: 0; }
.portal-model-summary strong { color: var(--ink); font-size: 14px; }
.portal-model-summary p { margin-top: 3px; color: var(--muted); font-size: 12px; }
.portal-model-summary button { min-height: 40px; display: inline-flex; align-items: center; gap: 6px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-hover); color: var(--ink-soft); font-size: 12px; }
.portal-model-summary button svg { width: 14px; height: 14px; }

.portal-model-category-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 16px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--home-surface);
  width: fit-content;
  max-width: 100%;
  overflow-x: auto;
}

.portal-model-category-tabs button { min-height: 40px; display: inline-flex; align-items: center; gap: 7px; padding: 0 13px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 12px; white-space: nowrap; }
.portal-model-category-tabs button:hover { color: var(--ink); background: var(--surface-hover); }
.portal-model-category-tabs button.active { color: var(--primary); background: color-mix(in oklch, var(--primary) 13%, var(--surface-hover)); }
.portal-model-category-tabs em { color: inherit; font-size: 11px; font-style: normal; opacity: .72; }

.portal-model-plaza-layout { display: grid; grid-template-columns: minmax(250px, 300px) minmax(460px, 1fr) minmax(210px, 250px); gap: 14px; align-items: start; }
.portal-model-catalog, .portal-model-workbench, .portal-model-task-history { border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--home-surface); overflow: hidden; }
.portal-model-catalog { display: grid; align-content: start; max-height: calc(100vh - 245px); overflow-y: auto; }

.portal-model-card { min-height: 116px; display: grid; grid-template-columns: 40px minmax(0, 1fr) 14px; align-items: start; gap: 10px; padding: 13px; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--ink); text-align: left; }
.portal-model-card:last-child { border-bottom: 0; }
.portal-model-card:hover { background: var(--surface-hover); }
.portal-model-card.active { background: color-mix(in oklch, var(--primary) 10%, var(--surface-hover)); box-shadow: inset 3px 0 var(--primary); }
.portal-model-card > svg { width: 14px; height: 14px; margin-top: 4px; color: var(--faint); }
.portal-model-card-icon { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; background: color-mix(in oklch, var(--primary) 10%, var(--surface-hover)); color: var(--primary); flex: 0 0 auto; }
.portal-model-card-icon.image { color: oklch(0.78 0.12 310); background: oklch(0.25 0.045 310 / .62); }
.portal-model-card-icon.video { color: oklch(0.77 0.13 40); background: oklch(0.25 0.04 40 / .62); }
.portal-model-card-icon svg { width: 19px; height: 19px; }
.portal-model-card-copy { min-width: 0; display: grid; gap: 5px; }
.portal-model-card-copy > span { display: flex; align-items: center; gap: 6px; }
.portal-model-card-copy em, .portal-model-card-copy i { padding: 2px 6px; border-radius: 999px; font-size: 10px; font-style: normal; font-weight: 700; }
.portal-model-card-copy em { background: var(--surface-hover); color: var(--muted); }
.portal-model-card-copy i.ready { background: color-mix(in oklch, var(--success) 15%, transparent); color: var(--success); }
.portal-model-card-copy i.warning { background: color-mix(in oklch, var(--warning) 15%, transparent); color: var(--warning); }
.portal-model-card-copy i.disabled { background: var(--surface-hover); color: var(--faint); }
.portal-model-card-copy strong { color: var(--ink); font-size: 13px; }
.portal-model-card-copy small { color: var(--muted); font-size: 12px; line-height: 1.45; }
.portal-model-card-copy b { color: var(--ink-soft); font-size: 11px; font-weight: 600; }

.portal-model-workbench > header { min-height: 110px; display: flex; align-items: flex-start; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.portal-model-workbench > header > div { min-width: 0; flex: 1; }
.portal-model-workbench > header small { color: var(--primary); font-size: 11px; }
.portal-model-workbench > header h2 { margin: 4px 0 0; color: var(--ink); font-size: 20px; }
.portal-model-workbench > header p { margin: 6px 0 0; color: var(--muted); font-size: 12px; line-height: 1.55; }
.portal-model-workbench-price { flex: 0 0 auto; padding: 5px 8px; border-radius: 999px; background: var(--surface-hover); color: var(--ink-soft); font-size: 11px; }
.portal-billing-chip { display: inline-flex; align-items: center; gap: 4px; width: fit-content; padding: 3px 7px; border: 1px solid color-mix(in oklch, var(--primary) 28%, var(--line)); border-radius: 999px; background: color-mix(in oklch, var(--primary) 9%, transparent); color: var(--primary); font-size: 11px; font-weight: 700; }
.portal-model-workbench form { display: grid; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.portal-model-workbench label { display: grid; gap: 6px; color: var(--ink-soft); font-size: 12px; font-weight: 650; }
.portal-model-workbench textarea, .portal-model-workbench select { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg); color: var(--ink); outline: none; }
.portal-model-workbench textarea { width: 100%; padding: 11px 12px; resize: vertical; font: inherit; font-size: 13px; line-height: 1.6; }
.portal-model-workbench textarea:focus, .portal-model-workbench select:focus { border-color: var(--primary); box-shadow: 0 0 0 2px color-mix(in oklch, var(--primary) 18%, transparent); }
.portal-model-references small { color: var(--faint); font-size: 11px; font-weight: 500; }
.portal-model-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.portal-model-options select { min-height: 42px; padding: 0 10px; font: inherit; font-size: 12px; }
.portal-model-submit-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.portal-model-submit-row > span { color: var(--muted); font-size: 11px; }
.portal-model-submit-row .portal-action-button { width: auto; }
.portal-model-submit-row .portal-action-button:disabled { cursor: not-allowed; opacity: .42; }

.portal-model-result { min-height: 260px; padding: 18px; }
.portal-model-result-empty, .portal-model-load-error, .portal-model-loading { min-height: 240px; display: grid; place-items: center; align-content: center; gap: 8px; color: var(--muted); text-align: center; }
.portal-model-result-empty > svg, .portal-model-load-error > svg { width: 28px; height: 28px; color: var(--faint); }
.portal-model-result-empty strong, .portal-model-load-error strong { color: var(--ink-soft); font-size: 14px; }
.portal-model-result-empty small, .portal-model-load-error p { margin: 0; color: var(--muted); font-size: 12px; }
.portal-model-loading i { width: 24px; height: 24px; border: 2px solid var(--line); border-top-color: var(--primary); border-radius: 50%; animation: portal-model-spin .8s linear infinite; }
@keyframes portal-model-spin { to { transform: rotate(360deg); } }
.portal-model-result-progress, .portal-model-result-error { min-height: 210px; display: flex; align-items: center; justify-content: center; gap: 13px; }
.portal-model-result-progress > span, .portal-model-result-error > svg { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 10px; background: var(--surface-hover); color: var(--primary); }
.portal-model-result-progress > span svg { width: 18px; height: 18px; }
.portal-model-result-progress > div, .portal-model-result-error > div { width: min(390px, 100%); }
.portal-model-result-progress strong, .portal-model-result-error strong { color: var(--ink); font-size: 14px; }
.portal-model-result-progress p, .portal-model-result-error p { margin: 5px 0; color: var(--muted); font-size: 12px; }
.portal-model-result-progress i { display: block; height: 5px; margin: 10px 0 7px; border-radius: 999px; background: var(--surface-hover); overflow: hidden; }
.portal-model-result-progress i b { display: block; height: 100%; border-radius: inherit; background: var(--primary); transition: width 180ms ease-out; }
.portal-model-result-progress small { color: var(--faint); font-size: 11px; }
.portal-model-result-error > svg { padding: 11px; color: var(--danger); }
.portal-model-result-error button { min-height: 34px; margin-top: 8px; padding: 0 10px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-hover); color: var(--ink-soft); }
.portal-model-text-result header, .portal-model-media-result header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 13px; }
.portal-model-text-result header strong, .portal-model-media-result header strong { color: var(--ink); font-size: 14px; }
.portal-model-text-result header span, .portal-model-media-result header span { color: var(--success); font-size: 11px; }
.portal-model-text-result > p { margin: 0; color: var(--ink-soft); font-size: 13px; line-height: 1.75; white-space: pre-wrap; }
.portal-model-image-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.portal-model-image-grid a { min-height: 180px; border-radius: var(--radius-sm); background: var(--bg); overflow: hidden; }
.portal-model-image-grid img { width: 100%; height: 100%; display: block; object-fit: cover; }
.portal-model-media-result video { width: 100%; max-height: 480px; display: block; margin-bottom: 10px; border-radius: var(--radius-sm); background: #000; }
.portal-model-media-result .portal-action-button { width: fit-content; }

.portal-model-task-history > header { display: grid; gap: 3px; padding: 14px; border-bottom: 1px solid var(--line); }
.portal-model-task-history > header strong { color: var(--ink); font-size: 13px; }
.portal-model-task-history > header small { color: var(--muted); font-size: 11px; }
.portal-model-task-history > button { width: 100%; min-height: 62px; display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 8px; align-items: center; padding: 9px 12px; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--ink); text-align: left; }
.portal-model-task-history > button:hover, .portal-model-task-history > button.active { background: var(--surface-hover); }
.portal-model-task-history > button > span:first-child { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 7px; background: var(--surface-hover); color: var(--primary); }
.portal-model-task-history > button svg { width: 13px; height: 13px; }
.portal-model-task-history > button strong, .portal-model-task-history > button small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.portal-model-task-history > button strong { color: var(--ink-soft); font-size: 12px; }
.portal-model-task-history > button small { margin-top: 3px; color: var(--muted); font-size: 11px; }
.portal-model-task-empty { min-height: 180px; display: grid; place-items: center; align-content: center; gap: 7px; color: var(--faint); font-size: 12px; }
.portal-model-task-empty svg { width: 22px; height: 22px; }

/* The model plaza is a full-height working surface, not a portal landing page. */
.portal-page.portal-model-plaza-active {
  height: calc(100dvh - var(--topbar-height));
  min-height: 0;
  padding: 0;
  overflow: hidden;
}
.portal-page.portal-model-plaza-active > .portal-model-plaza-shell {
  width: 100%;
  max-width: none;
  height: 100%;
  margin: 0;
}
.portal-model-plaza-state { display: grid; place-items: center; }
.portal-model-plaza-state .portal-model-loading,
.portal-model-plaza-state .portal-model-load-error { min-height: 0; padding: 28px; }
.portal-model-plaza-state .portal-model-loading strong { color: var(--ink); font-size: 14px; }
.portal-model-chat-layout {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  display: flex;
  border: 0;
  border-radius: 0;
  background: var(--home-surface);
  overflow: hidden;
}
.portal-model-chat-sidebar {
  flex: 0 0 310px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: color-mix(in oklch, var(--home-surface) 92%, var(--bg));
  overflow: hidden;
}
.portal-model-sidebar-header {
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.portal-model-sidebar-header > div { min-width: 0; display: grid; gap: 4px; }
.portal-model-sidebar-header strong { color: var(--ink); font-size: 14px; }
.portal-model-sidebar-header small { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 10px; }
.portal-model-sidebar-header small i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.portal-model-sidebar-header small.ready { color: var(--success); }
.portal-model-sidebar-header small.warning { color: var(--warning); }
.portal-model-sidebar-header nav { display: flex; align-items: center; gap: 3px; }
.portal-model-sidebar-header button {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 9px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 10px;
}
.portal-model-sidebar-header button { width: 32px; padding: 0; cursor: pointer; }
.portal-model-sidebar-header button:hover { background: var(--surface-hover); color: var(--ink); }
.portal-model-sidebar-header button:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.portal-model-sidebar-header svg { width: 13px; height: 13px; }
.portal-model-category-tabs.vertical {
  width: auto;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3px;
  margin: 0;
  padding: 10px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  overflow: visible;
}
.portal-model-category-tabs.vertical button { min-height: 36px; justify-content: space-between; padding-inline: 9px; }
.portal-model-category-tabs.vertical button:first-child { grid-column: 1 / -1; }
.portal-model-capability-tabs {
  display: flex;
  align-items: center;
  gap: 5px;
  overflow-x: auto;
}
.portal-model-capability-tabs.compact { padding: 9px 10px; border-bottom: 1px solid var(--line); }
.portal-model-capability-tabs button {
  min-height: 30px;
  flex: 0 0 auto;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
}
.portal-model-capability-tabs button:hover { color: var(--ink); background: var(--surface-hover); }
.portal-model-capability-tabs button.active { border-color: color-mix(in oklch, var(--primary) 55%, var(--line)); color: var(--primary); background: var(--primary-soft); }
.portal-model-capability-tabs em { font-style: normal; opacity: .7; }
.portal-model-chat-sidebar .portal-model-catalog { min-height: 0; flex: 1; max-height: none; border: 0; border-radius: 0; }
.portal-model-chat-sidebar .portal-model-card { height: 128px; min-height: 128px; }
.portal-model-chat-sidebar .portal-model-card-copy > strong,
.portal-model-chat-sidebar .portal-model-card-copy > b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.portal-model-chat-sidebar .portal-model-card-copy > small {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.portal-model-chat-sidebar .portal-model-capability-tags { display: none; }
.portal-model-capability-tags { flex-wrap: wrap; }
.portal-model-capability-tags em { padding: 2px 5px; font-size: 9px; font-weight: 600; }
.portal-model-chat { width: 0; min-width: 0; min-height: 0; flex: 1 1 auto; display: grid; grid-template-rows: auto minmax(150px, 1fr) auto; }
.portal-model-chat-header {
  min-height: 78px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.portal-model-chat-heading { min-width: 0; flex: 1; }
.portal-model-chat-header h2 { margin: 0; color: var(--ink); font-size: 16px; text-wrap: balance; }
.portal-model-chat-header p { max-width: 72ch; margin: 4px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.portal-model-chat-actions { display: flex; align-items: center; gap: 5px; }
.portal-model-chat-actions button {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 10px;
  border: 0;
  border-radius: 7px;
  background: var(--surface-hover);
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 700;
}
.portal-model-chat-actions button:hover { background: var(--surface-active); color: var(--ink); }
.portal-model-chat-actions button.primary { background: var(--primary); color: var(--bg); }
.portal-model-chat-actions button:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.portal-model-chat-actions svg { width: 13px; height: 13px; }
.portal-model-chat-thread {
  min-height: 0;
  overflow-y: auto;
  overflow-anchor: none;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding: 22px clamp(16px, 4vw, 64px);
  scroll-behavior: auto;
}
.portal-model-chat-empty { min-height: 300px; display: grid; place-items: center; align-content: center; gap: 8px; color: var(--muted); text-align: center; }
.portal-model-chat-empty > svg { width: 28px; height: 28px; color: var(--primary); }
.portal-model-chat-empty strong { color: var(--ink); font-size: 15px; }
.portal-model-chat-empty p { max-width: 56ch; margin: 0; color: var(--ink-soft); font-size: 12px; line-height: 1.55; }
.portal-model-chat-empty small { color: var(--faint); font-size: 11px; }
.portal-model-chat-turn { display: grid; gap: 18px; margin-bottom: 28px; }
.portal-model-chat-user { display: flex; justify-content: flex-end; gap: 9px; }
.portal-model-chat-user > span { order: 2; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; background: var(--primary); color: var(--bg); font-size: 10px; font-weight: 800; }
.portal-model-chat-user > div { max-width: min(680px, 82%); padding: 10px 13px; border-radius: 12px 4px 12px 12px; background: color-mix(in oklch, var(--primary) 12%, var(--surface-hover)); }
.portal-model-chat-user p { margin: 0; color: var(--ink); font-size: 13px; line-height: 1.65; white-space: pre-wrap; }
.portal-model-chat-user small { display: block; margin-top: 6px; color: var(--muted); font-size: 10px; }
.portal-model-chat-upload-strip { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.portal-model-chat-upload-strip a { width: 58px; height: 58px; display: block; position: relative; overflow: hidden; border: 1px solid color-mix(in oklch, var(--primary) 22%, var(--line)); border-radius: 7px; background: var(--bg); }
.portal-model-chat-upload-strip img,
.portal-model-chat-upload-strip video { width: 100%; height: 100%; display: block; object-fit: cover; }
.portal-model-chat-upload-strip span { width: 22px; height: 22px; display: grid; place-items: center; position: absolute; top: 50%; left: 50%; border-radius: 50%; color: var(--ink); background: color-mix(in oklch, var(--bg) 84%, transparent); transform: translate(-50%, -50%); }
.portal-model-chat-upload-strip span svg { width: 12px; height: 12px; }
.portal-model-chat-upload-strip a:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.portal-model-chat-assistant { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 10px; align-items: start; }
.portal-model-chat-assistant > span { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; background: var(--primary-soft); color: var(--primary); }
.portal-model-chat-assistant > span svg { width: 15px; height: 15px; }
.portal-model-chat-assistant > div { min-width: 0; padding-top: 2px; }
.portal-model-chat-assistant .portal-model-result-progress,
.portal-model-chat-assistant .portal-model-result-error { min-height: 90px; justify-content: flex-start; }
.portal-model-chat-assistant .portal-model-result-progress > div,
.portal-model-chat-assistant .portal-model-result-error > div { width: min(560px, 100%); }
.portal-model-thinking {
  min-height: 72px;
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: center;
  justify-content: start;
  gap: 7px;
  color: var(--ink-soft);
}
.portal-model-thinking strong { font-size: 13px; }
.portal-model-thinking small { grid-column: 1 / -1; color: var(--muted); font-size: 11px; }
.portal-model-thinking-dots,
.portal-model-send-dots { display: inline-flex; align-items: center; gap: 3px; }
.portal-model-thinking-dots i,
.portal-model-send-dots i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  animation: portal-model-thinking-dot 1.15s ease-in-out infinite;
}
.portal-model-thinking-dots i:nth-child(2),
.portal-model-send-dots i:nth-child(2) { animation-delay: 140ms; }
.portal-model-thinking-dots i:nth-child(3),
.portal-model-send-dots i:nth-child(3) { animation-delay: 280ms; }
@keyframes portal-model-thinking-dot {
  0%, 60%, 100% { opacity: .35; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-2px); }
}
.portal-model-chat-composer { position: relative; z-index: 1; margin: 0 clamp(12px, 3vw, 46px) 16px; padding: 7px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--bg); }
.portal-model-chat-composer:focus-within { border-color: var(--primary); }
.portal-model-composer-input { position: relative; }
.portal-model-input-guidance { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 12px; padding: 10px 12px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--primary) 6%, transparent); }
.portal-model-input-guidance > strong { display: inline-flex; align-items: center; align-self: start; gap: 5px; color: var(--ink-soft); font-size: 11px; }
.portal-model-input-guidance > strong svg { width: 13px; height: 13px; color: var(--primary); }
.portal-model-input-guidance ul { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 0; padding: 0; color: var(--muted); font-size: 10px; line-height: 1.45; list-style: none; }
.portal-model-input-guidance li { position: relative; padding-left: 9px; }
.portal-model-input-guidance li::before { position: absolute; left: 0; content: "·"; color: var(--primary); }
.portal-model-composer-input > textarea { width: 100%; min-height: 58px; padding: 9px 11px; border: 0; resize: vertical; outline: none; background: transparent; color: var(--ink); font: inherit; font-size: 13px; line-height: 1.55; }
.portal-model-composer-input > textarea:disabled { cursor: wait; color: var(--muted); opacity: 1; }
.portal-model-upload-strip { display: flex; align-items: center; gap: 7px; padding: 5px 8px 3px; overflow-x: auto; }
.portal-model-upload-item { position: relative; width: 56px; height: 56px; flex: 0 0 56px; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-hover); }
.portal-model-upload-item img,
.portal-model-upload-item video { width: 100%; height: 100%; display: block; object-fit: cover; }
.portal-model-upload-item > em { width: 22px; height: 22px; display: grid; place-items: center; position: absolute; top: 50%; left: 50%; border-radius: 50%; color: var(--ink); background: color-mix(in oklch, var(--bg) 84%, transparent); transform: translate(-50%, -50%); }
.portal-model-upload-item > em svg { width: 12px; height: 12px; }
.portal-model-upload-item > i { max-width: calc(100% - 4px); position: absolute; right: 2px; bottom: 2px; left: 2px; overflow: hidden; padding: 2px 3px; border-radius: 4px; color: var(--ink-soft); background: color-mix(in oklch, var(--bg) 88%, transparent); font-size: 8px; font-style: normal; line-height: 1.2; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
.portal-model-upload-item.uploading::after { content: ""; width: 16px; height: 16px; position: absolute; top: 20px; left: 20px; border: 2px solid color-mix(in oklch, var(--ink) 24%, transparent); border-top-color: var(--primary); border-radius: 50%; animation: portal-model-spin 760ms linear infinite; }
.portal-model-upload-item.uploading > img,
.portal-model-upload-item.uploading > video { opacity: 0.5; }
.portal-model-upload-item.error { border-color: var(--danger); }
.portal-model-upload-item.error > i { color: white; background: var(--danger); }
.portal-model-upload-item button { position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 50%; background: color-mix(in oklch, var(--bg) 88%, transparent); color: var(--ink); cursor: pointer; }
.portal-model-upload-item button:hover { background: var(--danger); color: white; }
.portal-model-upload-item button:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.portal-model-upload-item button svg { width: 11px; height: 11px; }
.portal-model-upload-strip > small { flex: 0 0 auto; color: var(--faint); font-size: 10px; line-height: 1.45; }
.portal-model-upload-strip > small strong { color: var(--ink-soft); font-weight: 700; }
.portal-model-composer-upload-button { min-height: 36px; display: inline-flex; align-items: center; gap: 6px; padding: 0 9px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); cursor: pointer; font: inherit; font-size: 11px; }
.portal-model-composer-upload-button:hover,
.portal-model-composer-upload-button.has-files { background: var(--surface-hover); color: var(--ink-soft); }
.portal-model-composer-upload-button.has-files { color: var(--primary); }
.portal-model-composer-upload-button:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.portal-model-composer-upload-button svg { width: 14px; height: 14px; }
.portal-model-composer-attachment { position: relative; z-index: 2; flex: 0 0 auto; align-self: flex-end; }
.portal-model-composer-attachment summary { min-height: 36px; display: inline-flex; align-items: center; gap: 6px; padding: 0 9px; border-radius: 7px; color: var(--muted); cursor: pointer; font-size: 11px; list-style: none; user-select: none; }
.portal-model-composer-attachment summary::-webkit-details-marker { display: none; }
.portal-model-composer-attachment summary:hover,
.portal-model-composer-attachment[open] summary { background: var(--surface-hover); color: var(--ink-soft); }
.portal-model-composer-attachment summary:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.portal-model-composer-attachment summary svg { width: 14px; height: 14px; }
.portal-model-composer-attachment > div { position: absolute; left: 0; bottom: 44px; width: min(360px, calc(100vw - 40px)); padding: 10px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--panel); }
.portal-model-composer-attachment label { display: block; margin-bottom: 7px; color: var(--ink-soft); font-size: 11px; font-weight: 650; }
.portal-model-composer-attachment textarea { width: 100%; min-height: 70px; padding: 8px 9px; border: 1px solid var(--line); border-radius: 7px; resize: vertical; outline: none; background: var(--bg); color: var(--ink); font: inherit; font-size: 11px; line-height: 1.5; }
.portal-model-composer-attachment textarea:focus { border-color: var(--primary); }
.portal-model-composer-attachment small { display: block; margin-top: 5px; color: var(--faint); font-size: 10px; }
.portal-model-composer-toolbar { position: relative; display: flex; align-items: flex-end; gap: 8px; padding: 5px; isolation: isolate; }
.portal-model-composer-toolbar .portal-model-options { min-width: 0; flex: 1; display: flex; flex-wrap: wrap; }
.portal-model-composer-toolbar .portal-model-options label { min-width: 132px; display: grid; gap: 4px; color: var(--muted); font-size: 10px; }
.portal-model-composer-toolbar .portal-model-options select { min-height: 36px; padding: 0 9px; border: 1px solid var(--line); border-radius: 7px; background: var(--home-surface); color: var(--ink-soft); font: inherit; font-size: 11px; }
.portal-model-composer-toolbar .portal-model-options input { min-height: 36px; width: 132px; padding: 0 9px; border: 1px solid var(--line); border-radius: 7px; outline: none; background: var(--home-surface); color: var(--ink-soft); font: inherit; font-size: 11px; }
.portal-model-composer-toolbar .portal-model-options input:focus { border-color: var(--primary); }
.portal-model-audio-preview { width: 100%; height: 100%; display: grid; place-items: center; background: var(--surface-hover); color: var(--primary); }
.portal-model-audio-preview svg { width: 22px; height: 22px; }
.portal-model-composer-toolbar > span { min-width: 0; overflow: hidden; color: var(--muted); font-size: 10px; pointer-events: none; text-overflow: ellipsis; white-space: nowrap; }
.portal-model-composer-toolbar .portal-action-button { position: relative; z-index: 3; flex: 0 0 auto; width: auto; min-height: 38px; pointer-events: auto; }
.portal-model-composer-toolbar .portal-action-button:disabled { cursor: wait; opacity: .68; }
.portal-tool-submit span { display: inline-flex; align-items: center; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.portal-tool-model em { display: block; margin-top: 3px; color: var(--primary); font-size: 11px; font-style: normal; font-weight: 700; }

.portal-model-history {
  flex: 0 0 280px;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--line);
  background: color-mix(in oklch, var(--home-surface) 92%, var(--bg));
  overflow: hidden;
}
.portal-model-history[hidden] { display: none; }
.portal-model-history > header {
  min-height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.portal-model-history > header > div { min-width: 0; display: grid; gap: 4px; }
.portal-model-history > header strong { color: var(--ink); font-size: 13px; }
.portal-model-history > header small { color: var(--muted); font-size: 10px; }
.portal-model-history > header button {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
}
.portal-model-history > header button:hover { background: var(--surface-hover); color: var(--ink); }
.portal-model-history > header button:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.portal-model-history > header svg { width: 13px; height: 13px; }
.portal-model-new-conversation {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin: 10px;
  border: 1px solid color-mix(in oklch, var(--primary) 42%, var(--line));
  border-radius: 8px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
}
.portal-model-new-conversation:hover { background: color-mix(in oklch, var(--primary) 18%, var(--surface-hover)); }
.portal-model-new-conversation:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.portal-model-new-conversation svg { width: 14px; height: 14px; }
.portal-model-history-list { min-height: 0; flex: 1; overflow-y: auto; }
.portal-model-history-item {
  width: 100%;
  min-height: 68px;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border: 0;
  border-top: 1px solid var(--line);
  background: transparent;
  color: var(--ink-soft);
  text-align: left;
}
.portal-model-history-item:hover { background: var(--surface-hover); }
.portal-model-history-item.active { background: var(--primary-soft); color: var(--ink); }
.portal-model-history-item > span:first-child { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 7px; background: var(--surface-hover); color: var(--primary); }
.portal-model-history-item > span:first-child svg { width: 13px; height: 13px; }
.portal-model-history-item > span:nth-child(2) { min-width: 0; }
.portal-model-history-item strong,
.portal-model-history-item small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.portal-model-history-item strong { color: inherit; font-size: 11px; }
.portal-model-history-item small { margin-top: 4px; color: var(--muted); font-size: 9px; }
.portal-model-history-item time { align-self: start; padding-top: 4px; color: var(--faint); font-size: 9px; }
.portal-model-history-empty { min-height: 220px; display: grid; place-items: center; align-content: center; gap: 7px; padding: 20px; color: var(--muted); text-align: center; }
.portal-model-history-empty svg { width: 22px; height: 22px; color: var(--faint); }
.portal-model-history-empty strong { color: var(--ink-soft); font-size: 12px; }
.portal-model-history-empty small { font-size: 10px; line-height: 1.5; }

.portal-toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: var(--z-toast);
  max-width: min(360px, calc(100vw - 36px));
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: var(--bg);
  font-size: 11px;
  font-weight: 700;
  box-shadow: var(--shadow-1);
}

.portal-toast[hidden] {
  display: none;
}

@media (max-width: 1200px) {
  .portal-model-history {
    position: absolute;
    inset: 0 0 0 auto;
    z-index: var(--z-drawer);
    width: min(320px, 88vw);
    box-shadow: -6px 0 8px oklch(0 0 0 / .22);
  }
}

@media (max-width: 960px) {
  .portal-page { padding-inline: 22px; }
  .portal-project-row { grid-template-columns: 70px minmax(160px, 1fr) minmax(110px, 0.7fr) auto; }
  .portal-project-row .portal-project-cell:nth-of-type(3) { display: none; }
  .portal-template-featured { grid-template-columns: 1fr; }
  .portal-model-plaza-layout { grid-template-columns: minmax(230px, 280px) minmax(0, 1fr); }
  .portal-model-task-history { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .portal-model-task-history > header { grid-column: 1 / -1; }
  .portal-model-chat-sidebar { flex-basis: 260px; }
  .portal-hermes-grid { grid-template-columns: 1fr; }
  .portal-hermes-result { position: static; }
  .portal-hermes-workflow { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .portal-page.portal-hermes-active > .portal-hermes-entry-shell {
    grid-template-columns: 1fr;
    overflow: auto;
    overscroll-behavior: contain;
  }
  .portal-page.portal-hermes-active > .portal-hermes-agent-shell {
    grid-template-columns: 190px minmax(0, 1fr);
    overflow: hidden;
    overscroll-behavior: none;
  }
  .portal-hermes-agent-history {
    display: none;
  }
  .portal-hermes-main { grid-template-columns: 1fr; }
  .portal-hermes-side-panel,
  .portal-hermes-asset-detail { order: 2; }
  .portal-hermes-canvas { min-height: 460px; }
  .portal-hermes-upload-stage .portal-hermes-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .portal-hermes-upload-stage .portal-hermes-row label {
    max-width: none;
  }
}

@media (max-width: 680px) {
  .portal-page { padding: 22px 14px 44px; }
  .portal-page-heading { align-items: flex-start; flex-direction: column; }
  .portal-heading-actions { justify-content: flex-start; }
  .portal-project-row { grid-template-columns: 62px minmax(0, 1fr) auto; }
  .portal-project-thumb { width: 62px; height: 48px; }
  .portal-project-row .portal-project-cell { display: none; }
  .portal-asset-upload { align-items: flex-start; flex-direction: column; }
  .portal-planned-list { grid-template-columns: 1fr; }
  .portal-community-hero { grid-template-columns: 48px minmax(0, 1fr); gap: 14px; }
  .portal-community-mark { width: 48px; height: 48px; border-radius: 12px; }
  .portal-community-status { grid-column: 1 / -1; justify-self: start; }
  .portal-community-grid { grid-template-columns: 1fr; }
  .portal-community-grid article { min-height: 112px; border-right: 0; border-bottom: 1px solid var(--line); }
  .portal-community-grid article:last-child { border-bottom: 0; }
  .portal-model-summary { align-items: flex-start; flex-wrap: wrap; }
  .portal-model-summary button { width: 100%; justify-content: center; }
  .portal-model-category-tabs { width: 100%; }
  .portal-model-plaza-layout { grid-template-columns: 1fr; }
  .portal-model-catalog { display: flex; max-height: none; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x proximity; }
  .portal-model-card { min-height: 112px; flex: 0 0 min(82vw, 310px); border-right: 1px solid var(--line); border-bottom: 0; scroll-snap-align: start; }
  .portal-model-options { grid-template-columns: 1fr; }
  .portal-model-submit-row { align-items: stretch; flex-direction: column; }
  .portal-model-submit-row .portal-action-button { width: 100%; }
  .portal-model-workbench > header { flex-wrap: wrap; }
  .portal-model-workbench-price { margin-left: 52px; }
  .portal-model-task-history { display: block; }
  .portal-model-image-grid { grid-template-columns: 1fr; }
  .portal-page.portal-model-plaza-active {
    height: calc(100dvh - var(--topbar-height) - env(safe-area-inset-top));
    padding: 0;
  }
  .portal-page.portal-model-plaza-active .portal-model-chat-layout {
    height: 100%;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
  }
  .portal-model-chat-sidebar { border-right: 0; border-bottom: 1px solid var(--line); }
  .portal-model-sidebar-header { min-height: 50px; padding: 7px 10px; }
  .portal-model-category-tabs.vertical { display: flex; overflow-x: auto; }
  .portal-model-category-tabs.vertical button:first-child { grid-column: auto; }
  .portal-model-chat-sidebar .portal-model-catalog { display: flex; max-height: none; overflow-x: auto; overflow-y: hidden; }
  .portal-model-chat-sidebar .portal-model-card { height: 92px; min-height: 92px; flex-basis: min(76vw, 272px); grid-template-columns: 32px minmax(0, 1fr) 12px; padding: 10px; }
  .portal-model-chat-sidebar .portal-model-card-icon { width: 32px; height: 32px; border-radius: 8px; }
  .portal-model-chat-sidebar .portal-model-card-icon svg { width: 15px; height: 15px; }
  .portal-model-chat-sidebar .portal-model-card-copy { gap: 4px; }
  .portal-model-chat-sidebar .portal-model-card-copy > small,
  .portal-model-chat-sidebar .portal-model-capability-tags,
  .portal-model-chat-sidebar .portal-model-card-copy > b { display: none; }
  .portal-page.portal-model-plaza-active .portal-model-chat { min-height: 0; }
  .portal-page.portal-model-plaza-active .portal-model-chat { width: auto; }
  .portal-model-chat-header { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: start; }
  .portal-model-chat-header .portal-model-workbench-price { grid-column: 2; margin-left: 0; justify-self: start; }
  .portal-model-chat-actions { grid-column: 3; grid-row: 1 / span 2; }
  .portal-model-chat-actions button { width: 34px; padding: 0; }
  .portal-model-chat-actions button span { display: none; }
  .portal-model-chat-thread { padding: 18px 14px; }
  .portal-model-chat-composer { margin: 0 10px 10px; }
  .portal-model-composer-toolbar { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: end; }
  .portal-model-composer-toolbar .portal-model-options { grid-column: 1 / -1; order: -1; width: 100%; }
  .portal-model-composer-toolbar .portal-model-options label { flex: 1 1 132px; }
  .portal-model-composer-attachment { align-self: end; }
  .portal-model-composer-toolbar > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right; }
  .portal-model-composer-toolbar .portal-action-button { width: auto; }
  .portal-hermes-status { align-items: flex-start; flex-direction: column; }
  .portal-hermes-workflow { grid-template-columns: 1fr; }
  .portal-hermes-entry-card { min-height: auto; padding: 18px; }
  .portal-hermes-entry-history header { align-items: flex-start; flex-direction: column; }
  .portal-hermes-history-list { grid-template-columns: 1fr; }
  .portal-page.portal-hermes-active > .portal-hermes-agent-shell {
    grid-template-columns: 1fr;
    overflow: auto;
  }
  .portal-hermes-agent-sidebar {
    min-height: auto;
    padding: 14px;
  }
  .portal-hermes-chat {
    min-height: 560px;
  }
  .portal-hermes-studio { grid-template-columns: 1fr; }
  .portal-hermes-rail { display: flex; overflow-x: auto; }
  .portal-hermes-rail button { flex: 0 0 34px; }
  .portal-hermes-row,
  .portal-hermes-meta { grid-template-columns: 1fr; }
  .portal-hermes-upload-stage .portal-hermes-row { grid-template-columns: 1fr; }
  .portal-hermes-panel,
  .portal-hermes-canvas,
  .portal-hermes-side-panel,
  .portal-hermes-asset-detail { padding: 14px; }
  .portal-hermes-stage-head { align-items: flex-start; flex-direction: column; }
  .portal-hermes-ratio-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .portal-hermes-asset-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .portal-page *,
  .portal-toast {
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .portal-model-thinking-dots i,
  .portal-model-send-dots i,
  .portal-model-upload-item.uploading::after,
  .portal-hermes-running i { animation: none; opacity: .72; transform: none; }
}

/* Scheme B — Hermes 资产图阶段（追加到 portal / site CSS） */
.portal-hermes-asset-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: flex-end;
  justify-content: space-between;
  margin: 0 0 14px;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, currentColor 12%, transparent);
  border-radius: 14px;
  background: color-mix(in srgb, canvas 88%, transparent);
}
.portal-hermes-asset-toolbar-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  align-items: baseline;
}
.portal-hermes-asset-toolbar-meta strong { font-size: 1.25rem; }
.portal-hermes-asset-toolbar-meta small { opacity: 0.72; }
.portal-hermes-asset-model {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  opacity: 0.9;
  min-width: min(240px, 100%);
}
.portal-hermes-asset-model select {
  min-height: 36px;
  border-radius: 10px;
  padding: 6px 10px;
}
.portal-hermes-asset-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.portal-hermes-asset-grid button {
  position: relative;
  text-align: left;
}
.portal-hermes-asset-grid button img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 10px;
  margin: 6px 0;
  background: #111;
}
.portal-hermes-asset-status {
  position: absolute;
  top: 10px;
  right: 10px;
  font-style: normal;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, canvas 80%, #888);
}
.portal-hermes-asset-grid button.status-done .portal-hermes-asset-status,
.portal-hermes-asset-grid button.status-approved .portal-hermes-asset-status {
  background: color-mix(in srgb, #1f9d55 35%, canvas);
}
.portal-hermes-asset-grid button.status-running .portal-hermes-asset-status,
.portal-hermes-asset-grid button.status-queued .portal-hermes-asset-status {
  background: color-mix(in srgb, #2f6fed 35%, canvas);
}
.portal-hermes-asset-grid button.status-failed .portal-hermes-asset-status {
  background: color-mix(in srgb, #d94848 40%, canvas);
}
.portal-hermes-asset-grid button.status-needs-base .portal-hermes-asset-status {
  background: color-mix(in srgb, #c9851a 40%, canvas);
}
.portal-hermes-asset-preview {
  display: grid;
  place-items: center;
  min-height: 180px;
  border-radius: 14px;
  border: 1px dashed color-mix(in srgb, currentColor 18%, transparent);
  overflow: hidden;
  margin-bottom: 12px;
}
.portal-hermes-asset-preview.has-image {
  border-style: solid;
  padding: 0;
}
.portal-hermes-asset-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #0b0b0b;
}
.portal-hermes-asset-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.portal-hermes-asset-detail-actions .is-approved {
  outline: 1px solid color-mix(in srgb, #1f9d55 55%, transparent);
}


/* CTA: keep asset-gen actions inside file cards, not over hero art */
.portal-hermes-embedded-preview > header,
.portal-hermes-message-file,
.portal-hermes-preview-panel > header {
  position: relative;
  z-index: 1;
}
.portal-hermes-embedded-preview {
  position: relative;
  z-index: 1;
  max-width: min(720px, 100%);
  margin: 12px 0;
}
.portal-hermes-embedded-preview > header {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  align-items: center;
  justify-content: space-between;
}
.portal-hermes-embedded-preview > header > div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.portal-hermes-embedded-preview > header button,
.portal-hermes-message-file > button {
  white-space: nowrap;
}
.portal-hermes-agent-shell .portal-hermes-chat-scroll,
.portal-hermes-agent-shell .portal-hermes-agent-chat {
  isolation: isolate;
}


/* Hermes sidebar brand avatar: keep as small mark, never full-bleed */
.portal-hermes-agent-sidebar .portal-hermes-brand-mark,
.portal-hermes-agent-sidebar .portal-hermes-entry-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 10px;
  background: var(--primary);
  flex: 0 0 auto;
}
.portal-hermes-agent-sidebar .portal-hermes-brand-mark img,
.portal-hermes-agent-sidebar .portal-hermes-entry-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.portal-hermes-agent-sidebar {
  overflow: hidden;
}




/* Asset detail: keep preview visible; prompt scrolls in its own pane */
.portal-hermes-assets-stage .portal-hermes-grid {
  min-height: 0;
  height: 100%;
  align-items: stretch;
}
.portal-hermes-assets-stage .portal-hermes-canvas {
  display: flex;
  flex-direction: column;
  align-content: stretch;
  gap: 12px;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  grid-template-rows: none;
}
.portal-hermes-assets-stage .portal-hermes-asset-detail {
  display: grid;
  grid-template-rows: minmax(180px, 0.9fr) auto auto minmax(140px, 1.1fr) auto;
  gap: 10px;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  align-content: stretch;
}
.portal-hermes-assets-stage .portal-hermes-asset-preview {
  min-height: 160px;
  height: 100%;
  margin: 0;
  overflow: hidden;
  aspect-ratio: auto;
}
.portal-hermes-assets-stage .portal-hermes-asset-preview img {
  width: 100%;
  height: 100%;
  max-height: 100%;
  object-fit: contain;
}
.portal-hermes-assets-stage .portal-hermes-asset-detail > section,
.portal-hermes-assets-stage .portal-hermes-asset-detail > .portal-hermes-error {
  margin: 0;
}
.portal-hermes-assets-stage .portal-hermes-asset-prompt {
  min-height: 0;
  margin: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 7px;
  overflow: hidden;
}
.portal-hermes-assets-stage .portal-hermes-asset-prompt textarea {
  min-height: 0;
  height: 100%;
  max-height: none;
  resize: none;
  overflow: auto;
  overscroll-behavior: contain;
}
.portal-hermes-assets-stage .portal-hermes-asset-detail-actions {
  margin-top: 0;
}
.portal-hermes-assets-stage .portal-hermes-asset-grid {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
}

/* Hermes asset lightbox + scroll-stable preview */
.portal-hermes-asset-preview.has-image {
  cursor: zoom-in;
  position: relative;
}
.portal-hermes-asset-preview-hint {
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 4px 8px;
  border-radius: 999px;
  background: color-mix(in oklch, black 55%, transparent);
  color: white;
  font-size: 11px;
  pointer-events: none;
}
.portal-hermes-lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 28px;
  background: color-mix(in oklch, black 72%, transparent);
}
.portal-hermes-lightbox img {
  max-width: min(1200px, 96vw);
  max-height: 90vh;
  border-radius: 12px;
  box-shadow: 0 18px 60px color-mix(in oklch, black 45%, transparent);
  background: #111;
  object-fit: contain;
}
.portal-hermes-lightbox-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: color-mix(in oklch, white 92%, transparent);
  color: #111;
  cursor: pointer;
}
.portal-hermes-asset-grid img[data-hermes-asset-lightbox] {
  cursor: zoom-in;
}


/* assets-b11: bulletproof asset cards — fixed media height, flex canvas */
.portal-hermes-assets-stage .portal-hermes-stage-head,
.portal-hermes-assets-stage .portal-hermes-running,
.portal-hermes-assets-stage .portal-hermes-error,
.portal-hermes-assets-stage .portal-hermes-asset-toolbar,
.portal-hermes-assets-stage .portal-hermes-stage-actions {
  flex: 0 0 auto;
}

.portal-hermes-assets-stage .portal-hermes-asset-grid {
  flex: 1 1 auto;
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  grid-auto-rows: minmax(248px, auto);
  align-items: stretch;
  align-content: start;
  gap: 14px;
  min-height: 0;
  height: auto;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  contain: none;
  padding-right: 4px;
}

.portal-hermes-assets-stage .portal-hermes-asset-grid > button {
  position: relative;
  display: flex !important;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 8px;
  width: 100%;
  height: 100%;
  min-height: 248px !important;
  max-height: none !important;
  padding: 11px;
  overflow: hidden;
  box-sizing: border-box;
  text-align: left;
}

.portal-hermes-assets-stage .portal-hermes-asset-grid > button .portal-hermes-asset-media {
  flex: 0 0 112px;
  width: 100%;
  height: 112px;
  min-height: 112px;
  max-height: 112px;
  margin: 0;
  border-radius: 10px;
  overflow: hidden;
  background: #111;
  border: 1px dashed color-mix(in oklch, var(--line) 80%, transparent);
  display: grid;
  place-items: center;
}

.portal-hermes-assets-stage .portal-hermes-asset-grid > button .portal-hermes-asset-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  margin: 0;
  aspect-ratio: auto;
  border-radius: 0;
  background: #111;
}

.portal-hermes-assets-stage .portal-hermes-asset-grid > button .portal-hermes-asset-media i,
.portal-hermes-assets-stage .portal-hermes-asset-grid > button .portal-hermes-asset-media svg {
  width: 28px;
  height: 28px;
  color: var(--primary);
}

.portal-hermes-assets-stage .portal-hermes-asset-grid > button > span {
  flex: 0 0 auto;
  width: max-content;
  max-width: calc(100% - 78px);
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--primary);
  font-size: 10px;
  font-weight: 850;
}

.portal-hermes-assets-stage .portal-hermes-asset-grid > button > strong,
.portal-hermes-assets-stage .portal-hermes-asset-grid > button > b {
  flex: 0 0 auto;
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  font-weight: 750;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.portal-hermes-assets-stage .portal-hermes-asset-grid > button > b {
  font-size: 12px;
  font-weight: 650;
}

.portal-hermes-assets-stage .portal-hermes-asset-grid > button > small {
  flex: 0 0 auto;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  max-height: 2.9em;
  color: var(--ink-soft);
  font-size: 11px;
  line-height: 1.45;
}

.portal-hermes-assets-stage .portal-hermes-asset-status {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
}

/* Kill the old direct-img sizing that fought the media wrapper */
.portal-hermes-assets-stage .portal-hermes-asset-grid > button > img,
.portal-hermes-assets-stage .portal-hermes-asset-grid > button > i {
  display: none !important;
}

/* assets-b15: enter storyboard from asset board */
.portal-hermes-asset-nextbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin-top: 4px;
  padding-top: 4px;
}
.portal-hermes-asset-nextbar small {
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.45;
}

/* assets-b16: storyboard entry from chat when assets approved */
.portal-hermes-storyboard-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 14px;
  margin: 0 0 12px;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--accent, #e11) 35%, transparent);
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent, #e11) 8%, transparent);
}
.portal-hermes-storyboard-banner strong {
  display: block;
  font-size: 14px;
}
.portal-hermes-storyboard-banner small {
  display: block;
  margin-top: 4px;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.45;
}

/* assets-b28: open asset board from chat message / file chips without requiring .md */
.portal-hermes-message-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.portal-hermes-message-actions .portal-action-button {
  min-height: 32px;
  padding: 0 12px;
  font-size: 12px;
}
.portal-hermes-message-file > button.primary,
.portal-hermes-embedded-preview header button.primary {
  border-color: color-mix(in oklch, var(--primary) 55%, var(--line));
  background: color-mix(in oklch, var(--primary) 18%, var(--surface));
  color: var(--ink);
  font-weight: 800;
}
.portal-hermes-message-file > button.primary:hover,
.portal-hermes-embedded-preview header button.primary:hover {
  border-color: color-mix(in oklch, var(--primary) 70%, var(--line));
  background: color-mix(in oklch, var(--primary) 28%, var(--surface));
}


/* assets-b17: storyboard script/range hints */
.portal-hermes-storyboard-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin: 0 0 10px;
}
.portal-hermes-storyboard-meta small {
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.4;
  word-break: break-all;
}

/* assets-b18: episode / shot storyboard board */
.portal-hermes-storyboard-board {
  display: grid;
  grid-template-columns: 148px minmax(0, 1fr);
  gap: 12px;
  min-height: 0;
  flex: 1;
  align-items: stretch;
}
.portal-hermes-episode-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  padding: 10px;
  border: 1px solid color-mix(in srgb, var(--line, #ddd) 90%, transparent);
  border-radius: 14px;
  background: color-mix(in srgb, var(--panel, #fff) 92%, transparent);
}
.portal-hermes-episode-nav > header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.portal-hermes-episode-nav > header small {
  color: var(--ink-soft);
  font-size: 12px;
}
.portal-hermes-episode-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow: auto;
  min-height: 0;
}
.portal-hermes-episode-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.portal-hermes-episode-item .num {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  font-weight: 700;
  background: color-mix(in srgb, var(--accent, #e11) 12%, transparent);
  color: var(--accent, #e11);
}
.portal-hermes-episode-item .meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.portal-hermes-episode-item .meta strong {
  font-size: 13px;
  line-height: 1.2;
}
.portal-hermes-episode-item .meta small {
  color: var(--ink-soft);
  font-size: 11px;
}
.portal-hermes-episode-item.active {
  border-color: color-mix(in srgb, var(--accent, #e11) 45%, transparent);
  background: color-mix(in srgb, var(--accent, #e11) 8%, transparent);
}
.portal-hermes-episode-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  min-height: 0;
}
.portal-hermes-episode-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.portal-hermes-episode-head h3 {
  margin: 0;
  font-size: 16px;
}
.portal-hermes-episode-head span,
.portal-hermes-storyboard-note small {
  color: var(--ink-soft);
  font-size: 12px;
}
.portal-hermes-shot-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: auto;
  min-height: 0;
  padding-right: 2px;
}
.portal-hermes-shot-card {
  border: 1px solid color-mix(in srgb, var(--line, #ddd) 90%, transparent);
  border-radius: 14px;
  padding: 12px 14px;
  background: color-mix(in srgb, var(--panel, #fff) 96%, transparent);
}
.portal-hermes-shot-card > header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.portal-hermes-shot-card > header strong {
  font-size: 15px;
}
.portal-hermes-shot-card > header span {
  color: var(--ink-soft);
  font-size: 12px;
}
.portal-hermes-shot-fields {
  display: grid;
  gap: 6px 12px;
  margin: 0 0 8px;
}
.portal-hermes-shot-fields > div {
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr);
  gap: 8px;
}
.portal-hermes-shot-fields dt {
  margin: 0;
  color: var(--ink-soft);
  font-size: 12px;
}
.portal-hermes-shot-fields dd {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}
.portal-hermes-shot-prompt summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--ink-soft);
  margin-bottom: 6px;
}
.portal-hermes-shot-prompt pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  font-size: 12.5px;
  line-height: 1.5;
  max-height: 220px;
  overflow: auto;
  padding: 8px 10px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--ink, #111) 4%, transparent);
}
@media (max-width: 1100px) {
  .portal-hermes-storyboard-board {
    grid-template-columns: 1fr;
  }
  .portal-hermes-episode-list {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .portal-hermes-episode-item {
    width: auto;
  }
}

/* assets-b19: no Tiger Agent left rail; storyboard 3-column studio */
.portal-hermes-agent-shell {
  grid-template-columns: minmax(0, 1fr) !important;
}
.portal-hermes-agent-sidebar {
  display: none !important;
}
.portal-hermes-chat-toolbar {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 0;
  padding: 8px 12px;
  position: relative;
  z-index: 5;
  background: var(--bg, #fff);
}
.portal-hermes-chat-toolbar .portal-action-button {
  position: relative;
  z-index: 6;
  pointer-events: auto;
}
.portal-hermes-chat-files,
.portal-hermes-chat-form,
.portal-hermes-storyboard-banner {
  flex: 0 0 auto;
}
.portal-hermes-chat-toolbar strong {
  display: block;
  font-size: 15px;
}
.portal-hermes-chat-toolbar small {
  color: var(--ink-soft);
  font-size: 12px;
}
.portal-hermes-chat-toolbar small.ready {
  color: #1a7f37;
}
.portal-hermes-chat-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.portal-hermes-storyboard-studio-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  width: 100%;
}
.portal-hermes-storyboard-studio-wrap > .portal-hermes-stage-head {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  min-height: 36px;
  padding-bottom: 4px;
}
.portal-hermes-storyboard-studio {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  flex: 1;
}
.portal-hermes-storyboard-board {
  display: grid !important;
  grid-template-columns: 220px minmax(0, 1.2fr) minmax(280px, 0.95fr) !important;
  gap: 12px !important;
  min-height: 0;
  flex: 1;
  align-items: stretch;
}
.portal-hermes-studio-left,
.portal-hermes-studio-center,
.portal-hermes-studio-right {
  min-height: 0;
  min-width: 0;
  border: 1px solid color-mix(in srgb, var(--line, #ddd) 90%, transparent);
  border-radius: 14px;
  background: color-mix(in srgb, var(--panel, #fff) 96%, transparent);
  display: flex;
  flex-direction: column;
}
.portal-hermes-studio-left {
  padding: 10px;
  gap: 8px;
}
.portal-hermes-studio-ephead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.portal-hermes-studio-ephead small {
  color: var(--ink-soft);
  font-size: 12px;
}
.portal-hermes-episode-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.portal-hermes-ep-tab {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: color-mix(in srgb, var(--accent, #e11) 10%, transparent);
  color: var(--accent, #e11);
  font-weight: 700;
  cursor: pointer;
}
.portal-hermes-ep-tab.active {
  border-color: color-mix(in srgb, var(--accent, #e11) 50%, transparent);
  background: color-mix(in srgb, var(--accent, #e11) 18%, transparent);
}
.portal-hermes-shot-rail {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow: auto;
  min-height: 0;
  flex: 1;
}
.portal-hermes-shot-item {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 8px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: inherit;
  cursor: pointer;
}
.portal-hermes-shot-item .idx {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent, #e11);
}
.portal-hermes-shot-item .body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.portal-hermes-shot-item .body strong {
  font-size: 12.5px;
  line-height: 1.35;
}
.portal-hermes-shot-item .body small {
  color: var(--ink-soft);
  font-size: 11px;
}
.portal-hermes-shot-item.active {
  border-color: color-mix(in srgb, var(--accent, #e11) 45%, transparent);
  background: color-mix(in srgb, var(--accent, #e11) 8%, transparent);
}
.portal-hermes-studio-center {
  padding: 10px;
  gap: 10px;
}
.portal-hermes-studio-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
}
.portal-hermes-studio-toolbar label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-soft);
}
.portal-hermes-studio-hint {
  color: var(--ink-soft);
  font-size: 12px;
}
.portal-hermes-video-stage {
  flex: 1;
  min-height: 320px;
  border-radius: 12px;
  background: #111;
  color: #eee;
  display: grid;
  place-items: center;
  overflow: hidden;
  padding: 12px;
}
.portal-hermes-video-stage video {
  width: 100%;
  max-height: min(62vh, 560px);
  height: auto;
  object-fit: contain;
  background: #000;
  border-radius: 8px;
}
.portal-hermes-video-player {
  width: 100%;
  max-width: 960px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
}
.portal-hermes-video-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: center;
}
.portal-hermes-video-meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.portal-hermes-video-meta .portal-hermes-video-actions {
  justify-content: flex-start;
}
.portal-hermes-video-url {
  margin: 0;
  word-break: break-all;
  color: var(--ink-soft, #888);
}
.portal-hermes-duration-hint {
  color: var(--accent, #e11);
  font-size: 12px;
}
.portal-hermes-video-empty .portal-hermes-duration-hint {
  margin: 8px 0 0;
}
.portal-hermes-video-empty {
  text-align: center;
  padding: 24px;
  max-width: 360px;
}
.portal-hermes-video-empty strong {
  display: block;
  margin-bottom: 8px;
}
.portal-hermes-video-empty p {
  margin: 0;
  color: #bbb;
  font-size: 13px;
  line-height: 1.5;
}
.portal-hermes-studio-right {
  padding: 12px;
  overflow: auto;
}
.portal-hermes-shot-detail {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.portal-hermes-shot-title {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-soft);
}
.portal-hermes-shot-title input {
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--line, #ddd) 90%, transparent);
  background: transparent;
  color: inherit;
  font-size: 13px;
}
.portal-hermes-bound-block header,
.portal-hermes-prompt-block header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.portal-hermes-bound-block header small {
  color: var(--ink-soft);
  font-size: 12px;
}
.portal-hermes-bound-assets {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
}
.portal-hermes-bound-asset {
  margin: 0;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--line, #ddd) 90%, transparent);
  background: color-mix(in srgb, var(--ink, #111) 3%, transparent);
}
.portal-hermes-bound-asset img,
.portal-hermes-bound-asset .ph {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #222;
  color: #aaa;
  font-size: 12px;
  place-items: center;
}
.portal-hermes-bound-asset .ph {
  display: grid;
}
.portal-hermes-bound-asset figcaption {
  padding: 6px 8px;
}
.portal-hermes-bound-asset figcaption strong {
  display: block;
  font-size: 11px;
}
.portal-hermes-bound-asset figcaption small {
  color: var(--ink-soft);
  font-size: 10px;
}
.portal-hermes-bound-empty {
  margin: 0;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.45;
}
.portal-hermes-prompt-block pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  font-size: 12.5px;
  line-height: 1.5;
  max-height: 360px;
  overflow: auto;
  padding: 10px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--ink, #111) 4%, transparent);
}
@media (max-width: 1200px) {
  .portal-hermes-storyboard-board {
    grid-template-columns: 1fr !important;
  }
  .portal-hermes-video-stage {
    min-height: 240px;
  }
}

/* assets-b20: history moves to top button popover */
.portal-page.portal-hermes-active > .portal-hermes-agent-shell {
  grid-template-columns: minmax(0, 1fr) !important;
}
.portal-page.portal-hermes-active > .portal-hermes-agent-shell.preview-open {
  grid-template-columns: minmax(0, 1fr) minmax(420px, 0.9fr) !important;
}
.portal-hermes-agent-history {
  display: none !important;
}
.portal-hermes-history-wrap {
  position: relative;
  display: inline-flex;
}
.portal-hermes-history-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
  align-items: stretch;
}
.portal-hermes-history-item > [data-hermes-history-open] {
  text-align: left;
  width: 100%;
}
.portal-hermes-history-delete {
  flex: 0 0 auto;
  width: 32px;
  min-width: 32px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-soft, #888);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.portal-hermes-history-delete:hover {
  background: color-mix(in srgb, #c62828 12%, transparent);
  color: #c62828;
}
.portal-hermes-history-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 40;
  width: min(360px, 78vw);
  max-height: min(480px, 70vh);
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--line, #ddd);
  border-radius: 14px;
  background: var(--surface, var(--panel, #fff));
  box-shadow: 0 12px 40px rgba(0,0,0,.14);
}
.portal-hermes-history-popover > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.portal-hermes-history-popover > header button {
  border: 0;
  background: transparent;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  color: var(--ink-soft);
}
.portal-hermes-history-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.portal-hermes-history-list [data-hermes-history-open] {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: color-mix(in srgb, var(--ink, #111) 3%, transparent);
  color: inherit;
  cursor: pointer;
}
.portal-hermes-history-list [data-hermes-history-open]:hover,
.portal-hermes-history-list [data-hermes-history-open]:focus-visible {
  border-color: color-mix(in srgb, var(--accent, #e11) 40%, transparent);
  background: color-mix(in srgb, var(--accent, #e11) 8%, transparent);
}
.portal-hermes-history-list [data-hermes-history-open] strong {
  font-size: 13px;
}
.portal-hermes-history-list [data-hermes-history-open] small {
  color: var(--ink-soft);
  font-size: 11px;
}
.portal-hermes-asset-board-bar {
  display: flex;
  align-items: center;
  gap: 12px;
}
.portal-hermes-asset-board-bar > div:nth-child(2) {
  flex: 1;
  min-width: 0;
}
.portal-hermes-stage-head-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px 14px;
}


/* assets-b21: storyboard blueprint + shot video gen */
.portal-hermes-blueprint-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 14px;
  margin: 0 0 10px;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--accent, #e11) 28%, var(--line, #ddd));
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent, #e11) 7%, var(--panel, #fff));
}
.portal-hermes-blueprint-bar strong {
  font-size: 13px;
}
.portal-hermes-blueprint-bar small,
.portal-hermes-blueprint-gap {
  color: var(--ink-soft, #666);
  font-size: 12px;
}
.portal-hermes-blueprint-gap {
  color: #b45309;
  font-weight: 600;
}
.portal-hermes-studio-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.portal-hermes-studio-toolbar-actions {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
}
.portal-hermes-video-empty-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.portal-hermes-video-stage.is-running {
  outline: 2px solid color-mix(in srgb, var(--accent, #e11) 45%, transparent);
}
.portal-hermes-video-stage.is-error {
  outline: 2px solid color-mix(in srgb, #dc2626 55%, transparent);
}
.portal-hermes-shot-item.video-running .body small {
  color: var(--accent, #e11);
}
.portal-hermes-shot-item.video-error .body small {
  color: #dc2626;
}
.portal-hermes-shot-item.video-done .body small {
  color: #059669;
}
.portal-hermes-shot-warn {
  margin: 0 0 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, #b45309 40%, transparent);
  background: color-mix(in srgb, #f59e0b 12%, transparent);
}
.portal-hermes-shot-warn p {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--ink-soft, #666);
}
.portal-hermes-video-meta.running small { color: var(--accent, #e11); }
.portal-hermes-video-meta.error small { color: #dc2626; }
.portal-hermes-prompt-block header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

/* b22: storyboard can scroll with wheel; columns scroll too */
.portal-hermes-asset-board .portal-hermes-storyboard-studio-wrap,
.portal-hermes-asset-board .portal-hermes-storyboard-stage {
  overflow-y: auto !important;
  overflow-x: hidden !important;
  overscroll-behavior: contain;
  height: 100%;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}
.portal-hermes-storyboard-studio {
  flex: 1 1 auto;
  min-height: 0;
}
.portal-hermes-storyboard-board {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
  max-height: none;
}
.portal-hermes-storyboard-board > .portal-hermes-studio-left,
.portal-hermes-storyboard-board > .portal-hermes-studio-center,
.portal-hermes-storyboard-board > .portal-hermes-studio-right {
  max-height: none;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.portal-hermes-storyboard-board > .portal-hermes-studio-left {
  overflow: hidden;
}
.portal-hermes-storyboard-board > .portal-hermes-studio-center,
.portal-hermes-storyboard-board > .portal-hermes-studio-right {
  overflow: auto;
}
.portal-hermes-studio-ephead-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin-top: 6px;
}
.portal-hermes-studio-ephead-actions .portal-action-button {
  font-size: 12px;
  padding: 6px 10px;
}

/* b23: episode accordion expand/collapse */
.portal-hermes-episode-accordion {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding-right: 2px;
}
.portal-hermes-ep-block {
  border: 1px solid color-mix(in srgb, var(--line, #ddd) 90%, transparent);
  border-radius: 12px;
  background: color-mix(in srgb, var(--panel, #fff) 98%, transparent);
  overflow: hidden;
  flex: 0 0 auto;
}
.portal-hermes-ep-block.active {
  border-color: color-mix(in srgb, var(--accent, #e11) 45%, transparent);
}
.portal-hermes-ep-block-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px;
  align-items: center;
  padding: 4px;
}
.portal-hermes-ep-toggle {
  display: grid;
  grid-template-columns: 14px 22px minmax(0, 1fr);
  grid-template-rows: auto auto;
  column-gap: 6px;
  row-gap: 2px;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 10px;
}
.portal-hermes-ep-toggle .chev {
  grid-row: 1 / span 2;
  align-self: center;
  font-size: 10px;
  color: var(--ink-soft);
}
.portal-hermes-ep-toggle .num {
  grid-row: 1 / span 2;
  align-self: center;
  width: 22px;
  height: 22px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent, #e11);
  background: color-mix(in srgb, var(--accent, #e11) 12%, transparent);
}
.portal-hermes-ep-toggle strong {
  grid-column: 3;
  font-size: 13px;
  line-height: 1.3;
}
.portal-hermes-ep-toggle small {
  grid-column: 3;
  color: var(--ink-soft);
  font-size: 11px;
}
.portal-hermes-ep-select {
  border: 1px solid transparent;
  background: color-mix(in srgb, var(--accent, #e11) 8%, transparent);
  color: var(--accent, #e11);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 11px;
  cursor: pointer;
}
.portal-hermes-ep-select.active {
  border-color: color-mix(in srgb, var(--accent, #e11) 40%, transparent);
  background: color-mix(in srgb, var(--accent, #e11) 16%, transparent);
  font-weight: 700;
}
.portal-hermes-ep-block .portal-hermes-shot-rail {
  max-height: min(42vh, 420px);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 0 6px 8px;
  border-top: 1px solid color-mix(in srgb, var(--line, #ddd) 80%, transparent);
}
.portal-hermes-ep-block.collapsed .portal-hermes-shot-rail {
  display: none;
}
.portal-hermes-studio-left {
  overflow: hidden;
}

/* b32: storyboard video clickable + progress poster + scroll isolation */
.portal-hermes-video-stage video,
.portal-hermes-video-player,
.portal-hermes-video-player video {
  pointer-events: auto;
  position: relative;
  z-index: 2;
}
.portal-hermes-video-stage.is-ready {
  cursor: default;
}
.portal-hermes-video-progress {
  position: relative;
  width: min(100%, 720px);
  display: grid;
  place-items: center;
  gap: 12px;
  text-align: center;
  padding: 16px;
}
.portal-hermes-video-poster {
  width: min(100%, 420px);
  max-height: min(48vh, 360px);
  object-fit: contain;
  border-radius: 10px;
  opacity: 0.45;
  pointer-events: none;
  user-select: none;
  filter: grayscale(0.15);
}
.portal-hermes-video-progress-copy {
  position: relative;
  z-index: 1;
  max-width: 360px;
}
.portal-hermes-video-progress-copy strong {
  display: block;
  margin-bottom: 6px;
  color: #fff;
}
.portal-hermes-video-progress-copy p {
  margin: 0;
  color: #bbb;
  font-size: 13px;
  line-height: 1.5;
}

.portal-hermes-video-progress-actions {
  margin-top: 12px;
  display: flex;
  justify-content: center;
  gap: 8px;
}
.portal-hermes-video-meta .portal-hermes-video-actions {
  margin-top: 8px;
}

.portal-hermes-shot-item.video-queued .body small {
  color: #d97706;
}
.portal-hermes-video-meta.queued small { color: #d97706; }
.portal-hermes-lightbox.portal-hermes-video-lightbox video {
  max-width: min(1200px, 96vw);
  max-height: 90vh;
  border-radius: 12px;
  background: #000;
  box-shadow: 0 18px 60px color-mix(in oklch, black 45%, transparent);
  pointer-events: auto;
}

/* b36: compact storyboard header + fill video stage */
.portal-hermes-main.portal-hermes-storyboard-stage.portal-hermes-storyboard-studio-wrap,
.portal-hermes-asset-board .portal-hermes-main.portal-hermes-storyboard-stage {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}
.portal-hermes-asset-board:has(.portal-hermes-storyboard-studio-wrap) {
  gap: 8px;
  padding: 8px 12px 10px;
}
.portal-hermes-asset-board:has(.portal-hermes-storyboard-studio-wrap) .portal-hermes-asset-board-bar {
  min-height: 0;
  gap: 8px;
}
.portal-hermes-asset-board:has(.portal-hermes-storyboard-studio-wrap) .portal-hermes-asset-board-bar strong {
  font-size: 13px;
  line-height: 1.2;
}
.portal-hermes-asset-board:has(.portal-hermes-storyboard-studio-wrap) .portal-hermes-asset-board-bar small {
  font-size: 10px;
  line-height: 1.3;
}
.portal-hermes-asset-board:has(.portal-hermes-storyboard-studio-wrap) .portal-hermes-workflow {
  gap: 6px;
  margin-bottom: 0;
}
.portal-hermes-asset-board:has(.portal-hermes-storyboard-studio-wrap) .portal-hermes-workflow button {
  min-height: 40px;
  padding: 6px 8px;
  gap: 2px 7px;
}
.portal-hermes-asset-board:has(.portal-hermes-storyboard-studio-wrap) .portal-hermes-workflow button > span {
  width: 20px;
  height: 20px;
}
.portal-hermes-asset-board:has(.portal-hermes-storyboard-studio-wrap) .portal-hermes-workflow strong {
  font-size: 12px;
  line-height: 1.2;
}
.portal-hermes-asset-board:has(.portal-hermes-storyboard-studio-wrap) .portal-hermes-workflow small {
  display: none;
}

.portal-hermes-storyboard-studio-wrap {
  gap: 6px !important;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.portal-hermes-storyboard-studio-wrap > .portal-hermes-stage-head,
.portal-hermes-storyboard-studio-wrap > .portal-hermes-storyboard-head {
  flex: 0 0 auto;
  display: flex !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  justify-content: space-between;
  gap: 10px;
  min-height: 36px;
  max-height: 44px;
  padding: 0 0 4px !important;
  margin: 0 !important;
  border-bottom: 1px solid color-mix(in srgb, var(--line, #ddd) 80%, transparent);
}
.portal-hermes-storyboard-head-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
}
.portal-hermes-storyboard-head-title h2,
.portal-hermes-storyboard-studio-wrap .portal-hermes-storyboard-head h2,
.portal-hermes-storyboard-studio-wrap .portal-hermes-stage-head h2 {
  margin: 0 !important;
  font-size: 15px !important;
  font-weight: 700 !important;
  line-height: 1.2 !important;
  white-space: nowrap;
  color: var(--ink);
}
.portal-hermes-storyboard-head-title span,
.portal-hermes-storyboard-studio-wrap .portal-hermes-storyboard-head span,
.portal-hermes-storyboard-studio-wrap .portal-hermes-stage-head span {
  margin: 0 !important;
  color: var(--ink-soft, var(--faint, #888)) !important;
  font-size: 11px !important;
  font-weight: 500 !important;
  line-height: 1.2 !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.portal-hermes-storyboard-studio-wrap > .portal-hermes-stage-head-actions,
.portal-hermes-storyboard-studio-wrap .portal-hermes-stage-head-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 0;
}
.portal-hermes-storyboard-studio-wrap .portal-hermes-history-wrap > .portal-action-button,
.portal-hermes-storyboard-studio-wrap .portal-hermes-stage-head-actions .portal-action-button {
  min-height: 28px;
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
  border-radius: 8px;
}

.portal-hermes-storyboard-studio-wrap > .portal-hermes-storyboard-studio,
.portal-hermes-storyboard-studio-wrap .portal-hermes-storyboard-studio {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  height: auto !important;
  gap: 6px !important;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.portal-hermes-storyboard-studio-wrap .portal-hermes-storyboard-note {
  flex: 0 0 auto;
  margin: 0;
  padding: 0;
  font-size: 11px;
}
.portal-hermes-storyboard-studio-wrap .portal-hermes-storyboard-board {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  height: auto !important;
  max-height: none !important;
  gap: 10px !important;
  align-items: stretch !important;
}
.portal-hermes-storyboard-studio-wrap .portal-hermes-storyboard-board > .portal-hermes-studio-left,
.portal-hermes-storyboard-studio-wrap .portal-hermes-storyboard-board > .portal-hermes-studio-center,
.portal-hermes-storyboard-studio-wrap .portal-hermes-storyboard-board > .portal-hermes-studio-right {
  max-height: none !important;
  min-height: 0 !important;
  height: 100%;
}
.portal-hermes-storyboard-studio-wrap .portal-hermes-studio-left {
  overflow: hidden;
  padding: 8px;
  gap: 6px;
}
.portal-hermes-storyboard-studio-wrap .portal-hermes-studio-center {
  overflow: hidden;
  padding: 8px;
  gap: 8px;
}
.portal-hermes-storyboard-studio-wrap .portal-hermes-studio-right {
  overflow: auto;
  padding: 8px;
  overscroll-behavior: contain;
}
.portal-hermes-storyboard-studio-wrap .portal-hermes-studio-toolbar {
  flex: 0 0 auto;
  gap: 8px 10px;
  min-height: 0;
}
.portal-hermes-storyboard-studio-wrap .portal-hermes-studio-toolbar .portal-action-button {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}
.portal-hermes-storyboard-studio-wrap .portal-hermes-video-stage {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  height: auto !important;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.portal-hermes-storyboard-studio-wrap .portal-hermes-video-player {
  width: 100%;
  height: 100%;
  max-width: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 0;
}
.portal-hermes-storyboard-studio-wrap .portal-hermes-video-stage video,
.portal-hermes-storyboard-studio-wrap .portal-hermes-video-player video {
  width: 100%;
  height: 100%;
  max-height: none !important;
  object-fit: contain;
  background: #000;
  border-radius: 8px;
  flex: 1 1 auto;
  min-height: 0;
}
.portal-hermes-storyboard-studio-wrap .portal-hermes-video-actions {
  flex: 0 0 auto;
  gap: 6px;
}
.portal-hermes-storyboard-studio-wrap .portal-hermes-video-actions .portal-action-button {
  min-height: 28px;
  padding: 0 10px;
  font-size: 12px;
}
.portal-hermes-storyboard-studio-wrap .portal-hermes-video-progress,
.portal-hermes-storyboard-studio-wrap .portal-hermes-video-empty {
  max-height: 100%;
}
.portal-hermes-storyboard-studio-wrap > .portal-hermes-stage-actions {
  flex: 0 0 auto;
  margin-top: 0 !important;
  padding-top: 6px !important;
  gap: 6px;
  border-top: 1px solid color-mix(in srgb, var(--line, #ddd) 80%, transparent);
}
.portal-hermes-storyboard-studio-wrap > .portal-hermes-stage-actions .portal-action-button {
  min-height: 32px;
  padding: 0 12px;
  font-size: 12px;
}

@media (max-width: 1100px) {
  .portal-hermes-storyboard-head-title span {
    display: none;
  }
}


/* Toolbox home · card grid (b44) */
.portal-toolbox-shell {
  width: min(1680px, 100%);
  max-width: none;
  padding-bottom: 36px;
}
.portal-toolbox-toolbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 4px 0 14px;
  color: var(--text-muted, var(--muted, #6b7280));
  font-size: 13px;
}
.portal-toolbox-scope {
  font-weight: 600;
  color: var(--text, var(--ink, #111827));
  letter-spacing: 0.02em;
}
.portal-toolbox-toolbar span strong {
  color: var(--primary, #c8102e);
  font-weight: 700;
}
.portal-toolbox-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  align-items: stretch;
}
.portal-toolbox-group-label {
  display: none;
}
.portal-toolbox-item {
  appearance: none;
  -webkit-appearance: none;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 14px;
  width: 100%;
  min-height: 148px;
  margin: 0;
  padding: 18px 18px 16px;
  text-align: left;
  cursor: pointer;
  border-radius: 18px;
  border: 1px solid color-mix(in oklch, var(--line, #e5e7eb) 88%, var(--primary, #c8102e) 12%);
  background: var(--surface, var(--panel, #fff));
  color: inherit;
  box-shadow: 0 1px 0 color-mix(in oklch, #000 4%, transparent);
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.portal-toolbox-item:hover {
  transform: translateY(-3px);
  border-color: color-mix(in oklch, var(--primary, #c8102e) 55%, var(--line, #e5e7eb));
  box-shadow:
    0 10px 24px color-mix(in oklch, var(--primary, #c8102e) 12%, transparent),
    0 2px 0 color-mix(in oklch, var(--primary, #c8102e) 8%, transparent);
}
.portal-toolbox-item:focus-visible {
  outline: 2px solid color-mix(in oklch, var(--primary, #c8102e) 55%, transparent);
  outline-offset: 2px;
}
.portal-toolbox-item.unavailable {
  opacity: 0.62;
  cursor: not-allowed;
}
.portal-toolbox-item.unavailable:hover {
  transform: none;
  box-shadow: 0 1px 0 color-mix(in oklch, #000 4%, transparent);
  border-color: color-mix(in oklch, var(--line, #e5e7eb) 88%, var(--primary, #c8102e) 12%);
}
.portal-toolbox-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: color-mix(in oklch, var(--primary, #c8102e) 14%, var(--surface, #fff));
  color: var(--primary, #c8102e);
  border: 1px solid color-mix(in oklch, var(--primary, #c8102e) 28%, var(--line, #e5e7eb));
}
.portal-toolbox-icon svg {
  width: 22px;
  height: 22px;
}
.portal-toolbox-copy {
  display: grid;
  gap: 6px;
  min-width: 0;
  width: 100%;
}
.portal-toolbox-copy strong {
  display: block;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text, var(--ink, #111827));
}
.portal-toolbox-copy small {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text-muted, var(--muted, #6b7280));
}
html[data-theme="dark"] .portal-toolbox-item {
  background: var(--surface, var(--panel, #15181e));
  box-shadow: none;
}
html[data-theme="dark"] .portal-toolbox-copy strong {
  color: var(--text, #f3f4f6);
}

/* RunningHub toolbox · motion transfer (b42 UI) */
.portal-toolbox-motion-shell {
  width: min(1680px, 100%);
  max-width: none;
  padding-bottom: 40px;
}

.portal-mt-hero {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
}
.portal-mt-back {
  justify-self: start;
  border: 0;
  background: transparent;
  color: var(--text-muted, var(--muted, #6b7280));
  font-size: 14px;
  cursor: pointer;
  padding: 4px 0;
}
.portal-mt-back:hover { color: var(--primary, #c8102e); }
.portal-mt-hero-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.portal-mt-title-row {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  min-width: 240px;
}
.portal-mt-badge {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: color-mix(in oklch, var(--primary, #c8102e) 14%, var(--surface, #fff));
  color: var(--primary, #c8102e);
  border: 1px solid color-mix(in oklch, var(--primary, #c8102e) 28%, var(--line, #e5e7eb));
  flex: 0 0 auto;
}
.portal-mt-badge svg { width: 22px; height: 22px; }
.portal-mt-title-row h1 {
  margin: 0 0 4px;
  font-size: 24px;
  letter-spacing: -0.02em;
}
.portal-mt-title-row p {
  margin: 0;
  color: var(--text-muted, var(--muted, #6b7280));
  font-size: 13px;
  line-height: 1.5;
  max-width: 520px;
}
.portal-mt-hero-aside {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}
.portal-mt-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--line, #e5e7eb);
  background: var(--surface-soft, var(--panel-raised, #f8fafc));
  color: var(--text, var(--ink, #111827));
}
.portal-mt-pill.ok {
  background: color-mix(in oklch, #10b981 12%, var(--surface, #fff));
  border-color: color-mix(in oklch, #10b981 35%, var(--line, #e5e7eb));
  color: #047857;
}
.portal-mt-pill.warn {
  background: color-mix(in oklch, #f59e0b 14%, var(--surface, #fff));
  border-color: color-mix(in oklch, #f59e0b 35%, var(--line, #e5e7eb));
  color: #b45309;
}
.portal-mt-pill.bad {
  background: color-mix(in oklch, var(--primary, #c8102e) 12%, var(--surface, #fff));
  border-color: color-mix(in oklch, var(--primary, #c8102e) 35%, var(--line, #e5e7eb));
  color: var(--primary, #c8102e);
}
.portal-mt-pill.tiny { padding: 3px 8px; font-size: 11px; }

.portal-mt-settings-drawer {
  border: 1px solid var(--line, #e5e7eb);
  border-radius: 18px;
  padding: 16px 18px;
  margin-bottom: 18px;
  background: var(--surface, var(--panel, #fff));
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
}
.portal-mt-settings-drawer > header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.portal-mt-settings-drawer > header strong { display: block; font-size: 15px; }
.portal-mt-settings-drawer > header small { color: var(--text-muted, var(--muted, #6b7280)); }
.portal-toolbox-settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.portal-toolbox-settings-grid label,
.portal-mt-settings-drawer label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
}
.portal-toolbox-settings-grid input,
.portal-toolbox-settings-grid select,
.portal-mt-settings-drawer input,
.portal-mt-settings-drawer select {
  border: 1px solid var(--line, #d1d5db);
  border-radius: 10px;
  padding: 9px 11px;
  background: var(--surface, var(--panel, #fff));
  color: inherit;
}
.portal-mt-settings-drawer footer {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.portal-mt-settings-drawer footer small { color: var(--text-muted, var(--muted, #6b7280)); }

.portal-mt-flow {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr;
  gap: 12px;
  align-items: stretch;
  margin-bottom: 18px;
}
.portal-mt-connector {
  display: grid;
  place-items: center;
  align-self: center;
}
.portal-mt-connector span {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: color-mix(in oklch, var(--primary, #c8102e) 10%, var(--surface, #fff));
  border: 1px solid color-mix(in oklch, var(--primary, #c8102e) 25%, var(--line, #e5e7eb));
  color: var(--primary, #c8102e);
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(200, 16, 46, 0.08);
}

.portal-mt-card {
  border: 1px solid var(--line, #e5e7eb);
  border-radius: 16px;
  background: var(--surface, var(--panel, #fff));
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
  display: flex;
  flex-direction: column;
  min-height: 360px;
  overflow: hidden;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.portal-mt-card.dragging {
  border-color: var(--primary, #c8102e);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--primary, #c8102e) 18%, transparent);
}
.portal-mt-card-top {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 14px 14px 0;
}
.portal-mt-step {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  background: color-mix(in oklch, var(--primary, #c8102e) 12%, var(--surface-soft, #f8fafc));
  color: var(--primary, #c8102e);
  flex: 0 0 auto;
}
.portal-mt-step.done { background: #ecfdf5; color: #047857; }
.portal-mt-step.fail { background: #fef2f2; color: #b91c1c; }
.portal-mt-step.pulse { animation: portal-mt-pulse 1.2s ease-in-out infinite; }
.portal-mt-card-top strong { display: block; font-size: 14px; }
.portal-mt-card-top small { color: var(--text-muted, var(--muted, #6b7280)); font-size: 12px; }
.portal-mt-card-body {
  flex: 1;
  margin: 12px 14px;
  border-radius: 12px;
  border: 1px dashed color-mix(in oklch, var(--line, #d1d5db) 80%, var(--primary, #c8102e) 20%);
  background: var(--surface-soft, var(--panel-raised, #fafafa));
  min-height: 220px;
  cursor: pointer;
  overflow: hidden;
}
.portal-mt-card.has-file .portal-mt-card-body {
  border-style: solid;
  border-color: var(--line, #e5e7eb);
  background: #0b0b0c;
  cursor: default;
}
.portal-mt-result .portal-mt-card-body { cursor: default; }
.portal-mt-empty {
  height: 100%;
  min-height: 220px;
  display: grid;
  place-content: center;
  gap: 8px;
  text-align: center;
  padding: 20px;
  color: var(--text-muted, var(--muted, #6b7280));
}
.portal-mt-empty strong { color: var(--text, var(--ink, #111827)); font-size: 14px; }
.portal-mt-empty-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 4px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: color-mix(in oklch, var(--primary, #c8102e) 10%, var(--surface, #fff));
  color: var(--primary, #c8102e);
}
.portal-mt-empty-icon svg { width: 24px; height: 24px; }
.portal-mt-preview {
  height: 100%;
  min-height: 220px;
  display: grid;
  place-items: center;
  background: #0b0b0c;
}
.portal-mt-preview img,
.portal-mt-preview video {
  width: 100%;
  height: 240px;
  object-fit: contain;
  background: #0b0b0c;
}
.portal-mt-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 14px 14px;
}
.portal-mt-card-meta strong {
  display: block;
  font-size: 13px;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.portal-mt-card-meta small { color: var(--text-muted, var(--muted, #6b7280)); }
.portal-mt-card-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.portal-mt-spinner {
  width: 36px;
  height: 36px;
  margin: 0 auto;
  border-radius: 999px;
  border: 3px solid color-mix(in oklch, var(--primary, #c8102e) 20%, transparent);
  border-top-color: var(--primary, #c8102e);
  animation: portal-mt-spin .8s linear infinite;
}
@keyframes portal-mt-spin { to { transform: rotate(360deg); } }
@keyframes portal-mt-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.06); opacity: .75; }
}

.portal-mt-actionbar {
  border: 1px solid var(--line, #e5e7eb);
  border-radius: 16px;
  padding: 14px 16px;
  background: var(--surface, var(--panel, #fff));
  margin-bottom: 18px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.04);
}
.portal-mt-action-main {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.portal-mt-start {
  min-width: 148px;
  min-height: 44px;
  font-size: 15px;
  border-radius: 12px;
}
.portal-mt-start:disabled {
  opacity: .55;
  cursor: not-allowed;
}
.portal-mt-action-status {
  flex: 1;
  min-width: 200px;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--surface-soft, var(--panel-raised, #f3f4f6));
}
.portal-mt-action-status[data-status="done"] { background: #ecfdf5; }
.portal-mt-action-status[data-status="failed"] { background: #fef2f2; }
.portal-mt-action-status[data-status="running"],
.portal-mt-action-status[data-status="queued"],
.portal-mt-action-status[data-status="uploading"] { background: #eff6ff; }
.portal-mt-action-status strong { display: block; font-size: 13px; }
.portal-mt-action-status small { color: var(--text-muted, var(--muted, #6b7280)); }
.portal-mt-action-status .error { color: #b91c1c; margin: 6px 0 0; }
.portal-mt-action-status .warn { color: #b45309; margin: 6px 0 0; }
.portal-mt-action-hint {
  display: block;
  margin-top: 10px;
  color: var(--text-muted, var(--muted, #6b7280));
}

.portal-mt-history > header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 12px;
  flex-wrap: wrap;
}
.portal-mt-history-tools {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.portal-mt-history-actions .portal-action-button.danger,
.portal-mt-history-tools .portal-action-button.danger {
  color: var(--danger, #b91c1c);
  border-color: color-mix(in oklch, var(--danger, #b91c1c) 35%, var(--line, #e5e7eb));
}
.portal-mt-history-actions .portal-action-button.danger:hover,
.portal-mt-history-tools .portal-action-button.danger:hover {
  background: color-mix(in oklch, var(--danger, #b91c1c) 10%, var(--surface, #fff));
}
.portal-mt-history > header strong { font-size: 16px; }
.portal-mt-history > header small { margin-left: 8px; color: var(--text-muted, var(--muted, #6b7280)); }
.portal-mt-history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.portal-mt-history-card {
  border: 1px solid var(--line, #e5e7eb);
  border-radius: 14px;
  background: var(--surface, var(--panel, #fff));
  padding: 10px;
  display: grid;
  grid-template-columns: 72px 1fr;
  grid-template-rows: auto auto;
  gap: 8px 10px;
}
.portal-mt-history-card.active {
  border-color: color-mix(in oklch, var(--primary, #c8102e) 55%, var(--line, #e5e7eb));
  box-shadow: 0 0 0 1px color-mix(in oklch, var(--primary, #c8102e) 35%, transparent);
}
.portal-mt-history-thumb {
  grid-row: 1 / span 2;
  width: 72px;
  height: 72px;
  border: 0;
  border-radius: 12px;
  overflow: hidden;
  background: #111;
  color: #fff;
  cursor: pointer;
  padding: 0;
  display: grid;
  place-items: center;
}
.portal-mt-history-thumb img,
.portal-mt-history-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.portal-mt-history-copy {
  display: grid;
  gap: 2px;
  align-content: start;
}
.portal-mt-history-copy strong { font-size: 13px; }
.portal-mt-history-copy small { color: var(--text-muted, var(--muted, #6b7280)); }
.portal-mt-history-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.portal-mt-history-empty {
  border: 1px dashed var(--line, #d1d5db);
  border-radius: 16px;
  padding: 28px 16px;
  text-align: center;
  color: var(--text-muted, var(--muted, #6b7280));
  display: grid;
  gap: 6px;
  place-items: center;
}
.portal-mt-history-empty svg { width: 28px; height: 28px; color: var(--primary, #c8102e); }
.portal-mt-history-empty strong { color: var(--text, var(--ink, #111827)); }

html[data-theme="dark"] .portal-mt-card,
html[data-theme="dark"] .portal-mt-actionbar,
html[data-theme="dark"] .portal-mt-settings-drawer,
html[data-theme="dark"] .portal-mt-history-card {
  background: var(--surface, var(--panel, #15181e));
  box-shadow: none;
}
html[data-theme="dark"] .portal-mt-card-body,
html[data-theme="dark"] .portal-mt-empty {
  background: color-mix(in oklch, var(--surface, #15181e) 86%, #000 14%);
}
html[data-theme="dark"] .portal-mt-preview,
html[data-theme="dark"] .portal-mt-card.has-file .portal-mt-card-body {
  background: #050505;
}

@media (max-width: 1000px) {
  .portal-mt-flow {
    grid-template-columns: 1fr;
  }
  .portal-mt-connector {
    transform: rotate(90deg);
    padding: 2px 0;
  }
  .portal-mt-card { min-height: 0; }
}

/* ===================== b55: script-analysis P0 ===================== */
/* Markdown inside chat bubbles / stage output */
.portal-hermes-md { min-width: 0; overflow-wrap: anywhere; color: var(--ink); font-size: 13px; line-height: 1.7; }
.portal-hermes-md > :first-child { margin-top: 0 !important; }
.portal-hermes-md > :last-child { margin-bottom: 0 !important; }
.portal-hermes-chat-thread article .portal-hermes-md p,
.portal-hermes-md p { margin: 0 0 8px; }
.portal-hermes-md h2, .portal-hermes-md h3, .portal-hermes-md h4 { margin: 14px 0 6px; line-height: 1.4; color: var(--ink); }
.portal-hermes-md h2 { font-size: 16px; }
.portal-hermes-md h3 { font-size: 14.5px; }
.portal-hermes-md h4 { font-size: 13.5px; }
.portal-hermes-md ul, .portal-hermes-md ol { margin: 0 0 8px; padding-left: 20px; }
.portal-hermes-md li { margin: 2px 0; }
.portal-hermes-md blockquote { margin: 0 0 8px; padding: 6px 10px; border-left: 3px solid var(--line); color: var(--ink-soft); }
.portal-hermes-md code { padding: 1px 4px; border-radius: 4px; background: color-mix(in srgb, var(--ink) 8%, transparent); font-size: 12px; }
.portal-hermes-md hr { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }
.portal-hermes-md-table { max-width: 100%; overflow-x: auto; margin: 0 0 10px; }
.portal-hermes-md-table table { border-collapse: collapse; min-width: 100%; font-size: 12px; }
.portal-hermes-md-table th, .portal-hermes-md-table td { border: 1px solid var(--line); padding: 5px 8px; text-align: left; vertical-align: top; }
.portal-hermes-md-table th { background: var(--surface-soft); font-weight: 600; white-space: nowrap; }
.portal-hermes-md-code { margin: 0 0 10px; padding: 10px 12px; max-width: 100%; overflow-x: auto; border-radius: 8px; background: color-mix(in srgb, var(--ink) 6%, transparent); white-space: pre-wrap; font-size: 12px; line-height: 1.6; }
.portal-hermes-md-code code { padding: 0; background: none; }
.portal-hermes-stage-md { padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-soft); max-height: min(62vh, 720px); overflow: auto; overscroll-behavior: contain; }
.portal-hermes-embedded-raw { margin-top: 6px; }
.portal-hermes-embedded-raw > summary { cursor: pointer; color: var(--ink-soft); font-size: 12px; }
.portal-hermes-embedded-raw pre { max-height: 320px; overflow: auto; white-space: pre-wrap; }

/* Explicit stage confirm bar under the chat thread */
.portal-hermes-stage-confirm-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 8px 0; padding: 10px 12px; border: 1px solid color-mix(in srgb, var(--accent, #e11) 35%, var(--line)); border-radius: var(--radius-sm); background: color-mix(in srgb, var(--accent, #e11) 6%, var(--surface-soft)); }
.portal-hermes-stage-confirm-bar > div:first-child { flex: 1 1 220px; min-width: 0; display: grid; gap: 2px; }
.portal-hermes-stage-confirm-bar strong { font-size: 13px; color: var(--ink); }
.portal-hermes-stage-confirm-bar small { font-size: 12px; color: var(--ink-soft); line-height: 1.5; }
.portal-hermes-stage-confirm-actions { display: inline-flex; gap: 8px; flex-wrap: wrap; }
.portal-hermes-stage-confirmed-badge { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px; font-size: 12px; color: #1a7f37; background: color-mix(in srgb, #1a7f37 12%, transparent); }

/* Editable prompt editor (asset + shot) */
.portal-hermes-prompt-editor { display: grid; gap: 6px; min-width: 0; }
.portal-hermes-prompt-editor textarea { width: 100%; min-height: 120px; box-sizing: border-box; resize: vertical; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface, var(--panel, #fff)); color: var(--ink); font: inherit; font-size: 12.5px; line-height: 1.65; }
.portal-hermes-prompt-editor textarea:focus { outline: none; border-color: var(--accent, #e11); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent, #e11) 15%, transparent); }
.portal-hermes-prompt-editor.is-edited textarea { border-color: color-mix(in srgb, #d97706 60%, var(--line)); }
.portal-hermes-prompt-editor footer { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.portal-hermes-prompt-editor footer small { color: var(--ink-soft); font-size: 11.5px; }
.portal-hermes-prompt-editor footer small[data-hermes-prompt-state] { flex: 1 1 auto; min-width: 0; }
.portal-hermes-prompt-editor.is-edited footer small[data-hermes-prompt-state] { color: #b45309; }
.portal-hermes-prompt-editor footer > span { display: inline-flex; gap: 6px; }
.portal-hermes-prompt-editor footer .portal-action-button { min-height: 28px; padding: 0 10px; font-size: 12px; }
.portal-hermes-prompt-editor footer .portal-action-button[hidden] { display: none; }
.portal-hermes-prompt-notice { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 10px; border-radius: 8px; font-size: 12px; background: color-mix(in srgb, #2563eb 10%, transparent); color: var(--ink); }
.portal-hermes-prompt-notice span { flex: 1 1 200px; }
.portal-hermes-prompt-notice button { border: 1px solid var(--line); border-radius: 6px; background: var(--surface, var(--panel, #fff)); color: var(--ink); padding: 3px 8px; font-size: 12px; cursor: pointer; }
.portal-hermes-prompt-warnings:empty { display: none; }
.portal-hermes-prompt-warnings p { display: flex; gap: 6px; align-items: flex-start; margin: 0 0 4px; padding: 6px 10px; border-radius: 8px; font-size: 12px; line-height: 1.5; color: #92400e; background: color-mix(in srgb, #f59e0b 14%, transparent); }
.portal-hermes-prompt-warnings svg { flex: 0 0 auto; width: 14px; height: 14px; margin-top: 2px; }
.portal-hermes-assets-stage .portal-hermes-asset-prompt { display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 6px; }
.portal-hermes-assets-stage .portal-hermes-asset-prompt > span { font-size: 12px; color: var(--ink-soft); }
.portal-hermes-assets-stage .portal-hermes-asset-prompt .portal-hermes-prompt-editor textarea { height: auto; min-height: 140px; }
.portal-hermes-shot-fields-raw { margin-top: 8px; }
.portal-hermes-shot-fields-raw > summary { cursor: pointer; font-size: 12px; color: var(--ink-soft); }

/* Per-card copy buttons */
.portal-hermes-card-tools { display: flex; align-items: center; justify-content: flex-end; gap: 6px; margin-top: auto; }
.portal-hermes-card-copy { display: inline-flex; align-items: center; gap: 3px; padding: 2px 8px; border: 1px solid var(--line); border-radius: 999px; font-size: 11px; font-style: normal; color: var(--ink-soft); background: var(--surface, var(--panel, #fff)); cursor: pointer; white-space: nowrap; }
.portal-hermes-card-copy:hover, .portal-hermes-card-copy:focus-visible { color: var(--ink); border-color: var(--accent, #e11); outline: none; }
.portal-hermes-card-copy svg { width: 12px !important; height: 12px !important; }
.portal-hermes-edited-badge { padding: 1px 6px; border-radius: 999px; font-size: 10.5px; font-style: normal; color: #b45309; background: color-mix(in srgb, #f59e0b 16%, transparent); }
.portal-hermes-shot-item > .portal-hermes-card-copy { grid-column: 1; grid-row: 2; justify-self: start; align-self: start; margin-top: 2px; }
.portal-hermes-shot-item > .body { grid-row: 1 / span 2; }

/* Mobile pane tabs (only shown on narrow screens when a preview is open) */
.portal-hermes-mobile-tabs { display: none; }

@media (max-width: 900px) {
  .portal-page.portal-hermes-active > .portal-hermes-agent-shell.preview-open {
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-rows: auto minmax(0, 1fr);
  }
  .portal-hermes-agent-shell.preview-open > .portal-hermes-mobile-tabs {
    display: flex;
    gap: 6px;
    padding: 4px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface-soft);
  }
  .portal-hermes-mobile-tabs button {
    flex: 1 1 0;
    min-height: 34px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--ink-soft);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .portal-hermes-mobile-tabs button.active { background: var(--surface, var(--panel, #fff)); color: var(--ink); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08); }
  .portal-hermes-agent-shell.preview-open.mobile-pane-preview > main { display: none !important; }
  .portal-hermes-agent-shell.preview-open.mobile-pane-chat > .portal-hermes-preview-panel { display: none !important; }
  .portal-hermes-agent-shell.preview-open > .portal-hermes-preview-panel { min-width: 0 !important; max-width: 100% !important; width: 100% !important; }
  .portal-hermes-agent-shell { overflow-x: hidden; }
  .portal-hermes-stage-confirm-actions { width: 100%; }
  .portal-hermes-stage-md { max-height: none; }
}

/* ===================== b56: prompt data layer (versions · results · 过期) ===================== */
:root {
  --hermes-state-idle: #9a9a9a;
  --hermes-state-running: #2563eb;
  --hermes-state-pending: #d97706;
  --hermes-state-confirmed: #15803d;
  --hermes-state-stale: #c2410c;
}
.portal-hermes-stage-pill { display: inline-block; padding: 0 6px; border-radius: 999px; font-style: normal; font-size: 11px; line-height: 17px; color: #fff; background: var(--hermes-state-idle); }
.portal-hermes-workflow button.stage-running .portal-hermes-stage-pill { background: var(--hermes-state-running); }
.portal-hermes-workflow button.stage-pending .portal-hermes-stage-pill { background: var(--hermes-state-pending); }
.portal-hermes-workflow button.stage-confirmed .portal-hermes-stage-pill { background: var(--hermes-state-confirmed); }
.portal-hermes-workflow button.stage-stale .portal-hermes-stage-pill { background: var(--hermes-state-stale); }
.portal-hermes-workflow button.stage-stale { border-color: color-mix(in srgb, var(--hermes-state-stale) 55%, var(--line)); }
.portal-hermes-workflow button.stage-stale > span { color: #fff; background: var(--hermes-state-stale); }

.portal-hermes-stale-notice { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 10px; padding: 9px 12px; border: 1px solid color-mix(in srgb, var(--hermes-state-stale) 40%, var(--line)); border-radius: var(--radius-sm); background: color-mix(in srgb, var(--hermes-state-stale) 8%, var(--surface-soft)); font-size: 12.5px; color: var(--ink); }
.portal-hermes-stale-notice > svg { width: 16px; height: 16px; color: var(--hermes-state-stale); flex: 0 0 auto; }
.portal-hermes-stale-notice > span { flex: 1 1 260px; line-height: 1.55; }
.portal-hermes-stale-notice strong { margin-right: 6px; color: var(--hermes-state-stale); }
.portal-hermes-stale-notice .portal-action-button { min-height: 28px; font-size: 12px; }

/* version dropdown */
.portal-hermes-version-menu { position: relative; display: inline-block; }
.portal-hermes-version-menu > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; min-height: 28px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface, var(--panel, #fff)); color: var(--ink); font-size: 12px; white-space: nowrap; }
.portal-hermes-version-menu > summary::-webkit-details-marker { display: none; }
.portal-hermes-version-menu > summary::after { content: "▾"; color: var(--ink-soft); font-size: 10px; }
.portal-hermes-version-menu[open] > summary { border-color: var(--primary, #e11); }
.portal-hermes-version-menu > ol { position: absolute; z-index: 30; right: 0; bottom: calc(100% + 6px); width: min(360px, 80vw); max-height: 320px; overflow: auto; margin: 0; padding: 6px; list-style: none; border: 1px solid var(--line); border-radius: 10px; background: var(--surface, var(--panel, #fff)); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.14); }
.portal-hermes-version-menu li { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; }
.portal-hermes-version-menu li.current { background: color-mix(in srgb, var(--primary, #e11) 7%, transparent); }
.portal-hermes-version-menu li > div { flex: 1 1 auto; min-width: 0; display: grid; grid-template-columns: auto auto 1fr; align-items: baseline; gap: 2px 6px; }
.portal-hermes-version-menu li b { font-size: 12.5px; color: var(--ink); }
.portal-hermes-version-menu li.source-user b { color: #b45309; }
.portal-hermes-version-menu li em { font-style: normal; font-size: 10.5px; padding: 0 5px; border-radius: 999px; color: #fff; background: var(--primary, #e11); }
.portal-hermes-version-menu li small { grid-column: 1 / -1; font-size: 11px; color: var(--ink-soft); }
.portal-hermes-version-menu li > span { display: inline-flex; gap: 4px; flex: 0 0 auto; }
.portal-hermes-version-menu li button,
.portal-hermes-version-inspect header button,
.portal-hermes-prompt-notice button { border: 1px solid var(--line); border-radius: 6px; background: var(--surface, var(--panel, #fff)); color: var(--ink); padding: 2px 7px; font-size: 11.5px; cursor: pointer; }
.portal-hermes-version-menu li button:hover,
.portal-hermes-version-inspect header button:hover { border-color: var(--primary, #e11); color: var(--primary, #e11); }
.portal-hermes-version-inspect { border: 1px solid var(--line); border-radius: 8px; background: var(--surface-soft); overflow: hidden; }
.portal-hermes-version-inspect header { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 6px 10px; border-bottom: 1px solid var(--line); font-size: 12px; }
.portal-hermes-version-inspect header strong { color: var(--ink); }
.portal-hermes-version-inspect header small { flex: 1 1 auto; color: var(--ink-soft); }
.portal-hermes-version-inspect pre,
.portal-hermes-diff { margin: 0; padding: 8px 10px; max-height: 220px; overflow: auto; white-space: pre-wrap; word-break: break-word; font: inherit; font-size: 12.5px; line-height: 1.65; color: var(--ink); }
.portal-hermes-diff ins, .portal-hermes-version-inspect small ins { text-decoration: none; background: color-mix(in srgb, #16a34a 22%, transparent); color: #14532d; border-radius: 3px; }
.portal-hermes-diff del, .portal-hermes-version-inspect small del { text-decoration: line-through; background: color-mix(in srgb, #dc2626 16%, transparent); color: #7f1d1d; border-radius: 3px; }

/* results per item */
.portal-hermes-result-strip { display: grid; gap: 6px; min-width: 0; }
.portal-hermes-result-thumbs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.portal-hermes-result-thumbs button { position: relative; flex: 0 0 auto; width: 74px; padding: 0; border: 2px solid transparent; border-radius: 8px; background: var(--surface-soft); cursor: pointer; overflow: hidden; }
.portal-hermes-result-thumbs button img,
.portal-hermes-result-thumbs button video { display: block; width: 100%; height: 48px; object-fit: cover; background: #111; }
.portal-hermes-result-thumbs button small { display: block; padding: 2px 4px; font-size: 10.5px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.portal-hermes-result-thumbs button.active { border-color: var(--primary, #e11); }
.portal-hermes-result-thumbs button.adopted small { color: var(--hermes-state-confirmed); font-weight: 600; }
.portal-hermes-result-thumbs button.stale small { color: var(--hermes-state-stale); }
.portal-hermes-result-strip footer { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.portal-hermes-result-strip footer small { flex: 1 1 auto; font-size: 11.5px; color: var(--ink-soft); }
.portal-hermes-result-strip footer .portal-action-button { min-height: 28px; font-size: 12px; }

/* item state on cards */
.portal-hermes-version-badge { padding: 1px 6px; border-radius: 999px; font-size: 10.5px; font-style: normal; color: var(--ink-soft); background: color-mix(in srgb, var(--ink) 8%, transparent); }
.portal-hermes-asset-grid button.status-stale .portal-hermes-asset-status { color: #fff; background: var(--hermes-state-stale); }
.portal-hermes-asset-grid button.status-stale { border-color: color-mix(in srgb, var(--hermes-state-stale) 50%, var(--line)); }
.portal-hermes-item-state { display: inline-block; margin-left: 4px; padding: 0 5px; border-radius: 999px; font-size: 10px; font-style: normal; line-height: 16px; color: #fff; background: var(--hermes-state-stale); vertical-align: middle; }
.portal-hermes-manifest-block { margin: 0 0 8px; }
.portal-hermes-manifest-block > summary { cursor: pointer; font-size: 12px; color: var(--ink-soft); }
/* b56 fixes: stale notice gets its own grid row; editor footer wraps instead of squashing */
.portal-hermes-asset-board:has(> .portal-hermes-stale-notice) { grid-template-rows: auto auto auto minmax(0, 1fr); }
.portal-hermes-asset-board > .portal-hermes-stale-notice { margin: 0; }
.portal-hermes-prompt-editor footer > span { flex: 1 1 100%; flex-wrap: wrap; justify-content: flex-end; align-items: center; min-width: 0; }
.portal-hermes-prompt-editor footer > span > * { flex: 0 0 auto; white-space: nowrap; }
.portal-hermes-prompt-editor footer .portal-hermes-version-menu { margin-right: auto; }
/* b56: when a version view/diff or agent-update notice is open, let the detail column scroll instead of squeezing it to 0 */
.portal-hermes-assets-stage .portal-hermes-asset-detail:has(.portal-hermes-version-inspect, .portal-hermes-prompt-notice, .portal-hermes-version-menu[open]) { grid-template-rows: none; grid-auto-rows: max-content; overflow-y: auto; }
.portal-hermes-assets-stage .portal-hermes-asset-detail:has(.portal-hermes-version-inspect, .portal-hermes-prompt-notice, .portal-hermes-version-menu[open]) > :first-child { height: 220px; }
.portal-hermes-assets-stage .portal-hermes-asset-detail:has(.portal-hermes-version-inspect, .portal-hermes-prompt-notice, .portal-hermes-version-menu[open]) .portal-hermes-asset-prompt { overflow: visible; grid-template-rows: auto auto; }
.portal-hermes-assets-stage .portal-hermes-asset-detail:has(.portal-hermes-version-inspect, .portal-hermes-prompt-notice, .portal-hermes-version-menu[open]) .portal-hermes-asset-prompt textarea { height: 150px; }
.portal-hermes-prompt-editor > .portal-hermes-version-inspect, .portal-hermes-prompt-editor > .portal-hermes-prompt-notice { min-height: max-content; }

/* ===================== b57: 三栏提示词工作台 ===================== */
.portal-page.portal-hermes-active > .portal-hermes-agent-shell.hwb-shell {
  display: grid;
  grid-template-columns: 208px minmax(0, 1fr) minmax(320px, 360px) !important;
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "top top top" "rail center chat";
  gap: 10px;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}
.hwb-shell > .hwb-top { grid-area: top; display: flex; align-items: center; gap: 12px; min-width: 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.hwb-title { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 0 0 auto; }
.hwb-title > div { display: grid; gap: 1px; min-width: 0; }
.hwb-title strong { font-size: 14px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px; }
.hwb-title small { font-size: 11px; color: var(--ink-soft); white-space: nowrap; }
.hwb-top-actions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; margin-left: auto; }
.hwb-top .portal-action-button { min-height: 30px; font-size: 12px; padding: 0 10px; }

.hwb-stages { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; flex: 1 1 auto; min-width: 0; }
.hwb-stage { width: 100%; display: flex; align-items: center; gap: 8px; min-width: 0; padding: 5px 9px; border: 1px solid var(--line); border-left: 3px solid var(--hermes-state-idle); border-radius: 8px; background: var(--surface-soft); color: var(--ink); text-align: left; cursor: pointer; }
.hwb-stage:hover { border-color: color-mix(in srgb, var(--primary) 45%, var(--line)); }
.hwb-stage > i { flex: 0 0 auto; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-style: normal; font-size: 11px; font-weight: 700; background: var(--surface); border: 1px solid var(--line); }
.hwb-stage > span { display: grid; min-width: 0; gap: 1px; }
.hwb-stage b { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hwb-stage small { display: flex; align-items: center; gap: 5px; font-size: 11px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hwb-stage.stage-running { border-left-color: var(--hermes-state-running); }
.hwb-stage.stage-pending { border-left-color: var(--hermes-state-pending); }
.hwb-stage.stage-confirmed { border-left-color: var(--hermes-state-confirmed); }
.hwb-stage.stage-stale { border-left-color: var(--hermes-state-stale); background: color-mix(in srgb, var(--hermes-state-stale) 7%, var(--surface-soft)); }
.hwb-stage.stage-confirmed > i { background: var(--hermes-state-confirmed); color: #fff; border-color: transparent; }
.hwb-stage.stage-stale > i { background: var(--hermes-state-stale); color: #fff; border-color: transparent; }

.hwb-pill { display: inline-block; flex: 0 0 auto; padding: 0 6px; border-radius: 999px; font-style: normal; font-size: 10.5px; line-height: 17px; color: #fff; background: var(--hermes-state-idle); white-space: nowrap; }
.hwb-pill.state-running { background: var(--hermes-state-running); }
.hwb-pill.state-pending, .hwb-pill.state-done { background: var(--hermes-state-pending); }
.hwb-pill.state-confirmed, .hwb-pill.state-adopted { background: var(--hermes-state-confirmed); }
.hwb-pill.state-stale { background: var(--hermes-state-stale); }
.hwb-pill.state-missing, .hwb-pill.state-idle { background: color-mix(in srgb, var(--ink-soft) 55%, transparent); }

/* rail */
.hwb-shell > .hwb-rail { grid-area: rail; min-height: 0; overflow: auto; overscroll-behavior: contain; display: grid; align-content: start; gap: 12px; padding: 10px 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.hwb-rail section { display: grid; gap: 2px; }
.hwb-rail h4 { margin: 0 0 4px; padding: 0 6px; display: flex; align-items: baseline; justify-content: space-between; gap: 6px; font-size: 12px; color: var(--ink); }
.hwb-rail h4 small { font-weight: 400; font-size: 10.5px; color: var(--ink-soft); text-align: right; }
.hwb-nav { display: flex; align-items: center; justify-content: space-between; gap: 6px; width: 100%; min-height: 30px; padding: 4px 8px; border: 0; border-radius: 6px; background: transparent; color: var(--ink); font-size: 12.5px; text-align: left; cursor: pointer; }
.hwb-nav span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hwb-nav small { flex: 0 0 auto; font-size: 11px; color: var(--ink-soft); }
.hwb-nav:hover { background: var(--surface-soft); }
.hwb-nav.active { background: color-mix(in srgb, var(--primary) 12%, var(--surface)); color: var(--primary); font-weight: 600; box-shadow: inset 2px 0 0 var(--primary); }
.hwb-stale-count { color: var(--hermes-state-stale); font-weight: 600; }
.hwb-empty-line { margin: 0; padding: 4px 8px; font-size: 11.5px; color: var(--ink-soft); }

/* center */
.hwb-shell > .hwb-center { grid-area: center; min-width: 0; min-height: 0; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.hwb-center-body { flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 0 14px 16px; }
.hwb-center-head { position: sticky; top: 0; z-index: 3; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 -14px 10px; padding: 10px 14px; background: var(--surface); border-bottom: 1px solid var(--line); }
.hwb-center-head > div:first-child { display: grid; gap: 2px; min-width: 0; flex: 1 1 220px; }
.hwb-center-head h2 { margin: 0; font-size: 15px; color: var(--ink); }
.hwb-center-head small { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 11.5px; color: var(--ink-soft); }
.hwb-head-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.hwb-head-actions .portal-action-button { min-height: 30px; font-size: 12px; padding: 0 10px; }
.hwb-model { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--ink-soft); }
.hwb-model select { min-height: 30px; max-width: 170px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-soft); color: var(--ink); font-size: 12px; padding: 0 6px; }
.hwb-mode, .hwb-filters { display: inline-flex; gap: 2px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-soft); }
.hwb-mode button, .hwb-filters button { min-height: 26px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent; color: var(--ink-soft); font-size: 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; }
.hwb-mode button.active, .hwb-filters button.active { background: var(--surface); color: var(--primary); font-weight: 600; box-shadow: 0 1px 2px rgb(0 0 0 / 8%); }
.hwb-filters { margin: 0 0 10px; }
.hwb-filters small { font-size: 10.5px; color: var(--ink-soft); }
.hwb-center .portal-hermes-stale-notice { margin: 0 0 10px; }

.hwb-cards { display: grid; gap: 10px; }
.hwb-card { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(220px, 0.75fr); gap: 0; border: 1px solid var(--line); border-left: 3px solid color-mix(in srgb, var(--ink-soft) 35%, transparent); border-radius: 10px; background: var(--surface); overflow: hidden; }
.hwb-card.item-stale { border-left-color: var(--hermes-state-stale); }
.hwb-card.item-adopted { border-left-color: var(--hermes-state-confirmed); }
.hwb-card.item-done { border-left-color: var(--hermes-state-pending); }
.hwb-card.status-running, .hwb-card.status-queued { border-left-color: var(--hermes-state-running); }
.hwb-card-prompt { display: grid; align-content: start; gap: 8px; min-width: 0; padding: 10px 12px; border-right: 1px solid var(--line); }
.hwb-card-prompt > header { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; }
.hwb-card-prompt > header b { font-size: 12px; color: var(--primary); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.hwb-card-prompt > header strong { font-size: 13.5px; color: var(--ink); }
.hwb-kind, .hwb-dep { font-size: 11px; color: var(--ink-soft); padding: 0 6px; border: 1px solid var(--line); border-radius: 999px; line-height: 17px; }
.hwb-card-prompt > header .hwb-pill { margin-left: auto; }
.hwb-card-prompt .portal-hermes-prompt-editor textarea { min-height: 96px; font-size: 12.5px; line-height: 1.6; }
.hwb-card-tools { display: flex; justify-content: flex-start; }
.hwb-ask { display: inline-flex; align-items: center; gap: 5px; min-height: 26px; padding: 0 10px; border: 1px dashed color-mix(in srgb, var(--primary) 45%, var(--line)); border-radius: 6px; background: transparent; color: var(--primary); font-size: 12px; cursor: pointer; }
.hwb-ask svg { width: 14px; height: 14px; }
.hwb-ask:hover { background: color-mix(in srgb, var(--primary) 8%, transparent); }
.hwb-card-result { display: grid; align-content: start; gap: 8px; min-width: 0; padding: 10px 12px; background: var(--surface-soft); }
.hwb-media { position: relative; display: grid; place-items: center; aspect-ratio: 16 / 9; border: 1px dashed var(--line); border-radius: 8px; background: var(--surface); overflow: hidden; color: var(--ink-soft); font-size: 12px; }
.hwb-media.has-media { border-style: solid; cursor: zoom-in; }
.hwb-media img, .hwb-media video { width: 100%; height: 100%; object-fit: contain; background: #111; }
.hwb-media > span { display: grid; justify-items: center; gap: 6px; }
.hwb-media > span svg { width: 22px; height: 22px; opacity: .7; }
.hwb-video { aspect-ratio: 9 / 16; max-height: 300px; justify-self: center; width: auto; min-width: 150px; }
.hwb-busy { position: absolute; left: 8px; top: 8px; padding: 2px 8px; border-radius: 999px; font-style: normal; font-size: 11px; color: #fff; background: var(--hermes-state-running); }
.hwb-result-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.hwb-result-actions .portal-action-button { min-height: 30px; font-size: 12px; padding: 0 12px; }
.hwb-error { margin: 0; font-size: 11.5px; color: #b91c1c; }
.hwb-card-result .portal-hermes-result-strip { margin: 0; }
.hwb-bound { display: flex; flex-wrap: wrap; gap: 4px; }
.hwb-bound span { display: inline-flex; align-items: center; gap: 4px; padding: 1px 6px 1px 2px; border: 1px solid var(--line); border-radius: 999px; font-size: 11px; color: var(--ink-soft); }
.hwb-bound span.ok { border-color: color-mix(in srgb, var(--hermes-state-confirmed) 50%, var(--line)); color: var(--hermes-state-confirmed); }
.hwb-bound img { width: 18px; height: 18px; border-radius: 50%; object-fit: cover; }

/* basis */
.hwb-basis-doc { display: grid; gap: 8px; }
.hwb-block { position: relative; padding: 8px 12px; border: 1px solid transparent; border-radius: 8px; }
.hwb-block:hover { border-color: var(--line); background: var(--surface-soft); }
.hwb-block .portal-hermes-md { font-size: 13px; }
.hwb-block-edit { position: absolute; top: 6px; right: 8px; display: inline-flex; align-items: center; gap: 4px; min-height: 24px; padding: 0 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink-soft); font-size: 11.5px; cursor: pointer; opacity: 0; }
.hwb-block:hover .hwb-block-edit, .hwb-block-edit:focus { opacity: 1; }
.hwb-block-edit svg { width: 13px; height: 13px; }
.hwb-block.editing { border-color: color-mix(in srgb, var(--primary) 50%, var(--line)); background: var(--surface); }
.hwb-block.editing textarea { width: 100%; box-sizing: border-box; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-soft); color: var(--ink); font: inherit; font-size: 12.5px; line-height: 1.6; padding: 8px; resize: vertical; }
.hwb-block.editing footer { display: flex; justify-content: flex-end; gap: 6px; margin-top: 6px; }
.hwb-doc header { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; font-size: 11.5px; color: var(--ink-soft); }
.hwb-doc .portal-hermes-md { padding: 10px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-soft); font-size: 13px; }
.hwb-quote-pop { position: fixed; z-index: 60; display: inline-flex; align-items: center; gap: 5px; min-height: 30px; padding: 0 12px; border: 0; border-radius: 999px; background: var(--primary); color: #fff; font-size: 12px; box-shadow: 0 6px 18px rgb(0 0 0 / 22%); cursor: pointer; }
.hwb-quote-pop[hidden] { display: none; }
.hwb-quote-pop svg { width: 14px; height: 14px; }

/* chat */
.hwb-shell > .hwb-chat { grid-area: chat; min-width: 0; min-height: 0; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.hwb-chat > .hwb-chat-head { padding: 8px 12px; }
.hwb-chat-head > div { display: grid; gap: 1px; }
.hwb-chat-head strong { font-size: 13px; color: var(--ink); }
.hwb-chat-head small { font-size: 11px; color: var(--ink-soft); }
.hwb-chat-head small.ready { color: var(--hermes-state-confirmed); }
.hwb-chat-head .portal-action-button { min-height: 28px; padding: 0 8px; }
.hwb-chat .portal-hermes-chat-thread { padding: 12px; gap: 10px; }
.hwb-chat .portal-hermes-chat-thread article { max-width: 100%; grid-template-columns: 26px minmax(0, 1fr); gap: 8px; }
.hwb-chat .portal-hermes-chat-thread article.user { grid-template-columns: minmax(0, 1fr) 26px; }
.hwb-chat .portal-hermes-chat-thread article > span svg { width: 16px; height: 16px; }
.hwb-chat .portal-hermes-md { font-size: 12.5px; }
.hwb-chat .portal-hermes-chat-form { grid-template-columns: minmax(0, 1fr) 36px 36px; padding: 8px 10px 10px; gap: 6px; }
.hwb-chat .portal-hermes-chat-form textarea { min-height: 48px; padding: 8px 10px; font-size: 12.5px; }
.hwb-chat .portal-hermes-stage-confirm-bar { margin: 0 10px 6px; display: grid; gap: 8px; padding: 10px 12px; border: 1px solid color-mix(in srgb, var(--hermes-state-pending) 45%, var(--line)); border-radius: 10px; background: color-mix(in srgb, var(--hermes-state-pending) 7%, var(--surface)); }
.hwb-chat .portal-hermes-stage-confirm-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.hwb-chat .portal-hermes-stage-confirm-actions .portal-action-button { min-height: 28px; font-size: 12px; padding: 0 10px; }
.hwb-sum-card { display: grid; gap: 6px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); }
.hwb-sum-card > header { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.hwb-sum-card > header strong { font-size: 13px; color: var(--ink); }
.hwb-sum-card > header small { font-size: 11px; color: var(--ink-soft); white-space: nowrap; }
.hwb-sum-card > p { margin: 0; font-size: 12px; line-height: 1.55; color: var(--ink-soft); }
.hwb-pending { padding: 6px 10px; border-left: 3px solid var(--hermes-state-pending); border-radius: 4px; background: color-mix(in srgb, var(--hermes-state-pending) 8%, var(--surface)); }
.hwb-pending b { font-size: 12px; color: var(--hermes-state-pending); }
.hwb-pending ul { margin: 4px 0 0; padding-left: 18px; font-size: 12px; line-height: 1.55; color: var(--ink); }
.hwb-sum-card > footer { display: grid; gap: 6px; }
.hwb-sum-card > footer .portal-action-button { justify-self: start; min-height: 26px; font-size: 11.5px; padding: 0 10px; }
.hwb-sum-card details summary { font-size: 11.5px; color: var(--ink-soft); cursor: pointer; }
.hwb-sum-card details .portal-hermes-md { margin-top: 6px; max-height: 360px; overflow: auto; }
.hwb-quote-chip { display: flex; align-items: center; gap: 6px; margin: 0 10px; padding: 5px 8px; border-left: 3px solid var(--primary); border-radius: 4px; background: color-mix(in srgb, var(--primary) 7%, var(--surface)); font-size: 11.5px; color: var(--ink); }
.hwb-quote-chip span { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hwb-quote-chip button { border: 0; background: transparent; color: var(--ink-soft); font-size: 15px; cursor: pointer; }
.hwb-shell > .hwb-tabs { display: none; }

@media (max-width: 1280px) {
  .portal-page.portal-hermes-active > .portal-hermes-agent-shell.hwb-shell { grid-template-columns: 184px minmax(0, 1fr) 300px !important; }
  .hwb-card { grid-template-columns: minmax(0, 1fr); }
  .hwb-card-prompt { border-right: 0; border-bottom: 1px solid var(--line); }
  .hwb-title small { display: none; }
}

/* mobile: one pane + bottom tabs 卡片 / Hermes / 依据 */
@media (max-width: 899px) {
  .portal-page.portal-hermes-active > .portal-hermes-agent-shell.hwb-shell {
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas: "top" "pane" "tabs";
    gap: 6px;
  }
  .hwb-shell > .hwb-top { flex-wrap: wrap; gap: 6px; padding: 6px; }
  .hwb-title small { display: none; }
  .hwb-title strong { max-width: 150px; }
  .hwb-stages { order: 3; flex: 1 1 100%; display: flex; overflow-x: auto; scrollbar-width: none; }
  .hwb-stages > li { flex: 0 0 auto; }
  .hwb-stage { padding: 4px 8px; }
  .hwb-stage small { max-width: 130px; }
  .hwb-shell > .hwb-rail, .hwb-shell > .hwb-center, .hwb-shell > .hwb-chat { grid-area: pane; display: none; }
  .hwb-shell.wb-tab-cards > .hwb-center { display: flex; }
  .hwb-shell.wb-tab-chat > .hwb-chat { display: flex; }
  .hwb-shell.wb-tab-basis > .hwb-rail { display: grid; }
  .hwb-shell > .hwb-tabs { grid-area: tabs; display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
  .hwb-tabs button { display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-height: 40px; border: 0; border-radius: 8px; background: transparent; color: var(--ink-soft); font-size: 13px; }
  .hwb-tabs button svg { width: 16px; height: 16px; }
  .hwb-tabs button.active { background: color-mix(in srgb, var(--primary) 12%, var(--surface)); color: var(--primary); font-weight: 600; }
  .hwb-center-body { padding: 0 10px 12px; }
  .hwb-center-head { margin: 0 -10px 8px; padding: 8px 10px; }
  .hwb-card { grid-template-columns: minmax(0, 1fr); }
  .hwb-card-prompt { border-right: 0; border-bottom: 1px solid var(--line); }
  .hwb-block-edit { opacity: 1; }
  .hwb-model select { max-width: 130px; }
}
/* b57 polish */
.hwb-rail h4 { display: grid; gap: 1px; }
.hwb-rail h4 small { text-align: left; }
.hwb-video { max-height: 240px; min-width: 135px; }
.hwb-chat .portal-hermes-chat-form > button { width: 36px; min-width: 0; height: auto; min-height: 36px; padding: 0; }
.hwb-center-head { z-index: 20; background: var(--surface, var(--panel, #fff)); box-shadow: 0 1px 0 var(--line); }
.hwb-card { scroll-margin-top: 76px; }

/* ===================== b58: image-first grid, click-to-open detail, slim collapsible rails ===================== */
.portal-page.portal-hermes-active > .portal-hermes-agent-shell.hwb-shell {
  --hwb-rail-w: 208px;
  --hwb-chat-w: 320px;
  grid-template-columns: var(--hwb-rail-w) minmax(0, 1fr) var(--hwb-chat-w) !important;
}
.portal-page.portal-hermes-active > .portal-hermes-agent-shell.hwb-shell.rail-collapsed { --hwb-rail-w: 52px; }
.portal-page.portal-hermes-active > .portal-hermes-agent-shell.hwb-shell.chat-collapsed { --hwb-chat-w: 52px; }
@media (max-width: 1280px) {
  .portal-page.portal-hermes-active > .portal-hermes-agent-shell.hwb-shell { --hwb-rail-w: 184px; --hwb-chat-w: 288px; }
}

/* rails: collapse buttons + slim icon bars */
.hwb-rail { position: relative; }
.hwb-collapse { position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink-soft); font-size: 14px; line-height: 1; cursor: pointer; z-index: 2; }
.hwb-collapse:hover, .hwb-slim-toggle:hover { color: var(--primary); border-color: color-mix(in srgb, var(--primary) 45%, var(--line)); }
.hwb-rail > section:first-of-type h4 { padding-right: 30px; }
.hwb-chat-head-actions { display: inline-flex; align-items: center; gap: 6px; }
.hwb-chat-head .hwb-collapse { position: static; }
.hwb-shell > .hwb-rail.collapsed, .hwb-shell > .hwb-chat.collapsed { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 4px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.hwb-slim-toggle { width: 34px; height: 28px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-soft); color: var(--ink-soft); font-size: 15px; cursor: pointer; }
.hwb-slim-btn { position: relative; width: 44px; display: grid; justify-items: center; gap: 2px; padding: 7px 0 5px; border: 0; border-radius: 8px; background: transparent; color: var(--ink-soft); cursor: pointer; }
.hwb-slim-btn svg { width: 18px; height: 18px; }
.hwb-slim-btn small { font-size: 10px; line-height: 1.2; }
.hwb-slim-btn:hover { background: var(--surface-soft); color: var(--ink); }
.hwb-slim-btn.active { background: color-mix(in srgb, var(--primary) 12%, var(--surface)); color: var(--primary); }
.hwb-dot { position: absolute; top: 4px; right: 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--hermes-state-pending); }
.hwb-dot.running { background: var(--hermes-state-running); }

/* center: grouped image grid */
.hwb-center { position: relative; }
.hwb-group { margin: 0 0 16px; }
.hwb-group > h3 { display: flex; align-items: baseline; gap: 8px; margin: 2px 0 8px; font-size: 13px; color: var(--ink); }
.hwb-group > h3 small { font-weight: 400; font-size: 11.5px; color: var(--ink-soft); }
.hwb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 12px; }
.hwb-grid-shots { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.hwb-grid-shots.landscape { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.hwb-tile { position: relative; display: grid; grid-template-rows: auto auto; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); overflow: hidden; cursor: pointer; transition: box-shadow .15s ease, transform .15s ease, border-color .15s ease; outline: none; }
.hwb-tile:hover, .hwb-tile:focus-visible { border-color: color-mix(in srgb, var(--primary) 50%, var(--line)); box-shadow: 0 6px 18px rgb(0 0 0 / 10%); transform: translateY(-1px); }
.hwb-tile.is-open { border-color: var(--primary); box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 35%, transparent); }
.hwb-tile.item-stale { border-color: color-mix(in srgb, var(--hermes-state-stale) 55%, var(--line)); }
.hwb-tile.item-adopted { border-color: color-mix(in srgb, var(--hermes-state-confirmed) 45%, var(--line)); }
.hwb-tile-media { position: relative; aspect-ratio: 4 / 3; background: color-mix(in srgb, var(--ink) 5%, var(--surface-soft)); overflow: hidden; }
.hwb-tile-shot .hwb-tile-media { aspect-ratio: var(--hwb-shot-ar, 9 / 16); }
.hwb-tile-media img, .hwb-tile-media video { width: 100%; height: 100%; object-fit: cover; display: block; background: #111; }
.hwb-tile-empty { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 6px; padding: 8px; color: var(--ink-soft); text-align: center; border: 1px dashed color-mix(in srgb, var(--ink-soft) 30%, transparent); border-radius: 9px 9px 0 0; }
.hwb-tile-empty svg { width: 24px; height: 24px; opacity: .55; }
.hwb-tile-empty small { font-size: 11.5px; }
.hwb-tile-empty .portal-action-button { min-height: 28px; padding: 0 12px; font-size: 12px; }
.hwb-tile .hwb-busy { left: 6px; top: 6px; }
.hwb-tile.is-busy .hwb-tile-media::after { content: ""; position: absolute; inset: 0; background: linear-gradient(100deg, transparent 30%, rgb(255 255 255 / 22%) 50%, transparent 70%); background-size: 200% 100%; animation: hwb-shimmer 1.4s linear infinite; }
@keyframes hwb-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.hwb-play { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; color: #fff; }
.hwb-play svg { width: 30px; height: 30px; filter: drop-shadow(0 1px 4px rgb(0 0 0 / 50%)); }
.hwb-dur { position: absolute; right: 6px; bottom: 6px; padding: 1px 6px; border-radius: 4px; background: rgb(0 0 0 / 55%); color: #fff; font-style: normal; font-size: 10.5px; }
.hwb-tile-cap { display: flex; align-items: center; justify-content: space-between; gap: 6px; min-width: 0; padding: 6px 8px; }
.hwb-tile-cap > span { display: inline-flex; align-items: center; gap: 5px; min-width: 0; }
.hwb-tile-cap > span:first-child { flex: 1 1 auto; overflow: hidden; }
.hwb-tile-cap b { flex: 0 0 auto; font-size: 11px; color: var(--primary); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.hwb-tile-cap strong { font-size: 12.5px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hwb-tile-cap small { display: inline-flex; align-items: center; gap: 2px; font-size: 10.5px; color: var(--ink-soft); }
.hwb-tile-cap small svg { width: 11px; height: 11px; }

/* detail drawer (over the center) */
.hwb-detail-backdrop { position: absolute; inset: 0; z-index: 30; background: rgb(15 15 15 / 28%); }
.hwb-detail { position: absolute; top: 0; right: 0; bottom: 0; z-index: 31; width: min(100%, 940px); display: flex; flex-direction: column; background: var(--surface, var(--panel, #fff)); border-left: 1px solid var(--line); box-shadow: -12px 0 32px rgb(0 0 0 / 18%); container-type: inline-size; outline: none; animation: hwb-drawer-in .16s ease-out; }
@keyframes hwb-drawer-in { from { transform: translateX(24px); opacity: .6; } to { transform: none; opacity: 1; } }
.hwb-detail-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.hwb-detail-head > div { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; min-width: 0; flex: 1 1 auto; }
.hwb-detail-head b { font-size: 12.5px; color: var(--primary); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.hwb-detail-head strong { font-size: 15px; color: var(--ink); }
.hwb-detail-nav { display: inline-flex; align-items: center; gap: 4px; }
.hwb-detail-nav small { min-width: 44px; text-align: center; font-size: 11.5px; color: var(--ink-soft); }
.hwb-detail-nav button, .hwb-detail-close { width: 30px; height: 30px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-soft); color: var(--ink); font-size: 18px; line-height: 1; cursor: pointer; }
.hwb-detail-nav button:disabled { opacity: .35; cursor: default; }
.hwb-detail-close { font-size: 20px; }
.hwb-detail-body { flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain; display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(280px, 1fr); gap: 16px; align-content: start; padding: 14px; }
.hwb-detail-left { display: grid; gap: 10px; align-content: start; min-width: 0; }
.hwb-detail-media { position: relative; display: grid; place-items: center; min-height: 260px; max-height: calc(100vh - 330px); aspect-ratio: 4 / 3; border: 1px dashed var(--line); border-radius: 10px; background: #111; overflow: hidden; color: #bbb; }
.hwb-detail-media.has-media { border-style: solid; cursor: zoom-in; }
.hwb-detail-media img, .hwb-detail-media video { width: 100%; height: 100%; object-fit: contain; }
.hwb-detail-media > span { display: grid; justify-items: center; gap: 8px; font-size: 13px; }
.hwb-detail-media > span svg { width: 30px; height: 30px; opacity: .6; }
.hwb-detail-video { aspect-ratio: auto; height: min(56vh, 520px); cursor: default; }
.hwb-detail-prompt { display: grid; gap: 8px; align-content: start; min-width: 0; }
.hwb-detail-prompt h4 { margin: 4px 0 0; font-size: 12.5px; color: var(--ink); }
.hwb-detail-prompt .portal-hermes-prompt-editor textarea { min-height: 220px; font-size: 13px; line-height: 1.65; }
.hwb-detail .portal-hermes-result-strip { margin: 0; }
@container (max-width: 720px) {
  .hwb-detail-body { grid-template-columns: minmax(0, 1fr); }
  .hwb-detail-media { max-height: 52vh; }
}

/* mobile: 2-column grid, detail = full-screen sheet */
@media (max-width: 899px) {
  .hwb-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .hwb-grid-shots, .hwb-grid-shots.landscape { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hwb-tile-cap { padding: 5px 6px; }
  .hwb-tile-cap strong { font-size: 12px; }
  .hwb-detail-backdrop { display: none; }
  .hwb-detail { position: fixed; inset: 0; z-index: 90; width: 100%; border-left: 0; box-shadow: none; animation: hwb-sheet-in .18s ease-out; }
  @keyframes hwb-sheet-in { from { transform: translateY(28px); opacity: .6; } to { transform: none; opacity: 1; } }
  .hwb-detail-head { padding: 8px 10px; padding-top: max(8px, env(safe-area-inset-top)); }
  .hwb-detail-body { grid-template-columns: minmax(0, 1fr); padding: 10px; }
  .hwb-detail-media { min-height: 200px; max-height: 50vh; }
  .hwb-detail-video { height: 52vh; }
  .hwb-shell:not(.wb-tab-cards) .hwb-detail { display: none; }
  .hwb-collapse { display: none; }
}
/* b58 tuning: asset boards are mostly 16:9 → less cropping; ~4 columns at 1440 with rails open */
.hwb-grid { grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); }
.hwb-tile-media { aspect-ratio: 16 / 10; }
@media (max-width: 899px) { .hwb-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 899px) {
  .portal-page.portal-hermes-active > .portal-hermes-agent-shell.hwb-shell { grid-template-columns: minmax(0, 1fr) !important; }
  .hwb-detail { z-index: 2000; }
}
@media (max-width: 899px) {
  /* the global nav reveal button sits above the app shell's stacking context; hide it while the sheet is open */
  html:has(.hwb-shell.detail-open.wb-tab-cards) .product-nav-reveal { display: none !important; }
}

/* b59: negative constraints shown under the asset prompt in the detail panel */
.hwb-detail .hwb-negative { margin: 6px 0 0; font-size: 12px; line-height: 1.5; color: var(--muted, #6b6b6b); word-break: break-word; }
.hwb-detail .hwb-negative b { margin-right: 6px; font-weight: 600; color: inherit; }

/* b61: ⑤ 成片 */
.hwb-stages { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.hwb-link { border: 0; background: none; padding: 0 2px; color: var(--accent, #c8102e); font-size: 12px; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.hwb-final-notice { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 0 0 10px; padding: 9px 12px; border: 1px solid color-mix(in srgb, var(--hermes-state-pending) 40%, var(--line)); border-radius: 8px; background: color-mix(in srgb, var(--hermes-state-pending) 8%, var(--surface-soft)); font-size: 12.5px; }
.hwb-final { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 340px); gap: 14px; align-items: start; }
.hwb-final-timeline ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.hwb-final-clip { display: grid; grid-template-columns: 22px auto minmax(0, 1fr); align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.hwb-final-clip.is-missing { border-style: dashed; opacity: .75; }
.hwb-final-idx { font-size: 12px; font-weight: 700; color: var(--ink-soft); text-align: center; }
.hwb-final-thumb { display: grid; place-items: center; width: 64px; aspect-ratio: var(--hwb-shot-ar, 9 / 16); max-height: 96px; overflow: hidden; border-radius: 6px; background: #111; }
.hwb-final-thumb img, .hwb-final-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.hwb-final-missing { font-size: 11px; color: #ddd; }
.hwb-final-meta { display: grid; gap: 2px; min-width: 0; }
.hwb-final-meta b { font-size: 12px; }
.hwb-final-meta strong { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hwb-final-meta small { font-size: 11.5px; color: var(--ink-soft); }
.hwb-final-sub { color: var(--ink) !important; }
.hwb-final-cut { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 0 0 0 28px; padding: 6px 10px; border-left: 2px dashed var(--line); font-size: 12px; }
.hwb-final-cut.is-custom { border-left-color: var(--hermes-state-running); }
.hwb-final-cut select, .hwb-final-opts select { min-height: 28px; padding: 0 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink); font-size: 12px; }
.hwb-final-cut small { color: var(--ink-soft); }
.hwb-final-total { margin: 8px 0 0; font-size: 12px; color: var(--ink-soft); }
.hwb-final-side { display: grid; gap: 12px; position: sticky; top: 0; }
.hwb-final-side section { padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.hwb-final-side h4 { margin: 0 0 8px; font-size: 13px; }
.hwb-final-opts { display: grid; gap: 8px; }
.hwb-final-opts > label:not(.hwb-final-check) { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12.5px; }
.hwb-final-check { display: flex; align-items: flex-start; gap: 6px; font-size: 12.5px; line-height: 1.4; }
.hwb-final-note { margin: 0; font-size: 11.5px; color: var(--ink-soft); line-height: 1.5; }
.hwb-final-progress { height: 8px; border-radius: 999px; background: var(--surface-soft); overflow: hidden; border: 1px solid var(--line); }
.hwb-final-bar { height: 100%; background: var(--hermes-state-running); transition: width .8s ease; }
.hwb-final-stage { display: block; margin-top: 6px; font-size: 12px; color: var(--ink-soft); }
.hwb-final-player { width: 100%; max-height: 62vh; aspect-ratio: var(--hwb-shot-ar, 9 / 16); background: #000; border-radius: 8px; overflow: hidden; display: grid; place-items: center; }
.hwb-final-player video { width: 100%; height: 100%; object-fit: contain; background: #000; }
.hwb-final-links { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
.hwb-final-links small { font-size: 11.5px; color: var(--ink-soft); }
.hwb-final-error { margin: 0; color: var(--hermes-state-stale); font-size: 12.5px; }
.hwb-final-versions { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; max-height: 220px; overflow: auto; }
.hwb-final-versions button { width: 100%; display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-soft); color: var(--ink); font-size: 12px; cursor: pointer; text-align: left; }
.hwb-final-versions button.active { border-color: var(--hermes-state-running); background: color-mix(in srgb, var(--hermes-state-running) 8%, var(--surface)); }
.hwb-final-versions small { color: var(--ink-soft); }
@media (max-width: 1180px) { .hwb-final { grid-template-columns: minmax(0, 1fr); } .hwb-final-side { position: static; } }
@media (max-width: 899px) {
  .hwb-final-cut { margin-left: 12px; }
  .hwb-final-player { max-height: 70vh; }
}
.hwb-center-head [data-hermes-final-render]:disabled { opacity: .45; cursor: not-allowed; }

/* b62: project style toggle 「真人写实 / 漫剧」 */
.hwb-style { display: inline-flex; align-items: center; gap: 2px; padding: 2px; border: 1px solid rgba(148, 163, 184, .35); border-radius: 999px; font-size: 12px; white-space: nowrap; }
.hwb-style > span { padding: 0 6px 0 8px; opacity: .7; }
.hwb-style button { border: 0; background: transparent; color: inherit; padding: 3px 10px; border-radius: 999px; cursor: pointer; font: inherit; }
.hwb-style button.active { background: var(--accent, #3b82f6); color: #fff; }
.hwb-style.unset { border-color: rgba(245, 158, 11, .7); }
.hwb-style.unset > span::after { content: " 未定"; color: #f59e0b; }
.hwb-style-ask { border-color: rgba(245, 158, 11, .55); }
@media (max-width: 899px) { .hwb-style > span { display: none; } .hwb-style button { padding: 3px 8px; } }

/* b65: top-bar account menu */
.account-menu{position:fixed;z-index:1000;min-width:240px;max-width:min(320px,calc(100vw - 16px));padding:8px;border-radius:14px;border:1px solid var(--line);background:var(--panel);color:var(--ink);box-shadow:0 18px 48px -18px rgb(0 0 0/.45),0 2px 6px rgb(0 0 0/.08);display:flex;flex-direction:column;gap:2px}
.account-menu-head{display:flex;align-items:center;gap:10px;padding:8px 8px 6px}
.account-menu-avatar{flex:none;width:36px;height:36px;border-radius:50%;display:grid;place-items:center;font-weight:700;font-size:14px;background:var(--primary-soft);color:var(--primary)}
.account-menu-who{display:flex;flex-direction:column;min-width:0}
.account-menu-who strong{font-size:14px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.account-menu-who small{font-size:12px;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.account-menu-role{align-self:flex-start;margin:0 8px 6px 54px;font-size:11.5px;padding:2px 8px;border-radius:999px;background:var(--panel-raised);color:var(--muted);border:1px solid var(--line)}
.account-menu button{font:inherit;font-size:13.5px;text-align:left;padding:9px 10px;border:0;border-radius:9px;background:none;color:inherit;cursor:pointer}
.account-menu button:hover,.account-menu button:focus-visible{background:var(--surface-hover,var(--panel-raised));outline:none}
.account-menu button.danger{color:var(--danger,var(--primary))}
.account-menu button + button{border-top:1px solid transparent}


/* ===== AI 电商换装：传参页（左上传 + 右详情/历史） ===== */
.portal-tryon-shell {
  width: min(1680px, 100%);
  max-width: none;
  padding-bottom: 40px;
}
.portal-tryon-layout {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.portal-tryon-left,
.portal-tryon-right {
  border: 1px solid var(--line, #e5e7eb);
  border-radius: 18px;
  background: var(--surface, var(--panel, #fff));
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
  overflow: hidden;
}
.portal-tryon-left {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0 0 14px;
}
.portal-tryon-panel {
  padding: 16px 16px 8px;
  border-bottom: 1px solid var(--line, #eef0f3);
}
.portal-tryon-panel h2 {
  margin: 0 0 12px;
  font-size: 14px;
  letter-spacing: 0.02em;
}
.portal-tryon-slot {
  border: 1px solid var(--line, #e5e7eb);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 12px;
  background: var(--surface-soft, var(--panel-raised, #fafafa));
  transition: border-color .15s ease, box-shadow .15s ease;
}
.portal-tryon-slot.dragging,
.portal-tryon-garments.dragging {
  border-color: var(--primary, #c8102e);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--primary, #c8102e) 18%, transparent);
}
.portal-tryon-slot > header {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 10px;
}
.portal-tryon-slot > header strong { font-size: 13px; }
.portal-tryon-slot > header small { color: var(--text-muted, var(--muted, #6b7280)); font-size: 12px; }
.portal-tryon-slot-body {
  border: 1px dashed color-mix(in oklch, var(--line, #d1d5db) 80%, var(--primary, #c8102e) 20%);
  border-radius: 12px;
  min-height: 160px;
  overflow: hidden;
  cursor: pointer;
  background: var(--surface, var(--panel, #fff));
}
.portal-tryon-slot.has-file .portal-tryon-slot-body {
  border-style: solid;
  cursor: default;
  background: #0b0b0c;
}
.portal-tryon-empty {
  min-height: 160px;
  display: grid;
  place-content: center;
  gap: 6px;
  text-align: center;
  padding: 16px;
  color: var(--text-muted, var(--muted, #6b7280));
}
.portal-tryon-empty strong { color: var(--text, var(--ink, #111827)); font-size: 13px; }
.portal-tryon-empty-icon {
  width: 44px;
  height: 44px;
  margin: 0 auto 4px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: color-mix(in oklch, var(--primary, #c8102e) 10%, var(--surface, #fff));
  color: var(--primary, #c8102e);
}
.portal-tryon-empty-icon svg { width: 22px; height: 22px; }
.portal-tryon-preview {
  position: relative;
  min-height: 160px;
  display: grid;
  place-items: center;
  background: #0b0b0c;
}
.portal-tryon-preview img {
  width: 100%;
  height: 180px;
  object-fit: contain;
}
.portal-tryon-slot-status {
  position: absolute;
  left: 8px;
  bottom: 8px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(0,0,0,.65);
  color: #fff;
}
.portal-tryon-slot[data-status="error"] .portal-tryon-slot-status { background: #b91c1c; }
.portal-tryon-slot-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.portal-tryon-garments-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 4px 0 10px;
}
.portal-tryon-garments-head small { color: var(--text-muted, var(--muted, #6b7280)); }
.portal-tryon-garment-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.portal-tryon-garment-card,
.portal-tryon-garment-add {
  position: relative;
  border: 1px solid var(--line, #e5e7eb);
  border-radius: 12px;
  min-height: 110px;
  overflow: hidden;
  background: var(--surface, var(--panel, #fff));
}
.portal-tryon-garment-card img {
  width: 100%;
  height: 110px;
  object-fit: cover;
  display: block;
  background: #111;
}
.portal-tryon-garment-card span {
  position: absolute;
  left: 6px;
  bottom: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
  background: rgba(0,0,0,.65);
  color: #fff;
}
.portal-tryon-garment-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 999px;
  background: rgba(0,0,0,.7);
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}
.portal-tryon-garment-add {
  display: grid;
  place-content: center;
  gap: 4px;
  text-align: center;
  cursor: pointer;
  border-style: dashed;
  color: var(--text-muted, var(--muted, #6b7280));
  background: var(--surface-soft, var(--panel-raised, #fafafa));
}
.portal-tryon-garment-add strong { color: var(--text, var(--ink, #111827)); font-size: 12px; }
.portal-tryon-garment-add svg { width: 18px; height: 18px; color: var(--primary, #c8102e); }
.portal-tryon-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  margin-bottom: 12px;
}
.portal-tryon-field select {
  border: 1px solid var(--line, #d1d5db);
  border-radius: 10px;
  padding: 9px 11px;
  background: var(--surface, var(--panel, #fff));
  color: inherit;
}
.portal-tryon-prompt-banner {
  margin: 0 0 4px;
}
.portal-tryon-prompt-banner code {
  font-size: 12px;
  padding: 1px 5px;
  border-radius: 6px;
  background: var(--surface-soft, var(--panel-raised, #f3f4f6));
}
.portal-tryon-actionbar {
  padding: 14px 16px 0;
  display: grid;
  gap: 10px;
}
.portal-tryon-run {
  width: 100%;
  min-height: 46px;
  font-size: 15px;
  border-radius: 12px;
}
.portal-tryon-run:disabled {
  opacity: .55;
  cursor: not-allowed;
}
.portal-tryon-action-status {
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface-soft, var(--panel-raised, #f3f4f6));
}
.portal-tryon-action-status strong { display: block; font-size: 13px; }
.portal-tryon-action-status small { color: var(--text-muted, var(--muted, #6b7280)); }
.portal-tryon-tabs {
  display: flex;
  gap: 4px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line, #eef0f3);
  background: var(--surface-soft, var(--panel-raised, #fafafa));
}
.portal-tryon-tab {
  border: 0;
  background: transparent;
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted, var(--muted, #6b7280));
  cursor: pointer;
}
.portal-tryon-tab.active {
  background: color-mix(in oklch, var(--primary, #c8102e) 12%, var(--surface, #fff));
  color: var(--primary, #c8102e);
}
.portal-tryon-detail,
.portal-tryon-history {
  padding: 16px;
}
.portal-tryon-cover {
  border-radius: 14px;
  overflow: hidden;
  background: #111;
  margin-bottom: 16px;
}
.portal-tryon-cover img {
  width: 100%;
  height: auto;
  max-height: none;
  object-fit: contain;
  display: block;
}
.portal-tryon-detail-copy h3 {
  margin: 0 0 8px;
  font-size: 15px;
}
.portal-tryon-detail-copy p,
.portal-tryon-detail-copy li {
  color: var(--text-muted, var(--muted, #4b5563));
  font-size: 13px;
  line-height: 1.6;
}
.portal-tryon-detail-copy ul {
  margin: 10px 0 0;
  padding-left: 18px;
}
.portal-tryon-history-grid {
  display: grid;
  gap: 12px;
}
.portal-tryon-history-card {
  border: 1px solid var(--line, #e5e7eb);
  border-radius: 14px;
  padding: 10px;
  display: grid;
  grid-template-columns: 72px 1fr;
  grid-template-rows: auto auto;
  gap: 8px 10px;
  background: var(--surface, var(--panel, #fff));
}
.portal-tryon-history-card.active {
  border-color: color-mix(in oklch, var(--primary, #c8102e) 55%, var(--line, #e5e7eb));
  box-shadow: 0 0 0 1px color-mix(in oklch, var(--primary, #c8102e) 35%, transparent);
}
.portal-tryon-history-thumb {
  grid-row: 1 / span 2;
  width: 72px;
  height: 72px;
  border: 0;
  border-radius: 12px;
  overflow: hidden;
  background: #111;
  color: #fff;
  cursor: pointer;
  padding: 0;
  display: grid;
  place-items: center;
}
.portal-tryon-history-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.portal-tryon-history-copy {
  display: grid;
  gap: 2px;
  align-content: start;
}
.portal-tryon-history-copy strong { font-size: 13px; }
.portal-tryon-history-copy small { color: var(--text-muted, var(--muted, #6b7280)); }
.portal-tryon-history-copy .error { color: #b91c1c; margin: 4px 0 0; font-size: 12px; }
.portal-tryon-history-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  grid-column: 2;
}
.portal-tryon-result-preview {
  margin-top: 14px;
  border-radius: 14px;
  overflow: hidden;
  background: #0b0b0c;
}
.portal-tryon-result-preview img {
  width: 100%;
  max-height: 480px;
  object-fit: contain;
  display: block;
}
html[data-theme="dark"] .portal-tryon-left,
html[data-theme="dark"] .portal-tryon-right,
html[data-theme="dark"] .portal-tryon-history-card,
html[data-theme="dark"] .portal-tryon-slot,
html[data-theme="dark"] .portal-tryon-garment-card,
html[data-theme="dark"] .portal-tryon-garment-add {
  background: var(--surface, var(--panel, #15181e));
  box-shadow: none;
}
html[data-theme="dark"] .portal-tryon-tabs {
  background: color-mix(in oklch, var(--surface, #15181e) 88%, #000 12%);
}
@media (max-width: 960px) {
  .portal-tryon-layout {
    grid-template-columns: 1fr;
  }
}


/* Shared param-form extras (hunyuan panorama/scene etc.) */
.portal-param-scene-field textarea {
  border: 1px solid var(--line, #d1d5db);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--surface, var(--panel, #fff));
  color: var(--text, var(--ink, #111827));
  font: inherit;
  line-height: 1.45;
  resize: vertical;
  min-height: 96px;
  width: 100%;
  box-sizing: border-box;
}
.portal-param-scene-field textarea::placeholder {
  color: var(--text-muted, var(--muted, #9ca3af));
}
.portal-param-file-result {
  display: grid;
  gap: 10px;
  place-items: start;
  padding: 16px;
}
.portal-param-file-result p {
  margin: 0;
  color: var(--text-muted, var(--muted, #6b7280));
  font-size: 13px;
}
.portal-param-active.portal-tryon-active .portal-tryon-cover img {
  width: 100%;
  height: auto;
  max-height: none;
  object-fit: contain;
  display: block;
  background: #0b0b0c;
}

.portal-param-media-preview {
  display: grid;
  gap: 8px;
  justify-items: center;
}
.portal-param-media-preview video,
.portal-param-media-preview audio {
  width: 100%;
  max-height: 180px;
  border-radius: 10px;
  background: #0b0b0c;
}
.portal-param-media-preview small {
  color: var(--text-muted, #9ca3af);
  font-size: 12px;
  word-break: break-all;
}
.portal-param-check {
  display: flex !important;
  align-items: flex-start;
  gap: 8px;
  flex-direction: row !important;
}
.portal-param-check input[type="checkbox"] {
  margin-top: 3px;
  width: auto;
}
