/* Harbor UI primitives — use with --hb-* tokens */

.hb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  max-width: 100%;
  gap: var(--hb-space-2);
  min-height: 2.65rem;
  padding: 0.5rem 1rem;
  border-radius: var(--hb-radius);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: var(--hb-text-sm);
  line-height: 1.35;
  letter-spacing: -0.01em;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  cursor: pointer;
  outline: none;
  transition:
    background 0.16s ease,
    color 0.16s ease,
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    transform 0.12s ease;
}

.hb-btn:focus-visible {
  border-color: color-mix(in srgb, var(--hb-brand) 55%, var(--hb-line));
  box-shadow: 0 0 0 3px var(--hb-brand-soft);
}

.hb-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/*
 * 主按鈕、選中的 tab、側欄與 dock 的選中項共用同一個配方：實心 --hb-brand +
 * --hb-brand-on。主色是淺藍，漸層到 --hb-brand-deep 會讓近黑字在深端失去對比，
 * 所以這裡不用漸層，深淺兩個主題也不需要各寫一份。
 */
.hb-btn--primary {
  background: var(--hb-brand);
  color: var(--hb-brand-on);
  box-shadow: var(--hb-shadow-soft);
  border-color: transparent;
}

.hb-btn--primary:hover:not(:disabled) {
  transform: translateY(-0.5px);
  background: var(--hb-brand-hover);
  box-shadow: var(--hb-shadow-glow), var(--hb-shadow-soft);
}

.hb-btn--secondary {
  background: color-mix(in srgb, var(--hb-brand) 10%, var(--hb-surface-solid));
  color: var(--hb-ink);
  border-color: transparent;
  box-shadow: 0 1px 2px color-mix(in srgb, var(--hb-ink) 6%, transparent);
}

.hb-btn--secondary:hover:not(:disabled) {
  background: color-mix(in srgb, var(--hb-magic) 22%, var(--hb-surface-solid));
  color: var(--hb-ink);
}

.hb-btn--ghost {
  background: color-mix(in srgb, var(--hb-surface-solid) 70%, transparent);
  color: var(--hb-ink-secondary);
  border-color: var(--hb-line-strong, var(--hb-line));
  backdrop-filter: blur(8px);
}

.hb-btn--ghost:hover:not(:disabled) {
  background: var(--hb-brand-soft);
  color: var(--hb-brand-deep);
  border-color: color-mix(in srgb, var(--hb-brand) 40%, var(--hb-line));
}

.hb-btn--danger {
  background: var(--hb-danger);
  color: var(--hb-danger-on);
}

.hb-btn--danger:hover:not(:disabled) {
  filter: brightness(0.95);
}

.hb-field {
  display: flex;
  flex-direction: column;
  gap: var(--hb-gap-tight);
  margin: 0;
  min-width: 0;
  max-width: 100%;
}

.hb-field__label {
  display: block;
  max-width: 100%;
  font-size: var(--hb-text-sm);
  font-weight: 600;
  color: var(--hb-ink-secondary);
  margin: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.hb-field__required {
  color: var(--hb-danger);
  margin-inline-start: 0.25rem;
}

.hb-field__hint {
  font-size: var(--hb-text-sm);
  color: var(--hb-muted);
  line-height: 1.5;
  margin: 0;
}

.hb-field__error {
  font-size: var(--hb-text-sm);
  color: var(--hb-danger-deep);
  line-height: 1.5;
  margin: 0;
}

.hb-field.is-invalid .hb-input,
.hb-field.is-invalid .hb-textarea,
.hb-field.is-invalid .hb-select {
  border-color: color-mix(in srgb, var(--hb-danger) 70%, var(--hb-line));
}

.hb-field.is-invalid .hb-input:focus,
.hb-field.is-invalid .hb-textarea:focus,
.hb-field.is-invalid .hb-select:focus {
  border-color: var(--hb-danger);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--hb-danger) 22%, transparent);
}

.hb-input-shell {
  position: relative;
  display: block;
  width: 100%;
  min-width: 0;
}

.hb-input-shell.has-reveal .hb-input {
  padding-inline-end: 2.75rem;
}

.hb-password-toggle {
  position: absolute;
  top: 50%;
  right: 0.35rem;
  display: grid;
  place-items: center;
  width: 2.1rem;
  height: 2.1rem;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: var(--hb-radius);
  background: transparent;
  color: var(--hb-muted);
  transform: translateY(-50%);
  cursor: pointer;
}

.hb-password-toggle:hover,
.hb-password-toggle:focus-visible {
  color: var(--hb-ink);
  background: color-mix(in srgb, var(--hb-brand) 10%, transparent);
}

.hb-password-toggle:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--hb-brand) 65%, var(--hb-line));
  outline-offset: 1px;
}

.hb-input,
.hb-textarea,
.hb-select {
  width: 100%;
  min-height: 2.8rem;
  padding: 0.65rem 0.95rem;
  border: 1px solid var(--hb-line-strong, var(--hb-line));
  border-radius: var(--hb-radius);
  background: var(--hb-surface-solid, var(--hb-surface));
  color: var(--hb-ink);
  font-size: var(--hb-text-input, 1rem);
  line-height: 1.5;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.hb-input:focus,
.hb-textarea:focus,
.hb-select:focus {
  border-color: color-mix(in srgb, var(--hb-brand) 65%, var(--hb-line));
  box-shadow: 0 0 0 3px var(--hb-brand-soft);
}

.hb-input::placeholder,
.hb-textarea::placeholder {
  color: var(--hb-subtle);
}

.hb-textarea {
  min-height: 6.5rem;
  resize: vertical;
}

.hb-select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--hb-muted) 50%),
    linear-gradient(135deg, var(--hb-muted) 50%, transparent 50%);
  background-position: calc(100% - 1.1rem) calc(50% - 0.15rem), calc(100% - 0.75rem) calc(50% - 0.15rem);
  background-size: 0.35rem 0.35rem, 0.35rem 0.35rem;
  background-repeat: no-repeat;
  padding-right: 2rem;
}

.hb-card {
  background: var(--hb-surface);
  backdrop-filter: blur(12px) saturate(125%);
  -webkit-backdrop-filter: blur(12px) saturate(125%);
  border: 1px solid color-mix(in srgb, var(--hb-brand) 14%, var(--hb-line));
  border-radius: var(--hb-radius-xl);
  box-shadow: var(--hb-shadow-card);
  padding: var(--hb-space-4);
  min-width: 0;
  max-width: 100%;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--hb-gap-stack);
}

.hb-card > .hb-stack {
  gap: var(--hb-gap-stack);
}

@media (min-width: 600px) {
  .hb-card {
    padding: var(--hb-space-5);
  }
}

.hb-card__title {
  margin: 0;
  font-size: var(--hb-text-lg);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.35;
}

.hb-card__body {
  margin: 0;
  color: var(--hb-ink-secondary);
  line-height: 1.6;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--hb-gap-stack);
}

/* 若 body 內再包 .hb-stack，避免雙重過大 gap 時仍至少一致 */
.hb-card__body > .hb-stack {
  gap: var(--hb-gap-stack);
}

.hb-badge {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 0.25rem 0.75rem;
  border-radius: var(--hb-radius-pill);
  font-size: var(--hb-text-xs);
  font-weight: 650;
  line-height: 1.35;
  white-space: normal;
  overflow-wrap: anywhere;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
}

.hb-badge--neutral {
  background: color-mix(in srgb, var(--hb-surface-muted) 90%, var(--hb-line));
  color: var(--hb-ink-secondary);
  border-color: color-mix(in srgb, var(--hb-line) 70%, transparent);
}

.hb-badge--brand {
  background: var(--hb-brand-soft);
  color: var(--hb-brand-deep);
  border-color: color-mix(in srgb, var(--hb-brand) 28%, transparent);
}

.hb-badge--success {
  background: var(--hb-success-soft);
  color: var(--hb-success);
  border-color: color-mix(in srgb, var(--hb-success) 16%, transparent);
}

.hb-badge--danger {
  background: var(--hb-danger-soft);
  color: var(--hb-danger-deep);
  border-color: color-mix(in srgb, var(--hb-danger) 16%, transparent);
}

.hb-badge--warning {
  background: var(--hb-warning-soft);
  color: var(--hb-warning-deep);
  border-color: color-mix(in srgb, var(--hb-warning) 18%, transparent);
}

.hb-empty {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--hb-gap-stack);
  padding: var(--hb-space-6) var(--hb-space-5);
  border: 1px dashed var(--hb-line);
  border-radius: var(--hb-radius-lg);
  background: var(--hb-surface);
  margin: 0;
}

.hb-empty__title {
  margin: 0;
  font-size: var(--hb-text-lg);
  font-weight: 700;
}

.hb-empty__desc {
  margin: 0;
  color: var(--hb-muted);
  line-height: 1.7;
  max-width: 28rem;
}

.hb-tabs {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.25rem;
  margin: 0 0 var(--hb-gap-stack);
  padding: 0.28rem;
  border: 1px solid color-mix(in srgb, var(--hb-line) 85%, transparent);
  border-radius: var(--hb-radius-pill);
  background: color-mix(in srgb, var(--hb-surface) 70%, var(--hb-brand-soft));
  width: 100%;
  max-width: 100%;
  box-shadow: 0 1px 2px color-mix(in srgb, var(--hb-brand) 8%, transparent);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.hb-tabs::-webkit-scrollbar {
  display: none;
}

.hb-tabs .hb-tab {
  flex: 1 0 auto;
  text-align: center;
  white-space: nowrap;
  min-height: 2.4rem;
}

@media (min-width: 720px) {
  .hb-tabs {
    width: fit-content;
    flex-wrap: wrap;
    margin-bottom: var(--hb-gap-block);
  }

  .hb-tabs .hb-tab {
    flex: 0 0 auto;
    min-height: 0;
  }
}

.hb-tabs--segment {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.2rem;
  border-radius: var(--hb-radius);
  padding: 0.22rem;
}

.hb-tabs--segment .hb-tab {
  width: 100%;
  text-align: center;
  min-height: var(--hb-touch);
  border-radius: calc(var(--hb-radius) - 0.1rem);
  padding: 0.55rem 0.75rem;
}

.hb-tab {
  border: 0;
  background: transparent;
  color: var(--hb-muted);
  font: inherit;
  font-weight: 600;
  font-size: var(--hb-text-sm);
  padding: 0.5rem 1.1rem;
  border-radius: var(--hb-radius-pill);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.hb-tab:hover {
  color: var(--hb-brand-deep);
  background: color-mix(in srgb, var(--hb-surface) 60%, transparent);
}

/* segment 樣式的 tab 是「白片浮起」，選中只換字色。 */
.hb-tab.is-active {
  background: var(--hb-surface);
  color: var(--hb-brand-deep);
  box-shadow: 0 1px 4px color-mix(in srgb, var(--hb-brand-deep) 18%, transparent);
}

/* 一般 tab 走與側欄選單相同的實心主色塊。 */
.hb-tabs:not(.hb-tabs--segment) .hb-tab.is-active {
  background: var(--hb-brand);
  color: var(--hb-brand-on);
  box-shadow: 0 2px 8px color-mix(in srgb, var(--hb-brand-deep) 24%, transparent);
}

[data-theme="dark"] .hb-badge--brand {
  background: color-mix(in srgb, var(--hb-brand) 14%, var(--hb-surface-solid));
  color: var(--hb-brand-deep);
  border-color: color-mix(in srgb, var(--hb-brand) 28%, transparent);
}

[data-theme="dark"] .hb-nav__item--active,
[data-theme="dark"] .hb-dock__item--active {
  background: color-mix(in srgb, var(--hb-brand) 14%, transparent);
  color: var(--hb-brand-deep);
}

.hb-grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--hb-gap-stack);
}

@media (min-width: 720px) {
  .hb-grid-2 {
    grid-template-columns: 1fr 1fr;
  }
}

.hb-inline-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.hb-banner-ok,
.hb-banner-warn,
.hb-banner-error {
  margin: 0;
  padding: 0.8rem 1rem;
  border-radius: var(--hb-radius);
  font-size: var(--hb-text-sm);
  line-height: 1.5;
}

.hb-banner-ok {
  border: 1px solid color-mix(in srgb, var(--hb-success) 35%, var(--hb-line));
  background: var(--hb-success-soft);
  color: var(--hb-ink);
}

.hb-banner-warn {
  border: 1px solid color-mix(in srgb, var(--hb-warning) 40%, var(--hb-line));
  background: var(--hb-warning-soft);
  color: var(--hb-ink);
}

.hb-banner-error {
  border-color: color-mix(in srgb, var(--hb-danger) 40%, var(--hb-line));
  background: color-mix(in srgb, var(--hb-danger) 10%, var(--hb-surface));
  color: var(--hb-danger-deep);
}

.hb-check-row {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  font-size: var(--hb-text-sm);
  line-height: 1.5;
  cursor: pointer;
}

.hb-check-row input {
  margin-top: 0.25rem;
}

.hb-ol {
  margin: 0;
  padding-left: 1.25rem;
  color: var(--hb-ink-secondary);
  line-height: 1.8;
}

.hb-mt-2 {
  margin-top: var(--hb-space-2);
}

/* 間距交給 gap，禁止靠 margin 硬疊造成貼死或雙縫 */
.hb-stack > .hb-card,
.hb-stack > .hb-empty,
.hb-main__inner > .hb-card,
.hb-main__inner > .hb-empty,
.hb-main__inner > .hb-stack,
.hb-main__inner > .hb-section {
  margin-top: 0;
  margin-bottom: 0;
}

.hb-studio-bar {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--hb-gap-stack);
  margin: 0 0 var(--hb-gap-section);
  padding: var(--hb-space-5);
  border: 1px solid var(--hb-line);
  border-radius: var(--hb-radius-lg);
  background: var(--hb-surface);
}

@media (min-width: 720px) {
  .hb-studio-bar {
    grid-template-columns: 1fr 1fr;
    align-items: end;
  }

  .hb-studio-bar__hint {
    grid-column: 1 / -1;
  }
}

.hb-studio-bar__hint {
  margin: 0;
  font-size: var(--hb-text-sm);
}

.hb-brand-create-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--hb-space-3);
  align-items: end;
}

@media (min-width: 720px) {
  .hb-brand-create-row {
    grid-template-columns: 1fr auto;
  }

  .hb-brand-create-row--topic {
    grid-template-columns: 1fr 1fr 1fr auto;
  }
}

.hb-product-form {
  display: flex;
  flex-direction: column;
  gap: var(--hb-gap-stack);
  padding: var(--hb-space-5);
  border: 1px solid var(--hb-line);
  border-radius: var(--hb-radius-lg);
  background: var(--hb-surface-muted);
  margin: 0;
}

.hb-product-import {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--hb-space-2);
  align-items: end;
}

@media (min-width: 720px) {
  .hb-product-import {
    grid-template-columns: 1fr auto;
  }
}

.hb-script-row.is-editing {
  border-color: var(--hb-brand);
  background: var(--hb-brand-soft);
}

.hb-brand-pick {
  cursor: pointer;
  text-align: left;
  width: 100%;
  border: 1px solid var(--hb-line);
  background: var(--hb-surface);
  font: inherit;
  color: inherit;
}

.hb-brand-pick.is-selected {
  border-color: color-mix(in srgb, var(--hb-brand) 45%, var(--hb-line));
  background: var(--hb-brand-soft);
}

.hb-linkish {
  border: 0;
  background: none;
  padding: 0;
  color: var(--hb-brand-deep);
  font: inherit;
  font-size: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.hb-text-link {
  border: 0;
  background: none;
  padding: 0;
  color: var(--hb-brand-deep);
  font: inherit;
  font-size: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.hb-text-link:hover {
  color: var(--hb-brand-hover, var(--hb-brand));
}

.hb-reply-thread {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin: 0.5rem 0 0.65rem;
  padding-left: 0.75rem;
  border-left: 2px solid var(--hb-brand-soft, color-mix(in srgb, var(--hb-brand) 35%, var(--hb-line)));
}

.hb-reply-child {
  padding: 0.55rem 0.7rem;
  border-radius: var(--hb-radius);
  border: 1px solid var(--hb-line);
  background: var(--hb-surface);
  font-size: var(--hb-text-sm);
}

.hb-reply-child.is-mine {
  border-color: color-mix(in srgb, var(--hb-brand) 40%, var(--hb-line));
  background: color-mix(in srgb, var(--hb-brand-soft, var(--hb-surface-muted)) 55%, var(--hb-surface));
}

.hb-reply-composer {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-top: 0.35rem;
  padding: 0.75rem;
  border: 1px solid var(--hb-line);
  border-radius: var(--hb-radius);
  background: var(--hb-surface-muted);
}

.hb-reply-composer__meta {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.65rem;
}

@media (min-width: 640px) {
  .hb-reply-composer__meta {
    grid-template-columns: 1fr 1fr;
  }
}

.hb-post-head {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  margin-bottom: 0.5rem;
}

.hb-post-head__body {
  flex: 1;
  min-width: 0;
}

.hb-post-thumb {
  width: 4.25rem;
  height: 4.25rem;
  border-radius: var(--hb-radius);
  object-fit: cover;
  border: 1px solid var(--hb-line);
  flex-shrink: 0;
  background: var(--hb-surface-muted);
}

.hb-metrics-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.65rem;
  margin: 0.25rem 0 0.35rem;
}

.hb-metrics-chip {
  font-size: var(--hb-text-xs);
  color: var(--hb-ink-secondary);
  white-space: nowrap;
}

.hb-metrics-chip strong {
  color: var(--hb-ink);
  font-variant-numeric: tabular-nums;
}

.hb-metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin: 0.65rem 0 0.75rem;
  padding: 0.65rem;
  border-radius: var(--hb-radius);
  background: var(--hb-surface-muted);
  border: 1px solid var(--hb-line);
}

@media (min-width: 520px) {
  .hb-metrics-grid {
    grid-template-columns: repeat(6, 1fr);
  }
}

.hb-metrics-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  text-align: center;
}

.hb-metrics-cell__val {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: var(--hb-text-base);
}

.hb-metrics-cell__label {
  font-size: var(--hb-text-2xs);
  color: var(--hb-muted);
}

.hb-thumb-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.hb-thumb {
  width: 4.5rem;
  height: 4.5rem;
  border-radius: var(--hb-radius);
  border: 1px solid var(--hb-line);
  object-fit: cover;
  background: var(--hb-surface-muted);
}

.hb-image-attach {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.hb-thumb-item {
  position: relative;
  display: inline-block;
}

.hb-thumb-item__remove {
  position: absolute;
  top: -0.3rem;
  right: -0.3rem;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 999px;
  border: 1px solid var(--hb-line);
  background: var(--hb-surface);
  color: var(--hb-text);
  font-size: var(--hb-text-sm);
  line-height: 1;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hb-thumb-item__badge {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: var(--hb-text-sm);
  font-weight: 600;
  color: var(--hb-fg);
  background: color-mix(in srgb, var(--hb-surface-solid) 85%, transparent);
  border-radius: 999px;
  padding: 0.1rem 0.4rem;
  pointer-events: none;
}
.hb-thumb-item__retry {
  position: absolute;
  left: 0.2rem;
  bottom: 0.2rem;
  z-index: 1;
  border: none;
  border-radius: 4px;
  font-size: var(--hb-text-2xs);
  padding: 0.1rem 0.3rem;
  cursor: pointer;
  background: var(--hb-danger);
  color: var(--hb-danger-on);
}
.hb-thumb-item__retry:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.hb-thumb-item__remove:hover:not(:disabled) {
  background: var(--hb-surface-muted);
}

.hb-thumb-item__remove:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

.hb-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: var(--hb-gap-inline);
  margin: 0 0 var(--hb-gap-stack);
}

.hb-toolbar > .hb-btn {
  flex: 1 1 auto;
  min-width: min(100%, 8.5rem);
}

.hb-toolbar__hint {
  margin: 0;
  font-size: var(--hb-text-sm);
  flex: 1 1 100%;
  min-width: 0;
  line-height: 1.5;
}

@media (min-width: 640px) {
  .hb-toolbar {
    align-items: center;
    gap: 0.65rem 1rem;
  }

  .hb-toolbar > .hb-btn {
    flex: 0 0 auto;
    min-width: 0;
  }

  .hb-toolbar__hint {
    flex: 1 1 auto;
    min-width: 12rem;
  }
}

.hb-compact-list {
  list-style: none;
  margin: 0;
  padding: 0.25rem 0;
  border: 1px solid color-mix(in srgb, var(--hb-line) 90%, transparent);
  border-radius: var(--hb-radius-xl);
  background: var(--hb-surface);
  box-shadow: var(--hb-shadow-card);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.hb-compact-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.75rem 0.85rem;
  padding: 1.05rem 1rem;
  border-bottom: 1px solid color-mix(in srgb, var(--hb-line) 75%, transparent);
  transition: background 0.12s ease;
  align-items: start;
}

/* 頭像 + 內文同一列；操作鍵整列在下 */
.hb-compact-row > .hb-avatar {
  grid-row: 1;
  grid-column: 1;
}

.hb-compact-row__body {
  grid-row: 1;
  grid-column: 2;
  min-width: 0;
}

.hb-compact-row__actions {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
}

.hb-compact-row:hover {
  background: color-mix(in srgb, var(--hb-brand-soft) 35%, var(--hb-surface));
}

.hb-compact-row:last-child {
  border-bottom: 0;
}

.hb-compact-row__title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.45rem;
  margin-bottom: 0.35rem;
}

.hb-compact-row__title strong {
  letter-spacing: -0.01em;
  word-break: break-word;
}

.hb-compact-row__meta {
  margin: 0.3rem 0 0;
  font-size: var(--hb-text-xs);
  line-height: 1.45;
  word-break: break-word;
}

.hb-compact-row__action {
  min-height: 2.4rem;
  padding: 0.35rem 0.65rem;
  white-space: nowrap;
  font-size: var(--hb-text-xs);
  width: 100%;
}

@media (min-width: 640px) {
  .hb-compact-row {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    padding: 1rem 1.1rem;
  }

  .hb-compact-row__body {
    flex: 1;
  }

  .hb-compact-row__actions {
    display: flex;
    flex-direction: row;
    align-items: center;
    flex-shrink: 0;
    width: auto;
  }

  .hb-compact-row__action {
    width: auto;
    min-height: 2.15rem;
  }
}

.hb-master-detail {
  display: grid;
  gap: var(--hb-gap-section);
  align-items: start;
  margin: 0;
}

.hb-md-list,
.hb-md-detail {
  min-width: 0;
}

.hb-md-detail {
  padding: var(--hb-space-5);
  border: 1px solid var(--hb-line);
  border-radius: var(--hb-radius-lg);
  background: var(--hb-surface);
  display: flex;
  flex-direction: column;
  gap: var(--hb-gap-stack);
  margin: 0;
}

.hb-md-detail__head {
  margin: 0;
}

.hb-md-detail__title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.25rem;
}

.hb-back-link {
  display: none;
  border: 0;
  background: transparent;
  color: var(--hb-brand-deep);
  font: inherit;
  font-size: var(--hb-text-sm);
  font-weight: 600;
  padding: 0;
  cursor: pointer;
  margin-bottom: 0.35rem;
}

.hb-tabs--sm .hb-tab {
  padding: 0.35rem 0.75rem;
  font-size: var(--hb-text-xs);
}

.hb-persona-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.hb-persona-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.25rem 0.75rem;
  width: 100%;
  text-align: left;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--hb-line);
  border-radius: var(--hb-radius);
  background: var(--hb-surface);
  cursor: pointer;
  font: inherit;
  color: inherit;
}

.hb-persona-item:hover {
  border-color: var(--hb-brand);
}

.hb-persona-item.is-active {
  border-color: var(--hb-brand);
  background: var(--hb-brand-soft);
}

.hb-persona-item__name {
  font-weight: 700;
}

.hb-persona-item__tone {
  grid-column: 1 / -1;
  font-size: var(--hb-text-sm);
}

/* Desktop: side-by-side master-detail */
@media (min-width: 900px) {
  .hb-master-detail {
    grid-template-columns: minmax(14rem, 17rem) 1fr;
  }

  .hb-back-link {
    display: none !important;
  }

  .hb-md-list {
    position: sticky;
    top: calc(var(--hb-topbar-height, 3.5rem) + 0.5rem);
  }
}

/* Mobile: list OR detail */
@media (max-width: 899px) {
  .hb-master-detail.is-list .hb-md-detail {
    display: none;
  }

  .hb-master-detail.is-detail .hb-md-list {
    display: none;
  }

  .hb-back-link {
    display: inline-block;
  }
}

.hb-dim-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.65rem;
}

@media (min-width: 720px) {
  .hb-dim-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.hb-dim-card {
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--hb-line);
  border-radius: var(--hb-radius);
  background: var(--hb-surface-muted);
}

.hb-dim-card strong {
  display: block;
  font-size: var(--hb-text-sm);
  margin-bottom: 0.35rem;
  color: var(--hb-brand-deep);
}

.hb-dim-card p {
  margin: 0;
  font-size: var(--hb-text-sm);
  line-height: 1.55;
}

.hb-evidence {
  margin: 0.4rem 0 0;
  padding-left: 1rem;
  color: var(--hb-muted);
  font-size: var(--hb-text-xs);
}
