:root {
  --bg: #f4efe7;
  --surface: rgba(255, 250, 244, 0.84);
  --ink: #20150d;
  --muted: #705d4c;
  --line: rgba(46, 25, 11, 0.12);
  --accent: #f06f2f;
  --accent-dark: #b34718;
  --shadow: 0 24px 70px rgba(86, 46, 15, 0.12);
  --radius-xl: 32px;
  --radius-lg: 24px;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Inter", "Noto Sans SC", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255, 193, 123, 0.55), transparent 28%),
    radial-gradient(circle at 80% 10%, rgba(244, 124, 45, 0.18), transparent 24%),
    linear-gradient(180deg, #f9f1e5 0%, var(--bg) 52%, #efe4d5 100%);
}

body.lightbox-open {
  overflow: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(rgba(32, 21, 13, 0.035) 1px, transparent 1px), linear-gradient(90deg, rgba(32, 21, 13, 0.035) 1px, transparent 1px);
  background-size: 22px 22px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.5), transparent 88%);
}

.page-shell {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 28px clamp(8px, 2vw, 28px) 68px;
}

img,
video,
canvas,
svg {
  max-width: 100%;
}

.topbar,
.hero-card,
.panel {
  backdrop-filter: blur(18px);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}


.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 17px;
  padding: 18px 30px;
  border-radius: var(--radius-xl);
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brand-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: linear-gradient(145deg, #ffdf9f, #f47a32);
  color: white;
  font: 700 1.1rem "Space Grotesk", sans-serif;
  flex-shrink: 0;
}

.brand-lockup h1,
.panel-heading h3 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  overflow-wrap: anywhere;
}

.brand-lockup h1 {
  font-size: 1.2rem;
}

.topbar-note,
.helper-text,
.empty-state p,
.meta-label,
.upload-subtitle,
.choice-chip small {
  color: var(--muted);
}

.user-badge {
  display: grid;
  gap: 2px;
  padding: 6px 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(46, 25, 11, 0.1);
  justify-items: center;
  text-align: center;
}

.user-badge span {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.user-badge strong {
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.12rem;
  font-weight: 800;
}

.topbar .ghost-button {
  padding: 6px 12px;
  font-size: 1rem;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--accent-dark);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.hero-card {
  margin-top: 28px;
  padding: 34px;
  border-radius: var(--radius-xl);
  display: block;
}

.studio-grid {
  display: grid;
  grid-template-columns: minmax(280px, 3fr) minmax(520px, 7fr);
  gap: 28px;
  margin-top: 30px;
}

.unified-workbench {
  gap: 0;
  position: relative;
  border-radius: var(--radius-xl);
  border: 1px solid rgba(240, 111, 47, 0.18);
  box-shadow: 0 24px 56px rgba(176, 71, 24, 0.14);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(255, 244, 231, 0.8));
  overflow: hidden;
}

.workbench-header {
  grid-column: 1 / -1;
  display: grid;
  gap: 14px;
  padding: 22px 34px 18px;
  background: rgba(255, 255, 255, 0.62);
  border-bottom: 1px solid rgba(240, 111, 47, 0.16);
}

.workbench-title-group {
  display: grid;
  gap: 4px;
}

.workbench-title-group h3 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  color: #7f3212;
  font-size: clamp(1.26rem, 1.8vw, 1.55rem);
  letter-spacing: 0.01em;
}

.workbench-lane-labels {
  display: grid;
  grid-template-columns: minmax(280px, 3fr) minmax(520px, 7fr);
  gap: 0;
}

.workbench-lane-label {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid rgba(240, 111, 47, 0.2);
  background: rgba(240, 111, 47, 0.12);
  color: #7f3212;
  font-size: 1.04rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: none;
}

.unified-workbench::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0));
}

.panel {
  border-radius: var(--radius-xl);
  padding: 32px;
}

.panel-heading {
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(46, 25, 11, 0.1);
}

.control-panel {
  background: rgba(255, 255, 255, 0.58);
  border: 0;
  padding-right: 26px;
  max-height: none;
  overflow-y: visible;
  overscroll-behavior: auto;
}

.result-panel {
  background: rgba(255, 248, 238, 0.58);
  border: 0;
  padding-left: 38px;
}

.unified-workbench .panel {
  position: relative;
  border-radius: 0;
  box-shadow: none;
  backdrop-filter: none;
  padding: 30px 34px 34px;
}

.unified-workbench .panel-heading {
  margin-bottom: 22px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(78, 47, 24, 0.14);
}

.unified-workbench .eyebrow {
  color: #9d4618;
}

.unified-workbench .panel-heading h3 {
  letter-spacing: 0.01em;
}

.generator-form,
.field-block {
  display: grid;
  gap: 14px;
}

.generator-form {
  gap: 26px;
}

.field-label {
  font-size: 0.96rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.field-select {
  width: 100%;
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid rgba(176, 84, 29, 0.28);
  background: rgba(255, 255, 255, 0.9);
  color: #4e2f18;
  padding: 10px 12px;
}

.field-select:focus {
  outline: 2px solid rgba(240, 111, 47, 0.28);
  outline-offset: 2px;
}


.upload-dropzone {
  display: grid;
  gap: 8px;
  justify-items: start;
  padding: 28px;
  border: 1.5px dashed rgba(176, 84, 29, 0.34);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(255, 243, 226, 0.95), rgba(246, 217, 187, 0.92));
  cursor: pointer;
}

.upload-dropzone input {
  display: none;
}

.upload-title {
  font-size: 1.06rem;
  font-weight: 700;
}

.upload-selection {
  min-height: 24px;
  color: #8a3713;
  font-size: 0.88rem;
  font-weight: 600;
}

.preview-frame,
.result-stage {
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid rgba(46, 25, 11, 0.08);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(247, 233, 219, 0.82));
}

.preview-frame {
  min-height: 220px;
  padding: 14px;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
}

.preview-item {
  position: relative;
  border-radius: 14px;
  overflow: visible;
  border: 1px solid rgba(46, 25, 11, 0.1);
  background: rgba(255, 255, 255, 0.72);
  min-height: 170px;
}

.preview-item img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 14px;
}

.preview-remove-button {
  position: absolute;
  top: -7px;
  right: -7px;
  width: 18px;
  height: 18px;
  border: 1.5px solid rgba(255, 255, 255, 0.88);
  border-radius: 999px;
  background: rgba(22, 14, 8, 0.82);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  z-index: 10;
}

.preview-remove-button:hover,
.preview-remove-button:focus-visible {
  background: rgba(148, 48, 9, 0.92);
}

.preview-frame img,
.result-stage img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.preview-frame img[hidden],
.result-stage img[hidden] {
  display: none !important;
}

.result-image-themed {
  width: 62%;
  max-width: 62%;
  height: auto;
  max-height: 88%;
  padding: 0;
  border-radius: 20px;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.result-gallery {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  padding: 18px;
}

.result-gallery-item {
  position: relative;
  border: 1px solid rgba(240, 111, 47, 0.24);
  border-radius: 16px;
  overflow: hidden;
  padding: 0;
  background: rgba(255, 255, 255, 0.88);
  cursor: zoom-in;
}

.result-gallery-item .result-image-themed {
  width: 100%;
  max-width: 100%;
  max-height: 360px;
  border-radius: 0;
  border: 0;
  box-shadow: none;
}

.result-gallery-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #fff7f1;
  background: rgba(111, 47, 15, 0.86);
}

.result-image-themed.is-zoomable {
  cursor: zoom-in;
}

.result-stage.has-result .result-image-themed {
  border: 1px solid rgba(240, 111, 47, 0.28);
  box-shadow: 0 24px 42px rgba(176, 71, 24, 0.22);
}


textarea {
  width: 100%;
  resize: vertical;
  min-height: 170px;
  padding: 18px 20px;
  border: 1px solid rgba(46, 25, 11, 0.12);
  border-radius: var(--radius-lg);
  background: rgba(255, 252, 248, 0.9);
  color: var(--ink);
  font: inherit;
  line-height: 1.7;
}

#prompt {
  min-height: 260px;
  height: 320px;
  max-height: 70vh;
  overflow-y: auto;
}

.auth-input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid rgba(46, 25, 11, 0.12);
  border-radius: 18px;
  background: rgba(255, 252, 248, 0.9);
  color: var(--ink);
  font: inherit;
}

.password-field-wrap {
  position: relative;
}

.password-field-wrap .auth-input {
  padding-right: 50px;
}

.password-visibility-toggle {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 240, 223, 0.9);
  color: var(--accent-dark);
  cursor: pointer;
}

.password-eye {
  position: relative;
  width: 16px;
  height: 10px;
  border: 2px solid currentColor;
  border-radius: 16px / 10px;
}

.password-eye::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  transform: translate(-50%, -50%);
}

.password-visibility-toggle[aria-pressed="true"] .password-eye::before {
  content: "";
  position: absolute;
  left: -3px;
  top: 3px;
  width: 20px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transform: rotate(-34deg);
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
[role="button"],
input[type="button"],
input[type="submit"],
input[type="reset"] {
  cursor: pointer;
}

button:disabled,
input[type="button"]:disabled,
input[type="submit"]:disabled,
input[type="reset"]:disabled {
  cursor: not-allowed;
}

textarea:focus,
.auth-input:focus,
.ghost-button:focus,
.primary-button:focus {
  outline: 2px solid rgba(240, 111, 47, 0.24);
  outline-offset: 3px;
}

.ghost-button:focus-visible,
.primary-button:focus-visible,
.nav-link-button:focus-visible,
.download-link:focus-visible,
.history-link-button:focus-visible,
.admin-tab-button:focus-visible,
.admin-subtab-button:focus-visible,
.auth-tab-button:focus-visible,
.workspace-tab:focus-visible,
.lightbox-tool-button:focus-visible,
.lightbox-close:focus-visible,
.password-visibility-toggle:focus-visible {
  outline: 3px solid rgba(240, 111, 47, 0.42);
  outline-offset: 2px;
}

.prompt-tools,
.action-row,
.result-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.prompt-split-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.split-prompt-list {
  display: grid;
  gap: 12px;
}

.split-prompt-card {
  padding: 12px;
  border-radius: 14px;
  border: 1px solid rgba(46, 25, 11, 0.1);
  background: rgba(255, 255, 255, 0.72);
  display: grid;
  gap: 10px;
}

.split-prompt-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.split-prompt-textarea {
  min-height: 96px;
  resize: vertical;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(46, 25, 11, 0.12);
  background: rgba(255, 252, 248, 0.9);
}

.split-run-button {
  padding: 8px 12px;
}

.split-tip-highlight {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid rgba(67, 160, 71, 0.35);
  background: linear-gradient(135deg, rgba(232, 245, 233, 0.95) 0%, rgba(220, 242, 224, 0.95) 100%);
  color: #1e6a32;
  font-size: 1.12rem;
  font-weight: 700;
  line-height: 1.6;
}


.ghost-button,
.primary-button {
  position: relative;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  font: inherit;
  cursor: pointer;
  user-select: none;
  transition: transform 150ms ease, box-shadow 170ms ease, filter 170ms ease, background 170ms ease, color 170ms ease, border-color 170ms ease;
}

.ghost-button::after,
.primary-button::after,
.download-link::after,
.history-link-button::after {
  content: "";
  position: absolute;
  top: -50%;
  left: -70%;
  width: 42%;
  height: 200%;
  transform: translateX(-140%) rotate(18deg);
  background: linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.36), rgba(255, 255, 255, 0));
  pointer-events: none;
}

.ghost-button:hover::after,
.primary-button:hover::after,
.download-link:hover::after,
.history-link-button:hover::after {
  animation: buttonSheen 580ms ease;
}

.ghost-button {
  padding: 10px 14px;
  background: linear-gradient(180deg, rgba(255, 242, 226, 0.96), rgba(253, 232, 208, 0.94));
  color: var(--accent-dark);
  border: 1px solid rgba(176, 84, 29, 0.32);
  box-shadow: 0 8px 18px rgba(128, 61, 20, 0.16);
}

.ghost-button:hover,
.nav-link-button:hover,
.download-link:hover,
.history-link-button:hover {
  transform: translateY(-1px);
  filter: saturate(1.05);
  box-shadow: 0 12px 24px rgba(128, 61, 20, 0.22);
}

.ghost-button.is-copied {
  background: linear-gradient(180deg, rgba(220, 252, 231, 0.96), rgba(187, 247, 208, 0.94));
  color: #16a34a;
  border-color: rgba(22, 163, 74, 0.4);
  box-shadow: 0 8px 18px rgba(22, 163, 74, 0.18);
  animation: kk-copy-pop 220ms cubic-bezier(0.22, 1, 0.36, 1);
}

#split-prompts-button {
  background: linear-gradient(135deg, rgba(67, 160, 71, 0.96) 0%, rgba(46, 125, 50, 0.96) 100%);
  color: #f4fff2;
  border: 1px solid rgba(34, 98, 39, 0.45);
  box-shadow: 0 12px 24px rgba(46, 125, 50, 0.24);
  transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease;
}

#split-prompts-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 30px rgba(46, 125, 50, 0.3);
  filter: saturate(1.05);
}

#split-prompts-button:focus,
#split-prompts-button:focus-visible {
  outline: 2px solid rgba(67, 160, 71, 0.36);
  outline-offset: 3px;
}

#split-prompts-button.is-loading::after {
  border: 2px solid rgba(232, 255, 229, 0.34);
  border-top-color: rgba(232, 255, 229, 0.98);
}

.ghost-button.is-loading {
  position: relative;
  padding-right: 40px;
  opacity: 0.98;
  transform: none;
}

.primary-button.is-loading {
  position: relative;
  padding-right: 40px;
  opacity: 0.98;
  transform: none;
}

.ghost-button.is-loading::after {
  content: "";
  position: absolute;
  right: 14px;
  top: 50%;
  width: 13px;
  height: 13px;
  margin-top: -6.5px;
  border-radius: 50%;
  border: 2px solid rgba(179, 71, 24, 0.26);
  border-right-color: rgba(179, 71, 24, 0.84);
  border-top-color: rgba(179, 71, 24, 0.95);
  animation: splitButtonSpin 0.9s linear infinite;
}

.primary-button.is-loading::after {
  content: "";
  position: absolute;
  right: 14px;
  top: 50%;
  width: 13px;
  height: 13px;
  margin-top: -6.5px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.28);
  border-right-color: rgba(255, 255, 255, 0.86);
  border-top-color: rgba(255, 255, 255, 0.98);
  animation: splitButtonSpin 0.9s linear infinite;
}

.nav-link-button {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.download-link,
.history-link-button {
  position: relative;
  overflow: hidden;
}

.ghost-button,
.primary-button,
.nav-link-button {
  max-width: 100%;
}


.chip-grid {
  display: grid;
  gap: 14px;
}

.choice-chip,
.segmented-chip {
  position: relative;
  display: block;
}

.choice-chip input,
.segmented-chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.choice-chip span,
.choice-chip small,
.segmented-chip span {
  display: block;
}

.choice-chip span,
.segmented-chip span {
  padding: 16px 18px;
  border: 1px solid rgba(46, 25, 11, 0.12);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  color: rgba(32, 21, 13, 0.9);
  font-weight: 600;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease, box-shadow 180ms ease, color 180ms ease;
}

.choice-chip small {
  margin-top: 8px;
  padding-left: 18px;
  font-size: 0.8rem;
  color: rgba(112, 93, 76, 0.92);
  transition: color 180ms ease;
}

.choice-chip:hover span,
.segmented-chip:hover span {
  border-color: rgba(176, 84, 29, 0.34);
  background: rgba(255, 247, 239, 0.96);
}

.choice-chip input:checked + span,
.segmented-chip input:checked + span {
  transform: translateY(-1px);
  border-color: #983b12;
  background: linear-gradient(180deg, #ea6a29 0%, #c84f17 100%);
  color: #fffaf5;
  box-shadow: 0 0 0 3px rgba(240, 111, 47, 0.2), 0 14px 28px rgba(176, 71, 24, 0.3);
}

.choice-chip input:checked + span + small {
  color: #8a3713;
  font-weight: 700;
}

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

.compact-block {
  align-content: start;
}

.segmented-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.segmented-chip span {
  padding: 12px 16px;
  min-width: 78px;
  text-align: center;
}

.primary-button {
  min-width: 148px;
  padding: 14px 22px;
  background: linear-gradient(135deg, var(--accent) 0%, #ff9e52 100%);
  color: white;
  font-weight: 700;
  border: 1px solid rgba(160, 61, 18, 0.35);
  box-shadow: 0 16px 32px rgba(240, 111, 47, 0.32);
}

.primary-button:hover,
.download-button:hover {
  transform: translateY(-1px);
  filter: brightness(1.03) saturate(1.06);
  box-shadow: 0 18px 34px rgba(240, 111, 47, 0.38);
}

#run-single-prompt-button,
#run-all-prompts-button,
#infer-submit-button,
#download-button {
  animation: ctaPulse 2.8s ease-in-out infinite;
}

#run-single-prompt-button:hover,
#run-all-prompts-button:hover,
#infer-submit-button:hover,
#download-button:hover {
  animation-play-state: paused;
}

.primary-button:disabled {
  opacity: 0.5;
  cursor: wait;
  filter: grayscale(0.1);
  box-shadow: none;
}

.ghost-button:active,
.primary-button:active,
.nav-link-button:active,
.download-link:active,
.history-link-button:active,
.admin-tab-button:active,
.admin-subtab-button:active,
.lightbox-tool-button:active,
.lightbox-close:active,
.workspace-tab:active {
  transform: translateY(0) scale(0.985);
}

.download-button {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}


@media (prefers-reduced-motion: reduce) {
  .result-stage.has-result::after {
    animation: none;
    opacity: 0.2;
  }

  #run-single-prompt-button,
  #run-all-prompts-button,
  #infer-submit-button,
  #download-button {
    animation: none;
  }
}

.result-meta {
  margin-top: 16px;
  padding: 16px 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(46, 25, 11, 0.08);
}

.meta-label {
  display: block;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.usage-box {
  margin: 16px 0 0;
  padding: 18px;
  overflow: auto;
  border-radius: 18px;
  background: #1f1a17;
  color: #fdebd9;
  font: 0.88rem/1.6 "Space Grotesk", monospace;
}


.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: stretch;
  background: rgba(27, 17, 10, 0.86);
  backdrop-filter: blur(6px);
}

.image-lightbox[hidden] {
  display: none !important;
}

/* Two-column body */
.lightbox-body {
  display: flex;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* Left: image area */
.lightbox-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.lightbox-image {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 22px 56px rgba(0, 0, 0, 0.42);
  transform-origin: center;
  transition: transform 140ms ease;
  cursor: zoom-in;
  touch-action: none;
}

.lightbox-image[hidden] {
  display: none !important;
}

.lightbox-image.is-zoomed {
  cursor: grab;
}

.lightbox-image.is-dragging {
  cursor: grabbing;
  transition: none;
}

.lightbox-tools {
  position: absolute;
  top: 14px;
  left: 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  z-index: 2;
}

.lightbox-tool-button {
  border-radius: 999px;
  min-width: 48px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.88);
  color: #6f2f0f;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid rgba(111, 47, 15, 0.24);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.22);
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.lightbox-tool-button:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.26);
}

/* Navigation arrows */
.lightbox-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 150ms ease, transform 150ms ease;
  backdrop-filter: blur(4px);
}

.lightbox-nav-btn:hover {
  background: rgba(255, 255, 255, 0.36);
  transform: translateY(-50%) scale(1.08);
}

.lightbox-nav-btn[hidden] {
  display: none !important;
}

.lightbox-nav-prev {
  left: 16px;
}

.lightbox-nav-next {
  right: 16px;
}

/* Right: info panel */
.lightbox-side-panel {
  width: 320px;
  flex-shrink: 0;
  background: #fff;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.lightbox-panel-hd {
  padding: 14px 16px 12px;
  border-bottom: 1px solid #f0f0f0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
}

.lightbox-close {
  position: absolute;
  top: 10px;
  right: 12px;
  border: 0;
  border-radius: 8px;
  padding: 6px 8px;
  background: transparent;
  color: #888;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 130ms ease, color 130ms ease;
}

.lightbox-close:hover {
  background: #f5f5f5;
  color: #333;
}

body.page-history .image-lightbox {
  align-items: center;
  justify-content: center;
  padding: 24px;
}

body.page-history .lightbox-download-btn {
  position: absolute;
  top: 10px;
  right: 78px;
  border-radius: 999px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.92);
  color: #5b260d;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid rgba(111, 47, 15, 0.24);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.28);
  text-decoration: none;
  z-index: 2;
}

body.page-history .lightbox-download-btn:hover {
  background: #ffffff;
}

body.page-history .lightbox-hint {
  position: absolute;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  margin: 0;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.42);
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.78rem;
}

.lightbox-panel-hd-info {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding-right: 36px;
}

.lightbox-panel-date,
.lightbox-panel-tool {
  font-size: 0.76rem;
  color: #999;
  line-height: 1.3;
}

.lightbox-panel-sep {
  color: #ddd;
  font-size: 0.76rem;
}

.lightbox-panel-hd-btns {
  display: flex;
  gap: 8px;
}

.lightbox-panel-hd-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid #e0e0e0;
  background: #fafafa;
  color: #333;
  font-size: 0.82rem;
  cursor: pointer;
  text-decoration: none;
  transition: background 130ms ease, border-color 130ms ease;
}

.lightbox-panel-hd-btn:hover {
  background: #f0f0f0;
  border-color: #ccc;
}

#lightbox-fav-btn.is-active {
  background: #fff7ed;
  border-color: #fbbf24;
  color: #f59e0b;
}

#lightbox-fav-btn.is-active svg {
  fill: #f59e0b;
  stroke: #f59e0b;
}

/* Panel body */
.lightbox-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.lightbox-panel-section {
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid #f2f2f2;
}

.lightbox-panel-section:last-child {
  border-bottom: 0;
  margin-bottom: 0;
}

.lightbox-panel-section-hd {
  margin: 0 0 10px;
  font-size: 0.84rem;
  font-weight: 600;
  color: #444;
  letter-spacing: 0;
}

.lightbox-panel-sub-label {
  margin: 0 0 4px;
  font-size: 0.74rem;
  color: #aaa;
}

.lightbox-panel-prompt {
  margin: 0;
  font-size: 0.86rem;
  color: #333;
  line-height: 1.65;
  word-break: break-all;
}

.lightbox-panel-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.lightbox-info-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  background: #f5f5f5;
  border: 1px solid #e8e8e8;
  color: #555;
  font-size: 0.74rem;
  white-space: nowrap;
}

.lightbox-panel-ref-imgs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.lightbox-ref-thumb {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid #eee;
  cursor: zoom-in;
}

.lightbox-panel-gen-row {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 8px;
}

.lightbox-gen-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 9px 14px;
  border-radius: 10px;
  border: 1px solid #e0e0e0;
  background: #fafafa;
  color: #333;
  font-size: 0.84rem;
  cursor: pointer;
  transition: background 130ms ease, border-color 130ms ease;
  text-align: left;
}

.lightbox-gen-btn:hover {
  background: #f0f5ff;
  border-color: #b8d4ff;
  color: #1a5cc8;
}

body.kk-global-lightbox-open {
  overflow: hidden;
}

.kk-global-image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(16, 10, 6, 0.88);
  backdrop-filter: blur(6px);
}

.kk-global-image-lightbox[hidden] {
  display: none !important;
}

.kk-global-image-lightbox-image {
  display: block;
  width: min(94vw, 1680px);
  max-height: 92vh;
  object-fit: contain;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  box-shadow: 0 24px 66px rgba(0, 0, 0, 0.48);
}

.kk-global-image-lightbox-close {
  position: absolute;
  top: 14px;
  right: 14px;
  border-radius: 999px;
  padding: 9px 15px;
  background: rgba(255, 255, 255, 0.92);
  color: #5b260d;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid rgba(111, 47, 15, 0.24);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.28);
}

.kk-global-image-lightbox-close:hover {
  background: #ffffff;
}

.kk-global-image-lightbox-download {
  position: absolute;
  top: 14px;
  right: 102px;
  border-radius: 999px;
  padding: 9px 15px;
  background: rgba(255, 255, 255, 0.92);
  color: #5b260d;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid rgba(111, 47, 15, 0.24);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.28);
  text-decoration: none;
}

.kk-global-image-lightbox-download:hover {
  background: #ffffff;
}

@media (max-width: 640px) {
  body.page-history .lightbox-download-btn {
    right: 70px;
    padding: 8px 12px;
  }

  .kk-global-image-lightbox-download {
    right: 94px;
    padding: 8px 12px;
  }
}


.history-topbar-filter {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.history-topbar-filter .auth-input {
  width: auto;
  min-width: 150px;
}


  margin-top: 22px;
}

.history-result-block.is-collapsed .compact-heading {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom-color: transparent;
}

.history-result-block.is-collapsed .generation-history {
  display: none;
}

.generation-history {
  display: grid;
  gap: 10px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  max-height: calc(100vh - 220px);
  padding-right: 4px;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* 主页历史记录容器：在默认基础上将可视高度提升为约 3 倍 */
body.page-workbench .generation-history {
  max-height: calc(300vh - 660px);
}

/* 执行记录独立页：不限制高度，由页面整体滚动 */
body.page-history .generation-history {
  max-height: none;
  overflow-y: visible;
}

.generation-history-empty {
  margin: 0;
  padding: 14px 16px;
  border: 1px dashed rgba(46, 25, 11, 0.16);
  border-radius: 12px;
  background: rgba(255, 250, 244, 0.6);
  color: var(--muted);
  font-size: 0.92rem;
}

.history-generation-item {
  border: 1px solid rgba(46, 25, 11, 0.1);
  border-radius: 16px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.76);
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: stretch;
  overflow: hidden;
  scrollbar-width: thin;
}

.history-generation-item.is-generating {
  border-style: dashed;
  border-color: rgba(176, 84, 29, 0.3);
  background: linear-gradient(135deg, rgba(255, 248, 238, 0.92), rgba(255, 242, 226, 0.86));
}

.history-generation-meta-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.history-generation-meta-row .history-generation-time,
.history-generation-user,
.history-generation-model {
  margin: 0;
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid rgba(176, 84, 29, 0.2);
  background: rgba(255, 246, 234, 0.9);
  color: #7f3212;
  font-size: 0.86rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.history-generation-model {
  border-color: rgba(110, 78, 196, 0.22);
  background: rgba(242, 237, 255, 0.9);
  color: #4f3e95;
}

.history-generation-meta {
  display: grid;
  gap: 6px;
}

.history-generation-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.history-purpose-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid rgba(46, 25, 11, 0.18);
  background: rgba(255, 245, 232, 0.9);
  color: #7f3212;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.history-purpose-badge.is-prompt-inference {
  border-color: rgba(12, 104, 137, 0.3);
  background: rgba(222, 245, 255, 0.86);
  color: #0f5472;
}

.history-purpose-badge.is-image-generation {
  border-color: rgba(176, 84, 29, 0.28);
  background: rgba(255, 241, 221, 0.9);
  color: #8a3713;
}

.history-generation-time {
  margin: 0;
  color: var(--muted);
  font-size: 1.08rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

.history-generation-prompt-wrap {
  min-width: 0;
}

.history-generation-media-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  min-width: 0;
}

.history-generation-media-row.is-single-column {
  grid-template-columns: 1fr;
}

.history-image-panel {
  min-width: 0;
  display: grid;
  gap: 8px;
}

.history-image-panel-title {
  margin: 0;
  color: #8a3713;
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.history-apply-prompt-button {
  margin-top: 10px;
  border: 1px solid rgba(176, 84, 29, 0.28);
  border-radius: 999px;
  background: rgba(255, 245, 232, 0.92);
  color: #7f3212;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 7px 12px;
}

.history-apply-prompt-button:hover,
.history-apply-prompt-button:focus-visible {
  background: rgba(240, 111, 47, 0.92);
  color: #fff8f2;
}

.history-generation-title {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.04rem;
}

#history-open-all {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(176, 84, 29, 0.28);
  background: linear-gradient(180deg, rgba(255, 242, 226, 0.95), rgba(253, 232, 208, 0.9));
  color: #8a3713;
  box-shadow: 0 8px 18px rgba(128, 61, 20, 0.16);
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease, filter 150ms ease;
}

#history-open-all:hover,
#history-open-all:focus-visible {
  transform: translateY(-1px);
  filter: saturate(1.05);
  box-shadow: 0 12px 24px rgba(128, 61, 20, 0.24);
  text-decoration: none;
}

#history-open-all:active {
  transform: translateY(0) scale(0.985);
}

.history-generation-prompt {
  margin: 0;
  color: var(--muted);
  font-size: 0.94rem;
  font-weight: 500;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: hidden;
  overflow-y: auto;
  max-height: 180px;
  min-height: 96px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(176, 84, 29, 0.16);
  background: rgba(255, 255, 255, 0.72);
  scrollbar-width: thin;
  text-align: left;
  width: 100%;
}

.history-generation-prompt-wrap {
  min-width: 0;
  display: grid;
  gap: 8px;
}

.history-prompt-copy-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  border-radius: 999px;
  border: 1px solid rgba(176, 84, 29, 0.24);
  background: rgba(255, 245, 232, 0.92);
  color: #7f3212;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 0 8px;
}

.history-prompt-copy-button:hover,
.history-prompt-copy-button:focus-visible {
  background: rgba(240, 111, 47, 0.92);
  color: #fff8f2;
}

.history-prompt-copy-button.is-copied {
  background: rgba(22, 163, 74, 0.14);
  border-color: rgba(22, 163, 74, 0.45);
  color: #16a34a;
  animation: kk-copy-pop 220ms cubic-bezier(0.22, 1, 0.36, 1);
}

.history-prompt-tools {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  padding-bottom: 2px;
}

.history-prompt-tools .history-apply-prompt-button {
  margin-top: 0;
  min-height: 24px;
  font-size: 0.7rem;
  padding: 0 8px;
}

.history-token-flow {
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(176, 84, 29, 0.18);
  background: rgba(255, 248, 239, 0.88);
}

.history-token-flow-summary {
  margin: 0;
  color: #6d2f12;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.45;
}

.history-token-flow-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
}

.history-token-flow-item {
  color: #6d2f12;
  font-size: 0.8rem;
  line-height: 1.45;
}

.history-token-flow-item.is-success {
  color: #256640;
}

.history-token-flow-item.is-failed {
  color: #8e2a2a;
}

.history-generation-gallery {
  display: flex;
  flex-wrap: nowrap;
  gap: 10px;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}

.history-generation-upload-wrap,
.history-generation-output-wrap {
  align-items: stretch;
}

.history-generation-image-card {
  position: relative;
  border: 1px solid rgba(46, 25, 11, 0.12);
  border-radius: 12px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.9);
  padding: 8px;
  min-height: 0;
  flex: 0 0 auto;
  width: auto;
  max-width: min(100%, 420px);
}

.history-generation-image-card.is-loading-card {
  min-height: 220px;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 246, 233, 0.92));
  border-color: rgba(176, 84, 29, 0.24);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.62);
}

.history-generation-image-card.is-loading-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 28%, rgba(255, 255, 255, 0.5) 48%, transparent 68%);
  transform: translateX(-130%);
  animation: history-loading-sheen 2.2s ease-in-out infinite;
  pointer-events: none;
}

.history-generation-loading-shell {
  display: grid;
  justify-items: center;
  gap: 10px;
  width: min(86%, 340px);
  text-align: center;
  z-index: 1;
}

.history-generation-spinner {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 3px solid rgba(176, 84, 29, 0.2);
  border-right-color: rgba(176, 84, 29, 0.78);
  border-top-color: rgba(176, 84, 29, 0.92);
  box-shadow: 0 0 0 6px rgba(240, 111, 47, 0.1);
  animation: history-loading-spin 1s linear infinite, history-loading-spinner-breathe 1.8s ease-in-out infinite;
}

.history-generation-loading-text {
  margin: 0;
  color: #8a3713;
  font-size: 0.9rem;
  font-weight: 800;
}

.history-generation-loading-hint {
  margin: 0;
  color: rgba(111, 47, 15, 0.82);
  font-size: 0.78rem;
  line-height: 1.45;
}

.history-generation-loading-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(176, 84, 29, 0.16);
  box-shadow: inset 0 1px 2px rgba(111, 47, 15, 0.14);
}

.history-generation-loading-bar {
  display: block;
  width: 42%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(240, 111, 47, 0.92), rgba(255, 165, 102, 0.94));
  animation: history-loading-bar-slide 1.45s ease-in-out infinite;
}

#generation-history .history-generation-image-card {
  max-width: min(100%, 235px);
}

#generation-history .history-generation-image-card.is-loading-card {
  min-height: 176px;
}

.history-image-tag {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  border: 1px solid rgba(46, 25, 11, 0.18);
  background: rgba(255, 255, 255, 0.9);
  color: #5e2b12;
}

.history-image-tag.is-original {
  border-color: rgba(64, 104, 182, 0.34);
  background: rgba(229, 241, 255, 0.92);
  color: #1f4f9b;
}

.history-image-tag.is-output {
  border-color: rgba(176, 84, 29, 0.32);
  background: rgba(255, 242, 224, 0.94);
  color: #8a3713;
}

.history-image-actions {
  position: absolute;
  right: 8px;
  bottom: 8px;
  z-index: 2;
  display: flex;
  gap: 6px;
}

.history-image-action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(176, 84, 29, 0.24);
  background: rgba(255, 245, 232, 0.92);
  color: #7f3212;
  text-decoration: none;
  font-size: 0.76rem;
  font-weight: 800;
}

.history-image-action-button:hover,
.history-image-action-button:focus-visible {
  background: rgba(240, 111, 47, 0.92);
  color: #fff8f2;
}

.history-generation-image {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 420px;
  margin: 0 auto;
  object-fit: contain;
  background: linear-gradient(180deg, rgba(255, 252, 248, 0.95), rgba(247, 236, 224, 0.95));
  cursor: zoom-in;
}

.history-generation-audio {
  display: block;
  width: 100%;
  margin: 0 auto;
}

.history-audio-visual {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: linear-gradient(135deg, #e8f0fe 0%, #c9d8fb 100%);
  border-radius: 8px;
  min-height: 160px;
  color: #5b7fe8;
  padding: 16px 12px 12px;
  margin-bottom: 8px;
}

.history-audio-filename {
  font-size: 0.75rem;
  color: #5b7fe8;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
  opacity: 0.85;
}

.history-generation-image-card.is-audio-card {
  min-height: 220px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: stretch;
}

.history-generation-image-card:has(.history-generation-audio) {
  min-height: 220px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: stretch;
}

.history-img-card-actions {
  position: absolute;
  right: 6px;
  bottom: 6px;
  z-index: 3;
  display: flex;
  gap: 4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.history-generation-image-card:hover .history-img-card-actions {
  opacity: 1;
  pointer-events: auto;
}

.history-img-card-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.52);
  color: #fff;
  border: none;
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: background 0.12s;
  flex-shrink: 0;
}

.history-img-card-btn:hover,
.history-img-card-btn:focus-visible {
  background: rgba(0, 0, 0, 0.75);
  outline: none;
}


.status-banner {
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(255, 240, 223, 0.88);
  color: var(--accent-dark);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.background-job-board {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(46, 25, 11, 0.12);
  background: rgba(255, 250, 243, 0.74);
}

.background-job-board .panel-heading {
  margin-bottom: 12px;
  padding-bottom: 10px;
}

.background-job-summary {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.background-job-list {
  display: grid;
  gap: 10px;
  max-height: 280px;
  overflow-y: auto;
  padding-right: 4px;
}

.background-job-item {
  display: grid;
  gap: 6px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(46, 25, 11, 0.12);
  background: rgba(255, 255, 255, 0.82);
}

.background-job-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.background-job-title {
  font-size: 0.9rem;
  color: #5f3017;
}

.background-job-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid rgba(160, 103, 67, 0.22);
  background: rgba(248, 233, 217, 0.86);
  color: #8a4a24;
  font-size: 0.76rem;
  font-weight: 800;
}

.background-job-item.is-running .background-job-status {
  border-color: rgba(48, 124, 191, 0.26);
  background: rgba(225, 240, 255, 0.88);
  color: #1c6097;
}

.background-job-item.is-succeeded .background-job-status {
  border-color: rgba(54, 146, 92, 0.26);
  background: rgba(228, 248, 235, 0.9);
  color: #24683f;
}

.background-job-item.is-failed .background-job-status {
  border-color: rgba(194, 73, 73, 0.28);
  background: rgba(255, 234, 234, 0.9);
  color: #9a3131;
}

.background-job-meta,
.background-job-message {
  margin: 0;
  color: #7f5a42;
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

.background-job-message {
  color: #5f341e;
  font-weight: 600;
}

.background-job-item.is-failed .background-job-message {
  color: #8c2626;
}

.background-job-item.is-running .background-job-message {
  color: #275f8b;
}
.status-banner.is-loading {
  position: relative;
  padding-right: 44px;
  background:
    linear-gradient(110deg, rgba(255, 240, 223, 0.88) 8%, rgba(255, 226, 201, 0.95) 32%, rgba(255, 240, 223, 0.88) 60%) 0 0 / 240% 100%,
    rgba(255, 240, 223, 0.88);
  animation: inferenceStatusSheen 1.4s ease-in-out infinite;
}
.status-banner.is-loading::after {
  content: "...";
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  letter-spacing: 0.08em;
  font-weight: 800;
  color: rgba(127, 50, 18, 0.92);
  animation: inferenceStatusDots 1s steps(4, end) infinite;
}

#inference-status.is-loading {
  padding-left: 54px;
  padding-right: 56px;
  border: 1px solid rgba(72, 128, 212, 0.38);
  box-shadow: 0 0 0 1px rgba(205, 228, 255, 0.55) inset, 0 14px 28px rgba(77, 129, 204, 0.22);
  background:
    linear-gradient(100deg, rgba(225, 239, 255, 0.95) 8%, rgba(191, 220, 255, 0.98) 32%, rgba(225, 239, 255, 0.95) 60%) 0 0 / 230% 100%,
    rgba(219, 236, 255, 0.95);
  animation: inferenceStatusSheenStrong 1s linear infinite;
}

#inference-status.is-loading::before {
  content: "";
  position: absolute;
  left: 16px;
  top: 50%;
  width: 20px;
  height: 20px;
  margin-top: -10px;
  border-radius: 999px;
  border: 3px solid rgba(72, 128, 212, 0.26);
  border-top-color: rgba(72, 128, 212, 0.98);
  box-shadow: 0 0 0 6px rgba(126, 171, 235, 0.16);
  animation: inferenceSpinnerBoost 0.7s linear infinite, inferenceSpinnerHalo 1.4s ease-in-out infinite;
}

#inference-status.is-loading::after {
  right: 16px;
  font-size: 1.12rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  animation: inferenceStatusDotsBoost 0.75s steps(4, end) infinite;
}

#inference-status.is-safety-blocked {
  position: relative;
  padding-left: 54px;
  border: 1px solid rgba(176, 84, 29, 0.45);
  background: linear-gradient(135deg, rgba(255, 246, 220, 0.96), rgba(255, 233, 198, 0.95));
  color: #7f3212;
  box-shadow: 0 0 0 1px rgba(255, 226, 175, 0.6) inset, 0 12px 24px rgba(176, 84, 29, 0.22);
  animation: inferenceSafetyPulse 1.1s ease-in-out infinite;
}

#inference-status.is-safety-blocked::before {
  content: "!";
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  font-weight: 900;
  color: #fff6ef;
  background: linear-gradient(135deg, #dc7435, #b44d20);
  box-shadow: 0 6px 14px rgba(167, 71, 25, 0.32);
}

.inference-safety-hint {
  margin: 0 0 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(180, 97, 42, 0.36);
  background: linear-gradient(135deg, rgba(255, 246, 223, 0.94), rgba(255, 236, 204, 0.94));
  color: #8a3713;
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.5;
}

#infer-submit-button {
  isolation: isolate;
  min-width: 152px;
}

.action-row.is-inference-running .helper-text.is-inference-running {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid rgba(72, 128, 212, 0.34);
  background: linear-gradient(135deg, rgba(223, 239, 255, 0.94), rgba(194, 221, 255, 0.96));
  color: #0f4d96;
  font-size: 0.86rem;
  font-weight: 700;
  box-shadow: 0 10px 20px rgba(72, 128, 212, 0.2);
}

.action-row .helper-text.is-inference-running::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(34, 107, 196, 1), rgba(77, 150, 238, 0.98));
  box-shadow: 0 0 0 0 rgba(71, 137, 222, 0.45);
  animation: inferenceHelperDotPulse 1s ease-in-out infinite;
}

#infer-submit-button .infer-click-ripple {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  pointer-events: none;
  z-index: 1;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.24);
  background: radial-gradient(circle, rgba(255, 255, 255, 0.84) 0%, rgba(255, 212, 156, 0.4) 50%, rgba(255, 176, 104, 0) 74%);
}

#infer-submit-button .infer-click-ripple.is-active {
  animation: inferenceButtonClickRipple 420ms cubic-bezier(0.22, 0.8, 0.2, 1);
}

#infer-submit-button.is-loading {
  overflow: visible;
  transform: translateY(-1px) scale(1.04);
  min-width: 214px;
  letter-spacing: 0.02em;
  box-shadow: 0 0 0 1px rgba(255, 247, 240, 0.55) inset, 0 20px 36px rgba(240, 111, 47, 0.5), 0 0 22px rgba(255, 166, 92, 0.6);
  animation: inferenceButtonPulseStrong 0.9s ease-in-out infinite, inferenceButtonGlow 1.4s ease-in-out infinite;
}

#infer-submit-button.is-loading::before {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 999px;
  border: 1px solid rgba(255, 178, 108, 0.75);
  pointer-events: none;
  animation: inferenceButtonRipple 1.1s ease-out infinite;
}

#infer-submit-button.is-loading::after {
  right: 14px;
  width: 18px;
  height: 18px;
  margin-top: -9px;
  border-width: 3px;
}

.result-stage {
  position: relative;
  margin-top: 18px;
  min-height: 640px;
  display: grid;
  place-items: center;
  isolation: isolate;
  transition: background 320ms ease, border-color 280ms ease, box-shadow 320ms ease;
}

.result-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0;
  background:
    radial-gradient(circle at 18% 16%, rgba(255, 212, 156, 0.4), transparent 34%),
    radial-gradient(circle at 85% 82%, rgba(240, 111, 47, 0.2), transparent 42%);
  transition: opacity 320ms ease;
}

.result-stage::after {
  content: "";
  position: absolute;
  top: -18%;
  left: -42%;
  width: 38%;
  height: 136%;
  pointer-events: none;
  z-index: 1;
  opacity: 0;
  transform: translateX(-120%) skewX(-14deg);
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.06) 36%,
    rgba(255, 255, 255, 0.28) 50%,
    rgba(255, 255, 255, 0.08) 64%,
    rgba(255, 255, 255, 0) 100%
  );
  transition: opacity 320ms ease;
}

.result-stage > * {
  position: relative;
  z-index: 1;
}

.result-stage.empty {
  background:
    radial-gradient(circle at center, rgba(255, 186, 126, 0.22), transparent 34%),
    linear-gradient(180deg, rgba(255, 250, 244, 0.85), rgba(248, 235, 220, 0.92));
}

.empty-state {
  max-width: 360px;
  padding: 20px;
  text-align: center;
  opacity: 0.92;
  transform: translateY(0);
  transition: opacity 240ms ease, transform 260ms ease;
}

.empty-state strong {
  font-size: 1.14rem;
}

.empty-state p {
  margin-top: 10px;
  font-size: 1.02rem;
  line-height: 1.75;
}

.loading-state {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: none;
  place-items: center;
  align-content: center;
  gap: 16px;
  padding: 28px;
  text-align: center;
  background:
    radial-gradient(circle at center, rgba(255, 179, 110, 0.26), transparent 32%),
    linear-gradient(180deg, rgba(255, 248, 238, 0.92), rgba(247, 233, 219, 0.96));
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 260ms ease, transform 280ms ease;
}

.loading-state strong {
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.35rem;
}

.loading-state p {
  max-width: 30ch;
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.prominent-alert-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(34, 16, 8, 0.52);
  backdrop-filter: blur(5px);
  pointer-events: auto;
  opacity: 0;
  transition: opacity 180ms ease;
}

.prominent-alert-overlay[hidden] {
  display: none !important;
  pointer-events: none;
}

.prominent-alert-overlay.is-visible {
  opacity: 1;
}

.prominent-alert-panel {
  width: min(520px, 100%);
  border-radius: 20px;
  border: 2px solid rgba(176, 71, 24, 0.45);
  background:
    radial-gradient(circle at 16% 12%, rgba(255, 212, 167, 0.58), transparent 30%),
    linear-gradient(180deg, rgba(255, 252, 248, 0.98), rgba(255, 242, 228, 0.98));
  box-shadow: 0 28px 68px rgba(56, 24, 8, 0.43);
  padding: 20px 20px 18px;
  pointer-events: auto;
  transform: translateY(8px) scale(0.985);
  opacity: 0;
  animation: prominentAlertPopIn 220ms cubic-bezier(0.22, 0.8, 0.2, 1) forwards;
}

.prominent-alert-panel.is-warning {
  border-color: rgba(176, 71, 24, 0.45);
}

.prominent-alert-panel.is-info {
  border-color: rgba(44, 106, 166, 0.45);
}

.prominent-alert-panel.is-error {
  border-color: rgba(168, 41, 41, 0.5);
}

.prominent-alert-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(176, 71, 24, 0.12);
  color: #8d3411;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.prominent-alert-title {
  margin: 10px 0 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.26rem;
  color: #8d3411;
}

.prominent-alert-message {
  margin: 10px 0 0;
  color: #5e2d16;
  font-size: 1rem;
  line-height: 1.7;
  font-weight: 600;
  white-space: pre-line;
}

.prominent-alert-actions {
  margin-top: 16px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.prominent-alert-cancel {
  min-width: 92px;
}

.prominent-alert-confirm {
  min-width: 132px;
  pointer-events: auto;
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease;
}

.prominent-alert-confirm:hover,
.prominent-alert-confirm:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 16px 30px rgba(176, 71, 24, 0.34);
}

body.prominent-alert-open {
  overflow: hidden;
}


.result-stage.has-result {
  border-color: rgba(240, 111, 47, 0.24);
  box-shadow: inset 0 0 0 1px rgba(255, 226, 188, 0.32);
  background:
    radial-gradient(circle at 24% 20%, rgba(255, 195, 126, 0.22), transparent 36%),
    linear-gradient(180deg, rgba(255, 251, 245, 0.9), rgba(247, 235, 221, 0.9));
}

.result-stage.has-result::before {
  opacity: 1;
}

.result-stage.has-result::after {
  opacity: 0.42;
  animation: resultSheen 4.8s ease-in-out infinite;
}

.result-stage.has-result .empty-state {
  opacity: 0;
  transform: translateY(-10px);
}

.result-stage.has-result .result-image-themed {
  animation: resultReveal 420ms cubic-bezier(0.22, 0.8, 0.2, 1);
}

.history-panel {
  margin-top: 30px;
  border: 1px solid rgba(111, 63, 34, 0.22);
  background:
    linear-gradient(180deg, rgba(255, 251, 247, 0.95), rgba(246, 236, 224, 0.92)),
    var(--surface);
}


.workspace-tabbar {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: 12px;
  width: min(760px, 100%);
  margin: 0;
  padding: 10px;
  border-radius: 18px;
  border: 1px solid rgba(46, 25, 11, 0.16);
  background: linear-gradient(135deg, rgba(255, 246, 235, 0.95), rgba(255, 236, 214, 0.92));
  overflow: hidden;
}

.workspace-tabbar::before {
  content: "";
  position: absolute;
  inset: -30%;
  background: radial-gradient(circle at 20% 30%, rgba(255, 172, 99, 0.24), transparent 28%), radial-gradient(circle at 80% 70%, rgba(255, 111, 0, 0.18), transparent 30%);
  pointer-events: none;
  animation: workspaceAurora 7s ease-in-out infinite;
}

.workspace-tab-indicator {
  position: absolute;
  left: 8px;
  top: 8px;
  height: calc(100% - 16px);
  width: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(240, 111, 47, 0.95) 0%, rgba(255, 158, 82, 0.96) 100%);
  box-shadow: 0 12px 26px rgba(240, 111, 47, 0.32), 0 0 0 1px rgba(255, 242, 230, 0.38) inset;
  transform: translateX(0);
  opacity: 0;
  transition: transform 260ms cubic-bezier(0.22, 0.8, 0.2, 1), width 260ms cubic-bezier(0.22, 0.8, 0.2, 1), opacity 180ms ease;
  pointer-events: none;
}

.workspace-tab-indicator.is-visible {
  opacity: 1;
}

.workspace-tab {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 72px;
  min-width: 0;
  text-align: center;
  border: 1px solid rgba(165, 92, 47, 0.38);
  border-radius: 999px;
  padding: 12px 20px;
  background: rgba(255, 252, 247, 0.9);
  color: #7a4a2d;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 18px rgba(143, 74, 31, 0.18);
  transition: transform 220ms ease, background 220ms ease, color 220ms ease, box-shadow 220ms ease, border-color 220ms ease;
}

.workspace-tab:hover {
  transform: translateY(-1px);
  border-color: rgba(176, 84, 29, 0.62);
  background: rgba(255, 250, 243, 0.98);
  box-shadow: 0 14px 24px rgba(163, 72, 24, 0.26);
}

.workspace-tab-title {
  font-size: 1.25rem;
  line-height: 1.2;
}

.workspace-tab-subtitle {
  color: rgba(95, 68, 47, 0.95);
  font-size: 0.86rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

@media (min-width: 1200px) {
  .workspace-tab-title {
    font-size: 1.35rem;
  }

  .workspace-tab-subtitle {
    font-size: 0.9rem;
  }
}

.workspace-tab.is-active {
  background: transparent;
  color: #fff;
  transform: translateY(-1px) scale(1.02);
  box-shadow: none;
  border-color: transparent;
}

.workspace-tab.is-active .workspace-tab-subtitle {
  color: rgba(255, 246, 236, 0.95);
}

.workspace-tab:focus-visible {
  outline: 3px solid rgba(240, 111, 47, 0.5);
  outline-offset: 2px;
}

.workspace-pane {
  margin-top: 14px;
}

.workspace-pane.pane-enter {
  animation: workspacePaneEnter 320ms cubic-bezier(0.22, 0.8, 0.2, 1);
}

body[data-workspace-tab="image"] {
  background:
    radial-gradient(circle at top left, rgba(255, 193, 123, 0.55), transparent 28%),
    radial-gradient(circle at 80% 10%, rgba(244, 124, 45, 0.18), transparent 24%),
    linear-gradient(180deg, #f9f1e5 0%, var(--bg) 52%, #efe4d5 100%);
}

body[data-workspace-tab="infer"] {
  background:
    radial-gradient(circle at 12% 8%, rgba(135, 206, 235, 0.42), transparent 24%),
    radial-gradient(circle at 84% 14%, rgba(108, 152, 255, 0.2), transparent 22%),
    linear-gradient(180deg, #eef5ff 0%, #e7eef9 54%, #dde7f3 100%);
}

body[data-workspace-tab="infer"] .chat-input-dock,
body[data-workspace-tab="infer"] #chat-completion-notify,
body[data-workspace-tab="infer"] .kk-thumb-zoom-popup {
  display: none !important;
}

body[data-workspace-tab="infer"] #workspace-pane-image {
  display: none !important;
}


.page-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px;
  border-radius: 999px;
  border: 1px solid rgba(12, 52, 108, 0.18);
  background: linear-gradient(132deg, rgba(228, 241, 255, 0.78), rgba(255, 241, 224, 0.84));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.88), 0 10px 24px rgba(8, 43, 92, 0.16);
}

.page-switch .nav-link-button {
  position: relative;
  min-height: 40px;
  padding: 10px 16px;
  border-width: 1.5px;
  border-radius: 999px;
  letter-spacing: 0.01em;
  font-weight: 700;
  overflow: hidden;
  opacity: 1;
  transform: translateY(0) scale(1);
  transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1), box-shadow 220ms ease, filter 220ms ease, background 240ms ease, color 220ms ease, border-color 220ms ease;
  animation: page-switch-enter 440ms cubic-bezier(0.25, 0.9, 0.2, 1) both;
}

.page-switch .nav-link-button:nth-child(1) {
  animation-delay: 40ms;
}

.page-switch .nav-link-button:nth-child(2) {
  animation-delay: 100ms;
}

.page-switch .nav-link-button:nth-child(3) {
  animation-delay: 160ms;
}

.page-switch .nav-link-button::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(120deg, transparent 4%, rgba(255, 255, 255, 0.58) 42%, transparent 74%);
  transform: translateX(-150%);
}

.page-switch .nav-link-button:hover::after,
.page-switch .nav-link-button:focus-visible::after {
  opacity: 1;
  animation: page-switch-sheen 760ms ease;
}

.page-switch .nav-link-button:not(.is-active):not([aria-current="page"]) {
  background: linear-gradient(180deg, rgba(237, 248, 255, 0.98), rgba(207, 230, 255, 0.94));
  border-color: rgba(10, 89, 178, 0.34);
  color: #0b4f9d;
  box-shadow: 0 8px 18px rgba(10, 72, 145, 0.16);
  filter: saturate(0.82);
}

.page-switch .nav-link-button:not(.is-active):not([aria-current="page"]):hover,
.page-switch .nav-link-button:not(.is-active):not([aria-current="page"]):focus-visible {
  background: linear-gradient(180deg, rgba(226, 243, 255, 1), rgba(186, 221, 255, 0.98));
  border-color: rgba(0, 96, 198, 0.48);
  color: #003f88;
  filter: saturate(0.98);
  transform: translateY(-1px) scale(1.02);
  box-shadow: 0 12px 24px rgba(0, 71, 144, 0.22);
}

.page-switch .nav-link-button.is-active,
.page-switch .nav-link-button[aria-current="page"] {
  background: linear-gradient(138deg, #ffc07e 0%, #ff8b3b 34%, #f4652a 64%, #c43c16 100%);
  border-color: rgba(114, 32, 8, 0.86);
  color: #fffaf4;
  filter: none;
  transform: translateY(-1px) scale(1.03);
  box-shadow: 0 0 0 2px rgba(255, 243, 230, 0.68) inset, 0 18px 34px rgba(181, 73, 18, 0.44);
  animation: page-switch-enter 440ms cubic-bezier(0.25, 0.9, 0.2, 1) both, page-switch-active-pulse 2.8s ease-in-out 520ms infinite;
}

.page-switch .nav-link-button.is-active:hover,
.page-switch .nav-link-button[aria-current="page"]:hover,
.page-switch .nav-link-button.is-active:focus-visible,
.page-switch .nav-link-button[aria-current="page"]:focus-visible {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 0 0 2px rgba(255, 243, 230, 0.74) inset, 0 22px 38px rgba(181, 73, 18, 0.52);
}



.workspace-tabbar .workspace-tab {
  opacity: 0.7;
  filter: saturate(0.7);
  transition: transform 220ms ease, background 220ms ease, color 220ms ease, box-shadow 220ms ease, border-color 220ms ease, opacity 220ms ease, filter 220ms ease;
}

.workspace-tabbar .workspace-tab:not(.is-active) {
  background: rgba(255, 250, 242, 0.88);
  color: rgba(132, 59, 20, 0.9);
}

.workspace-tabbar .workspace-tab:not(.is-active) .workspace-tab-subtitle {
  color: rgba(112, 69, 44, 0.74);
}

.workspace-tabbar .workspace-tab.is-active {
  opacity: 1;
  filter: none;
  color: #fffdf9;
  text-shadow: 0 1px 0 rgba(87, 31, 2, 0.38);
  transform: translateY(-1px) scale(1.03);
}

.workspace-tabbar .workspace-tab.is-active .workspace-tab-subtitle {
  color: rgba(255, 247, 239, 0.94);
}

.workspace-tabbar .workspace-tab-indicator {
  background: linear-gradient(135deg, rgba(188, 73, 19, 0.98) 0%, rgba(249, 115, 22, 0.98) 55%, rgba(255, 184, 108, 0.98) 100%);
  box-shadow: 0 14px 28px rgba(188, 73, 19, 0.4), 0 0 0 1px rgba(255, 242, 230, 0.45) inset;
}

@media (max-width: 820px) {
  .page-switch {
    width: 100%;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    grid-template-columns: none;
  }

  .page-switch .nav-link-button {
    justify-content: center;
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .page-switch .nav-link-button,
  .page-switch .nav-link-button.is-active,
  .page-switch .nav-link-button[aria-current="page"] {
    animation: none;
    transition: background 140ms ease, color 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
  }

  .page-switch .nav-link-button::after,
  .page-switch .nav-link-button:hover::after,
  .page-switch .nav-link-button:focus-visible::after {
    animation: none;
    opacity: 0;
  }
}

.workspace-pane > .studio-grid {
  margin-top: 18px;
}

@media (max-width: 820px) {
  .workspace-pane > .studio-grid {
    margin-top: 14px;
  }
}


body.apple-ui .hero-card .model-strip,
body.apple-ui .hero-card .model-pill {
  display: none !important;
}

body.apple-ui .topbar .page-switch {
  --kk-nav-shell-a: rgba(7, 28, 60, 0.95);
  --kk-nav-shell-b: rgba(12, 52, 99, 0.9);
  --kk-nav-idle-bg-a: rgba(244, 250, 255, 0.97);
  --kk-nav-idle-bg-b: rgba(210, 228, 255, 0.96);
  --kk-nav-idle-fg: #113f7a;
  --kk-nav-idle-border: rgba(72, 129, 207, 0.52);
  --kk-nav-active-bg: linear-gradient(140deg, #ffd9ac 0%, #ffa14d 32%, #f7741f 66%, #ba370f 100%);
  --kk-nav-active-fg: #fff8ef;
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  width: min(640px, 100%);
  padding: 8px;
  border-radius: 24px;
  border: 1px solid rgba(121, 184, 255, 0.42);
  overflow: hidden;
  background:
    radial-gradient(circle at 15% 6%, rgba(126, 208, 255, 0.34), transparent 42%),
    radial-gradient(circle at 88% 90%, rgba(255, 177, 109, 0.32), transparent 48%),
    linear-gradient(132deg, var(--kk-nav-shell-a), var(--kk-nav-shell-b));
  box-shadow: inset 0 1px 0 rgba(228, 244, 255, 0.3), 0 16px 34px rgba(7, 33, 70, 0.32);
}

body.apple-ui .topbar .page-switch::before {
  content: "";
  position: absolute;
  inset: -40% -16%;
  z-index: 0;
  pointer-events: none;
  background: conic-gradient(from 90deg, rgba(133, 213, 255, 0.2), rgba(255, 208, 146, 0.2), rgba(108, 174, 255, 0.18), rgba(133, 213, 255, 0.2));
  animation: kk-nav-shell-flow 10s linear infinite;
}

body.apple-ui .topbar .page-switch::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.2), transparent 30%, transparent 70%, rgba(4, 16, 38, 0.14));
}

body.apple-ui .topbar .page-switch .nav-link-button {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-rows: auto auto;
  justify-items: center;
  align-content: center;
  gap: 2px;
  min-height: 54px;
  margin: 0;
  padding: 8px 14px 10px;
  border: 1.6px solid var(--kk-nav-idle-border);
  border-radius: 16px;
  background: linear-gradient(164deg, var(--kk-nav-idle-bg-a), var(--kk-nav-idle-bg-b));
  color: var(--kk-nav-idle-fg);
  text-decoration: none;
  line-height: 1.05;
  transform: translateY(0) scale(1);
  opacity: 0;
  box-shadow: 0 9px 18px rgba(9, 58, 121, 0.2), 0 1px 0 rgba(255, 255, 255, 0.65) inset;
  transition: transform 240ms cubic-bezier(0.22, 1, 0.36, 1), box-shadow 220ms ease, border-color 220ms ease, color 220ms ease, filter 220ms ease, background 220ms ease;
  animation: kk-nav-item-enter 520ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

body.apple-ui .topbar .page-switch .nav-link-button:nth-child(1) {
  animation-delay: 40ms;
}

body.apple-ui .topbar .page-switch .nav-link-button:nth-child(2) {
  animation-delay: 120ms;
}

body.apple-ui .topbar .page-switch .nav-link-button:nth-child(3) {
  animation-delay: 200ms;
}

body.apple-ui .topbar .page-switch .nav-link-button::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  transform: translateX(-140%);
  background: linear-gradient(120deg, transparent 8%, rgba(255, 255, 255, 0.56) 44%, transparent 76%);
}

body.apple-ui .topbar .page-switch .nav-link-button:hover::after,
body.apple-ui .topbar .page-switch .nav-link-button:focus-visible::after {
  opacity: 1;
  animation: kk-nav-button-sheen 760ms ease;
}

body.apple-ui .topbar .page-switch .nav-link-button .nav-link-kicker {
  font-size: 0.58rem;
  letter-spacing: 0.2em;
  font-weight: 700;
  text-transform: uppercase;
  opacity: 0.78;
}

body.apple-ui .topbar .page-switch .nav-link-button .nav-link-title {
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.01em;
}

body.apple-ui .topbar .page-switch .nav-link-button:not(.is-active):not([aria-current="page"]) {
  filter: saturate(0.84);
}

body.apple-ui .topbar .page-switch .nav-link-button:not(.is-active):not([aria-current="page"]):hover,
body.apple-ui .topbar .page-switch .nav-link-button:not(.is-active):not([aria-current="page"]):focus-visible {
  transform: translateY(-2px) scale(1.025);
  filter: saturate(1);
  border-color: rgba(35, 116, 213, 0.66);
  box-shadow: 0 14px 26px rgba(13, 73, 147, 0.28), 0 1px 0 rgba(255, 255, 255, 0.7) inset;
}

body.apple-ui .topbar .page-switch .nav-link-button.is-active,
body.apple-ui .topbar .page-switch .nav-link-button[aria-current="page"] {
  border-color: rgba(128, 44, 8, 0.86);
  background: var(--kk-nav-active-bg);
  color: var(--kk-nav-active-fg);
  filter: none;
  text-shadow: 0 1px 0 rgba(81, 19, 0, 0.46);
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 0 0 1px rgba(255, 234, 209, 0.48) inset, 0 18px 36px rgba(177, 67, 15, 0.48);
  animation: kk-nav-item-enter 520ms cubic-bezier(0.22, 1, 0.36, 1) forwards, kk-nav-active-breathe 2.7s ease-in-out 560ms infinite;
}

body.apple-ui .topbar .page-switch .nav-link-button.is-active:hover,
body.apple-ui .topbar .page-switch .nav-link-button[aria-current="page"]:hover,
body.apple-ui .topbar .page-switch .nav-link-button.is-active:focus-visible,
body.apple-ui .topbar .page-switch .nav-link-button[aria-current="page"]:focus-visible {
  transform: translateY(-3px) scale(1.035);
  box-shadow: 0 0 0 1px rgba(255, 241, 224, 0.56) inset, 0 22px 40px rgba(177, 67, 15, 0.54);
}

body.apple-ui .topbar .page-switch .nav-link-button:focus-visible {
  outline: 2px solid rgba(255, 220, 168, 0.92);
  outline-offset: 1px;
}

body.apple-ui .workspace-tabbar {
  position: relative;
  isolation: isolate;
  border: 1px solid rgba(118, 183, 255, 0.4);
  background:
    radial-gradient(circle at 14% 10%, rgba(124, 208, 255, 0.3), transparent 40%),
    radial-gradient(circle at 84% 90%, rgba(255, 178, 109, 0.28), transparent 48%),
    linear-gradient(132deg, rgba(7, 28, 60, 0.95), rgba(12, 52, 99, 0.9));
  box-shadow: inset 0 1px 0 rgba(228, 244, 255, 0.28), 0 18px 36px rgba(7, 33, 70, 0.3);
}

body.apple-ui .workspace-tabbar::before {
  content: "";
  position: absolute;
  inset: -60% -26%;
  z-index: 0;
  pointer-events: none;
  background: conic-gradient(from 120deg, rgba(132, 214, 255, 0.22), rgba(255, 206, 143, 0.2), rgba(106, 173, 255, 0.2), rgba(132, 214, 255, 0.22));
  animation: kk-nav-shell-flow 12s linear infinite reverse;
}

body.apple-ui .workspace-tabbar .workspace-tab {
  position: relative;
  z-index: 1;
  min-height: 66px;
  border-radius: 18px;
  border: 1.5px solid rgba(72, 129, 207, 0.5);
  background: linear-gradient(164deg, rgba(244, 250, 255, 0.97), rgba(210, 228, 255, 0.96));
  color: #113f7a;
  text-shadow: none;
  filter: saturate(0.85);
  box-shadow: 0 10px 20px rgba(9, 58, 121, 0.2), 0 1px 0 rgba(255, 255, 255, 0.65) inset;
  transition: transform 240ms cubic-bezier(0.22, 1, 0.36, 1), box-shadow 220ms ease, border-color 220ms ease, filter 220ms ease, color 220ms ease, background 220ms ease;
}

body.apple-ui .workspace-tabbar .workspace-tab:hover,
body.apple-ui .workspace-tabbar .workspace-tab:focus-visible {
  transform: translateY(-2px) scale(1.015);
  filter: saturate(1);
  border-color: rgba(35, 116, 213, 0.66);
  box-shadow: 0 14px 26px rgba(13, 73, 147, 0.28), 0 1px 0 rgba(255, 255, 255, 0.7) inset;
}

body.apple-ui .workspace-tabbar .workspace-tab .workspace-tab-subtitle {
  color: rgba(20, 67, 125, 0.7);
}

body.apple-ui .workspace-tabbar .workspace-tab.is-active {
  border-color: rgba(128, 44, 8, 0.86);
  background: linear-gradient(140deg, #ffd9ac 0%, #ffa14d 32%, #f7741f 66%, #ba370f 100%);
  color: #fff8ef;
  filter: none;
  text-shadow: 0 1px 0 rgba(81, 19, 0, 0.46);
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 0 0 1px rgba(255, 234, 209, 0.48) inset, 0 18px 36px rgba(177, 67, 15, 0.48);
  animation: kk-nav-active-breathe 2.7s ease-in-out 520ms infinite;
}

body.apple-ui .workspace-tabbar .workspace-tab.is-active .workspace-tab-subtitle {
  color: rgba(255, 246, 237, 0.92);
}

body.apple-ui .workspace-tabbar .workspace-tab-indicator {
  opacity: 0;
  pointer-events: none;
}



@media (max-width: 980px) {
  body.apple-ui .topbar .page-switch {
    width: 100%;
    min-width: 0;
  }
}

@media (max-width: 700px) {
  body.apple-ui .topbar .page-switch {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  body.apple-ui .topbar .page-switch .nav-link-button {
    min-height: 48px;
    grid-template-columns: auto 1fr;
    grid-template-rows: none;
    justify-items: start;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
  }

  body.apple-ui .topbar .page-switch .nav-link-button .nav-link-kicker {
    font-size: 0.56rem;
    letter-spacing: 0.16em;
  }

  body.apple-ui .topbar .page-switch .nav-link-button .nav-link-title {
    font-size: 0.92rem;
  }

  body.apple-ui .workspace-tabbar .workspace-tab {
    min-height: 60px;
  }
}

body.apple-ui.page-admin .topbar-actions {
  flex-wrap: wrap;
  align-items: stretch;
}

body.apple-ui.page-admin .topbar .page-switch {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  grid-template-columns: none;
  gap: 10px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  flex: 1 1 100%;
  overflow: visible;
  white-space: normal;
}

body.apple-ui.page-admin .topbar .page-switch .nav-link-button {
  width: 100%;
  min-width: 0;
  justify-content: center;
}

/* Compact tabbar when nested inside topbar */
.topbar .workspace-tabbar {
  display: flex;
  margin-left: auto;
  width: auto;
  max-width: 420px;
  min-width: 0;
}

.topbar .workspace-tab {
  flex: 1;
  min-height: 37px;
  padding: 5px 12px;
}

.topbar .workspace-tab-title {
  font-size: 0.8rem;
  white-space: nowrap;
}

.topbar .workspace-tab-subtitle {
  font-size: 0.73rem;
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  body.apple-ui .topbar .page-switch::before,
  body.apple-ui .workspace-tabbar::before {
    animation: none;
  }

  body.apple-ui .topbar .page-switch .nav-link-button,
  body.apple-ui .topbar .page-switch .nav-link-button.is-active,
  body.apple-ui .topbar .page-switch .nav-link-button[aria-current="page"],
  body.apple-ui .workspace-tabbar .workspace-tab,
  body.apple-ui .workspace-tabbar .workspace-tab.is-active {
    animation: none;
    transition: background 150ms ease, color 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
  }

  body.apple-ui .topbar .page-switch .nav-link-button::after,
  body.apple-ui .topbar .page-switch .nav-link-button:hover::after,
  body.apple-ui .topbar .page-switch .nav-link-button:focus-visible::after {
    animation: none;
    opacity: 0;
  }
}

.auth-shell {
  padding-top: 56px;
}

.auth-topbar {
  margin-bottom: 24px;
  padding: 26px 30px;
  gap: 24px;
}

.auth-topbar .brand-lockup {
  gap: 16px;
}

.auth-topbar .brand-mark {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  font: 700 1.5rem "Inter", "Noto Sans SC", sans-serif;
}

body.apple-ui .auth-topbar .brand-mark {
  border-radius: 18px;
}

.auth-topbar .brand-lockup h1 {
  font-size: revert;
}

.auth-topbar .eyebrow {
  margin-bottom: 6px;
  font-size: 0.76rem;
}

.auth-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(360px, 0.95fr);
  gap: 24px;
}

.auth-intro-panel,
.auth-panel {
  min-height: 100%;
}

.auth-intro-panel h2 {
  margin: 0;
  font-family: "Inter", "Noto Sans SC", sans-serif;
  font-size: clamp(2rem, 3vw, 2.8rem);
  line-height: 1.05;
}

.auth-copy {
  margin: 18px 0 0;
  color: var(--muted);
  line-height: 1.8;
}

.auth-points {
  margin: 24px 0 0;
  padding-left: 20px;
  color: var(--ink);
  line-height: 1.9;
}

.auth-tabbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0 0;
}

.auth-tab-button {
  border: 1px solid rgba(46, 25, 11, 0.12);
  background: rgba(255, 245, 233, 0.88);
  color: var(--muted);
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background-color 160ms ease;
}

.auth-tab-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 16px rgba(48, 28, 14, 0.08);
}

.auth-tab-button.is-active {
  background: linear-gradient(135deg, var(--accent) 0%, #ff9e52 100%);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 12px 24px rgba(240, 111, 47, 0.22);
}

.auth-tab-panel {
  margin-top: 14px;
}

.auth-tab-panel[hidden] {
  display: none;
}

.auth-panel-status {
  margin-top: 14px;
}

.auth-helper-copy {
  margin: 2px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.auth-form {
  display: grid;
  gap: 18px;
  margin-top: 22px;
}

.auth-submit {
  width: 100%;
}

.auth-error-banner {
  margin-top: 18px;
  background: rgba(255, 232, 228, 0.92);
  color: #8c2f18;
}

.page-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.prompt-inference-grid {
  grid-template-columns: minmax(320px, 0.95fr) minmax(420px, 1.05fr);
}

#inference-preview-frame {
  width: 50%;
  min-height: 110px;
  padding: 10px;
}

#inference-preview-image {
  display: block;
  width: 100%;
  height: 100%;
  margin: 0 auto;
  object-fit: contain;
}


.admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
  padding: 8px;
  border-radius: 18px;
  background: rgba(255, 246, 234, 0.9);
  border: 1px solid rgba(46, 25, 11, 0.08);
}

.admin-tab-button {
  border-radius: 999px;
  padding: 10px 16px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
  border: 1px solid rgba(46, 25, 11, 0.16);
  transition: transform 150ms ease, background 180ms ease, color 180ms ease, box-shadow 180ms ease;
}

.admin-tab-button:hover {
  transform: translateY(-1px);
  background: rgba(255, 239, 222, 0.88);
  color: #7f3212;
}

.admin-tab-button.is-active {
  background: linear-gradient(135deg, var(--accent) 0%, #ff9e52 100%);
  color: #fff;
  box-shadow: 0 12px 24px rgba(240, 111, 47, 0.22);
}

.admin-tab-panel {
  margin-top: 24px;
}

.admin-tab-panel[hidden] {
  display: none;
}

.admin-subtabs {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 2px;
  padding: 6px;
  border-radius: 14px;
  background: rgba(255, 244, 230, 0.82);
  border: 1px solid rgba(46, 25, 11, 0.08);
}

.admin-subtab-button {
  border-radius: 999px;
  padding: 8px 14px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
  border: 1px solid rgba(46, 25, 11, 0.16);
  transition: transform 150ms ease, background 180ms ease, color 180ms ease, box-shadow 180ms ease;
}

.admin-subtab-button:hover {
  transform: translateY(-1px);
  background: rgba(255, 239, 222, 0.88);
  color: #7f3212;
}

.admin-subtab-button.is-active {
  background: rgba(240, 111, 47, 0.18);
  color: #7f3212;
  box-shadow: inset 0 0 0 1px rgba(240, 111, 47, 0.18);
}

.admin-subtab-panel {
  margin-top: 18px;
}

.admin-subtab-panel[hidden] {
  display: none;
}

.admin-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  margin-top: 26px;
}

.summary-card,
.model-summary-card {
  display: grid;
  gap: 8px;
  padding: 18px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(46, 25, 11, 0.08);
}

.summary-card strong,
.model-summary-card strong {
  font-family: "Inter", "Noto Sans SC", sans-serif;
  font-size: 1.35rem;
}

.model-summary-panel {
  margin-top: 28px;
}

.compact-heading {
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.compact-heading > div {
  min-width: 0;
}

.history-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.history-link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  white-space: nowrap;
}

.model-summary-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.model-summary-card span {
  color: var(--muted);
}

.admin-filter-form {
  display: grid;
  gap: 20px;
  margin-top: 20px;
}

.admin-filter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.admin-action-button {
  width: auto;
}

.history-table-wrap {
  margin-top: 22px;
  overflow-x: auto;
  border-radius: 16px;
  border: 1px solid rgba(46, 25, 11, 0.1);
  background: rgba(255, 255, 255, 0.56);
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}

.history-table th,
.history-table td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid rgba(46, 25, 11, 0.1);
}

.history-table th {
  color: var(--accent-dark);
  font-size: 0.84rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: rgba(255, 241, 227, 0.9);
}

.history-table td {
  color: rgba(32, 21, 13, 0.92);
  background: rgba(255, 255, 255, 0.35);
  word-break: break-word;
}

.history-table tbody tr:hover td {
  background: rgba(255, 247, 239, 0.82);
}

.history-empty-row td {
  color: var(--muted);
  text-align: center;
}

.admin-pagination {
  margin-top: 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.admin-pagination-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.pagination-indicator {
  color: var(--muted);
  font-weight: 600;
}

.is-disabled {
  opacity: 0.55;
  pointer-events: none;
}
/* Admin/company record views: keep filters and records in vertical scroll containers. */
:root {
  --admin-record-visible-rows: 21;
  --admin-record-row-height: 42px;
  --admin-record-header-height: 44px;
  --admin-record-filter-max-height: calc(var(--admin-record-row-height) * 8);
}

.admin-filter-form.admin-record-filter-scroll {
  max-height: var(--admin-record-filter-max-height);
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 6px;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
}

.history-table-wrap.admin-record-table-scroll {
  overflow-y: auto;
  max-height: calc(var(--admin-record-header-height) + (var(--admin-record-row-height) * var(--admin-record-visible-rows)));
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
}

.history-table-wrap.admin-record-table-scroll .history-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
}

.history-table-wrap.admin-record-table-scroll .history-table th,
.history-table-wrap.admin-record-table-scroll .history-table td {
  padding-top: 10px;
  padding-bottom: 10px;
}

.history-table-wrap.admin-record-table-scroll .history-table th.admin-local-sortable {
  cursor: pointer;
  user-select: none;
  transition: color 0.15s ease;
}

.history-table-wrap.admin-record-table-scroll .history-table th.admin-local-sortable:hover,
.history-table-wrap.admin-record-table-scroll .history-table th.admin-local-sortable.is-active-sort {
  color: #2b69ff;
}

.staff-local-tools-panel {
  border: 1px solid rgba(46, 25, 11, 0.12);
}

.staff-local-filter-grid {
  margin-top: 10px;
}

.staff-local-summary-grid .summary-card strong {
  font-family: "Inter", "Noto Sans SC", sans-serif;
}

.staff-page-size-block {
  min-width: 160px;
}

#staff-local-result-meta {
  margin-left: auto;
}

#staff-export-hint {
  margin-top: 8px;
}

#staff-full-data-table th:first-child,
#staff-full-data-table td:first-child {
  width: 54px;
  text-align: center;
}

#staff-full-data-table th:last-child,
#staff-full-data-table td:last-child {
  min-width: 116px;
}

#staff-local-pagination {
  margin-top: 12px;
}

@media (max-width: 1200px) {
  .staff-local-filter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .staff-local-filter-grid {
    grid-template-columns: 1fr;
  }

  #staff-local-result-meta {
    margin-left: 0;
    width: 100%;
  }

  .staff-page-size-block {
    min-width: 0;
    width: 100%;
  }
}

/* -------------------------------------------------------------------------- */
/* Admin Console Visual Hierarchy Refresh                                     */
/* -------------------------------------------------------------------------- */

body.apple-ui.page-admin {
  --admin-bg-top: #f7fbff;
  --admin-bg-bottom: #eef4fb;
  --admin-surface-1: #ffffff;
  --admin-surface-2: #f7faff;
  --admin-line-soft: rgba(17, 61, 122, 0.14);
  --admin-line-strong: rgba(17, 61, 122, 0.24);
  --admin-title: #0f2f61;
  --admin-text: #25344f;
  --admin-muted: #60708a;
  --admin-accent: #236fd6;
  --admin-accent-soft: rgba(35, 111, 214, 0.12);
  --admin-warn: #f18823;
  background:
    radial-gradient(circle at 8% 4%, rgba(105, 180, 255, 0.2), transparent 26%),
    radial-gradient(circle at 92% 10%, rgba(251, 171, 96, 0.2), transparent 24%),
    linear-gradient(180deg, var(--admin-bg-top), var(--admin-bg-bottom));
  color: var(--admin-text);
}

body.apple-ui.page-admin .topbar {
  border: 1px solid var(--admin-line-strong);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(245, 250, 255, 0.9));
  box-shadow: 0 18px 40px rgba(16, 51, 102, 0.14);
}

body.apple-ui.page-admin .history-panel {
  border: 1px solid var(--admin-line-strong);
  border-radius: 26px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(244, 249, 255, 0.9));
  box-shadow: 0 20px 42px rgba(15, 48, 95, 0.12);
  padding: clamp(16px, 2vw, 28px);
}

body.apple-ui.page-admin .history-panel > .panel,
body.apple-ui.page-admin .staff-local-tools-panel,
body.apple-ui.page-admin details.panel {
  border: 1px solid var(--admin-line-soft);
  background: linear-gradient(180deg, var(--admin-surface-1), var(--admin-surface-2));
  box-shadow: 0 10px 24px rgba(15, 47, 97, 0.08);
}

body.apple-ui.page-admin .panel-heading {
  margin-top: 20px;
  margin-bottom: 12px;
  padding: 12px 14px;
  border: 1px solid var(--admin-line-soft);
  border-left: 4px solid var(--admin-accent);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(235, 245, 255, 0.72), rgba(255, 255, 255, 0.74));
}

body.apple-ui.page-admin .history-panel > .panel-heading:first-child {
  margin-top: 0;
}

body.apple-ui.page-admin .panel-heading h3 {
  color: var(--admin-title);
  font-weight: 800;
}

body.apple-ui.page-admin .eyebrow {
  color: #2d63b3;
}

body.apple-ui.page-admin .helper-text,
body.apple-ui.page-admin .meta-label,
body.apple-ui.page-admin .pagination-indicator {
  color: var(--admin-muted);
}

body.apple-ui.page-admin .admin-filter-form,
body.apple-ui.page-admin .admin-filter-grid,
body.apple-ui.page-admin .admin-actions,
body.apple-ui.page-admin .admin-summary-grid {
  border-radius: 16px;
}

body.apple-ui.page-admin .admin-filter-form {
  padding: 14px;
  border: 1px solid var(--admin-line-soft);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(247, 251, 255, 0.88));
}

body.apple-ui.page-admin .field-block.compact-block {
  padding: 10px;
  border-radius: 12px;
  border: 1px solid rgba(17, 61, 122, 0.11);
  background: rgba(255, 255, 255, 0.76);
}

body.apple-ui.page-admin .status-banner {
  border-radius: 12px;
  border-color: rgba(35, 111, 214, 0.28);
  background: linear-gradient(180deg, rgba(232, 242, 255, 0.9), rgba(226, 239, 255, 0.88));
}

body.apple-ui.page-admin .auth-error-banner {
  border-color: rgba(192, 63, 63, 0.32);
  background: linear-gradient(180deg, rgba(255, 238, 238, 0.96), rgba(255, 233, 233, 0.94));
}

body.apple-ui.page-admin .summary-card,
body.apple-ui.page-admin .model-summary-card {
  border: 1px solid var(--admin-line-soft);
  border-radius: 16px;
  background: linear-gradient(180deg, #ffffff, #f5f9ff);
  box-shadow: 0 8px 18px rgba(15, 47, 97, 0.08);
}

body.apple-ui.page-admin .summary-card strong,
body.apple-ui.page-admin .model-summary-card strong {
  color: #1f4f9f;
  letter-spacing: 0.01em;
}

body.apple-ui.page-admin .history-table-wrap {
  margin-top: 14px;
  border: 1px solid var(--admin-line-strong);
  border-radius: 16px;
  background: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.56);
}

body.apple-ui.page-admin .history-table {
  min-width: 820px;
}

body.apple-ui.page-admin .history-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: linear-gradient(180deg, #e9f2ff, #dceafe);
  color: #124b96;
  border-bottom: 1px solid rgba(19, 66, 130, 0.24);
}

body.apple-ui.page-admin .history-table tbody td {
  background: #ffffff;
}

body.apple-ui.page-admin .history-table tbody tr:nth-child(even) td {
  background: #f7fbff;
}

body.apple-ui.page-admin .history-table tbody tr:hover td {
  background: #eaf3ff;
}

body.apple-ui.page-admin .admin-subtabs {
  padding: 8px;
  border-radius: 14px;
  border: 1px solid var(--admin-line-soft);
  background: rgba(244, 250, 255, 0.9);
}

body.apple-ui.page-admin .admin-subtab-button {
  border-radius: 10px;
  border-color: rgba(19, 66, 130, 0.18);
}

body.apple-ui.page-admin .admin-subtab-button.is-active {
  border-color: rgba(35, 111, 214, 0.34);
  background: linear-gradient(180deg, #e8f1ff, #dcecff);
  color: #104b95;
}

body.apple-ui.page-admin .page-switch {
  border: 1px solid var(--admin-line-strong);
  box-shadow: 0 10px 24px rgba(15, 47, 97, 0.12);
}

body.apple-ui.page-admin .page-switch .nav-link-button {
  border-width: 1px;
}

body.apple-ui.page-admin .page-switch .nav-link-button.is-active,
body.apple-ui.page-admin .page-switch .nav-link-button[aria-current="page"] {
  box-shadow: 0 10px 22px rgba(182, 87, 25, 0.35);
}

body.apple-ui.page-admin .ghost-button,
body.apple-ui.page-admin .primary-button {
  border-radius: 12px;
}

body.apple-ui.page-admin .primary-button {
  background: linear-gradient(135deg, #2992ff, #1f73d8 62%, #175cb1);
  border-color: rgba(18, 70, 136, 0.4);
}

body.apple-ui.page-admin .ghost-button {
  background: linear-gradient(180deg, #ffffff, #f3f8ff);
  color: #1f4f9f;
}

body.apple-ui.page-admin .history-empty-row td {
  background: linear-gradient(180deg, #f9fcff, #f3f8ff);
  color: #5b6f8f;
}

@media (max-width: 980px) {
  body.apple-ui.page-admin .history-panel {
    border-radius: 20px;
    padding: 14px;
  }

  body.apple-ui.page-admin .panel-heading {
    padding: 10px 12px;
  }
}

/* -------------------------------------------------------------------------- */
/* Custom confirm modal (replaces native window.confirm)                      */
/* -------------------------------------------------------------------------- */

.sl-confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sl-confirm-overlay[hidden] {
  display: none;
}

.sl-confirm-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 20, 40, 0.5);
  backdrop-filter: blur(3px);
}

.sl-confirm-box {
  position: relative;
  z-index: 1;
  background: linear-gradient(180deg, #ffffff, #f5faff);
  border: 1px solid rgba(17, 61, 122, 0.2);
  border-radius: 20px;
  padding: 28px 32px;
  max-width: 440px;
  width: calc(100% - 40px);
  box-shadow: 0 28px 64px rgba(10, 30, 70, 0.24);
  display: grid;
  gap: 22px;
  animation: sl-confirm-pop 0.18s ease;
}

@keyframes sl-confirm-pop {
  from { transform: scale(0.92); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

.sl-confirm-title {
  margin: 0;
  font-family: "Inter", "Noto Sans SC", sans-serif;
  font-size: 1.08rem;
  font-weight: 700;
  color: #0f2f61;
}

.sl-confirm-msg {
  margin: 0;
  font-size: 0.97rem;
  line-height: 1.65;
  color: #25344f;
}

/* -------------------------------------------------------------------------- */
/* Expandable prompt cell in log tables (click to expand / collapse)          */
/* -------------------------------------------------------------------------- */

.log-prompt-cell {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
  cursor: pointer;
  position: relative;
}

.log-prompt-cell:not(.is-expanded):not(:empty):after {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 32px;
  background: linear-gradient(to right, transparent, var(--table-row-bg, #fff));
  pointer-events: none;
}

.log-prompt-cell:not(.is-expanded):hover {
  color: var(--accent-dark, #c7511f);
}

.log-prompt-cell.is-expanded {
  white-space: normal;
  word-break: break-word;
  max-width: 480px;
  overflow: visible;
  text-overflow: clip;
  background: rgba(240, 111, 47, 0.05);
  border-radius: 4px;
  padding: 4px 6px;
}


/* ============================================================ */
/* Animations - all @keyframes rules collected from styles.css  */
/* ============================================================ */

@keyframes history-loading-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes history-loading-sheen {
  0% {
    transform: translateX(-130%);
  }
  100% {
    transform: translateX(130%);
  }
}

@keyframes history-loading-spinner-breathe {
  0%,
  100% {
    box-shadow: 0 0 0 5px rgba(240, 111, 47, 0.08);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(240, 111, 47, 0.14);
  }
}

@keyframes history-loading-bar-slide {
  0% {
    transform: translateX(-118%);
  }
  60% {
    transform: translateX(120%);
  }
  100% {
    transform: translateX(120%);
  }
}

@keyframes splitButtonSpin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes buttonSheen {
  from {
    transform: translateX(-140%) rotate(18deg);
  }

  to {
    transform: translateX(320%) rotate(18deg);
  }
}

@keyframes ctaPulse {
  0%,
  100% {
    box-shadow: 0 16px 32px rgba(240, 111, 47, 0.32);
  }

  50% {
    box-shadow: 0 18px 36px rgba(240, 111, 47, 0.46);
  }
}

@keyframes prominentAlertPopIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes bananaPulse {
  0%,
  100% {
    transform: scale(0.94);
    filter: saturate(0.96);
  }

  50% {
    transform: scale(1.04);
    filter: saturate(1.08);
  }
}

@keyframes bananaBounce {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.45;
  }

  40% {
    transform: translateY(-8px);
    opacity: 1;
  }
}

@keyframes inferenceStatusSheen {
  0% {
    background-position: 100% 0;
  }

  100% {
    background-position: -40% 0;
  }
}

@keyframes inferenceStatusDots {
  0% {
    opacity: 0.25;
  }

  100% {
    opacity: 1;
  }
}

@keyframes inferenceStatusSheenStrong {
  0% {
    background-position: 120% 0;
  }

  100% {
    background-position: -30% 0;
  }
}

@keyframes inferenceSpinnerBoost {
  to {
    transform: rotate(360deg);
  }
}

@keyframes inferenceSpinnerHalo {
  0%,
  100% {
    box-shadow: 0 0 0 6px rgba(126, 171, 235, 0.14);
  }

  50% {
    box-shadow: 0 0 0 11px rgba(126, 171, 235, 0.28);
  }
}

@keyframes inferenceStatusDotsBoost {
  0% {
    opacity: 0.2;
    transform: translateY(-50%) scale(0.88);
  }

  100% {
    opacity: 1;
    transform: translateY(-50%) scale(1.14);
  }
}

@keyframes inferenceButtonPulseStrong {
  0%,
  100% {
    transform: translateY(-1px) scale(1.03);
    filter: saturate(1.04) brightness(1);
  }

  50% {
    transform: translateY(-2px) scale(1.07);
    filter: saturate(1.16) brightness(1.06);
  }
}

@keyframes inferenceButtonGlow {
  0%,
  100% {
    box-shadow: 0 0 0 1px rgba(255, 247, 240, 0.55) inset, 0 20px 36px rgba(240, 111, 47, 0.5), 0 0 20px rgba(255, 166, 92, 0.5);
  }

  50% {
    box-shadow: 0 0 0 1px rgba(255, 247, 240, 0.62) inset, 0 24px 42px rgba(240, 111, 47, 0.56), 0 0 28px rgba(255, 186, 120, 0.75);
  }
}

@keyframes inferenceButtonRipple {
  0% {
    opacity: 0.8;
    transform: scale(0.98);
  }

  100% {
    opacity: 0;
    transform: scale(1.08);
  }
}

@keyframes inferenceButtonClickRipple {
  0% {
    opacity: 0.86;
    transform: translate(-50%, -50%) scale(0.24);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(9.2);
  }
}

@keyframes inferenceSafetyPulse {
  0%,
  100% {
    transform: translateY(0) scale(1);
    filter: saturate(1);
  }

  50% {
    transform: translateY(-1px) scale(1.01);
    filter: saturate(1.08);
  }
}

@keyframes inferenceHelperDotPulse {
  0%,
  100% {
    transform: scale(0.92);
    opacity: 0.78;
    box-shadow: 0 0 0 0 rgba(71, 137, 222, 0.42);
  }

  50% {
    transform: scale(1.15);
    opacity: 1;
    box-shadow: 0 0 0 8px rgba(71, 137, 222, 0);
  }
}

@keyframes resultReveal {
  0% {
    opacity: 0;
    transform: scale(0.98) translateY(10px);
  }

  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes resultSheen {
  0% {
    transform: translateX(-120%) skewX(-14deg);
  }

  52% {
    transform: translateX(220%) skewX(-14deg);
  }

  100% {
    transform: translateX(220%) skewX(-14deg);
  }
}

@keyframes workspacePaneEnter {
  0% {
    opacity: 0;
    transform: translateY(10px) scale(0.992);
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes workspaceAurora {
  0%,
  100% {
    transform: translateX(0) translateY(0) scale(1);
    opacity: 0.7;
  }

  50% {
    transform: translateX(3%) translateY(-2%) scale(1.04);
    opacity: 1;
  }
}

@keyframes appleFadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes page-switch-enter {
  0% {
    opacity: 0;
    transform: translateY(8px) scale(0.95);
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes page-switch-sheen {
  0% {
    transform: translateX(-150%);
  }

  100% {
    transform: translateX(150%);
  }
}

@keyframes page-switch-active-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 2px rgba(255, 243, 230, 0.68) inset, 0 16px 30px rgba(181, 73, 18, 0.4);
  }

  50% {
    box-shadow: 0 0 0 2px rgba(255, 243, 230, 0.78) inset, 0 22px 40px rgba(181, 73, 18, 0.54);
  }
}

@keyframes kk-nav-shell-flow {
  0% {
    transform: rotate(0deg) scale(1);
  }

  100% {
    transform: rotate(360deg) scale(1.08);
  }
}

@keyframes kk-nav-item-enter {
  0% {
    opacity: 0;
    transform: translateY(8px) scale(0.95);
  }

  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes kk-nav-button-sheen {
  0% {
    transform: translateX(-140%);
  }

  100% {
    transform: translateX(140%);
  }
}

@keyframes kk-nav-active-breathe {
  0%,
  100% {
    box-shadow: 0 0 0 1px rgba(255, 234, 209, 0.48) inset, 0 16px 32px rgba(177, 67, 15, 0.42);
  }

  50% {
    box-shadow: 0 0 0 1px rgba(255, 242, 227, 0.62) inset, 0 22px 42px rgba(177, 67, 15, 0.56);
  }
}

@keyframes chatLoadingGrad {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.06); }
}

@keyframes chatShimmer {
  0% { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}

@keyframes sendPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

@keyframes kk-copy-pop {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.18); }
  70%  { transform: scale(0.96); }
  100% { transform: scale(1); }
}

@media (max-width: 1040px) {
  .topbar {
    align-items: flex-start;
  }

  .studio-grid,
  .dual-grid,
  .auth-grid,
  .admin-filter-grid,
  .admin-summary-grid {
    grid-template-columns: 1fr;
  }

  .topbar-actions {
    justify-content: flex-start;
  }

  .history-table {
    min-width: 760px;
  }

  .prompt-inference-grid {
    grid-template-columns: 1fr;
  }

  .auth-tabbar {
    display: grid;
    grid-template-columns: 1fr;
  }

  .workspace-tabbar {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .workspace-tab {
    min-width: 0;
  }

  .unified-workbench .panel {
    padding: 26px;
  }

  .workbench-header {
    padding: 20px 26px 16px;
  }

  .workbench-lane-labels {
    grid-template-columns: 1fr;
  }

  .control-panel {
    max-height: none;
    overflow-y: visible;
  }
}

@media (max-width: 720px) {
  .page-shell {
    padding-top: 14px;
  }

  .topbar,
  .hero-card,
  .panel {
    padding: 22px;
    border-radius: 24px;
  }

  .unified-workbench .panel {
    padding: 22px;
  }

  .workbench-header {
    padding: 18px 22px 14px;
  }

  .brand-lockup {
    width: 100%;
    align-items: flex-start;
  }

  .topbar,
  .prompt-tools,
  .action-row,
  .result-meta,
  .topbar-actions {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar .workspace-tabbar {
    width: 100%;
    max-width: none;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .topbar-actions,
  .admin-actions,
  .admin-pagination-actions,
  .admin-tabs,
  .admin-subtabs {
    width: 100%;
  }

  .topbar-actions > *,
  .prompt-tools > *,
  .action-row > *,
  .result-meta > *,
  .admin-actions > *,
  .admin-pagination-actions > *,
  .admin-tabs > *,
  .admin-subtabs > * {
    width: 100%;
  }

  .topbar-note,
  .helper-text,
  .pagination-indicator {
    width: 100%;
  }

  .page-switch {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .choice-chip small {
    padding-left: 0;
  }

  .result-stage {
    min-height: 360px;
  }

  .result-image-themed {
    width: 76%;
    max-width: 76%;
  }

  .summary-card strong,
  .model-summary-card strong {
    font-size: 1.15rem;
  }

  .history-table {
    min-width: 640px;
  }

  .history-table th,
  .history-table td {
    padding: 12px 14px;
  }

  .result-stage {
    min-height: 360px;
  }

  .primary-button {
    width: 100%;
  }

  .download-button,
  .nav-link-button,
  .ghost-button,
  .admin-tab-button,
  .admin-subtab-button {
    justify-content: center;
  }

  .image-lightbox {
    flex-direction: column;
  }

  .lightbox-side-panel {
    width: 100%;
    max-height: 220px;
    border-left: 0;
    border-top: 1px solid #e8e8e8;
  }

  .lightbox-panel-body {
    padding: 10px 14px;
  }

  .lightbox-image {
    max-width: 100%;
    max-height: calc(100vh - 240px);
  }

  .lightbox-tools {
    top: 10px;
    left: 10px;
    gap: 6px;
  }

  .lightbox-tool-button {
    min-width: 44px;
    padding: 9px 10px;
  }

  .lightbox-close {
    top: 8px;
    right: 10px;
  }
}

@media (max-width: 560px) {
  .page-shell {
    padding-bottom: 28px;
  }

  .topbar,
  .hero-card,
  .panel {
    padding: 16px;
    border-radius: 20px;
  }

  .brand-mark {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    font-size: 1.2rem;
  }

  .brand-lockup {
    gap: 12px;
  }

  .brand-lockup h1,
  .panel-heading h3 {
    font-size: 1.15rem;
  }

  textarea,
  .auth-input,
  .ghost-button,
  .primary-button {
    font-size: 16px;
  }

  .upload-dropzone,
  .result-meta,
  .usage-box {
    padding: 16px;
  }

  .prompt-tools,
  .action-row,
  .result-meta,
  .admin-pagination {
    gap: 10px;
  }

  .segmented-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .segmented-chip {
    min-width: 0;
  }

  .segmented-chip span {
    min-width: 0;
    width: 100%;
    padding-inline: 10px;
  }

  .choice-chip span {
    padding: 14px 16px;
  }

  .model-summary-list {
    grid-template-columns: 1fr;
  }

  .history-table {
    min-width: 560px;
  }
}

@media (max-width: 420px) {
  .preview-frame,
  .result-stage {
    min-height: 150px;
  }

  .segmented-row {
    grid-template-columns: 1fr;
  }

  .history-table {
    min-width: 520px;
  }
}


/* -------------------------------------------------------------------------- */
/* Apple-inspired Fullscreen Redesign                                         */
/* -------------------------------------------------------------------------- */

html,
body {
  min-height: 100%;
}

body.apple-ui {
  --bg: #f3f6fb;
  --surface: rgba(255, 255, 255, 0.74);
  --ink: #0f172a;
  --muted: #566076;
  --line: rgba(15, 23, 42, 0.12);
  --accent: #0071e3;
  --accent-dark: #004a98;
  --shadow: 0 24px 60px rgba(2, 17, 48, 0.14);
  --radius-xl: 28px;
  --radius-lg: 20px;
  min-height: 100dvh;
  color: var(--ink);
  font-family: "Inter", "SF Pro Display", "PingFang SC", "Noto Sans SC", sans-serif;
  background:
    radial-gradient(circle at 12% 8%, rgba(100, 165, 255, 0.45), transparent 30%),
    radial-gradient(circle at 86% 14%, rgba(0, 113, 227, 0.28), transparent 28%),
    radial-gradient(circle at 50% 92%, rgba(80, 140, 240, 0.18), transparent 40%),
    linear-gradient(180deg, #e8f2ff 0%, #dce8f8 52%, #cfddf4 100%);
}

body.apple-ui::before {
  background-image:
    radial-gradient(circle at 16% 14%, rgba(255, 255, 255, 0.5), transparent 38%),
    radial-gradient(circle at 78% 72%, rgba(0, 113, 227, 0.12), transparent 36%);
  background-size: auto;
  mask-image: none;
}

body.apple-ui[data-workspace-tab="image"] {
  background:
    radial-gradient(circle at 12% 8%, rgba(100, 165, 255, 0.45), transparent 30%),
    radial-gradient(circle at 86% 14%, rgba(0, 113, 227, 0.28), transparent 28%),
    radial-gradient(circle at 50% 92%, rgba(80, 140, 240, 0.18), transparent 40%),
    linear-gradient(180deg, #e8f2ff 0%, #dce8f8 52%, #cfddf4 100%);
}

body.apple-ui[data-workspace-tab="infer"] {
  background:
    radial-gradient(circle at 10% 10%, rgba(100, 210, 170, 0.32), transparent 28%),
    radial-gradient(circle at 84% 14%, rgba(60, 130, 255, 0.26), transparent 28%),
    radial-gradient(circle at 50% 92%, rgba(80, 140, 240, 0.16), transparent 38%),
    linear-gradient(180deg, #e6f5ff 0%, #daeef8 54%, #cce4f2 100%);
}

body.apple-ui .page-shell {
  min-height: 100dvh;
  width: 100%;
  padding: clamp(16px, 2.4vw, 34px);
  display: flex;
  flex-direction: column;
  gap: clamp(14px, 1.8vw, 24px);
}

body.apple-ui .topbar,
body.apple-ui .hero-card,
body.apple-ui .panel,
body.apple-ui .history-table-wrap,
body.apple-ui .history-generation-item,
body.apple-ui .summary-card,
body.apple-ui .model-summary-card {
  border-color: rgba(255, 255, 255, 0.75);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.88), rgba(240, 248, 255, 0.76));
  box-shadow: 0 8px 32px rgba(8, 26, 80, 0.14), 0 1px 0 rgba(255, 255, 255, 0.9) inset;
  backdrop-filter: blur(28px) saturate(180%);
}

body.apple-ui .topbar {
  align-items: center;
  border-radius: var(--radius-xl);
}

body.apple-ui .brand-mark {
  border-radius: 13px;
  background: linear-gradient(140deg, #7c3aed 0%, #4338ca 46%, #0891b2 100%);
  box-shadow: 0 18px 36px rgba(99, 56, 210, 0.36), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}

body.apple-ui .eyebrow {
  color: #3e6da5;
  letter-spacing: 0.14em;
}

body.apple-ui .brand-lockup h1,
body.apple-ui .panel-heading h3,
body.apple-ui .workbench-title-group h3,
body.apple-ui .history-generation-title,
body.apple-ui .history-brand h1,
body.apple-ui .auth-intro-panel h2 {
  color: #0b1b37;
  font-family: "Inter", "SF Pro Display", "PingFang SC", "Noto Sans SC", sans-serif;
}

body.apple-ui .topbar-note,
body.apple-ui .helper-text,
body.apple-ui .meta-label,
body.apple-ui .upload-subtitle,
body.apple-ui .choice-chip small,
body.apple-ui .history-brand .subline,
body.apple-ui .pagination-indicator,
body.apple-ui .model-summary-card span {
  color: #5d6880;
}

body.apple-ui .user-badge {
  border: 1px solid rgba(10, 29, 62, 0.12);
  background: rgba(250, 253, 255, 0.86);
}

body.apple-ui .workbench-header,
body.apple-ui .unified-workbench .panel-heading {
  border-bottom-color: rgba(20, 55, 112, 0.14);
}

body.apple-ui .workbench-lane-label {
  border: 1px solid rgba(0, 113, 227, 0.24);
  background: linear-gradient(135deg, rgba(227, 241, 255, 0.9), rgba(214, 233, 255, 0.78));
  color: #1458aa;
}

body.apple-ui textarea,
body.apple-ui .auth-input,
body.apple-ui .field-select,
body.apple-ui .split-prompt-textarea {
  border: 1px solid rgba(18, 45, 92, 0.16);
  border-radius: 16px;
  background: rgba(252, 254, 255, 0.92);
  color: #0f1f3a;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

body.apple-ui textarea:focus,
body.apple-ui .auth-input:focus,
body.apple-ui .field-select:focus,
body.apple-ui .split-prompt-textarea:focus {
  outline: 2px solid rgba(0, 113, 227, 0.35);
  outline-offset: 2px;
  border-color: rgba(0, 113, 227, 0.42);
}

body.apple-ui .upload-dropzone {
  border: 1.5px dashed rgba(0, 113, 227, 0.34);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(245, 251, 255, 0.96), rgba(231, 242, 255, 0.9));
}

body.apple-ui .preview-frame,
body.apple-ui .result-stage {
  border: 1px solid rgba(16, 43, 84, 0.14);
  background: linear-gradient(180deg, rgba(252, 255, 255, 0.92), rgba(236, 244, 253, 0.86));
}

body.apple-ui .ghost-button,
body.apple-ui .nav-link-button,
body.apple-ui .download-link,
body.apple-ui .history-link-button,
body.apple-ui .admin-tab-button,
body.apple-ui .admin-subtab-button,
body.apple-ui .workspace-tab,
body.apple-ui .lightbox-tool-button,
body.apple-ui .lightbox-close {
  border: 1px solid rgba(18, 58, 116, 0.2);
  background: linear-gradient(180deg, rgba(250, 253, 255, 0.96), rgba(233, 244, 255, 0.92));
  color: #0d4f9d;
  box-shadow: 0 10px 22px rgba(5, 46, 99, 0.13);
}

body.apple-ui .ghost-button:hover,
body.apple-ui .nav-link-button:hover,
body.apple-ui .download-link:hover,
body.apple-ui .history-link-button:hover,
body.apple-ui .admin-tab-button:hover,
body.apple-ui .admin-subtab-button:hover,
body.apple-ui .workspace-tab:hover,
body.apple-ui .lightbox-tool-button:hover,
body.apple-ui .lightbox-close:hover {
  color: #003f88;
  border-color: rgba(0, 113, 227, 0.36);
  box-shadow: 0 14px 26px rgba(0, 71, 144, 0.18);
}

body.apple-ui .primary-button,
body.apple-ui #split-prompts-button,
body.apple-ui #run-single-prompt-button,
body.apple-ui #run-all-prompts-button,
body.apple-ui #infer-submit-button,
body.apple-ui #download-button {
  border: 1px solid rgba(0, 74, 152, 0.35);
  background: linear-gradient(135deg, #27a7ff 0%, #0071e3 45%, #005bc4 100%);
  color: #f6fbff;
  box-shadow: 0 16px 34px rgba(0, 113, 227, 0.34);
}

body.apple-ui .primary-button:hover,
body.apple-ui #split-prompts-button:hover,
body.apple-ui #run-single-prompt-button:hover,
body.apple-ui #run-all-prompts-button:hover,
body.apple-ui #infer-submit-button:hover,
body.apple-ui #download-button:hover {
  box-shadow: 0 20px 36px rgba(0, 113, 227, 0.4);
}

body.apple-ui .chip-grid {
  gap: 12px;
}

body.apple-ui .choice-chip span,
body.apple-ui .segmented-chip span {
  border-color: rgba(18, 58, 116, 0.16);
  background: rgba(252, 255, 255, 0.88);
  color: #102a54;
}

body.apple-ui .choice-chip input:checked + span,
body.apple-ui .segmented-chip input:checked + span {
  border-color: rgba(0, 113, 227, 0.65);
  background: linear-gradient(135deg, #37b1ff, #0071e3);
  color: #f8fcff;
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.18), 0 16px 30px rgba(0, 113, 227, 0.25);
}

body.apple-ui .workspace-tabbar {
  border: 1px solid rgba(17, 54, 106, 0.16);
  background: linear-gradient(180deg, rgba(247, 252, 255, 0.95), rgba(232, 243, 255, 0.92));
}

body.apple-ui .workspace-tabbar::before {
  background:
    radial-gradient(circle at 20% 30%, rgba(0, 113, 227, 0.16), transparent 32%),
    radial-gradient(circle at 82% 68%, rgba(53, 179, 255, 0.12), transparent 30%);
}

body.apple-ui .workspace-tab {
  color: #1d4f92;
  border-color: rgba(19, 58, 116, 0.18);
  background: rgba(252, 255, 255, 0.9);
}

body.apple-ui .workspace-tab.is-active {
  color: #f6fbff;
}

body.apple-ui .workspace-tab-indicator {
  background: linear-gradient(135deg, rgba(31, 170, 255, 0.96), rgba(0, 113, 227, 0.98));
  box-shadow: 0 12px 26px rgba(0, 113, 227, 0.32);
}

body.apple-ui .status-banner {
  border: 1px solid rgba(0, 113, 227, 0.2);
  background: linear-gradient(135deg, rgba(232, 244, 255, 0.92), rgba(223, 239, 255, 0.9));
  color: #0d4f9d;
}

body.apple-ui .auth-error-banner {
  border-color: rgba(197, 55, 55, 0.25);
  background: rgba(255, 236, 236, 0.92);
  color: #a43030;
}

body.apple-ui .history-result-block {
  margin-top: 18px;
}

body.apple-ui .generation-history {
  max-height: min(198dvh, 2580px);
  padding-right: 2px;
}

body.page-history .generation-history,
body.page-history #generation-history {
  max-height: none;
}

body.page-history[data-history-purpose="image_generation"],
body.page-history[data-history-purpose="prompt_inference"] {
  overflow: hidden;
}

body.page-history[data-history-purpose="image_generation"] .page-shell,
body.page-history[data-history-purpose="prompt_inference"] .page-shell {
  height: 100dvh;
  overflow: hidden;
}

body.page-history[data-history-purpose="image_generation"] #generation-history,
body.page-history[data-history-purpose="prompt_inference"] #generation-history {
  max-height: calc(100dvh - 240px);
  overflow-y: scroll;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

body.apple-ui .history-generation-item {
  border: 1px solid rgba(20, 60, 120, 0.12);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(240, 247, 255, 0.8));
}

body.apple-ui .history-generation-time,
body.apple-ui .history-generation-user,
body.apple-ui .history-generation-model,
body.apple-ui .history-purpose-badge,
body.apple-ui .history-image-tag,
body.apple-ui .history-image-action-button,
body.apple-ui .history-prompt-copy-button,
body.apple-ui .history-apply-prompt-button {
  border-color: rgba(10, 62, 129, 0.22);
  background: rgba(235, 245, 255, 0.92);
  color: #1458aa;
}

body.apple-ui .history-purpose-badge.is-prompt-inference,
body.apple-ui .history-image-tag.is-original {
  background: rgba(225, 247, 241, 0.92);
  border-color: rgba(35, 138, 110, 0.26);
  color: #17755b;
}

body.apple-ui .history-purpose-badge.is-image-generation,
body.apple-ui .history-image-tag.is-output {
  background: rgba(231, 241, 255, 0.92);
  border-color: rgba(10, 74, 160, 0.24);
  color: #1458aa;
}

body.apple-ui .history-generation-image-card {
  border-color: rgba(18, 60, 116, 0.14);
  background: rgba(252, 255, 255, 0.92);
}

body.apple-ui .history-generation-image {
  background: linear-gradient(180deg, rgba(252, 255, 255, 0.96), rgba(238, 246, 255, 0.92));
}

body.apple-ui .history-generation-prompt {
  border-color: rgba(18, 61, 119, 0.14);
  background: rgba(248, 252, 255, 0.88);
  color: #233251;
}

body.apple-ui .history-table-wrap {
  border-color: rgba(15, 56, 110, 0.16);
  background: rgba(252, 255, 255, 0.85);
}

body.apple-ui .history-table th {
  background: linear-gradient(180deg, rgba(234, 245, 255, 0.95), rgba(226, 239, 255, 0.92));
  color: #1255a3;
  border-bottom-color: rgba(18, 60, 116, 0.16);
}

body.apple-ui .history-table td {
  background: rgba(252, 255, 255, 0.7);
  border-bottom-color: rgba(18, 60, 116, 0.1);
  color: #1f2d45;
}

body.apple-ui .history-table tbody tr:hover td {
  background: rgba(236, 246, 255, 0.8);
}

body.apple-ui .admin-tabs,
body.apple-ui .admin-subtabs {
  border-color: rgba(12, 54, 110, 0.14);
  background: rgba(247, 252, 255, 0.9);
}

body.apple-ui .admin-tab-button.is-active {
  border-color: rgba(0, 113, 227, 0.44);
  background: linear-gradient(135deg, #2ab0ff, #0071e3);
  color: #f7fcff;
  box-shadow: 0 14px 26px rgba(0, 113, 227, 0.28);
}

body.apple-ui .admin-subtab-button.is-active {
  border-color: rgba(0, 113, 227, 0.28);
  background: rgba(227, 241, 255, 0.88);
  color: #0e4d98;
}

body.apple-ui .history-panel {
  border-color: rgba(13, 53, 108, 0.14);
  background: linear-gradient(180deg, rgba(253, 255, 255, 0.9), rgba(239, 247, 255, 0.85));
}

body.apple-ui .summary-card strong,
body.apple-ui .model-summary-card strong {
  color: #0d4f9d;
}

body.apple-ui .image-lightbox {
  background: rgba(8, 17, 34, 0.82);
  backdrop-filter: blur(8px);
}

body.apple-ui .lightbox-image {
  border-color: rgba(196, 226, 255, 0.42);
}

body.apple-ui .auth-shell {
  padding-top: clamp(18px, 4vh, 56px);
}

body.page-auth .auth-grid {
  min-height: calc(100dvh - 200px);
  align-items: stretch;
}

body.page-admin .history-panel,
body.page-history .history-page-block {
  margin-top: 0;
}

body.apple-ui .workspace-pane.pane-enter {
  animation-duration: 240ms;
}

body.apple-ui .page-shell,
body.apple-ui .topbar,
body.apple-ui .hero-card,
body.apple-ui .panel {
  animation: appleFadeIn 320ms ease both;
}



@media (max-width: 1180px) {
  body.apple-ui .page-shell {
    padding: clamp(14px, 3vw, 24px);
  }

  body.apple-ui .studio-grid,
  body.apple-ui .prompt-inference-grid,
  body.apple-ui .auth-grid,
  body.apple-ui .admin-filter-grid,
  body.apple-ui .admin-summary-grid {
    grid-template-columns: 1fr;
  }

  body.apple-ui .workbench-lane-labels {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  body.apple-ui .topbar,
  body.apple-ui .topbar-actions,
  body.apple-ui .prompt-tools,
  body.apple-ui .action-row,
  body.apple-ui .result-meta {
    flex-direction: column;
    align-items: flex-start;
  }

  body.apple-ui .topbar-actions,
  body.apple-ui .topbar-actions > *,
  body.apple-ui .admin-actions,
  body.apple-ui .admin-actions > * {
    width: 100%;
  }

  body.apple-ui .workspace-tabbar {
    width: 100%;
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 8px;
  }

  body.apple-ui .workspace-tab-indicator {
    display: none;
  }

  body.apple-ui .workspace-tab {
    min-height: 60px;
  }

  body.apple-ui .workspace-tab.is-active {
    border-color: rgba(0, 113, 227, 0.42);
    background: linear-gradient(135deg, #2ab0ff, #0071e3);
  }

  body.apple-ui .generation-history {
    max-height: min(168dvh, 2040px);
  }
}

@media (max-width: 560px) {
  body.apple-ui .page-shell {
    padding: 12px;
    gap: 12px;
  }

  body.apple-ui .topbar,
  body.apple-ui .hero-card,
  body.apple-ui .panel {
    border-radius: 20px;
    padding: 16px;
  }

  body.apple-ui .brand-mark {
    width: 48px;
    height: 48px;
  }

  body.apple-ui .history-table {
    min-width: 560px;
  }

  body.apple-ui .result-stage {
    min-height: 300px;
  }

  body.apple-ui .primary-button,
  body.apple-ui .ghost-button,
  body.apple-ui .nav-link-button {
    width: 100%;
    justify-content: center;
  }
}

/* Panel close button lives on white background — neutralize all apple-ui theme overrides */
.lightbox-side-panel .lightbox-close,
.lightbox-side-panel .lightbox-close:hover {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  color: #888 !important;
  transform: none !important;
}

.lightbox-side-panel .lightbox-close:hover {
  background: #f5f5f5 !important;
  color: #333 !important;
}

.lightbox-side-panel .lightbox-close:active {
  transform: none !important;
  background: #ebebeb !important;
}

body.apple-ui #prompt,
body.apple-ui .history-generation-prompt,
body.apple-ui .split-prompt-textarea,
body.apple-ui #inference-output {
  color: #000;
}

/* =======================================================
   DOUBAO-STYLE CHAT UI
   ======================================================= */

/* ---- Chat pane layout ---- */
.chat-pane {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 140px);
  min-height: 480px;
  margin-top: 20px;
  border-radius: 0;
  background: transparent;
  border: none;
  box-shadow: none;
  overflow: hidden;
  position: relative;
}

/* Status / usage banners within chat pane */
.chat-pane > .status-banner,
.chat-pane > .usage-box {
  margin: 8px 16px 0;
  flex-shrink: 0;
}

/* ---- Chat history wrap ---- */
.chat-history-wrap {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-width: 1920px;
  width: 100%;
  margin: 0 auto;
}

.chat-history-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 10px 20px 6px;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(46, 25, 11, 0.06);
}

.chat-history-link {
  font-size: 0.8rem;
  padding: 5px 12px;
  color: var(--muted);
  text-decoration: none;
}

/* ---- Chat history (scrollable conversation) ---- */
.chat-pane .generation-history,
.chat-pane .chat-history {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column-reverse; /* newest at bottom, oldest at top */
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 0 220px;
  gap: 0;
  max-height: none;
  scrollbar-width: thin;
  scrollbar-color: rgba(46, 25, 11, 0.40) transparent;
  will-change: scroll-position;
  -webkit-overflow-scrolling: touch;
}
.chat-pane .generation-history::-webkit-scrollbar,
.chat-pane .chat-history::-webkit-scrollbar {
  width: 5px;
}
.chat-pane .generation-history::-webkit-scrollbar-track,
.chat-pane .chat-history::-webkit-scrollbar-track {
  background: transparent;
}
.chat-pane .generation-history::-webkit-scrollbar-thumb,
.chat-pane .chat-history::-webkit-scrollbar-thumb {
  background: rgba(46, 25, 11, 0.40);
  border-radius: 3px;
}
.chat-pane .generation-history::-webkit-scrollbar-thumb:hover,
.chat-pane .chat-history::-webkit-scrollbar-thumb:hover {
  background: rgba(46, 25, 11, 0.60);
}

.chat-empty-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  color: var(--muted);
  font-size: 0.9rem;
  border: none;
  background: transparent;
}

.chat-empty-hint[hidden],
.generation-history-empty[hidden] {
  display: none !important;
}

/* ---- Chat message items (doubao-style) ---- */
.chat-pane .history-generation-item,
.chat-pane .chat-msg {
  display: flex;
  flex-direction: column;
  content-visibility: auto;
  contain-intrinsic-size: auto 500px;
  gap: 10px;
  padding: 16px 24px 20px;
  border: none;
  border-radius: 0;
  background: transparent;
  overflow: visible;
  width: 100%;
}

.chat-pane .history-generation-item + .history-generation-item {
  border-top: 1px solid rgba(46, 25, 11, 0.06);
}

/* -- Message header (thumbs + prompt + badges) -- */
.chat-msg-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.chat-msg-thumbs {
  display: flex;
  gap: 0;
  flex-shrink: 0;
  overflow: visible;
  transition: gap 0.25s ease;
}

.chat-ref-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
  margin-left: -14px;
  transition: margin-left 0.25s ease;
}

.chat-ref-card:first-child {
  margin-left: 0;
}

.chat-msg-thumbs:hover {
  gap: 6px;
}

.chat-msg-thumbs:hover .chat-ref-card {
  margin-left: 0;
}

.chat-msg-thumb {
  width: 40px;
  height: 40px;
  object-fit: contain;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 8px;
  border: 1.5px solid rgba(255, 255, 255, 0.9);
  box-shadow: -3px 0 8px rgba(0, 0, 0, 0.14), 0 2px 6px rgba(0, 0, 0, 0.08);
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  margin-left: 0;
  transition: box-shadow 0.2s ease;
}

.chat-msg-thumb:first-child {
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.chat-msg-thumbs:hover .chat-msg-thumb {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.10);
}

.chat-ref-card-label {
  font-size: 10px;
  color: var(--muted, #999);
  white-space: nowrap;
  line-height: 1.2;
  user-select: none;
  pointer-events: none;
}

.chat-msg-thumb--video {
  object-fit: cover;
  background: #111;
}

.chat-msg-thumb--video-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #1a1a2e;
  border-radius: 8px;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}

.chat-msg-thumb--video-placeholder::after {
  content: '';
  display: block;
  width: 18px;
  height: 18px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%238899dd'%3E%3Cpath d='M8 5v14l11-7z'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

.chat-msg-thumb--audio {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #e8f0fe 0%, #c9d8fb 100%);
  border-radius: 8px;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}

.chat-msg-thumb--audio::after {
  content: '';
  display: block;
  width: 16px;
  height: 16px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%235b7fe8'%3E%3Cpath d='M12 3v10.55A4 4 0 1 0 14 17V7h4V3h-6z'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

.chat-msg-text-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-msg-prompt {
  margin: 0;
  font-size: 0.95rem;
  color: var(--ink);
  line-height: 1.6;
  word-break: break-word;
}

.chat-msg-prompt-wrap {
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  max-height: 3.2em;
  transition: max-height 0.3s ease;
  cursor: default;
}

.chat-msg-prompt-wrap:hover {
  -webkit-line-clamp: 100;
  line-clamp: 100;
  max-height: 60em;
}

.chat-msg-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.chat-msg-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 500;
  background: rgba(246, 246, 248, 0.9);
  border: 1px solid rgba(46, 25, 11, 0.12);
  color: var(--muted);
}

.chat-msg-badge--token {
  background: rgba(255, 246, 230, 0.95);
  border-color: rgba(210, 130, 30, 0.28);
  color: #9a5a00;
}

/* -- Message output (generated images) -- */
.chat-msg-outputs {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 10px;
  padding-left: 50px; /* align under text */
}

.chat-msg-img-card {
  position: relative;
  display: inline-flex;
  align-items: stretch;
  border-radius: 16px;
  overflow: hidden;
  max-width: 380px;
  min-width: 160px;
  flex: 0 0 auto;
  border: 1px solid rgba(46, 25, 11, 0.08);
  background: rgba(248, 248, 250, 0.8);
  cursor: zoom-in;
  transition: box-shadow 150ms;
}

.chat-msg-img-card:hover {
  box-shadow: 0 4px 18px rgba(46, 25, 11, 0.14);
}

/* Two or more cards: shrink to side-by-side */
.chat-msg-outputs:has(.chat-msg-img-card:nth-child(2)) .chat-msg-img-card {
  max-width: calc(50% - 5px);
  flex: 1 1 calc(50% - 5px);
}

.chat-msg-img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 640px;
  object-fit: contain;
  border-radius: 0;
  background: rgba(248, 248, 250, 0.8);
}

.chat-ai-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  color: rgba(255,255,255,0.92);
  background: rgba(0,0,0,0.36);
  backdrop-filter: blur(4px);
  pointer-events: none;
}

.chat-msg-no-output {
  margin: 0;
  font-size: 0.86rem;
  color: var(--muted);
  padding: 10px;
}

/* -- Message action buttons -- */
.chat-msg-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-left: 50px;
}

.chat-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid rgba(46, 25, 11, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 500;
  padding: 5px 14px;
  cursor: pointer;
  transition: background 140ms, border-color 140ms;
}

.chat-action-btn:hover {
  background: rgba(240, 111, 47, 0.08);
  border-color: rgba(240, 111, 47, 0.3);
  color: var(--accent-dark);
}

/* -- Loading state (doubao blue gradient) -- */
.chat-msg-loading {
  position: relative;
  width: 260px;
  height: 340px;
  border-radius: 16px;
  overflow: hidden;
  margin-left: 50px;
  background: linear-gradient(135deg, #c8d8f8 0%, #b8d0f8 30%, #d0e8ff 60%, #b8d8f8 100%);
  animation: chatLoadingGrad 3s ease-in-out infinite;
  border: none !important;
  box-shadow: none;
}



.chat-loading-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  color: rgba(40, 70, 120, 0.9);
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(6px);
}

.chat-loading-hint {
  position: absolute;
  bottom: 12px;
  left: 0;
  right: 0;
  text-align: center;
  margin: 0;
  font-size: 0.8rem;
  color: rgba(40, 70, 120, 0.8);
  font-weight: 500;
}

/* ---- Bottom chat input dock ---- */
.chat-input-dock {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(calc(100% - 32px), 1000px);
  z-index: 200;
  padding: 28px 0 20px;
  background: linear-gradient(to top, var(--bg) 60%, transparent);
  display: flex;
  flex-direction: column;
  gap: 0;
  pointer-events: none;
}

/* ---- Dock topbar: "回到底部" button ---- */
.chat-dock-topbar {
  pointer-events: none;
  display: flex;
  justify-content: flex-end;
  padding: 0 0 6px;
}

.chat-dock-topbar[hidden] {
  display: none !important;
}

.chat-scroll-bottom-btn {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(46, 25, 11, 0.14);
  border-radius: 999px;
  padding: 6px 16px;
  font-size: 0.82rem;
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 2px 12px rgba(46, 25, 11, 0.1);
  transition: background 140ms, border-color 140ms;
}

.chat-scroll-bottom-btn:hover {
  background: rgba(240, 111, 47, 0.06);
  border-color: rgba(240, 111, 47, 0.3);
  color: var(--accent-dark);
}

/* ---- Settings popup (above input) ---- */
.chat-settings-popup {
  pointer-events: auto;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(46, 25, 11, 0.12);
  border-radius: 18px;
  padding: 18px 20px;
  margin-bottom: 10px;
  box-shadow: 0 8px 28px rgba(46, 25, 11, 0.12);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chat-settings-popup[hidden] {
  display: none !important;
}

.chat-settings-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.chat-settings-label {
  flex-shrink: 0;
  min-width: 60px;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--ink);
  padding-top: 4px;
}

.chat-settings-opts {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chat-opt-btn {
  border: 1px solid rgba(46, 25, 11, 0.16);
  border-radius: 999px;
  background: rgba(246, 246, 248, 0.9);
  color: var(--ink);
  font-size: 0.84rem;
  padding: 6px 16px;
  cursor: pointer;
  transition: background 140ms, border-color 140ms;
}

.chat-opt-btn.is-active {
  background: rgba(240, 111, 47, 0.12);
  border-color: rgba(240, 111, 47, 0.5);
  color: var(--accent-dark);
  font-weight: 700;
}

.chat-opt-btn:hover:not(.is-active) {
  background: rgba(46, 25, 11, 0.06);
}

.chat-settings-ratio-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chat-ratio-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  border: 1px solid rgba(46, 25, 11, 0.16);
  border-radius: 10px;
  background: rgba(246, 246, 248, 0.9);
  padding: 8px 10px;
  cursor: pointer;
  min-width: 46px;
  transition: background 140ms, border-color 140ms;
}

.chat-ratio-btn.is-active {
  background: rgba(240, 111, 47, 0.1);
  border-color: rgba(240, 111, 47, 0.5);
}

.chat-ratio-icon {
  display: block;
  background: rgba(46, 25, 11, 0.18);
  border-radius: 2px;
  width: 18px;
  height: 18px;
}

.chat-ratio-btn.is-active .chat-ratio-icon {
  background: var(--accent);
}

/* Ratio icon sizing approximations */
.chat-ratio-btn[data-value="9:16"] .chat-ratio-icon { width: 12px; height: 20px; }
.chat-ratio-btn[data-value="2:3"] .chat-ratio-icon { width: 13px; height: 20px; }
.chat-ratio-btn[data-value="3:4"] .chat-ratio-icon { width: 15px; height: 20px; }
.chat-ratio-btn[data-value="4:5"] .chat-ratio-icon { width: 16px; height: 20px; }
.chat-ratio-btn[data-value="1:1"] .chat-ratio-icon { width: 20px; height: 20px; }
.chat-ratio-btn[data-value="5:4"] .chat-ratio-icon { width: 20px; height: 16px; }
.chat-ratio-btn[data-value="4:3"] .chat-ratio-icon { width: 20px; height: 15px; }
.chat-ratio-btn[data-value="3:2"] .chat-ratio-icon { width: 20px; height: 13px; }
.chat-ratio-btn[data-value="16:9"] .chat-ratio-icon { width: 20px; height: 11px; }
.chat-ratio-btn[data-value="21:9"] .chat-ratio-icon { width: 22px; height: 9px; }

.chat-ratio-label {
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
}

.chat-ratio-btn.is-active .chat-ratio-label {
  color: var(--accent-dark);
  font-weight: 700;
}

/* ---- Main input card ---- */
.chat-input-card {
  pointer-events: auto;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(46, 25, 11, 0.14);
  border-radius: 20px;
  box-shadow: 0 4px 20px rgba(46, 25, 11, 0.08);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
  transition: border-color 180ms, box-shadow 180ms;
}

.chat-input-card:focus-within {
  border-color: rgba(240, 111, 47, 0.4);
  box-shadow: 0 4px 24px rgba(240, 111, 47, 0.12), 0 0 0 3px rgba(240, 111, 47, 0.07);
}

/* Mode tab bar */
.chat-mode-bar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 10px 14px 0;
  padding-right: 246px;
  border-bottom: 1px solid rgba(46, 25, 11, 0.07);
  padding-bottom: 8px;
}

.chat-mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 0.84rem;
  padding: 6px 12px;
  cursor: pointer;
  transition: background 140ms, color 140ms;
  white-space: nowrap;
}

.chat-mode-btn.is-active {
  background: rgba(240, 111, 47, 0.1);
  color: var(--accent-dark);
  font-weight: 700;
}

.chat-mode-btn.is-disabled {
  cursor: default;
  opacity: 0.55;
}

.chat-mode-btn.is-disabled:hover {
  background: transparent;
}

.chat-mode-btn:not(.is-disabled):hover {
  background: rgba(46, 25, 11, 0.05);
  color: var(--ink);
}

.chat-corner-actions {
  position: absolute;
  top: 10px;
  right: 14px;
  z-index: 7;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

.chat-corner-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
  height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(46, 25, 11, 0.2);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(46, 25, 11, 0.08);
  transition: background 140ms, border-color 140ms, color 140ms;
}

.chat-corner-btn svg {
  flex-shrink: 0;
}

.chat-corner-btn-label {
  line-height: 1;
  white-space: nowrap;
}

.chat-corner-btn:hover {
  background: #fff;
  border-color: rgba(46, 25, 11, 0.32);
}

.chat-corner-btn:focus-visible {
  outline: 2px solid rgba(240, 111, 47, 0.35);
  outline-offset: 1px;
}

.chat-corner-btn--expand {
  color: #1f4f88;
  border-color: rgba(53, 123, 198, 0.36);
  background: rgba(232, 243, 255, 0.9);
}

.chat-corner-btn--expand:hover {
  background: rgba(223, 239, 255, 1);
  border-color: rgba(53, 123, 198, 0.58);
}

.chat-corner-btn--retract {
  color: var(--accent-dark);
  border-color: rgba(240, 111, 47, 0.44);
  background: rgba(255, 237, 226, 0.95);
}

.chat-corner-btn--retract:hover {
  background: rgba(255, 230, 212, 1);
  border-color: rgba(240, 111, 47, 0.66);
}

/* Override components.css #prompt rule in chat context (specificity: class+ID > ID) */
.chat-input-card #prompt {
  min-height: 52px;
  height: auto;
  max-height: 200px;
}

.chat-input-card.is-textarea-expanded #prompt {
  min-height: 260px;
  max-height: 520px;
}

.chat-input-card.is-textarea-expanded .chat-prompt-area {
  min-height: 260px;
  max-height: 520px;
}

/* Prompt textarea */
.chat-prompt-area {
  width: 100%;
  min-height: 52px;
  max-height: 200px;
  padding: 12px 16px;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.94rem;
  line-height: 1.6;
  resize: none;
  outline: none;
  overflow-y: auto;
}

.chat-prompt-area:focus {
  outline: none;
}

/* Reference images row */
.chat-refs-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px 4px;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}

.chat-refs-bar::-webkit-scrollbar {
  display: none;
}

.chat-style-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid rgba(240, 111, 47, 0.3);
  border-radius: 999px;
  background: rgba(240, 111, 47, 0.08);
  color: var(--accent-dark);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 5px 12px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 140ms;
}

.chat-style-pill:hover {
  background: rgba(240, 111, 47, 0.16);
}

.optimize-platform-popup .chat-settings-label {
  font-size: 0.80rem;
  color: var(--ink-muted, #888);
  font-weight: 600;
  padding-top: 0;
}

.optimize-platform-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chat-thumb-grid {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}

.chat-thumb-grid::-webkit-scrollbar { display: none; }

/* Override preview-item styles inside chat thumb grid */
.chat-thumb-grid .preview-item {
  width: 66px;
  height: 66px;
  min-height: 0;
  border-radius: 12px;
  flex-shrink: 0;
  overflow: visible;
  position: relative;
}

.chat-thumb-grid .preview-item img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.04);
}

/* ── 拖拽排序 ── */
.chat-thumb-grid .preview-item {
  cursor: grab;
}
.chat-thumb-grid .preview-item:active {
  cursor: grabbing;
}
.chat-thumb-grid .preview-item.is-dragging {
  opacity: 0.35;
  outline: 2px dashed rgba(240, 111, 47, 0.55);
  outline-offset: 2px;
}
/* 拖拽进行时强制展开折叠态，方便定位插入位置 */
.chat-thumb-grid.drag-active {
  gap: 6px !important;
  overflow: visible !important;
}
.chat-thumb-grid.drag-active .preview-item {
  margin-left: 0 !important;
  transition: none !important;
}

.chat-add-img-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px dashed rgba(46, 25, 11, 0.22);
  border-radius: 10px;
  background: rgba(246, 246, 248, 0.8);
  color: var(--muted);
  font-size: 0.82rem;
  padding: 6px 10px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 140ms, border-color 140ms;
}

.chat-add-img-btn input {
  display: none;
}

.chat-add-img-btn:hover {
  background: rgba(240, 111, 47, 0.08);
  border-color: rgba(240, 111, 47, 0.3);
  color: var(--accent-dark);
}

.chat-paste-hint {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  opacity: 0.45;
  user-select: none;
  pointer-events: none;
}

.chat-paste-key {
  display: inline-block;
  font-size: 10px;
  font-family: inherit;
  color: var(--muted, #9e8e80);
  background: rgba(46, 25, 11, 0.06);
  border: 1px solid rgba(46, 25, 11, 0.22);
  border-bottom: 2px solid rgba(46, 25, 11, 0.28);
  border-radius: 4px;
  padding: 1px 5px;
  line-height: 1.5;
}

.chat-paste-hint-plus {
  font-size: 10px;
  color: var(--muted, #9e8e80);
}

/* Toolbar row */
.chat-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px 12px;
  padding-right: 110px; /* space for absolute send-area (credit + send btn) */
  border-top: 1px solid rgba(46, 25, 11, 0.07);
  max-height: 64px;
  overflow: hidden;
  transition: max-height 0.28s cubic-bezier(0.4, 0, 0.2, 1),
              padding 0.28s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.22s ease,
              border-color 0.28s ease;
}

.chat-toolbar-spacer {
  flex: 1;
}

.chat-model-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(46, 25, 11, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 500;
  padding: 6px 14px;
  cursor: pointer;
  white-space: nowrap;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 140ms, border-color 140ms;
}

.chat-model-pill:hover {
  background: rgba(240, 111, 47, 0.06);
  border-color: rgba(240, 111, 47, 0.3);
}

#chat-model-display {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-size-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid rgba(46, 25, 11, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 500;
  padding: 6px 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 140ms, border-color 140ms;
}

.chat-size-pill:hover {
  background: rgba(240, 111, 47, 0.06);
  border-color: rgba(240, 111, 47, 0.3);
}

.chat-enhance-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid rgba(46, 25, 11, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--muted);
  cursor: pointer;
  transition: background 140ms, color 140ms;
}

.chat-enhance-pill:hover {
  background: rgba(255, 220, 50, 0.15);
  color: #c8860a;
  border-color: rgba(200, 134, 10, 0.3);
}

.chat-enhance-pill.is-active {
  background: rgba(255, 210, 30, 0.18);
  border-color: rgba(200, 134, 10, 0.5);
  color: #b87800;
}

.chat-enhance-pill.is-active:hover {
  background: rgba(255, 210, 30, 0.26);
}

/* Send area: wraps credit display + send button, absolutely positioned */
.chat-send-area {
  position: absolute;
  right: 14px;
  bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 5;
  transition: bottom 0.28s cubic-bezier(0.4, 0, 0.2, 1),
              top 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-send-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  transition: background 140ms, transform 100ms;
}

.chat-send-btn:hover {
  background: #3d2b1f;
  transform: scale(1.05);
}

.chat-send-btn:active {
  transform: scale(0.96);
}

.chat-send-btn:disabled {
  background: rgba(46, 25, 11, 0.25);
  cursor: not-allowed;
  transform: none;
}

/* ---- Hidden form ---- */
.chat-hidden-form {
  display: none !important;
}

/* ---- Chat-pane override: history prompt action buttons ---- */
/* Neutralize the global apple-ui blue theme for these buttons in chat context */
.chat-pane .history-prompt-tools {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 5px;
  vertical-align: middle;
  opacity: 0;
  transition: opacity 0.15s;
}

.chat-pane .chat-msg-text-wrap:hover .history-prompt-tools {
  opacity: 1;
}

.chat-pane .history-prompt-copy-button,
.chat-pane .history-apply-prompt-button,
body.apple-ui .chat-pane .history-prompt-copy-button,
body.apple-ui .chat-pane .history-apply-prompt-button {
  font-size: 0.76rem;
  padding: 3px 10px;
  min-height: 0;
  border-radius: 999px;
  border: 1px solid rgba(46, 25, 11, 0.16);
  background: rgba(246, 246, 248, 0.9);
  color: var(--muted);
}

.chat-pane .history-prompt-copy-button:hover,
.chat-pane .history-apply-prompt-button:hover,
body.apple-ui .chat-pane .history-prompt-copy-button:hover,
body.apple-ui .chat-pane .history-apply-prompt-button:hover {
  background: rgba(240, 111, 47, 0.08);
  border-color: rgba(240, 111, 47, 0.3);
  color: var(--accent-dark);
}

.chat-pane .history-prompt-copy-button.is-copied,
body.apple-ui .chat-pane .history-prompt-copy-button.is-copied {
  background: rgba(22, 163, 74, 0.12);
  border-color: rgba(22, 163, 74, 0.4);
  color: #16a34a;
  animation: kk-copy-pop 220ms cubic-bezier(0.22, 1, 0.36, 1);
}

/* ---- Empty state improvements ---- */
.chat-empty-hint {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 260px;
  color: var(--muted);
  font-size: 0.88rem;
  padding: 40px 24px;
  text-align: center;
  user-select: none;
}

.chat-empty-hint::before {
  content: "✦";
  display: block;
  font-size: 2.2rem;
  opacity: 0.18;
  line-height: 1;
}

/* ---- Action buttons below each message ---- */
.chat-msg-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-left: 50px;
  flex-wrap: wrap;
}

/* ---- Loading shimmer animation ---- */


.chat-msg-loading {
  background: linear-gradient(
    90deg,
    #c8d8f8 0%,
    #d8e8ff 25%,
    #e8f2ff 50%,
    #d8e8ff 75%,
    #c8d8f8 100%
  );
  background-size: 800px 100%;
  animation: chatShimmer 2s linear infinite;
}

/* ---- Send button loading state ---- */
.chat-send-btn.is-loading {
  background: rgba(46, 25, 11, 0.45);
  cursor: not-allowed;
  animation: sendPulse 1s ease-in-out infinite;
}




/* ---- Model selection modal ---- */
.model-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1100;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.model-modal-overlay[hidden] {
  display: none !important;
}

.model-modal-dialog {
  background: rgba(255, 255, 255, 0.98);
  border-radius: 24px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.22);
  width: min(760px, 100%);
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.model-modal-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 28px 16px;
  border-bottom: 1px solid rgba(46, 25, 11, 0.09);
  flex-shrink: 0;
}

.model-modal-title {
  margin: 0;
  font-size: 1.18rem;
  font-family: "Space Grotesk", sans-serif;
  color: var(--ink);
}

.model-modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(46, 25, 11, 0.14);
  border-radius: 999px;
  background: rgba(246, 246, 248, 0.9);
  color: var(--muted);
  cursor: pointer;
  transition: background 140ms;
}

.model-modal-close:hover {
  background: rgba(240, 111, 47, 0.1);
  color: var(--accent-dark);
  border-color: rgba(240, 111, 47, 0.3);
}

.model-modal-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding: 20px 24px 24px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.model-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid rgba(46, 25, 11, 0.1);
  border-radius: 16px;
  background: rgba(249, 249, 251, 0.9);
  cursor: pointer;
  text-align: left;
  transition: background 140ms, border-color 140ms, box-shadow 140ms;
}

.model-card:hover {
  background: rgba(240, 111, 47, 0.05);
  border-color: rgba(240, 111, 47, 0.25);
  box-shadow: 0 4px 12px rgba(240, 111, 47, 0.1);
}

.model-card.is-active {
  background: rgba(240, 111, 47, 0.08);
  border-color: rgba(240, 111, 47, 0.4);
  box-shadow: 0 0 0 2px rgba(240, 111, 47, 0.2);
}

.model-card-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #ffe0c0, #f87a3a);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ── Per-model icon accent colors ────────────────────────────────────────
   Order: company fallback → broad prefix → narrow prefix → exact match.
   Equal specificity: later rule wins, so most-specific listed last.
   ─────────────────────────────────────────────────────────────────────── */
.model-card[data-company="grsai"] .model-card-icon {
  background: linear-gradient(135deg, #d8b4fe, #9333ea);
}
.model-card[data-model^="nano-banana"] .model-card-icon {
  background: linear-gradient(135deg, #fed7aa, #f97316);
}
.model-card[data-model^="nano-banana-fast"] .model-card-icon {
  background: linear-gradient(135deg, #fcd34d, #d97706);
}
.model-card[data-model^="nano-banana-pro"] .model-card-icon {
  background: linear-gradient(135deg, #86efac, #16a34a);
}
.model-card[data-model="nano-banana-pro-4k-vip"] .model-card-icon {
  background: linear-gradient(135deg, #6ee7d4, #0d9488);
}
.model-card[data-model^="gpt-image"] .model-card-icon {
  background: linear-gradient(135deg, #93c5fd, #2563eb);
}
.model-card[data-model^="gemini"] .model-card-icon {
  background: linear-gradient(135deg, #fca5a5, #dc2626);
}

/* ── Model color dot on pill button ───────────────────────────────────── */
.chat-model-pill::before {
  content: '';
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--model-dot, rgba(46, 25, 11, 0.22));
  flex-shrink: 0;
}
.chat-model-pill[data-company="grsai"] { --model-dot: #9333ea; }
.chat-model-pill[data-model^="nano-banana"] { --model-dot: #f97316; }
.chat-model-pill[data-model^="nano-banana-fast"] { --model-dot: #d97706; }
.chat-model-pill[data-model^="nano-banana-pro"] { --model-dot: #16a34a; }
.chat-model-pill[data-model="nano-banana-pro-4k-vip"] { --model-dot: #0d9488; }
.chat-model-pill[data-model^="gpt-image"] { --model-dot: #2563eb; }
.chat-model-pill[data-model^="gemini"] { --model-dot: #dc2626; }

.model-icon-inner {
  font-size: 1.2rem;
  font-weight: 900;
  color: white;
  font-family: "Space Grotesk", sans-serif;
  line-height: 1;
}

.model-card-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.model-card-name {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-card-desc {
  font-size: 0.76rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- Image card hover actions ---- */
.chat-msg-img-card {
  position: relative;
}

.chat-img-actions {
  position: absolute;
  bottom: 6px;
  right: 6px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
}

.chat-msg-img-card:hover .chat-img-actions {
  opacity: 1;
  pointer-events: auto;
}

.chat-img-dl-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 0.85rem;
  text-decoration: none;
  border: none;
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: background 0.12s;
}

.chat-img-dl-btn:hover {
  background: rgba(0, 0, 0, 0.8);
}

.chat-img-dl-btn[data-tooltip] {
  position: relative;
}

.chat-img-dl-btn[data-tooltip]:hover::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20, 20, 20, 0.88);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 200;
}

/* ---- Responsive tweaks for chat UI ---- */
@media (max-width: 700px) {
  .chat-pane {
    height: calc(100vh - 160px);
    border-radius: 0;
    margin-top: 12px;
  }

  .chat-input-dock {
    width: min(calc(100% - 20px), 1000px);
    padding: 20px 0 14px;
  }

  .model-modal-grid {
    grid-template-columns: 1fr;
  }

  .chat-msg-outputs {
    padding-left: 0;
  }

  .chat-msg-actions {
    padding-left: 0;
  }

  .chat-msg-loading {
    margin-left: 0;
    width: 100%;
  }

  .chat-mode-btn {
    font-size: 0.78rem;
    padding: 5px 8px;
    gap: 3px;
  }

  .chat-mode-bar {
    padding-right: 190px;
  }

  .chat-corner-actions {
    top: 9px;
    right: 10px;
    gap: 6px;
  }

  .chat-corner-btn {
    height: 30px;
    padding: 0 8px;
    font-size: 0.74rem;
  }

  .chat-mode-btn svg {
    display: none;
  }
}

@media (max-width: 480px) {
  .chat-input-dock {
    width: min(calc(100% - 16px), 1000px);
    padding: 16px 0 10px;
  }

  .chat-history-wrap .generation-history {
    padding: 12px 0 180px;
  }

  .chat-pane .history-generation-item {
    padding: 12px 14px 16px;
  }

  .chat-mode-bar {
    padding-right: 172px;
  }

  .chat-corner-btn {
    padding: 0 7px;
    font-size: 0.72rem;
  }
}

/* ============================================================
   DOUBAO-STYLE ENHANCEMENTS — loading progress, completion
   notification, credit display, model card richness,
   web-search toggle
   ============================================================ */

/* ---- Loading card: percentage overlay ---- */
.chat-loading-pct {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 28px 16px 14px;
  background: linear-gradient(transparent, rgba(0,0,0,.55));
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  pointer-events: none;
}

.chat-loading-pct-text {
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1;
}

.chat-loading-pct-bar-wrap {
  width: 100%;
  height: 3px;
  background: rgba(255,255,255,.25);
  border-radius: 2px;
  overflow: hidden;
}

.chat-loading-pct-bar {
  height: 100%;
  width: 0%;
  background: #fff;
  border-radius: 2px;
  transition: width 0.4s ease;
}

.chat-loading-member {
  position: absolute;
  top: 12px;
  left: 12px;
  font-size: 0.72rem;
  color: rgba(255,255,255,.85);
  background: rgba(0,0,0,.35);
  padding: 2px 8px;
  border-radius: 20px;
  backdrop-filter: blur(4px);
  pointer-events: none;
}

/* ---- Completion notification toast ---- */
#chat-completion-notify {
  position: fixed;
  bottom: 110px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  z-index: 2000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

#chat-completion-notify.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

.chat-notify-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(30,30,30,.92);
  color: #fff;
  font-size: 0.83rem;
  padding: 8px 16px;
  border-radius: 24px;
  white-space: nowrap;
  box-shadow: 0 4px 18px rgba(0,0,0,.28);
  backdrop-filter: blur(8px);
}

.chat-notify-thumb {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
}

.chat-notify-text {
  flex: 1;
}

#chat-completion-notify.is-pending .chat-notify-inner {
  background: rgba(20, 90, 200, 0.88);
}

.chat-notify-scroll-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,.7);
  font-size: 0.78rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color 0.12s;
  white-space: nowrap;
}

.chat-notify-scroll-btn:hover {
  color: #fff;
}

/* ---- Credit display next to send button ---- */
.chat-credit-display {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--ink-light, #888);
  padding: 0 4px;
  line-height: 1;
  user-select: none;
  transition: color 0.2s;
}

.chat-credit-display[hidden] {
  display: none !important;
}

.chat-credit-icon {
  flex-shrink: 0;
  color: var(--accent, #f06f2f);
}

.chat-credit-val {
  font-size: 1.2rem;
  font-variant-numeric: tabular-nums;
}

.chat-credit-display.is-low {
  color: #e53e3e;
}

.chat-credit-display.is-low .chat-credit-icon {
  color: #e53e3e;
}

/* ---- Cost hint (fixed token consumption for selected model) ---- */
.chat-cost-hint {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-right: 8px;
  color: var(--text-secondary, #888);
}

.chat-cost-hint[hidden] {
  display: none !important;
}

.chat-cost-icon {
  flex-shrink: 0;
  color: #0071e3;
}

.chat-cost-val {
  font-size: 1.1rem;
  font-variant-numeric: tabular-nums;
}
.model-card-new {
  display: inline-block;
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #fff;
  background: var(--accent, #f06f2f);
  padding: 1px 5px;
  border-radius: 3px;
  vertical-align: middle;
  margin-left: 5px;
  line-height: 1.6;
  text-transform: uppercase;
}

.model-card-desc-line {
  font-size: 0.72rem;
  color: var(--ink-light, #888);
  line-height: 1.35;
  margin-top: 3px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.model-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 5px;
}

.model-card-tag {
  font-size: 0.66rem;
  padding: 2px 6px;
  border-radius: 20px;
  background: var(--surface2, rgba(240,111,47,.08));
  color: var(--accent, #f06f2f);
  border: 1px solid rgba(240,111,47,.18);
  white-space: nowrap;
  line-height: 1.5;
}

/* ---- Web search toggle in settings popup ---- */
.chat-settings-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
}

.chat-toggle-btn {
  position: relative;
  width: 36px;
  height: 20px;
  border: none;
  border-radius: 20px;
  background: var(--border, #ddd);
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
  padding: 0;
}

.chat-toggle-btn::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}

.chat-toggle-btn.is-on {
  background: var(--accent, #f06f2f);
}

.chat-toggle-btn.is-on::after {
  transform: translateX(16px);
}

/* ─── 参考图缩略图 tooltip ─────────────────────── */
.chat-msg-thumbs[data-tooltip] {
  position: relative;
}
.chat-msg-thumbs[data-tooltip]:hover::before {
  content: attr(data-tooltip);
  position: absolute;
  top: -28px;
  left: 0;
  background: rgba(30, 30, 30, 0.85);
  color: #fff;
  font-size: 0.72rem;
  padding: 3px 8px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 10;
}

/* ─── 参考图缩略图单张 tooltip（双击说明）──────── */
.chat-msg-thumb[data-tooltip] {
  position: relative;
}
.chat-msg-thumb[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20, 20, 20, 0.88);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 200;
  cursor: zoom-in;
}

/* ─── 参考图上传栏 preview-remove 改为悬停 X 图标 ─── */
.chat-thumb-grid .preview-item {
  position: relative;
  overflow: visible;
  z-index: 1;
  margin-top: 7px;
}

.chat-thumb-grid .preview-item:last-child {
  margin-right: 7px;
}
.chat-thumb-grid .preview-item img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.04);
}
.chat-thumb-grid .preview-remove-button {
  position: absolute;
  top: -7px;
  right: -7px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 1.5px solid rgba(255, 255, 255, 0.88);
  background: rgba(22, 14, 8, 0.82);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  opacity: 0;
  transition: opacity 140ms;
}

.chat-thumb-grid .preview-item:hover .preview-remove-button {
  opacity: 1;
}

.chat-thumb-grid .preview-item:hover,
.chat-thumb-grid .preview-item:focus-within {
  z-index: 30;
}

.chat-thumb-grid .preview-remove-button:hover {
  background: rgba(148, 48, 9, 0.92);
}

/* ─── 上传缩略图折叠：卡片式叠加效果 ──────────────────── */
.chat-thumb-grid {
  transition: gap 0.25s ease;
}

.chat-thumb-grid.is-collapsed {
  overflow: visible;
  gap: 0;
}

.chat-thumb-grid.is-collapsed .preview-item {
  margin-left: -44px;
  position: relative;
  box-shadow: -3px 0 8px rgba(0, 0, 0, 0.14), 0 2px 6px rgba(0, 0, 0, 0.08);
  border: 1.5px solid rgba(255, 255, 255, 0.9);
  transition: margin-left 0.25s ease, box-shadow 0.2s ease;
}

.chat-thumb-grid.is-collapsed .preview-item:first-child {
  margin-left: 0;
}

/* Hover：展开所有卡片 */
.chat-refs-bar:hover .chat-thumb-grid.is-collapsed {
  gap: 6px;
}

.chat-refs-bar:hover .chat-thumb-grid.is-collapsed .preview-item {
  margin-left: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.10);
}

/* +N 溢出徽章（卡片叠加模式下隐藏）*/
.thumb-more-badge {
  display: none;
}

/* ─── 历史条目操作区更多菜单 ─────────────────────── */
.chat-action-more-btn {
  min-width: unset;
  padding: 5px 12px;
  font-size: 16px;
  line-height: 1;
  letter-spacing: 0;
}
.chat-action-btn--danger {
  color: #d93025;
  border-color: rgba(217, 48, 37, 0.2);
}
.chat-action-btn--danger:hover {
  background: rgba(217, 48, 37, 0.07);
  border-color: rgba(217, 48, 37, 0.4);
  color: #b52b1e;
}
.chat-action-dropdown {
  display: none;
  position: absolute;
  top: 0;
  left: calc(100% + 4px);
  right: 0;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(46, 25, 11, 0.12);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(46, 25, 11, 0.14);
  min-width: 148px;
  padding: 6px;
  z-index: 200;
  flex-direction: column;
  gap: 2px;
}
.chat-action-dropdown.is-open {
  display: flex;
}
.chat-action-dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: none;
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.84rem;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  transition: background 0.12s;
}
.chat-action-dropdown-item:hover {
  background: rgba(46, 25, 11, 0.06);
}
.chat-action-dropdown-item--danger {
  color: #d93025;
}
.chat-action-dropdown-item--danger:hover {
  background: rgba(217, 48, 37, 0.07);
}

/* ─── Lightbox 面板新元素 ─────────────────────────── */
.lightbox-ai-label {
  font-size: 0.72rem;
  color: #bbb;
  margin-left: 2px;
}

.lightbox-more-wrap {
  position: relative;
  display: inline-flex;
}
.lightbox-more-btn {
  padding: 6px 10px;
}
.lightbox-more-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(46, 25, 11, 0.12);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(46, 25, 11, 0.14);
  min-width: 130px;
  padding: 6px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.lightbox-more-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: none;
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 0.84rem;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  transition: background 0.12s;
}
.lightbox-more-item:hover {
  background: rgba(46, 25, 11, 0.06);
}
.lightbox-more-item--danger {
  color: #d93025;
}
.lightbox-more-item--danger:hover {
  background: rgba(217, 48, 37, 0.07);
}

/* ─── 查看结果时自动收起输入区 ────────────────────────────────── */

.chat-input-dock {
  transition: padding 0.32s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 不改变 border-radius，保持圆角矩形 */
.chat-input-card {
  transition: border-color 180ms, box-shadow 180ms;
}

.chat-mode-bar,
.chat-refs-bar {
  overflow: hidden;
  transition: max-height 0.32s cubic-bezier(0.4, 0, 0.2, 1),
              opacity 0.22s ease,
              padding 0.32s cubic-bezier(0.4, 0, 0.2, 1);
  max-height: 120px;
}

/* 工具栏 pill：padding 同步收缩避免留白抖动 */
.chat-toolbar .chat-model-pill,
.chat-toolbar .chat-size-pill,
.chat-toolbar .chat-enhance-pill,
.chat-toolbar .chat-refmode-pill {
  transition: opacity 0.2s ease,
              max-width 0.32s cubic-bezier(0.4, 0, 0.2, 1),
              padding-left 0.28s ease,
              padding-right 0.28s ease;
  max-width: 300px;
  overflow: hidden;
  white-space: nowrap;
}

/* 收起状态 */
.chat-input-dock.is-retracted {
  padding: 8px 0 10px;
}

.chat-input-dock.is-retracted .chat-mode-bar,
.chat-input-dock.is-retracted .chat-refs-bar {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
}

.chat-input-dock.is-retracted .chat-corner-actions {
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
}

.chat-input-dock.is-retracted .chat-toolbar .chat-model-pill,
.chat-input-dock.is-retracted .chat-toolbar .chat-size-pill,
.chat-input-dock.is-retracted .chat-toolbar .chat-enhance-pill,
.chat-input-dock.is-retracted .chat-toolbar .chat-refmode-pill {
  opacity: 0;
  max-width: 0;
  padding-left: 0;
  padding-right: 0;
}

/* 工具栏折叠到零高度 */
.chat-input-dock.is-retracted .chat-toolbar {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
  border-top-color: transparent;
}

/* 单行输入高度，左侧为 + 按钮留空，右侧为 send-area 留空 */
.chat-input-dock.is-retracted .chat-prompt-area {
  min-height: 36px;
  max-height: 36px;
  padding-top: 8px;
  padding-bottom: 8px;
  padding-left: 46px;
  padding-right: 108px;
}
/* #prompt ID 规则在 components.css 中（specificity 0-1-0-0），此处需更高优先级覆盖 */
.chat-input-dock.is-retracted #prompt {
  min-height: 36px;
  height: 36px;
  max-height: 36px;
  overflow: hidden;
  resize: none;
}

/* send-area 垂直居中到输入框 */
.chat-input-dock.is-retracted .chat-send-area {
  bottom: auto;
  top: 50%;
  transform: translateY(-50%);
}

.chat-input-dock.is-retracted .chat-prompt-area::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

/* "+" 展开按钮：仅在收起状态显示 */
.chat-expand-left-btn {
  display: none;
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(46, 25, 11, 0.18);
  border-radius: 8px;
  background: rgba(246, 246, 248, 0.92);
  color: var(--muted);
  cursor: pointer;
  transition: background 140ms, border-color 140ms;
  z-index: 6;
  padding: 0;
}

.chat-expand-left-btn:hover {
  background: rgba(240, 111, 47, 0.08);
  border-color: rgba(240, 111, 47, 0.3);
  color: var(--accent-dark);
}

.chat-input-dock.is-retracted .chat-expand-left-btn {
  display: inline-flex;
}

/* ─── 参考图悬停放大预览 ──────────────────────────────────── */
.kk-thumb-zoom-popup {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  background: #f8f8f8;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.22), 0 2px 8px rgba(0, 0, 0, 0.10);
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.95);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.14s ease, visibility 0.14s ease;
}

.kk-thumb-zoom-popup.is-visible {
  opacity: 1;
  visibility: visible;
}

.kk-thumb-zoom-popup img {
  display: block;
  max-width: min(240px, 80vw);
  max-height: min(300px, 55vh);
  object-fit: contain;
}

/* 图生图工作台（主页）：历史记录参考图缩略图（84px），对齐偏移同步调整 */
/* !important 覆盖 theme-neural-dark.css 中的全局 112px !important 规则 */
body.page-workbench .chat-msg-thumb {
  width: 84px !important;
  height: 84px !important;
}

body.page-workbench .chat-ref-card {
  margin-left: -28px !important;
}

body.page-workbench .chat-msg-thumbs:hover .chat-ref-card {
  margin-left: 0 !important;
}

body.page-workbench .chat-msg-outputs,
body.page-workbench .chat-msg-actions {
  padding-left: 62px;
}

/* 图生图工作台：历史结果展示区宽度缩小 20% */
body.page-workbench {
  --workbench-chat-content-width: 64%;
}

body.page-workbench .chat-history-wrap {
  width: var(--workbench-chat-content-width);
  margin-left: auto;
  margin-right: auto;
}

/* 图生图工作台：输入区与历史区使用同一宽度并保持同一中心线 */
body.page-workbench #workspace-pane-image .chat-input-dock {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: var(--workbench-chat-content-width);
  max-width: none;
}

/* 主工作台：生成结果卡片缩小20%（图片/视频共用） */
body.page-workbench .chat-msg-img-card {
  max-width: 192px;
  min-width: 80px;
  border-radius: 13px;
}

body.page-workbench .chat-msg-img {
  max-height: 262px;
}

/* 多图时保持与单图相同的卡片尺寸，不缩小为50% */
body.page-workbench .chat-msg-outputs:has(.chat-msg-img-card:nth-child(2)) .chat-msg-img-card {
  max-width: 192px;
  flex: 0 0 auto;
}

/* 图生图工作台：隐藏后台任务队列展示区 */
body.page-workbench .background-job-board {
  display: none !important;
}

/* 4K-only 警告弹窗卡片 */
.only4k-alert-card {
  background: rgba(255, 255, 255, 0.98);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.22);
  width: min(360px, 100%);
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
}

.only4k-alert-badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 14px;
  border-radius: 999px;
  background: rgba(240, 111, 47, 0.12);
  border: 1px solid rgba(240, 111, 47, 0.3);
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.1em;
}

.only4k-alert-title {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.12rem;
  color: var(--ink);
}

.only4k-alert-body {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.6;
}

/* ===== VIDEO GENERATION UI ===== */

/* Video upload bar */
.video-upload-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 14px 8px;
  overflow-x: auto;
  overflow-y: visible;
}

.video-upload-bar[hidden] { display: none !important; }

.video-frame-slots {
  display: flex;
  gap: 10px;
  overflow: visible;
}

.video-frame-slots[hidden] { display: none !important; }

/* Each upload slot */
.video-frame-slot {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  overflow: visible;
}

.video-slot-remove-btn {
  position: absolute;
  top: -7px;
  right: -7px;
  width: 18px;
  height: 18px;
  border: 1.5px solid rgba(255, 255, 255, 0.88);
  border-radius: 999px;
  background: rgba(22, 14, 8, 0.82);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  padding: 0;
  opacity: 0;
  transition: opacity 140ms;
}

.video-frame-slot:hover .video-slot-remove-btn {
  opacity: 1;
}

.video-slot-remove-btn:hover {
  background: rgba(148, 48, 9, 0.92);
}

/* Filename label below slot inner div */
.video-slot-label {
  font-size: 0.66rem;
  color: var(--muted);
  max-width: 72px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
  margin-top: 3px;
  line-height: 1.2;
  pointer-events: none;
  user-select: none;
}

/* ── 拖拽排序（allround 模式） ── */
.video-allround-thumb {
  cursor: grab;
}
.video-allround-thumb:active {
  cursor: grabbing;
}
.video-allround-thumb.is-dragging {
  opacity: 0.35;
  outline: 2px dashed rgba(240, 111, 47, 0.55);
  outline-offset: 2px;
}
.video-frame-slots.drag-active {
  gap: 10px !important;
}
.video-frame-slots.drag-active .video-allround-thumb {
  transition: none !important;
}

.video-frame-slot input[type="file"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.video-frame-slot-inner {
  width: 72px;
  height: 72px;
  border: 1.5px dashed rgba(46, 25, 11, 0.25);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: rgba(246, 246, 248, 0.9);
  color: var(--muted);
  font-size: 0.78rem;
  transition: border-color 140ms, background 140ms;
  overflow: hidden;
}

.video-frame-slot:hover .video-frame-slot-inner {
  border-color: rgba(240, 111, 47, 0.5);
  background: rgba(240, 111, 47, 0.05);
}

#video-allround-add-slot .video-frame-slot-inner {
  width: auto;
  min-width: 108px;
  padding: 0 14px;
  white-space: nowrap;
}

/* Hover-expand video popup */
.video-slot-hover-popup {
  position: fixed;
  z-index: 9999;
  width: 300px;
  background: rgba(22, 14, 8, 0.92);
  border-radius: 14px;
  border: 1px solid rgba(240, 111, 47, 0.35);
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.52), 0 6px 16px rgba(176, 71, 24, 0.28);
  overflow: hidden;
  animation: videoPopupIn 180ms cubic-bezier(0.22, 1, 0.36, 1);
}

.video-slot-hover-popup video {
  display: block;
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  background: #000;
  border-radius: 0;
}

@keyframes videoPopupIn {
  from { opacity: 0; transform: scale(0.92) translateY(6px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* Reference mode pill in video toolbar */
.chat-refmode-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid rgba(46, 25, 11, 0.18);
  border-radius: 999px;
  background: rgba(246, 246, 248, 0.9);
  color: var(--ink);
  font-size: 0.84rem;
  padding: 5px 12px;
  cursor: pointer;
  transition: background 140ms, border-color 140ms;
}

.chat-refmode-pill:hover {
  background: rgba(46, 25, 11, 0.06);
}

/* Reference mode dropdown — fixed positioned above trigger button */
.video-refmode-dropdown {
  position: fixed;
  z-index: 9999;
  padding: 6px;
  min-width: 220px;
}

.video-refmode-dropdown[hidden] { display: none !important; }

.video-refmode-option {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  border: none;
  border-radius: 10px;
  background: transparent;
  padding: 10px 14px;
  cursor: pointer;
  text-align: left;
  transition: background 120ms;
}

.video-refmode-option:hover,
.video-refmode-option.is-active {
  background: rgba(240, 111, 47, 0.08);
}

.video-refmode-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
}

.video-refmode-desc {
  font-size: 0.78rem;
  color: var(--muted);
}

/* Duration slider row */
.video-duration-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.video-duration-slider {
  flex: 1;
  accent-color: var(--accent, #f06f2f);
  height: 4px;
  cursor: pointer;
}

.video-duration-val {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--ink);
  min-width: 28px;
  text-align: right;
}

/* Spin animation for loading indicator */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Positioning context for video dropdowns */
#chat-video-toolbar {
  position: relative;
}

/* Ensure hidden toolbars are truly invisible regardless of other CSS rules */
#chat-image-toolbar[hidden],
#chat-video-toolbar[hidden] {
  display: none !important;
}

/* Ensure image refs bar and video upload bar respect [hidden] */
#preview-frame[hidden],
.video-upload-bar[hidden] {
  display: none !important;
}

/* Ensure only one send button shows at a time */
#chat-send-btn[hidden],
#chat-video-send-btn[hidden] {
  display: none !important;
}

/* ── Video ratio - adaptive (circle icon) ── */
.chat-ratio-btn[data-value="adaptive"] .chat-ratio-icon {
  width: 18px;
  height: 18px;
  border-radius: 50%;
}

/* ── Video duration: number input + "s" unit wrapper ── */
.video-duration-input-wrap {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: rgba(246, 246, 248, 0.9);
  border: 1px solid rgba(46, 25, 11, 0.18);
  border-radius: 8px;
  padding: 3px 8px;
  min-width: 52px;
  justify-content: center;
  transition: border-color 140ms, background 140ms;
}

.video-duration-input-wrap:focus-within {
  border-color: rgba(240, 111, 47, 0.5);
  background: rgba(255, 255, 255, 0.98);
}

.video-duration-input {
  width: 28px;
  text-align: center;
  border: none;
  background: transparent;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 700;
  outline: none;
  -moz-appearance: textfield;
  appearance: textfield;
  padding: 0;
}

.video-duration-input::-webkit-outer-spin-button,
.video-duration-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.video-duration-unit {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--ink);
  flex-shrink: 0;
  line-height: 1;
}

/* ---- Single scroll layer for image/video workbench ---- */
body.page-workbench[data-workspace-tab="image"] {
  overflow: hidden;
}

body.page-workbench[data-workspace-tab="image"] .page-shell {
  height: 100dvh;
  min-height: 100dvh;
  overflow: hidden;
}

body.page-workbench[data-workspace-tab="image"] #workspace-pane-image.chat-pane {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
}

body.page-workbench[data-workspace-tab="image"] #workspace-pane-image .chat-history-wrap {
  min-height: 0;
}

body.page-workbench[data-workspace-tab="image"] #workspace-pane-image .chat-history-toolbar {
  position: relative;
  z-index: 3;
}

body.page-workbench[data-workspace-tab="image"] #workspace-pane-image .generation-history,
body.page-workbench[data-workspace-tab="image"] #workspace-pane-image .chat-history {
  position: relative;
  z-index: 1;
  overscroll-behavior: contain;
}

@media (min-width: 1041px) {
  body.page-workbench .page-shell {
    display: grid;
    grid-template-columns: clamp(168px, 14vw, 217px) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    gap: clamp(10px, 1.1vw, 18px);
    padding-left: 0;
    transition: grid-template-columns 220ms ease;
  }

  body.page-workbench .topbar {
    grid-column: 1;
    grid-row: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 14px;
    min-height: 0;
    padding: 20px 16px 20px 12px;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
  }

  body.page-workbench .brand-toggle-button {
    appearance: none;
    border: 0;
    padding: 0;
    cursor: pointer;
  }

  body.page-workbench .brand-toggle-button:focus-visible {
    outline: 3px solid rgba(240, 111, 47, 0.45);
    outline-offset: 3px;
  }

  body.page-workbench .brand-lockup {
    width: 100%;
    align-items: flex-start;
  }

  body.page-workbench .sidebar-collapse-hint-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 6;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    width: 30px;
    min-height: 30px;
    padding: 0;
    border: 1px solid rgba(164, 67, 23, 0.5);
    border-radius: 8px;
    background: linear-gradient(135deg, rgba(246, 121, 56, 0.96), rgba(224, 83, 31, 0.96));
    color: #fff;
    cursor: pointer;
    box-shadow: 0 10px 22px rgba(208, 84, 31, 0.26), inset 0 1px 0 rgba(255, 255, 255, 0.22);
    transition: background 140ms, border-color 140ms, color 140ms, transform 140ms, box-shadow 160ms;
    animation: none;
  }

  body.page-workbench .sidebar-collapse-hint-btn svg {
    transition: transform 140ms ease;
  }

  body.page-workbench .sidebar-collapse-hint-btn span {
    display: none;
  }

  body.page-workbench .sidebar-collapse-hint-btn:hover {
    background: linear-gradient(135deg, #ff8e4e, #ee6328);
    border-color: rgba(184, 69, 18, 0.66);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 14px 30px rgba(208, 84, 31, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.26);
  }

  body.page-workbench .sidebar-collapse-hint-btn:hover svg {
    transform: translateX(-1px);
  }

  body.page-workbench .sidebar-collapse-hint-btn:active {
    transform: translateY(0);
  }

  body.page-workbench .sidebar-collapse-hint-btn:focus-visible {
    outline: 2px solid rgba(240, 111, 47, 0.52);
    outline-offset: 2px;
  }

  @keyframes sidebar-collapse-hint-pulse {
    0%,
    100% {
      box-shadow: 0 10px 22px rgba(208, 84, 31, 0.26), inset 0 1px 0 rgba(255, 255, 255, 0.22);
    }
    50% {
      box-shadow: 0 14px 30px rgba(208, 84, 31, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.22);
    }
  }

  body.page-workbench .topbar .workspace-tabbar,
  body.apple-ui.page-workbench .topbar .workspace-tabbar {
    width: 100%;
    max-width: none;
    margin-left: 0;
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
  }

  body.page-workbench .topbar .workspace-tabbar::before,
  body.apple-ui.page-workbench .topbar .workspace-tabbar::before {
    display: none;
  }

  body.page-workbench .topbar .workspace-tab,
  body.apple-ui.page-workbench .topbar .workspace-tab {
    min-height: 52px;
    padding: 11px 16px;
    border-radius: 16px;
    font-size: 0.88rem;
    font-weight: 700;
    letter-spacing: 0.025em;
    background: linear-gradient(160deg, #fff9f4 0%, #ffeedd 100%);
    color: #5a1b05;
    border: 1.5px solid rgba(200, 76, 20, 0.26);
    box-shadow: 0 2px 8px rgba(155, 48, 8, 0.09), inset 0 1px 0 rgba(255, 255, 255, 0.8);
    transition: background 160ms ease, box-shadow 160ms ease, color 160ms ease, border-color 160ms ease, transform 160ms ease;
  }

  body.page-workbench .topbar .workspace-tab:hover,
  body.apple-ui.page-workbench .topbar .workspace-tab:hover {
    background: linear-gradient(160deg, #ffeedd 0%, #ffd9bc 100%);
    color: #381002;
    border-color: rgba(200, 76, 20, 0.46);
    box-shadow: 0 4px 14px rgba(155, 48, 8, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.7);
    transform: translateY(-1px);
  }

  body.page-workbench .topbar .workspace-tab .workspace-tab-title,
  body.apple-ui.page-workbench .topbar .workspace-tab .workspace-tab-title {
    font-size: 1rem;
    font-weight: 700;
    white-space: nowrap;
  }

  body.page-workbench .topbar .workspace-tab.is-active,
  body.apple-ui.page-workbench .topbar .workspace-tab.is-active {
    background: linear-gradient(150deg, #f57432 0%, #c95015 100%);
    color: #fff;
    border-color: rgba(168, 58, 12, 0.55);
    box-shadow: 0 6px 18px rgba(195, 72, 16, 0.42), inset 0 1px 0 rgba(255, 220, 185, 0.28);
  }

  body.page-workbench .topbar .workspace-tab.is-active:hover,
  body.apple-ui.page-workbench .topbar .workspace-tab.is-active:hover {
    background: linear-gradient(150deg, #e8641e 0%, #b84610 100%);
    box-shadow: 0 8px 22px rgba(195, 72, 16, 0.5), inset 0 1px 0 rgba(255, 220, 185, 0.25);
    transform: translateY(-1px);
  }

  body.page-workbench .topbar .workspace-tab-indicator {
    display: none;
  }

  body.page-workbench .topbar-actions {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 8px;
    margin-top: auto;
  }

  body.page-workbench .topbar-actions > * {
    width: 100%;
  }

  body.page-workbench .topbar-actions .user-badge {
    width: 100%;
  }

  body.page-workbench .topbar-actions .ghost-button {
    width: 100%;
    justify-content: flex-start;
    padding: 11px 16px;
    border-radius: 16px;
    font-size: 0.88rem;
    font-weight: 700;
    letter-spacing: 0.025em;
    background: linear-gradient(160deg, #fff9f4 0%, #ffeedd 100%);
    color: #5a1b05;
    border: 1.5px solid rgba(200, 76, 20, 0.26);
    box-shadow: 0 2px 8px rgba(155, 48, 8, 0.09), inset 0 1px 0 rgba(255, 255, 255, 0.8);
    transition: background 160ms ease, box-shadow 160ms ease, color 160ms ease, border-color 160ms ease, transform 160ms ease;
  }

  body.page-workbench .topbar-actions .ghost-button:hover {
    background: linear-gradient(160deg, #ffeedd 0%, #ffd9bc 100%);
    color: #381002;
    border-color: rgba(200, 76, 20, 0.46);
    box-shadow: 0 4px 14px rgba(155, 48, 8, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.7);
    transform: translateY(-1px);
  }

  body.page-workbench .workspace-pane {
    grid-column: 2;
    grid-row: 1;
    margin-top: 0;
    min-width: 0;
  }

  body.page-workbench.sidebar-collapsed .page-shell {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  body.page-workbench.sidebar-collapsed .topbar {
    padding: 18px 8px;
    align-items: center;
    gap: 0;
  }

  body.page-workbench.sidebar-collapsed .brand-lockup {
    justify-content: center;
  }

  body.page-workbench.sidebar-collapsed .brand-lockup > div {
    display: none;
  }

  body.page-workbench.sidebar-collapsed .sidebar-collapse-hint-btn {
    display: none !important;
  }

  body.page-workbench.sidebar-collapsed .topbar .workspace-tabbar,
  body.page-workbench.sidebar-collapsed .topbar-actions {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.page-workbench .sidebar-collapse-hint-btn {
    animation: none;
    transition: background 140ms, border-color 140ms, color 140ms;
  }

  body.page-workbench .sidebar-collapse-hint-btn svg {
    transition: none;
  }
}

/* ==========================================================================
   Plan B — Inline agent mode (chat-mode-bar integration)
   ========================================================================== */

/* Category chips bar inside the input dock */
.agent-inline-category-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 8px 14px 4px;
  border-bottom: 1px solid var(--border, rgba(0,0,0,.06));
}

.agent-inline-category-bar[hidden] {
  display: none !important;
}

.agent-inline-label {
  font-size: 0.76rem;
  color: var(--accent, #f06f2f);
  font-weight: 600;
  margin-right: 2px;
  white-space: nowrap;
}

.agent-inline-clear {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--muted, #888);
  background: none;
  border: none;
  cursor: pointer;
  padding: 3px 8px;
  border-radius: 6px;
  transition: background 120ms, color 120ms;
  white-space: nowrap;
}

.agent-inline-clear:hover {
  background: rgba(0,0,0,.05);
  color: var(--ink, #1a1a1a);
}

/* Agent reply bubble inside generation-history */
.chat-msg--agent-reply {
  background: linear-gradient(135deg, rgba(240,111,47,.06) 0%, transparent 100%);
  border-left: 3px solid var(--accent, #f06f2f);
  border-radius: 0 12px 12px 0;
  padding: 12px 16px;
  margin: 4px 0;
}

.chat-msg--agent-reply .chat-msg-agent-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent, #f06f2f);
  letter-spacing: .04em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.chat-msg--agent-reply .chat-msg-agent-text {
  font-size: 0.9rem;
  line-height: 1.65;
  color: var(--ink, #1a1a1a);
  white-space: pre-wrap;
  word-break: break-word;
}

/* Inline agent send button (same visual as chat-send-btn) */
#chat-agent-send-btn {
  background: var(--accent, #f06f2f);
}

/* In agent mode: hide send button and token displays; Enter key is used instead */
.is-agent-mode #chat-send-btn,
.is-agent-mode #chat-cost-hint,
.is-agent-mode #chat-credit-display {
  display: none !important;
}

/* ===== COMPANY GALLERY MODAL ===== */
.company-gallery-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.company-gallery-overlay[hidden] {
  display: none !important;
}

.company-gallery-dialog {
  background: rgba(255, 255, 255, 0.99);
  border-radius: 24px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.24);
  width: min(1100px, 100%);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.company-gallery-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 28px 16px;
  border-bottom: 1px solid rgba(46, 25, 11, 0.09);
  flex-shrink: 0;
  gap: 12px;
}

.company-gallery-hd-left {
  display: flex;
  align-items: center;
  gap: 20px;
  flex: 1;
  min-width: 0;
}

.company-gallery-title {
  margin: 0;
  font-size: 1.15rem;
  font-family: "Space Grotesk", sans-serif;
  color: var(--ink);
  white-space: nowrap;
  flex-shrink: 0;
}

.company-gallery-subtitle {
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--muted);
  margin-left: 6px;
}

.company-gallery-filter {
  display: flex;
  align-items: center;
  gap: 8px;
}

.company-gallery-filter[hidden] {
  display: none !important;
}

.company-gallery-filter-label {
  font-size: 0.82rem;
  color: var(--muted);
  white-space: nowrap;
}

.company-gallery-select {
  font-size: 0.85rem;
  padding: 5px 10px;
  border: 1px solid rgba(46, 25, 11, 0.18);
  border-radius: 8px;
  background: rgba(249, 249, 251, 0.95);
  color: var(--ink);
  cursor: pointer;
  min-width: 130px;
}

.company-gallery-select:focus {
  outline: none;
  border-color: var(--accent);
}

.company-gallery-close {
  flex-shrink: 0;
}

.company-gallery-body {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  padding: 20px 24px 24px;
  position: relative;
}

.company-gallery-loading,
.company-gallery-empty {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  padding: 40px 0;
  margin: 0;
}

.company-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 200px));
  gap: 14px;
  align-items: start;
  justify-content: start;
}

.gallery-card {
  border: 1px solid rgba(46, 25, 11, 0.1);
  border-radius: 14px;
  overflow: hidden;
  background: rgba(249, 249, 251, 0.9);
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: box-shadow 140ms, transform 140ms;
  content-visibility: auto;
  contain-intrinsic-size: auto 240px;
}

.gallery-card:hover {
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.13);
  transform: translateY(-2px);
}

.gallery-card-img-wrap {
  overflow: hidden;
  background: rgba(46, 25, 11, 0.05);
  position: relative;
}

.gallery-card-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  transition: opacity 200ms;
}

.gallery-card-img[data-loading] {
  opacity: 0.4;
}

.gallery-card-dl-btn {
  position: absolute;
  bottom: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 160ms, background 140ms;
  text-decoration: none;
  z-index: 2;
}

.gallery-card:hover .gallery-card-dl-btn {
  opacity: 1;
}

.gallery-card-dl-btn:hover {
  background: rgba(240, 111, 47, 0.85);
}

.gallery-card-meta {
  padding: 8px 10px 10px;
  flex-shrink: 0;
}

.gallery-card-user {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.gallery-card-date {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 2px;
}

@media (max-width: 600px) {
  .company-gallery-dialog {
    border-radius: 16px;
    max-height: 92vh;
  }
  .company-gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 140px));
    gap: 10px;
  }
  .company-gallery-hd {
    flex-wrap: wrap;
    padding: 14px 16px 12px;
  }
}

/* ===== SUB SHARED LIBRARY ===== */

/* Header layout adjustments */
.company-gallery-hd-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.cgl-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: 1px solid rgba(46, 25, 11, 0.15);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 0.82rem;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 140ms, color 140ms;
  flex-shrink: 0;
}

.cgl-back-btn[hidden] {
  display: none !important;
}

.cgl-back-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.cgl-sm-btn {
  font-size: 0.8rem;
  font-weight: 500;
  padding: 5px 14px;
  border-radius: 8px;
  border: 1px solid rgba(176, 84, 29, 0.28);
  background: linear-gradient(180deg, rgba(255, 242, 226, 0.96), rgba(253, 232, 208, 0.94));
  color: var(--accent-dark, #a0522d);
  cursor: pointer;
  transition: box-shadow 130ms, transform 130ms, filter 130ms;
  white-space: nowrap;
  line-height: 1.5;
  box-shadow: 0 2px 6px rgba(128, 61, 20, 0.1);
}

.cgl-sm-btn:hover {
  transform: translateY(-1px);
  filter: saturate(1.08);
  box-shadow: 0 5px 14px rgba(128, 61, 20, 0.18);
}

/* List view */
.cgl-list-view,
.cgl-gallery-view {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  padding: 20px 24px 24px;
  position: relative;
}

.cgl-library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  padding: 4px 2px;
}

.cgl-lib-card {
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(30, 64, 175, 0.22);
  border-radius: 16px;
  background: linear-gradient(160deg, rgba(30, 58, 138, 0.88) 0%, rgba(37, 99, 235, 0.82) 100%);
  cursor: pointer;
  transition: box-shadow 160ms ease, transform 160ms ease, border-color 160ms ease;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(30, 58, 138, 0.2);
}

.cgl-lib-card:hover {
  box-shadow: 0 8px 24px rgba(30, 58, 138, 0.32);
  transform: translateY(-2px);
  border-color: rgba(59, 130, 246, 0.32);
}

.cgl-lib-card-main {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 16px 14px;
}

.cgl-lib-card-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.9);
}

.cgl-lib-card-body {
  flex: 1;
  min-width: 0;
}

.cgl-lib-card-name {
  font-size: 1.12rem;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.35;
}

.cgl-lib-card-meta {
  font-size: 0.92rem;
  color: rgba(255, 255, 255, 0.7);
  margin-top: 3px;
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cgl-lib-card-actions {
  display: flex;
  gap: 7px;
  padding: 0 14px 13px;
}

.cgl-delete-btn {
  background: linear-gradient(180deg, rgba(255, 235, 235, 0.96), rgba(254, 215, 215, 0.94)) !important;
  border-color: rgba(185, 50, 50, 0.28) !important;
  color: #c0392b !important;
  box-shadow: 0 2px 6px rgba(185, 50, 50, 0.1) !important;
}

.cgl-delete-btn:hover {
  background: linear-gradient(180deg, rgba(255, 220, 220, 0.96), rgba(254, 195, 195, 0.94)) !important;
  border-color: rgba(185, 50, 50, 0.42) !important;
  color: #a93226 !important;
  box-shadow: 0 5px 14px rgba(185, 50, 50, 0.18) !important;
}

/* Username badge on gallery cards */
.cgl-card-user {
  font-size: 0.72rem;
  color: var(--accent, #a0522d);
  font-weight: 500;
}

/* Create modal */
.cgl-create-modal {
  position: fixed;
  inset: 0;
  z-index: 1210;
  background: rgba(20, 10, 5, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.cgl-create-modal[hidden] {
  display: none !important;
}

.cgl-create-box {
  background: #fffaf5;
  border-radius: 20px;
  box-shadow: 0 24px 64px rgba(46, 25, 11, 0.24), 0 4px 16px rgba(46, 25, 11, 0.1);
  width: min(440px, 100%);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  max-height: min(620px, 90vh);
}

/* Header */
.cgl-create-hd {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 18px 14px;
  border-bottom: 1px solid rgba(46, 25, 11, 0.08);
  flex-shrink: 0;
}

.cgl-create-hd-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--accent) 0%, #ff9e52 100%);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(240, 111, 47, 0.32);
}

.cgl-create-title {
  flex: 1;
  margin: 0;
  font-size: 0.98rem;
  font-weight: 700;
  font-family: "Space Grotesk", sans-serif;
  color: var(--ink);
}

.cgl-create-x-btn {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 7px;
  background: rgba(46, 25, 11, 0.07);
  color: var(--muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 140ms, color 140ms;
  padding: 0;
}

.cgl-create-x-btn:hover {
  background: rgba(46, 25, 11, 0.13);
  color: var(--ink);
}

/* Body */
.cgl-create-body {
  padding: 18px 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
  flex: 1;
}

.cgl-create-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cgl-create-section-hd {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.cgl-create-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.01em;
}

.cgl-create-hint {
  font-size: 0.76rem;
  color: var(--muted);
  margin: 0;
}

.cgl-create-input {
  padding: 10px 14px;
  border: 1.5px solid rgba(46, 25, 11, 0.14);
  border-radius: 10px;
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--ink);
  background: #fff;
  width: 100%;
  box-sizing: border-box;
  transition: border-color 150ms, box-shadow 150ms;
}

.cgl-create-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(240, 111, 47, 0.12);
}

.cgl-create-input::placeholder {
  color: rgba(112, 93, 76, 0.45);
}

/* Member checklist */
.cgl-member-checklist {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 200px;
  overflow-y: auto;
}

.cgl-member-check-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: 9px;
  cursor: pointer;
  transition: background 120ms;
  user-select: none;
  position: relative;
}

.cgl-member-check-item:hover {
  background: rgba(240, 111, 47, 0.07);
}

.cgl-member-check-item:has(.cgl-member-cb:checked) {
  background: rgba(240, 111, 47, 0.08);
}

.cgl-member-cb {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.cgl-member-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(240, 111, 47, 0.12);
  border: 1.5px solid rgba(240, 111, 47, 0.22);
  color: var(--accent-dark);
  font-size: 0.76rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  text-transform: uppercase;
  transition: background 150ms, border-color 150ms, color 150ms;
}

.cgl-member-cb:checked ~ .cgl-member-avatar {
  background: linear-gradient(135deg, var(--accent) 0%, #ff9e52 100%);
  border-color: transparent;
  color: #fff;
}

.cgl-member-name {
  flex: 1;
  font-size: 0.87rem;
  color: var(--ink);
  font-weight: 500;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cgl-member-checkmark {
  width: 18px;
  height: 18px;
  border: 1.5px solid rgba(46, 25, 11, 0.22);
  border-radius: 5px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  transition: background 150ms, border-color 150ms;
}

.cgl-member-cb:checked ~ .cgl-member-checkmark {
  background: var(--accent);
  border-color: var(--accent);
}

.cgl-member-cb:checked ~ .cgl-member-checkmark::after {
  content: "";
  width: 4px;
  height: 8px;
  border: 1.5px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg) translateY(-1px);
  display: block;
}

/* Footer */
.cgl-create-foot {
  padding: 12px 18px 18px;
  border-top: 1px solid rgba(46, 25, 11, 0.07);
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.cgl-create-submit-btn {
  width: 100%;
  padding: 11px 20px;
  background: linear-gradient(135deg, var(--accent) 0%, #ff9e52 100%);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 700;
  font-family: inherit;
  border: none;
  border-radius: 11px;
  cursor: pointer;
  transition: filter 150ms, transform 150ms, box-shadow 150ms;
  box-shadow: 0 6px 18px rgba(240, 111, 47, 0.3);
}

.cgl-create-submit-btn:hover {
  filter: brightness(1.04) saturate(1.06);
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(240, 111, 47, 0.38);
}

.cgl-create-submit-btn:active {
  transform: translateY(0);
  box-shadow: 0 4px 12px rgba(240, 111, 47, 0.28);
}

.cgl-create-submit-btn:disabled {
  opacity: 0.52;
  cursor: wait;
  filter: none;
  transform: none;
  box-shadow: none;
}

.cgl-create-cancel-link {
  background: none;
  border: none;
  font: inherit;
  font-size: 0.82rem;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  text-align: center;
  transition: color 140ms;
}

.cgl-create-cancel-link:hover {
  color: var(--ink);
}

/* Members panel */
.cgl-members-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(300px, 100%);
  z-index: 8;
  background: #fff;
  border-radius: 16px 0 0 16px;
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 28px rgba(0, 0, 0, 0.16);
}

.cgl-members-panel[hidden] {
  display: none !important;
}

.cgl-members-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.cgl-members-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 14px;
  border-bottom: 1px solid rgba(46, 25, 11, 0.08);
  flex-shrink: 0;
}

.cgl-members-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
}

.cgl-members-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.cgl-member-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 4px;
  font-size: 0.88rem;
  color: var(--ink);
  border-bottom: 1px solid rgba(46, 25, 11, 0.06);
}

.cgl-member-row:last-child {
  border-bottom: none;
}

.cgl-creator-badge {
  display: inline-block;
  margin-left: 6px;
  font-size: 0.7rem;
  font-weight: 600;
  background: rgba(var(--accent-rgb, 120, 80, 40), 0.1);
  color: var(--accent, #a0522d);
  padding: 2px 6px;
  border-radius: 4px;
  vertical-align: middle;
}

.cgl-remove-btn {
  background: none;
  border: 1px solid rgba(200, 60, 60, 0.3);
  border-radius: 6px;
  color: #c83c3c;
  font-size: 0.78rem;
  padding: 3px 8px;
  cursor: pointer;
  transition: background 120ms;
  flex-shrink: 0;
}

.cgl-remove-btn:hover {
  background: rgba(200, 60, 60, 0.08);
}

.cgl-add-member-row {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 12px 16px;
  border-top: 1px solid rgba(46, 25, 11, 0.08);
  flex-shrink: 0;
}

.cgl-add-member-row[hidden] {
  display: none !important;
}

.cgl-add-select {
  flex: 1;
  min-width: 0;
}

@media (max-width: 600px) {
  .cgl-library-grid {
    grid-template-columns: 1fr;
  }
  .cgl-members-panel {
    width: 100%;
    border-radius: 0;
    border-left: none;
    border-top: 1px solid rgba(46, 25, 11, 0.1);
    top: auto;
    bottom: 0;
    height: 60%;
    border-radius: 16px 16px 0 0;
  }
}

/* ===== USER GALLERY MODAL ===== */
.user-gallery-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(16, 10, 6, 0.72);
  backdrop-filter: blur(5px);
  padding: 24px;
}

.user-gallery-overlay[hidden] {
  display: none !important;
}

.user-gallery-dialog {
  background: rgba(255, 255, 255, 0.99);
  border-radius: 24px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.24);
  width: 100%;
  max-width: 1000px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.user-gallery-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 14px;
  border-bottom: 1px solid rgba(46, 25, 11, 0.08);
  gap: 12px;
  flex-shrink: 0;
}

.user-gallery-hd-left {
  display: flex;
  align-items: center;
  gap: 20px;
  flex: 1;
  min-width: 0;
}

.user-gallery-title {
  margin: 0;
  font-size: 1.15rem;
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  color: var(--ink);
  flex-shrink: 0;
}

.user-gallery-filter {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-gallery-filter-label {
  font-size: 0.82rem;
  color: var(--muted);
  white-space: nowrap;
}

.user-gallery-date-input {
  font-size: 0.85rem;
  padding: 5px 10px;
  border: 1px solid rgba(46, 25, 11, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  cursor: pointer;
}

.user-gallery-date-input:focus {
  outline: none;
  border-color: var(--accent);
}

.user-gallery-close {
  flex-shrink: 0;
}

.user-gallery-body {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  padding: 16px 20px 80px;
  position: relative;
}

.user-gallery-loading,
.user-gallery-empty {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  padding: 48px 0;
  margin: 0;
}

.user-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 200px));
  gap: 14px;
  align-items: start;
  justify-content: start;
}

.user-gallery-float-dl {
  position: absolute;
  bottom: 20px;
  right: 20px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--accent, #f06f2f);
  color: #fff;
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
  transition: background 140ms ease, transform 140ms ease, box-shadow 140ms ease;
  z-index: 10;
  cursor: pointer;
}

.user-gallery-float-dl[hidden] {
  display: none !important;
}

.user-gallery-float-dl:hover {
  background: #d95c1e;
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.26);
}

@media (max-width: 600px) {
  .user-gallery-dialog {
    border-radius: 16px;
    max-height: 92vh;
  }
  .user-gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 140px));
    gap: 10px;
  }
  .user-gallery-hd {
    flex-wrap: wrap;
    padding: 14px 16px 12px;
  }
}

/* =======================================================
   AI ECOM ASSISTANT PANEL
   ======================================================= */

/* ---- Tab trigger button in sidebar (matches workspace-tab style) ---- */

/* ---- Main panel (floating draggable card) ---- */
.ai-asst-panel {
  position: fixed;
  left: 20px;
  top: 80px;
  width: 833px;
  height: 92vh;
  background: linear-gradient(180deg, #fff8ee 0%, #fffaf5 100%);
  border: 1px solid rgba(240, 111, 47, 0.18);
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(176, 71, 24, 0.22), 0 2px 8px rgba(176, 71, 24, 0.1);
  z-index: 600;
  display: none;
  flex-direction: column;
  overflow: hidden;
  transition: box-shadow 0.2s;
}

.ai-asst-panel.is-open {
  display: flex;
}

.ai-asst-panel.is-dragging {
  box-shadow: 0 16px 56px rgba(176, 71, 24, 0.32), 0 4px 16px rgba(176, 71, 24, 0.15);
  transition: none;
}

/* ---- Header ---- */
.ai-asst-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 12px;
  background: linear-gradient(135deg, rgba(255, 223, 159, 0.55) 0%, rgba(244, 122, 50, 0.12) 100%);
  border-bottom: 1px solid rgba(240, 111, 47, 0.14);
  flex-shrink: 0;
  cursor: grab;
  user-select: none;
}

.ai-asst-hd:active {
  cursor: grabbing;
}

.ai-asst-title {
  display: flex;
  align-items: center;
  gap: 9px;
}

.ai-asst-title-badge {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(145deg, #ffdf9f, #f47a32);
  display: grid;
  place-items: center;
  color: white;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(240, 111, 47, 0.28);
}

.ai-asst-title-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.ai-asst-title-main {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  font-size: 0.92rem;
  color: #7f3212;
  line-height: 1.2;
}

.ai-asst-title-sub {
  font-size: 0.72rem;
  color: rgba(127, 50, 18, 0.6);
  font-weight: 400;
}

.ai-asst-hd-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ---- Session token counter bar (between msgs and footer) ---- */
.ai-asst-token-bar {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 14px;
  background: rgba(255, 244, 231, 0.85);
  border-top: 1px solid rgba(240, 111, 47, 0.12);
  flex-shrink: 0;
}

.ai-asst-token-bar[hidden] {
  display: none !important;
}

.ai-asst-token-bar-icon {
  font-size: 0.75rem;
  line-height: 1;
}

.ai-asst-token-bar-text {
  font-size: 0.72rem;
  color: rgba(127, 50, 18, 0.72);
}

.ai-asst-clear-btn,
.ai-asst-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-radius: 8px;
  border: 1px solid rgba(240, 111, 47, 0.22);
  background: rgba(255, 255, 255, 0.7);
  color: #9d4618;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  font-family: inherit;
}

.ai-asst-clear-btn {
  padding: 4px 10px;
  font-size: 0.76rem;
}

.ai-asst-close-btn {
  width: 30px;
  height: 30px;
}

.ai-asst-clear-btn:hover,
.ai-asst-close-btn:hover {
  background: rgba(240, 111, 47, 0.1);
  border-color: rgba(240, 111, 47, 0.35);
}

/* ---- Messages area ---- */
.ai-asst-msgs {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scrollbar-width: thin;
  scrollbar-color: rgba(240, 111, 47, 0.18) transparent;
}

.ai-asst-msgs::-webkit-scrollbar {
  width: 4px;
}

.ai-asst-msgs::-webkit-scrollbar-track {
  background: transparent;
}

.ai-asst-msgs::-webkit-scrollbar-thumb {
  background: rgba(240, 111, 47, 0.2);
  border-radius: 2px;
}

/* ---- Message row ---- */
.ai-asst-msg {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  animation: ai-msg-in 0.2s ease;
}

@keyframes ai-msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ai-asst-msg--user {
  flex-direction: row-reverse;
}

.ai-asst-msg-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  font-size: 0.68rem;
  font-weight: 700;
  margin-top: 2px;
}

.ai-asst-msg--assistant .ai-asst-msg-avatar {
  background: linear-gradient(145deg, #ffdf9f, #f47a32);
  color: white;
}

.ai-asst-msg--user .ai-asst-msg-avatar {
  background: linear-gradient(145deg, #c7d8f5, #6b8ed6);
  color: white;
}

.ai-asst-msg-body {
  max-width: 84%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.ai-asst-msg--welcome .ai-asst-msg-body {
  max-width: 100%;
  flex: 1;
  min-width: 0;
}

.ai-asst-msg-bubble {
  border-radius: 14px;
  padding: 10px 13px;
  font-size: 0.875rem;
  line-height: 1.65;
  word-break: break-word;
}

.ai-asst-msg--assistant .ai-asst-msg-bubble {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(240, 111, 47, 0.1);
  color: #4e2f18;
  border-top-left-radius: 4px;
  box-shadow: 0 1px 6px rgba(176, 71, 24, 0.06);
}

.ai-asst-msg--user .ai-asst-msg-bubble {
  background: linear-gradient(135deg, #f47a32, #e05a18);
  color: white;
  border-top-right-radius: 4px;
}

.ai-asst-msg-bubble p {
  margin: 0 0 6px;
}

.ai-asst-msg-bubble p:last-child {
  margin-bottom: 0;
}

.ai-asst-msg-bubble strong {
  font-weight: 700;
}

/* ---- Typing indicator ---- */
.ai-asst-typing-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.ai-asst-cancel-btn {
  align-self: center;
  margin-left: 4px;
  padding: 3px 10px;
  border-radius: 5px;
  border: 1px solid rgba(180, 80, 30, 0.35);
  background: transparent;
  color: #a04010;
  font-size: 0.75rem;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.15s, background 0.15s;
  white-space: nowrap;
}
.ai-asst-cancel-btn:hover {
  opacity: 1;
  background: rgba(244, 122, 50, 0.1);
}

.ai-asst-typing-bubble {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(240, 111, 47, 0.1);
  border-radius: 14px;
  border-top-left-radius: 4px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.ai-asst-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(240, 111, 47, 0.5);
  animation: ai-dot-bounce 1.3s infinite;
}

.ai-asst-typing-dot:nth-child(2) { animation-delay: 0.18s; }
.ai-asst-typing-dot:nth-child(3) { animation-delay: 0.36s; }

@keyframes ai-dot-bounce {
  0%, 80%, 100% { transform: scale(0.65); opacity: 0.35; }
  40% { transform: scale(1); opacity: 1; }
}

.ai-asst-typing-status {
  font-size: 0.8rem;
  color: #b05a28;
  margin-left: 4px;
  animation: ai-status-fadein 0.4s ease;
}

@keyframes ai-status-fadein {
  from { opacity: 0; transform: translateY(3px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---- Tool call card ---- */
.ai-asst-tool-card {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  background: rgba(244, 122, 50, 0.07);
  border: 1px solid rgba(240, 111, 47, 0.18);
  border-radius: 10px;
  font-size: 0.8rem;
  color: #9d4618;
}

.ai-asst-tool-card.is-done {
  background: rgba(34, 163, 102, 0.07);
  border-color: rgba(34, 163, 102, 0.2);
  color: #1a6b4a;
}

.ai-asst-tool-card.is-error {
  background: rgba(220, 53, 69, 0.07);
  border-color: rgba(220, 53, 69, 0.18);
  color: #842029;
}

.ai-asst-tool-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(240, 111, 47, 0.25);
  border-top-color: #f47a32;
  border-radius: 50%;
  flex-shrink: 0;
  animation: ai-spin 0.75s linear infinite;
}

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

.ai-asst-tool-icon {
  flex-shrink: 0;
  font-size: 0.9rem;
}

.ai-asst-tool-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- User message uploaded image: half size, right-aligned ---- */
.ai-asst-msg--user .ai-asst-result-grid {
  max-width: 50%;
  margin-left: auto;
}

/* ---- Generated image grid ---- */
.ai-asst-result-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  margin-top: 6px;
}

.ai-asst-result-grid.count-1 {
  grid-template-columns: 1fr;
}

.ai-asst-result-img-wrap {
  position: relative;
  border-radius: 8px;
  border: 1px solid rgba(240, 111, 47, 0.12);
  cursor: zoom-in;
  background: rgba(240, 111, 47, 0.04);
  aspect-ratio: 1;
  overflow: hidden;
}

.ai-asst-result-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.2s;
}

.ai-asst-result-img-wrap:hover img {
  transform: scale(1.03);
}

/* ---- Download button overlay on generated image ---- */
.ai-asst-img-dl-btn {
  position: absolute;
  bottom: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.52);
  color: white;
  display: grid;
  place-items: center;
  font-size: 0.8rem;
  text-decoration: none;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s;
  line-height: 1;
}

.ai-asst-result-img-wrap:hover .ai-asst-img-dl-btn {
  opacity: 1;
}

.ai-asst-img-dl-btn:hover {
  background: rgba(0, 0, 0, 0.76);
}

/* ---- Crop size label overlay ---- */
.ai-asst-crop-size-label {
  position: absolute;
  bottom: 6px;
  left: 6px;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.48);
  color: white;
  font-size: 0.7rem;
  pointer-events: none;
  white-space: nowrap;
}

/* ---- Category chips (welcome) ---- */
.ai-asst-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.ai-asst-chip {
  padding: 4px 11px;
  border-radius: 20px;
  border: 1px solid rgba(240, 111, 47, 0.26);
  background: rgba(255, 244, 231, 0.85);
  color: #9d4618;
  font-size: 0.78rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  font-family: inherit;
}

.ai-asst-chip:hover {
  background: rgba(240, 111, 47, 0.14);
  border-color: rgba(240, 111, 47, 0.4);
}

/* ---- Attachment preview bar ---- */
.ai-asst-attach-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 12px 4px;
  border-top: 1px solid rgba(240, 111, 47, 0.1);
  background: rgba(255, 248, 238, 0.6);
}

.ai-asst-attach-bar[hidden] {
  display: none !important;
}

.ai-asst-thumb {
  position: relative;
  width: 46px;
  height: 46px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(240, 111, 47, 0.18);
  flex-shrink: 0;
  cursor: grab;
}

.ai-asst-thumb:active {
  cursor: grabbing;
}

.ai-asst-thumb.is-dragging {
  opacity: 0.35;
  outline: 2px dashed rgba(240, 111, 47, 0.55);
  outline-offset: 2px;
}

.ai-asst-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ai-asst-thumb-video {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(244, 122, 50, 0.08);
  color: #9d4618;
  font-size: 1.2rem;
}

.ai-asst-thumb-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: white;
  border: none;
  cursor: pointer;
  font-size: 0.6rem;
  display: grid;
  place-items: center;
  line-height: 1;
  padding: 0;
}

.ai-asst-intent-badge {
  position: absolute;
  bottom: 2px;
  left: 2px;
  font-size: 0.7rem;
  background: rgba(255,255,255,0.9);
  border-radius: 4px;
  padding: 0 2px;
  line-height: 1.4;
  pointer-events: none;
}

/* ---- Input area ---- */
.ai-asst-foot {
  flex-shrink: 0;
  border-top: 1px solid rgba(240, 111, 47, 0.12);
  background: rgba(255, 255, 255, 0.88);
}

.ai-asst-input-row {
  display: flex;
  align-items: flex-end;
  gap: 7px;
  padding: 10px 12px;
}

.ai-asst-attach-label {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid rgba(240, 111, 47, 0.2);
  background: rgba(255, 244, 231, 0.8);
  color: #9d4618;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.15s;
}

.ai-asst-attach-label:hover {
  background: rgba(240, 111, 47, 0.12);
}

.ai-asst-attach-label input {
  display: none;
}

.ai-asst-textarea {
  flex: 1;
  min-height: 36px;
  max-height: 130px;
  border: 1px solid rgba(240, 111, 47, 0.2);
  border-radius: 10px;
  padding: 7px 10px;
  resize: none;
  background: rgba(255, 248, 238, 0.9);
  color: #4e2f18;
  font-size: 0.875rem;
  line-height: 1.5;
  font-family: "Noto Sans SC", sans-serif;
  overflow-y: auto;
  scrollbar-width: none;
}

.ai-asst-textarea::-webkit-scrollbar {
  display: none;
}

.ai-asst-textarea:focus {
  outline: none;
  border-color: rgba(240, 111, 47, 0.45);
  box-shadow: 0 0 0 3px rgba(240, 111, 47, 0.09);
}

.ai-asst-textarea::placeholder {
  color: rgba(78, 47, 24, 0.38);
}

.ai-asst-textarea:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ai-asst-send-btn {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: linear-gradient(135deg, #f47a32, #df5910);
  color: white;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: opacity 0.15s, transform 0.1s;
  box-shadow: 0 2px 8px rgba(240, 111, 47, 0.28);
}

.ai-asst-send-btn:hover {
  opacity: 0.88;
  transform: scale(1.04);
}

.ai-asst-send-btn:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ---- Upload progress indicator ---- */
.ai-asst-upload-hint {
  font-size: 0.75rem;
  color: rgba(78, 47, 24, 0.5);
  padding: 0 12px 6px;
  text-align: center;
}

/* ---- Markdown-lite in bubble ---- */
.ai-asst-msg-bubble code {
  background: rgba(240, 111, 47, 0.1);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: "Space Grotesk", monospace;
  font-size: 0.82em;
  color: #9d4618;
}

.ai-asst-msg-bubble ul,
.ai-asst-msg-bubble ol {
  margin: 4px 0;
  padding-left: 18px;
}

.ai-asst-msg-bubble li {
  margin-bottom: 3px;
}

/* ---- Parse result card ---- */
.ai-asst-parse-card {
  border: 1px solid rgba(240, 111, 47, 0.2);
  border-radius: 10px;
  overflow: hidden;
  font-size: 0.82rem;
  margin-top: 6px;
}

.ai-asst-parse-card-hd {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  background: linear-gradient(135deg, rgba(255, 223, 159, 0.45) 0%, rgba(244, 122, 50, 0.1) 100%);
  border-bottom: 1px solid rgba(240, 111, 47, 0.15);
  font-weight: 700;
  color: #7f3212;
  font-size: 0.8rem;
}

.ai-asst-parse-card-body {
  padding: 8px 11px;
  background: rgba(255, 255, 255, 0.85);
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.ai-asst-parse-row {
  display: flex;
  gap: 6px;
  align-items: flex-start;
}

.ai-asst-parse-key {
  flex-shrink: 0;
  width: 72px;
  color: rgba(127, 50, 18, 0.6);
  padding-top: 1px;
}

.ai-asst-parse-val {
  flex: 1;
  color: #4e2f18;
  line-height: 1.55;
  word-break: break-word;
}

/* ---- Drag-drop highlight ---- */
.ai-asst-foot.drag-over {
  background: rgba(244, 122, 50, 0.06);
  border-top-color: rgba(240, 111, 47, 0.4);
}

.ai-asst-foot.drag-over .ai-asst-textarea {
  border-color: rgba(240, 111, 47, 0.5);
  box-shadow: 0 0 0 3px rgba(240, 111, 47, 0.12);
}

/* ---- Quick action buttons ---- */
.ai-asst-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.ai-asst-qa-btn {
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid rgba(240, 111, 47, 0.28);
  background: rgba(255, 248, 238, 0.9);
  color: #9d4618;
  font-size: 0.76rem;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.14s, border-color 0.14s, transform 0.1s;
}

.ai-asst-qa-btn:hover {
  background: rgba(240, 111, 47, 0.14);
  border-color: rgba(240, 111, 47, 0.42);
  transform: scale(1.02);
}

.ai-asst-qa-btn:active {
  transform: scale(0.97);
}

/* ---- Crop results grid ---- */
.ai-asst-crop-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.ai-asst-crop-item {
  border: 1px solid rgba(240, 111, 47, 0.16);
  border-radius: 10px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.88);
}

.ai-asst-crop-item img {
  width: 100%;
  display: block;
}

.ai-asst-crop-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  font-size: 0.78rem;
  color: #7f3212;
  border-top: 1px solid rgba(240, 111, 47, 0.1);
  background: rgba(255, 248, 238, 0.8);
}

.ai-asst-crop-dl,
.ai-asst-crop-trigger {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 16px;
  border: 1px solid rgba(240, 111, 47, 0.28);
  background: rgba(255, 244, 231, 0.9);
  color: #9d4618;
  font-size: 0.74rem;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
  transition: background 0.14s;
}

.ai-asst-crop-dl:hover,
.ai-asst-crop-trigger:hover {
  background: rgba(240, 111, 47, 0.14);
}

/* ---- Export card ---- */
.ai-asst-export-card {
  border: 1px solid rgba(34, 163, 102, 0.2);
  border-radius: 10px;
  overflow: hidden;
  margin-top: 6px;
  font-size: 0.82rem;
}

.ai-asst-export-hd {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  background: rgba(34, 163, 102, 0.08);
  border-bottom: 1px solid rgba(34, 163, 102, 0.14);
  font-weight: 700;
  color: #1a6b4a;
  font-size: 0.8rem;
}

.ai-asst-export-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  border-bottom: 1px solid rgba(34, 163, 102, 0.08);
  background: rgba(255, 255, 255, 0.88);
}

.ai-asst-export-item:last-child {
  border-bottom: none;
}

.ai-asst-export-num {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(34, 163, 102, 0.12);
  color: #1a6b4a;
  font-size: 0.72rem;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.ai-asst-export-dl {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 16px;
  border: 1px solid rgba(34, 163, 102, 0.28);
  background: rgba(220, 248, 235, 0.8);
  color: #1a6b4a;
  font-size: 0.74rem;
  text-decoration: none;
  margin-left: auto;
  transition: background 0.14s;
}

.ai-asst-export-dl:hover {
  background: rgba(34, 163, 102, 0.16);
}

/* ---- Video thumbnails (attachment bar) ---- */
.ai-asst-thumb--video {
  background: rgba(244, 122, 50, 0.07);
}

.ai-asst-thumb-video-inner {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: #9d4618;
}

.ai-asst-thumb-video-inner svg {
  opacity: 0.8;
}

.ai-asst-thumb-vid-name {
  font-size: 0.56rem;
  color: #9d4618;
  max-width: 42px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
  line-height: 1.2;
}

/* ---- Video thumbnail in user message bubble ---- */
.ai-asst-vid-thumb {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.2);
  font-size: 0.78rem;
  color: white;
  margin-top: 4px;
  max-width: 100%;
  overflow: hidden;
}

.ai-asst-vid-thumb span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---- Resolution hint bar ---- */
.ai-asst-res-hint {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 7px 12px;
  background: rgba(255, 248, 238, 0.85);
  border: 1px solid rgba(240, 111, 47, 0.12);
  border-radius: 10px;
  margin: 0 12px 4px;
  font-size: 0.78rem;
}

.ai-asst-res-label {
  color: rgba(78, 47, 24, 0.55);
  flex-shrink: 0;
}

.ai-asst-res-btn {
  padding: 3px 10px;
  border-radius: 14px;
  border: 1px solid rgba(240, 111, 47, 0.25);
  background: rgba(255, 255, 255, 0.8);
  color: #9d4618;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.13s, border-color 0.13s;
}

.ai-asst-res-btn:hover {
  background: rgba(240, 111, 47, 0.1);
  border-color: rgba(240, 111, 47, 0.4);
}

.ai-asst-res-btn.is-active {
  background: linear-gradient(135deg, #f47a32, #df5910);
  border-color: transparent;
  color: white;
}

.ai-asst-res-tip {
  color: rgba(127, 50, 18, 0.5);
  font-size: 0.73rem;
}

/* ---- Platform / count quick-select bar ---- */
.ai-asst-pref-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  padding: 5px 12px 4px;
  border-top: 1px solid rgba(240, 111, 47, 0.1);
  background: rgba(255, 248, 238, 0.6);
  flex-shrink: 0;
}

.ai-asst-pref-label {
  font-size: 0.71rem;
  color: rgba(78, 47, 24, 0.48);
  flex-shrink: 0;
  line-height: 1.6;
}

.ai-asst-pref-sep {
  color: rgba(78, 47, 24, 0.22);
  font-size: 0.71rem;
  padding: 0 2px;
}

.ai-asst-pref-group {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
}

.ai-asst-pref-btn {
  padding: 1px 9px;
  border-radius: 12px;
  border: 1px solid rgba(240, 111, 47, 0.2);
  background: rgba(255, 255, 255, 0.75);
  color: rgba(78, 47, 24, 0.6);
  font-size: 0.71rem;
  cursor: pointer;
  font-family: inherit;
  line-height: 1.7;
  transition: background 0.13s, border-color 0.13s, color 0.13s;
}

.ai-asst-pref-btn:hover {
  background: rgba(240, 111, 47, 0.1);
  border-color: rgba(240, 111, 47, 0.35);
  color: #9d4618;
}

.ai-asst-pref-btn.is-active {
  background: linear-gradient(135deg, #f47a32, #df5910);
  border-color: transparent;
  color: white;
  font-weight: 600;
}

/* ---- Responsive ---- */
@media (max-width: 860px) {
  .ai-asst-panel {
    width: calc(100vw - 16px);
    left: 8px;
  }
}

/* ---- Children quick-select card ---- */
.ai-asst-children-card {
  margin-top: 10px;
  border: 1px solid rgba(240, 111, 47, 0.18);
  border-radius: 12px;
  padding: 10px 12px 8px;
  background: rgba(255, 248, 238, 0.75);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ai-asst-ccard-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.ai-asst-ccard-label {
  font-size: 0.78rem;
  color: rgba(127, 50, 18, 0.72);
  flex-shrink: 0;
  min-width: 68px;
  font-weight: 600;
  line-height: 1.6;
}

.ai-asst-ccard-opts {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.ai-asst-ccard-actions {
  display: flex;
  gap: 6px;
  margin-top: 4px;
  flex-wrap: wrap;
  padding-top: 6px;
  border-top: 1px solid rgba(240, 111, 47, 0.1);
}

/* ════════════════════════════════════════════════════════
   新增功能样式（Phase 1-3）
   ════════════════════════════════════════════════════════ */

/* ---- Phase 1.1: 首次引导卡 ---- */
.ai-asst-guide-card {
  background: linear-gradient(135deg, rgba(255, 223, 159, 0.35) 0%, rgba(244, 122, 50, 0.07) 100%);
  border: 1px solid rgba(240, 111, 47, 0.22);
  border-radius: 12px;
  padding: 12px 14px 10px;
  margin-bottom: 10px;
  position: relative;
}
.ai-asst-guide-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: #7f3212;
  margin-bottom: 8px;
}
.ai-asst-guide-steps {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}
.ai-asst-guide-step {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid rgba(240, 111, 47, 0.18);
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 0.76rem;
  color: #7f3212;
  white-space: nowrap;
}
.ai-asst-guide-step-num {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f47a32, #df5910);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ai-asst-guide-arrow {
  color: rgba(240, 111, 47, 0.4);
  font-size: 0.85rem;
  flex-shrink: 0;
}
.ai-asst-guide-dismiss {
  position: absolute;
  top: 7px;
  right: 9px;
  background: none;
  border: none;
  color: rgba(127, 50, 18, 0.35);
  cursor: pointer;
  font-size: 1.05rem;
  line-height: 1;
  padding: 0;
  font-family: inherit;
  transition: color 0.15s;
}
.ai-asst-guide-dismiss:hover { color: rgba(127, 50, 18, 0.7); }

/* ---- Phase 1.4 + Phase 3.1: 套图主按钮 ---- */
.ai-asst-qa-btn--primary {
  background: linear-gradient(135deg, rgba(244, 122, 50, 0.16), rgba(223, 89, 16, 0.11));
  border-color: rgba(240, 111, 47, 0.38) !important;
  font-weight: 600;
}
.ai-asst-qa-btn--primary:hover {
  background: linear-gradient(135deg, rgba(244, 122, 50, 0.26), rgba(223, 89, 16, 0.2));
}

/* ---- Phase 2.4: 品牌色提取条 ---- */
.ai-asst-brand-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px 3px;
  border-top: 1px solid rgba(240, 111, 47, 0.1);
  background: rgba(255, 250, 245, 0.6);
  flex-shrink: 0;
  flex-wrap: wrap;
  min-height: 28px;
}
.ai-asst-brand-bar-label {
  font-size: 0.7rem;
  color: rgba(78, 47, 24, 0.46);
  flex-shrink: 0;
}
.ai-asst-brand-swatches {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  align-items: center;
}
.ai-asst-brand-swatch {
  width: 17px;
  height: 17px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.75);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  transition: transform 0.13s;
}
.ai-asst-brand-swatch:hover { transform: scale(1.18); }
.ai-asst-brand-swatch-clear {
  font-size: 0.65rem;
  color: rgba(127, 50, 18, 0.4);
  cursor: pointer;
  padding: 0 2px;
  border: none;
  background: none;
  font-family: inherit;
  line-height: 1;
}
.ai-asst-brand-swatch-clear:hover { color: rgba(220, 50, 50, 0.7); }
.ai-asst-brand-upload {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: 10px;
  border: 1px dashed rgba(240, 111, 47, 0.28);
  color: rgba(127, 50, 18, 0.55);
  font-size: 0.68rem;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.13s, color 0.13s;
}
.ai-asst-brand-upload input { display: none; }
.ai-asst-brand-upload:hover {
  border-color: rgba(240, 111, 47, 0.5);
  color: #9d4618;
}

/* ---- Phase 3.4: 我的风格按钮 ---- */
.ai-asst-my-styles-btn {
  padding: 3px 9px;
  border-radius: 12px;
  border: 1px solid rgba(240, 111, 47, 0.22);
  background: rgba(255, 255, 255, 0.65);
  color: rgba(78, 47, 24, 0.62);
  font-size: 0.72rem;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.13s, border-color 0.13s;
  white-space: nowrap;
}
.ai-asst-my-styles-btn:hover {
  background: rgba(255, 244, 231, 0.9);
  border-color: rgba(240, 111, 47, 0.38);
}

/* ---- Phase 3.4: 风格库面板 ---- */
.ai-asst-styles-panel { margin-top: 6px; }
.ai-asst-styles-empty {
  font-size: 0.78rem;
  color: rgba(78, 47, 24, 0.5);
  text-align: center;
  padding: 12px 8px;
  line-height: 1.6;
}
.ai-asst-style-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 9px 10px;
  border-bottom: 1px solid rgba(240, 111, 47, 0.08);
}
.ai-asst-style-item:last-child { border-bottom: none; }
.ai-asst-style-info { flex: 1; min-width: 0; }
.ai-asst-style-name {
  font-size: 0.78rem;
  font-weight: 600;
  color: #7f3212;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ai-asst-style-preview {
  font-size: 0.72rem;
  color: rgba(78, 47, 24, 0.65);
  line-height: 1.45;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.ai-asst-style-meta {
  font-size: 0.68rem;
  color: rgba(127, 50, 18, 0.42);
  margin-top: 2px;
}
.ai-asst-style-btns {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}
.ai-asst-style-apply-btn, .ai-asst-style-del-btn {
  padding: 3px 9px;
  border-radius: 10px;
  font-size: 0.71rem;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  border: 1px solid;
  transition: background 0.13s;
}
.ai-asst-style-apply-btn {
  background: rgba(255, 244, 231, 0.9);
  border-color: rgba(240, 111, 47, 0.28);
  color: #9d4618;
}
.ai-asst-style-apply-btn:hover { background: rgba(244, 122, 50, 0.15); }
.ai-asst-style-del-btn {
  background: rgba(255, 255, 255, 0.7);
  border-color: rgba(200, 80, 80, 0.2);
  color: rgba(180, 60, 60, 0.7);
}
.ai-asst-style-del-btn:hover { background: rgba(220, 50, 50, 0.08); }

/* ---- Phase 3.3: 场景模板面板 ---- */
.ai-asst-scene-hd {
  font-size: 0.8rem;
  font-weight: 700;
  color: #7f3212;
  margin-bottom: 8px;
}
.ai-asst-scene-templates {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 4px;
}
.ai-asst-scene-tmpl-card {
  border: 1px solid rgba(240, 111, 47, 0.15);
  border-radius: 9px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.7);
  cursor: pointer;
  transition: background 0.13s, border-color 0.13s, transform 0.1s;
}
.ai-asst-scene-tmpl-card:hover {
  background: rgba(255, 244, 231, 0.9);
  border-color: rgba(240, 111, 47, 0.35);
  transform: translateY(-1px);
}
.ai-asst-scene-tmpl-name {
  font-size: 0.79rem;
  font-weight: 600;
  color: #7f3212;
  margin-bottom: 2px;
}
.ai-asst-scene-tmpl-desc {
  font-size: 0.71rem;
  color: rgba(78, 47, 24, 0.58);
  line-height: 1.45;
}
.ai-asst-scene-tmpl-tags {
  display: flex;
  gap: 3px;
  margin-top: 4px;
  flex-wrap: wrap;
}
.ai-asst-scene-tmpl-tag {
  font-size: 0.63rem;
  padding: 1px 5px;
  border-radius: 6px;
  background: rgba(240, 111, 47, 0.1);
  color: rgba(127, 50, 18, 0.65);
}

/* ---- Phase 3.1: 套图进度条 ---- */
.ai-asst-listing-progress {
  margin-top: 8px;
  font-size: 0.76rem;
  color: rgba(78, 47, 24, 0.6);
}
.ai-asst-listing-progress-bar {
  height: 4px;
  border-radius: 2px;
  background: rgba(240, 111, 47, 0.12);
  margin-top: 4px;
  overflow: hidden;
}
.ai-asst-listing-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #f47a32, #df5910);
  border-radius: 2px;
  transition: width 0.3s ease;
}

/* ---- Phase 2.1: 图片分析中提示 ---- */
.ai-asst-analyze-hint {
  font-size: 0.72rem;
  color: rgba(127, 50, 18, 0.55);
  padding: 3px 8px;
  animation: ai-asst-pulse 1.4s ease-in-out infinite;
}
@keyframes ai-asst-pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* ---- Plan confirm card ---- */
.ai-asst-confirm-card {
  border: 1px solid rgba(240, 111, 47, 0.28);
  border-radius: 10px;
  overflow: hidden;
  font-size: 0.82rem;
  margin-top: 6px;
}

.ai-asst-confirm-card-hd {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  background: linear-gradient(135deg, rgba(255, 223, 159, 0.55) 0%, rgba(244, 122, 50, 0.15) 100%);
  border-bottom: 1px solid rgba(240, 111, 47, 0.15);
  font-weight: 700;
  color: #7f3212;
  font-size: 0.8rem;
}

.ai-asst-confirm-summary {
  margin: 0;
  padding: 8px 11px 4px;
  color: #5a3018;
  font-size: 0.84rem;
  line-height: 1.5;
  background: rgba(255, 255, 255, 0.85);
}

.ai-asst-role-badge {
  padding: 4px 11px 5px;
  font-size: 0.78rem;
  color: #6b4c2a;
  background: rgba(255, 244, 230, 0.9);
  border-top: 1px solid rgba(180, 120, 60, 0.12);
  letter-spacing: 0.01em;
}

.ai-asst-confirm-detail {
  padding: 6px 11px 8px;
  background: rgba(255, 255, 255, 0.85);
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: rgba(78, 47, 24, 0.85);
  line-height: 1.5;
  font-size: 0.8rem;
}

.ai-asst-confirm-meta {
  color: rgba(78, 47, 24, 0.6);
  font-size: 0.76rem;
}

.ai-asst-confirm-actions {
  display: flex;
  gap: 8px;
  padding: 8px 11px;
  background: rgba(255, 248, 238, 0.9);
  border-top: 1px solid rgba(240, 111, 47, 0.12);
}

.ai-asst-confirm-btn {
  flex: 1;
  padding: 7px 12px;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, #f47a32 0%, #df5910 100%);
  color: #fff;
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  transition: opacity 0.15s;
}

.ai-asst-confirm-btn:hover:not(:disabled) { opacity: 0.88; }
.ai-asst-confirm-btn:disabled { opacity: 0.45; cursor: default; }

.ai-asst-modify-btn {
  padding: 7px 12px;
  border: 1px solid rgba(240, 111, 47, 0.35);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.7);
  color: #b04718;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.15s;
}

.ai-asst-modify-btn:hover:not(:disabled) { background: rgba(244, 122, 50, 0.1); }
.ai-asst-modify-btn:disabled { opacity: 0.45; cursor: default; }

/* ── Multi-plan confirm card ── */
.ai-asst-multi-plan-list {
  background: rgba(255, 255, 255, 0.85);
  padding: 4px 0;
}

.ai-asst-multi-plan-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 11px;
  border-bottom: 1px solid rgba(240, 111, 47, 0.1);
}
.ai-asst-multi-plan-item:last-child { border-bottom: none; }

.ai-asst-multi-plan-idx {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f47a32 0%, #df5910 100%);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  display: grid;
  place-items: center;
  margin-top: 1px;
}

.ai-asst-multi-plan-info { flex: 1; min-width: 0; }

.ai-asst-multi-plan-summary {
  font-size: 0.83rem;
  color: #4e2f18;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ai-asst-multi-plan-meta {
  font-size: 0.74rem;
  color: rgba(78, 47, 24, 0.55);
  margin-top: 2px;
}

/* ── Error bubble with inline retry button ── */
.ai-asst-error-bubble {
  background: rgba(255, 240, 235, 0.9);
  border: 1px solid rgba(220, 80, 30, 0.25);
}

.ai-asst-retry-inline-btn {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 10px;
  border-radius: 5px;
  border: 1px solid rgba(240, 111, 47, 0.5);
  background: rgba(244, 122, 50, 0.08);
  color: #c04010;
  font-size: 0.78rem;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.15s;
  vertical-align: middle;
}
.ai-asst-retry-inline-btn:hover {
  background: rgba(244, 122, 50, 0.18);
}

/* ── Offline banner ── */
#ai-asst-offline-banner {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #e53935;
  color: #fff;
  text-align: center;
  padding: 6px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* =========================================================
   品牌需求面板 — 触发按钮 & 可展开面板
   ======================================================= */

.ai-asst-brand-req-toggle {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 9px;
  border-radius: 5px;
  border: 1px solid rgba(240, 111, 47, 0.32);
  background: transparent;
  color: #b04718;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  position: relative;
  white-space: nowrap;
}

.ai-asst-brand-req-toggle:hover {
  background: rgba(240, 111, 47, 0.08);
  border-color: rgba(240, 111, 47, 0.55);
}

.ai-asst-brand-req-toggle.is-active {
  background: rgba(240, 111, 47, 0.12);
  border-color: rgba(240, 111, 47, 0.7);
  color: #f06f2f;
}

.ai-asst-brand-req-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: #f06f2f;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1;
  margin-left: 2px;
}

/* 品牌需求展开面板 */
.ai-asst-brand-req-panel {
  display: none;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
  background: linear-gradient(180deg, rgba(255,247,235,0.95) 0%, #fffcf8 100%);
  border-top: 1px solid rgba(240, 111, 47, 0.14);
  border-bottom: 1px solid rgba(240, 111, 47, 0.14);
  flex-shrink: 0;
  max-height: 300px;
  overflow-y: auto;
}

.ai-asst-brand-req-panel.is-open {
  display: flex;
}

.ai-asst-brand-req-title {
  font-size: 0.83rem;
  font-weight: 700;
  color: #7f3212;
  line-height: 1.3;
}

.ai-asst-brand-req-subtitle {
  font-size: 0.73rem;
  color: rgba(78, 47, 24, 0.55);
  margin-top: -6px;
  line-height: 1.4;
}

.ai-asst-brand-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.ai-asst-brand-field-label {
  font-size: 0.76rem;
  font-weight: 600;
  color: rgba(78, 47, 24, 0.75);
}

.ai-asst-brand-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.ai-asst-brand-chip {
  padding: 3px 9px;
  border-radius: 20px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  background: #fff;
  color: #444;
  font-size: 0.74rem;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.ai-asst-brand-chip:hover {
  background: rgba(240, 111, 47, 0.08);
  border-color: rgba(240, 111, 47, 0.4);
}

.ai-asst-brand-chip.is-active {
  background: rgba(240, 111, 47, 0.14);
  border-color: rgba(240, 111, 47, 0.65);
  color: #b04718;
  font-weight: 600;
}

.ai-asst-brand-text {
  padding: 5px 9px;
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  background: #fff;
  font-size: 0.76rem;
  color: #333;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
  box-sizing: border-box;
}

.ai-asst-brand-text:focus {
  border-color: rgba(240, 111, 47, 0.55);
}

.ai-asst-brand-req-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 2px;
}

.ai-asst-brand-req-save {
  padding: 4px 14px;
  border-radius: 6px;
  border: none;
  background: linear-gradient(135deg, #f47a32, #e05a18);
  color: #fff;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

.ai-asst-brand-req-save:hover { opacity: 0.88; }

.ai-asst-brand-req-clear {
  padding: 4px 12px;
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  background: transparent;
  color: #888;
  font-size: 0.76rem;
  cursor: pointer;
  transition: background 0.12s;
}

.ai-asst-brand-req-clear:hover { background: rgba(0, 0, 0, 0.05); }

/* =============================================================
 * Intent Picker — 上传图片后的意图选择浮层
 * ============================================================= */
.ai-asst-intent-picker {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.18), 0 1px 6px rgba(0,0,0,0.08);
  padding: 10px 10px 8px;
  z-index: 200;
  min-width: 230px;
  animation: intentPickerIn 0.15s ease;
  border: 1px solid rgba(0,0,0,0.08);
}

@keyframes intentPickerIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ai-asst-intent-picker-title {
  font-size: 0.72rem;
  color: #999;
  margin-bottom: 7px;
  padding: 0 2px;
  font-weight: 500;
}

.ai-asst-intent-picker-btns {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ai-asst-intent-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.8rem;
  color: #333;
  text-align: left;
  transition: background 0.1s;
  width: 100%;
}

.ai-asst-intent-btn:hover { background: rgba(244,122,50,0.08); color: #e05a18; }

.ai-asst-intent-btn .ai-asst-intent-icon {
  font-size: 1rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.ai-asst-intent-btn .ai-asst-intent-label { font-weight: 500; }
.ai-asst-intent-btn .ai-asst-intent-desc  { font-size: 0.7rem; color: #999; }

/* Inline intent choice buttons inside a chat bubble */
.ai-asst-msg-choices {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 10px;
  background: rgba(0,0,0,0.03);
  border-radius: 10px;
  padding: 5px;
}
.ai-asst-msg-choices .ai-asst-intent-btn:disabled {
  opacity: 0.45;
  cursor: default;
  pointer-events: none;
}

/* =============================================================
 * Guide Quick-Start Cards — 空白对话引导卡片
 * ============================================================= */
.ai-asst-quickstart {
  margin: 10px 0 4px;
}

.ai-asst-quickstart-title {
  font-size: 0.75rem;
  color: rgba(78,47,24,0.55);
  margin-bottom: 8px;
  font-weight: 500;
}

.ai-asst-quickstart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.ai-asst-quickstart-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 9px 10px;
  background: rgba(244,122,50,0.06);
  border: 1px solid rgba(244,122,50,0.15);
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.12s, transform 0.12s;
  text-align: left;
  font-family: inherit;
}

.ai-asst-quickstart-card:hover {
  background: rgba(244,122,50,0.12);
  transform: translateY(-1px);
}

.ai-asst-quickstart-card .qs-icon  { font-size: 1.1rem; }
.ai-asst-quickstart-card .qs-label { font-size: 0.8rem; font-weight: 600; color: #333; }
.ai-asst-quickstart-card .qs-desc  { font-size: 0.68rem; color: #999; line-height: 1.3; }

/* =============================================================
 * Parse Result Card — 图片解析结果内嵌卡片
 * ============================================================= */
.ai-asst-parse-result-card {
  background: #fff;
  border: 1px solid rgba(244,122,50,0.2);
  border-radius: 12px;
  overflow: hidden;
  margin-top: 4px;
}

.ai-asst-prc-header {
  background: linear-gradient(135deg, #f47a32 0%, #e05a18 100%);
  color: #fff;
  padding: 9px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-asst-prc-body { padding: 12px 14px; }

.ai-asst-prc-field { margin-bottom: 10px; }

.ai-asst-prc-label {
  font-size: 0.7rem;
  color: #999;
  font-weight: 500;
  margin-bottom: 4px;
}

.ai-asst-prc-textarea {
  width: 100%;
  min-height: 64px;
  max-height: 120px;
  resize: vertical;
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 7px;
  padding: 7px 9px;
  font-size: 0.78rem;
  line-height: 1.5;
  color: #333;
  font-family: inherit;
  background: #fafafa;
  box-sizing: border-box;
  transition: border-color 0.15s;
}

.ai-asst-prc-textarea:focus {
  outline: none;
  border-color: #f47a32;
  background: #fff;
}

.ai-asst-prc-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}

.ai-asst-prc-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 8px;
  background: rgba(244,122,50,0.1);
  border-radius: 20px;
  font-size: 0.72rem;
  color: #e05a18;
  font-weight: 500;
}

.ai-asst-prc-tag-rm {
  border: none;
  background: transparent;
  color: #e05a18;
  cursor: pointer;
  padding: 0;
  font-size: 0.75rem;
  line-height: 1;
  opacity: 0.6;
}
.ai-asst-prc-tag-rm:hover { opacity: 1; }

.ai-asst-prc-meta {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.ai-asst-prc-meta select {
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.75rem;
  color: #444;
  background: #fafafa;
  cursor: pointer;
}

.ai-asst-prc-meta-item {
  font-size: 0.73rem;
  color: #666;
}

.ai-asst-prc-footer {
  padding: 10px 14px 12px;
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  border-top: 1px solid rgba(0,0,0,0.07);
}

.ai-asst-prc-btn-primary {
  padding: 6px 14px;
  background: linear-gradient(135deg, #f47a32, #e05a18);
  color: #fff;
  border: none;
  border-radius: 7px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.ai-asst-prc-btn-primary:hover { opacity: 0.88; }

.ai-asst-prc-btn-secondary {
  padding: 6px 14px;
  border: 1.5px solid rgba(244,122,50,0.4);
  color: #e05a18;
  background: transparent;
  border-radius: 7px;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s;
}
.ai-asst-prc-btn-secondary:hover { background: rgba(244,122,50,0.07); }

.ai-asst-prc-btn-text {
  padding: 6px 10px;
  border: none;
  background: transparent;
  color: #999;
  font-size: 0.75rem;
  cursor: pointer;
  border-radius: 7px;
  transition: color 0.12s;
}
.ai-asst-prc-btn-text:hover { color: #666; }

/* =============================================================
 * Reference Gen Panel — 参考图信息收集面板（内联于输入区上方）
 * ============================================================= */
.ai-asst-ref-panel {
  background: linear-gradient(135deg, #fff8f3, #fff3ec);
  border: 1px solid rgba(244,122,50,0.2);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 6px;
  animation: refPanelIn 0.18s ease;
}

@keyframes refPanelIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ai-asst-ref-panel-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.ai-asst-ref-panel-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: #c04a10;
  display: flex;
  align-items: center;
  gap: 5px;
}

.ai-asst-ref-panel-close {
  border: none;
  background: transparent;
  color: #ccc;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  line-height: 1;
}
.ai-asst-ref-panel-close:hover { color: #999; background: rgba(0,0,0,0.05); }

.ai-asst-ref-panel-row {
  display: flex;
  gap: 6px;
  align-items: flex-start;
  margin-bottom: 7px;
}

.ai-asst-ref-thumb-mini {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid rgba(0,0,0,0.1);
  flex-shrink: 0;
}

.ai-asst-ref-desc-input {
  flex: 1;
  border: 1px solid rgba(0,0,0,0.12);
  border-radius: 7px;
  padding: 7px 9px;
  font-size: 0.78rem;
  font-family: inherit;
  background: #fff;
  resize: none;
  height: 44px;
  box-sizing: border-box;
  line-height: 1.4;
}
.ai-asst-ref-desc-input:focus { outline: none; border-color: #f47a32; }

.ai-asst-ref-panel-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 7px;
}

.ai-asst-ref-chip {
  padding: 3px 9px;
  border: 1px solid rgba(0,0,0,0.14);
  border-radius: 20px;
  font-size: 0.72rem;
  background: #fff;
  cursor: pointer;
  color: #555;
  transition: all 0.1s;
}
.ai-asst-ref-chip.is-active, .ai-asst-ref-chip:hover {
  background: rgba(244,122,50,0.1);
  border-color: rgba(244,122,50,0.3);
  color: #e05a18;
}

.ai-asst-ref-panel-count {
  display: flex;
  gap: 4px;
  margin-bottom: 9px;
  align-items: center;
}

.ai-asst-ref-count-label { font-size: 0.7rem; color: #999; margin-right: 2px; }

.ai-asst-ref-count-btn {
  padding: 3px 10px;
  border: 1px solid rgba(0,0,0,0.14);
  border-radius: 6px;
  font-size: 0.72rem;
  background: #fff;
  cursor: pointer;
  color: #555;
  transition: all 0.1s;
  font-weight: 500;
}
.ai-asst-ref-count-btn.is-active, .ai-asst-ref-count-btn:hover {
  background: rgba(244,122,50,0.1);
  border-color: rgba(244,122,50,0.3);
  color: #e05a18;
}

.ai-asst-ref-gen-btn {
  width: 100%;
  padding: 8px;
  background: linear-gradient(135deg, #f47a32, #e05a18);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
.ai-asst-ref-gen-btn:hover { opacity: 0.88; }

/* =============================================================
 * Progress Indicator — 信息收集进度条（textarea 上方）
 * ============================================================= */
.ai-asst-progress {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px 4px;
  font-size: 0.7rem;
  color: #aaa;
  background: rgba(244,122,50,0.04);
  border-top: 1px solid rgba(244,122,50,0.08);
  animation: progressIn 0.2s ease;
}

@keyframes progressIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.ai-asst-progress.is-complete { opacity: 0; transition: opacity 0.5s ease 0.3s; }

.ai-asst-progress-label { flex-shrink: 0; }

.ai-asst-progress-segs {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.ai-asst-progress-seg {
  width: 20px;
  height: 4px;
  border-radius: 2px;
  background: rgba(0,0,0,0.1);
  transition: background 0.3s;
}

.ai-asst-progress-seg.is-done { background: #f47a32; }

.ai-asst-progress-pills {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  flex: 1;
}

.ai-asst-progress-pill {
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 0.65rem;
  font-weight: 500;
}

.ai-asst-progress-pill.done  { background: rgba(244,122,50,0.12); color: #e05a18; }
.ai-asst-progress-pill.empty { background: rgba(0,0,0,0.05); color: #bbb; }

/* =============================================================
 * Beginner Button & Badge — 新手引导入口与激活徽标
 * ============================================================= */
.ai-asst-beginner-btn {
  width: 100%;
  margin-top: 9px;
  padding: 9px 0;
  border: 1.5px dashed rgba(244,122,50,0.35);
  border-radius: 9px;
  background: rgba(244,122,50,0.04);
  color: #c04a10;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  transition: background 0.12s, border-color 0.12s;
  font-family: inherit;
}

.ai-asst-beginner-btn:hover {
  background: rgba(244,122,50,0.10);
  border-color: rgba(244,122,50,0.55);
}

.ai-asst-beginner-badge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 12px;
  background: linear-gradient(135deg, rgba(244,122,50,0.10), rgba(224,90,24,0.07));
  border-bottom: 1px solid rgba(244,122,50,0.15);
  font-size: 0.74rem;
  color: #c04a10;
  font-weight: 500;
}

.ai-asst-beginner-badge-exit {
  border: none;
  background: transparent;
  color: rgba(192,74,16,0.55);
  font-size: 0.7rem;
  cursor: pointer;
  padding: 1px 6px;
  border-radius: 4px;
  transition: background 0.1s, color 0.1s;
  font-family: inherit;
}

.ai-asst-beginner-badge-exit:hover {
  background: rgba(244,122,50,0.12);
  color: #c04a10;
}

/* =========================================================
   Loading tips — rotating hints inside tool card
   ========================================================= */

.ai-asst-tool-tip-wrap {
  width: 100%;
  margin-top: 6px;
  min-height: 18px;
}

.ai-asst-tool-tip {
  display: block;
  font-size: 0.73rem;
  color: rgba(78, 47, 24, 0.52);
  line-height: 1.4;
  transition: opacity 0.25s ease;
  opacity: 1;
}

/* =========================================================
   Quick modify bar — post-generation instant adjustments
   ========================================================= */

.ai-asst-qmod-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 0 4px;
  border-bottom: 1px solid rgba(240, 111, 47, 0.1);
  margin-bottom: 6px;
}

.ai-asst-qmod-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 5px 11px;
  background: #fff;
  border: 1.5px solid rgba(240, 111, 47, 0.35);
  border-radius: 20px;
  font-size: 0.77rem;
  color: #c04a10;
  font-family: inherit;
  cursor: pointer;
  font-weight: 500;
  transition: background 0.12s, border-color 0.12s, transform 0.1s, box-shadow 0.12s;
  white-space: nowrap;
}

.ai-asst-qmod-btn:hover {
  background: rgba(244, 122, 50, 0.08);
  border-color: rgba(240, 111, 47, 0.6);
  box-shadow: 0 1px 4px rgba(176, 71, 24, 0.12);
  transform: translateY(-1px);
}

.ai-asst-qmod-btn:active {
  transform: translateY(0);
  background: rgba(244, 122, 50, 0.14);
}


/* ── 平台套图选择条 ── */
.ai-asst-listing-picker {
  padding: 8px 12px 6px;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  background: rgba(255,251,245,0.97);
  animation: ai-asst-slide-in 0.15s ease;
}

@keyframes ai-asst-slide-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ai-asst-listing-ref-hint {
  font-size: 0.72rem;
  color: #a06030;
  margin-bottom: 5px;
}

.ai-asst-listing-picker-label {
  font-size: 0.75rem;
  color: rgba(78,47,24,0.6);
  margin-bottom: 5px;
}

.ai-asst-listing-picker-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}

.ai-asst-listing-chip {
  font-size: 0.78rem;
  padding: 4px 10px;
  border-radius: 14px;
  border: 1.5px solid rgba(160,96,48,0.4);
  background: white;
  color: #7a3a10;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.ai-asst-listing-chip:hover {
  background: rgba(160,96,48,0.08);
  border-color: rgba(160,96,48,0.7);
}

.ai-asst-listing-chip-count {
  font-size: 0.68rem;
  opacity: 0.65;
  margin-left: 2px;
}

.ai-asst-listing-picker-close {
  margin-left: auto;
  font-size: 0.85rem;
  background: none;
  border: none;
  color: #999;
  cursor: pointer;
  padding: 2px 4px;
  line-height: 1;
  font-family: inherit;
}

.ai-asst-listing-picker-close:hover {
  color: #555;
}

/* ===== PROMPT TEMPLATE LIBRARY PANEL ===== */

.tmpl-panel {
  position: fixed;
  top: 80px;
  left: clamp(178px, calc(14vw + 10px), 235px);
  width: 468px;
  max-height: calc(100vh - 100px);
  background: #fff;
  border: 1px solid rgba(46, 25, 11, 0.12);
  border-radius: 23px;
  box-shadow: 0 8px 36px rgba(0, 0, 0, 0.16), 0 2px 8px rgba(0, 0, 0, 0.07);
  z-index: 700;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: box-shadow 150ms ease;
}

.tmpl-panel[hidden] {
  display: none !important;
}

/* Header — drag handle */
.tmpl-panel-hd {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 21px 16px;
  border-bottom: 1px solid rgba(46, 25, 11, 0.07);
  flex-shrink: 0;
  cursor: grab;
  user-select: none;
}

.tmpl-panel-title {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 700;
  font-family: "Space Grotesk", sans-serif;
  color: var(--ink, #1a1008);
  flex: 1;
}

.tmpl-new-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 16px;
  border-radius: 999px;
  border: 1px solid rgba(240, 111, 47, 0.4);
  background: rgba(240, 111, 47, 0.07);
  color: #c95820;
  font-size: 1.04rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 130ms ease, border-color 130ms ease;
  white-space: nowrap;
}

.tmpl-new-btn:hover {
  background: rgba(240, 111, 47, 0.14);
  border-color: rgba(240, 111, 47, 0.7);
}

.tmpl-panel-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 0;
  background: transparent;
  color: #aaa;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}

.tmpl-panel-close svg {
  width: 18px;
  height: 18px;
}

.tmpl-panel-close:hover {
  background: #f5f0eb;
  color: #555;
}

/* List area */
.tmpl-list-wrap {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: none;
  padding: 13px 16px 18px;
}

.tmpl-list-wrap::-webkit-scrollbar {
  display: none;
}

.tmpl-loading,
.tmpl-empty {
  text-align: center;
  color: var(--muted, #aaa);
  font-size: 1.12rem;
  padding: 42px 0;
  margin: 0;
}

.tmpl-empty[hidden],
.tmpl-loading[hidden] {
  display: none !important;
}

.tmpl-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Template card */
.tmpl-card {
  border: 1px solid rgba(46, 25, 11, 0.1);
  border-radius: 16px;
  padding: 14px 17px 13px;
  background: #fdfaf7;
  transition: box-shadow 130ms ease, border-color 130ms ease;
}

.tmpl-card:hover {
  border-color: rgba(240, 111, 47, 0.3);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.07);
}

.tmpl-card-name {
  margin: 0 0 7px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink, #1a1008);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tmpl-card-preview {
  margin: 0 0 13px;
  font-size: 0.88rem;
  color: var(--muted, #888);
  line-height: 1.6;
  max-height: 5em;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  word-break: break-all;
  white-space: pre-wrap;
}

.tmpl-card-preview::-webkit-scrollbar {
  display: none;
}

.tmpl-card-actions {
  display: flex;
  gap: 8px;
}

.tmpl-card-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 13px;
  border-radius: 10px;
  border: 1px solid rgba(46, 25, 11, 0.14);
  background: #fff;
  color: #555;
  font-size: 0.83rem;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
  white-space: nowrap;
}

.tmpl-card-btn:hover {
  background: #f5f0eb;
  border-color: rgba(46, 25, 11, 0.22);
  color: #333;
}

.tmpl-card-btn.use-btn {
  background: var(--accent, #f06f2f);
  color: #fff;
  border-color: var(--accent, #f06f2f);
  font-weight: 600;
}

.tmpl-card-btn.use-btn:hover {
  background: #d95c1e;
  border-color: #d95c1e;
}

.tmpl-card-btn.del-btn:hover {
  background: #fff2f2;
  border-color: #f87171;
  color: #dc2626;
}

/* -------------------------------------------------------------------------- */
/* Edit / Create modal                                                         */
/* -------------------------------------------------------------------------- */

.tmpl-edit-box {
  position: relative;
  z-index: 1;
  background: #fff;
  border-radius: 26px;
  padding: 36px 42px;
  width: min(754px, calc(100vw - 32px));
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.2);
  display: grid;
  gap: 21px;
  animation: tmpl-edit-pop 0.16s ease;
}

@keyframes tmpl-edit-pop {
  from { transform: scale(0.94); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

.tmpl-edit-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tmpl-edit-title {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.43rem;
  font-weight: 700;
  color: #1a1008;
}

.tmpl-edit-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: 0;
  background: transparent;
  cursor: pointer;
  color: #aaa;
  border-radius: 10px;
  transition: background 120ms ease, color 120ms ease;
}

.tmpl-edit-close:hover {
  background: #f5f0eb;
  color: #555;
}

.tmpl-edit-input {
  width: 100%;
  padding: 14px 21px;
  border: 1px solid rgba(46, 25, 11, 0.18);
  border-radius: 16px;
  font-size: 1.25rem;
  color: var(--ink, #1a1008);
  background: #fafaf8;
  box-sizing: border-box;
  transition: border-color 130ms ease;
}

.tmpl-edit-input:focus {
  outline: none;
  border-color: var(--accent, #f06f2f);
  background: #fff;
}

.tmpl-edit-textarea {
  width: 100%;
  padding: 14px 21px;
  border: 1px solid rgba(46, 25, 11, 0.18);
  border-radius: 16px;
  font-size: 1.25rem;
  color: var(--ink, #1a1008);
  background: #fafaf8;
  box-sizing: border-box;
  resize: vertical;
  min-height: 234px;
  font-family: inherit;
  line-height: 1.6;
  transition: border-color 130ms ease;
}

.tmpl-edit-textarea:focus {
  outline: none;
  border-color: var(--accent, #f06f2f);
  background: #fff;
}

.tmpl-edit-actions {
  display: flex;
  gap: 16px;
  justify-content: flex-end;
}

.tmpl-edit-save-btn {
  padding: 13px 36px;
  border-radius: 13px;
  border: 0;
  background: var(--accent, #f06f2f);
  color: #fff;
  font-size: 1.24rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 130ms ease;
}

.tmpl-edit-save-btn:hover {
  background: #d95c1e;
}

.tmpl-edit-save-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.tmpl-edit-cancel-btn {
  padding: 13px 26px;
  border-radius: 13px;
  border: 1px solid rgba(46, 25, 11, 0.14);
  background: #f5f0eb;
  color: #666;
  font-size: 1.24rem;
  cursor: pointer;
  transition: background 130ms ease;
}

.tmpl-edit-cancel-btn:hover {
  background: #ece5dc;
}

/* -------------------------------------------------------------------------- */
/* Tab button text styles                                                      */
/* -------------------------------------------------------------------------- */

#workspace-tab-image .workspace-tab-title,
#workspace-tab-infer .workspace-tab-title,
#ai-asst-tab-btn .workspace-tab-title,
#tmpl-tab-btn .workspace-tab-title {
  color: #000;
  font-weight: 900;
}

#workspace-tab-image.is-active .workspace-tab-title,
#workspace-tab-infer.is-active .workspace-tab-title,
#ai-asst-tab-btn.is-active .workspace-tab-title,
#tmpl-tab-btn.is-active .workspace-tab-title {
  color: #fff;
}

@media (max-width: 1040px) {
  .tmpl-panel {
    left: 12px;
    top: auto;
    bottom: 16px;
    max-height: 70vh;
    width: calc(100vw - 24px);
    max-width: 520px;
  }
}

/* ===== ANNOUNCEMENT PANEL ===== */

/* 公告按钮红点 */
.announcement-btn {
  position: relative;
}

.announcement-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ef4444;
  border: 1.5px solid #fff;
  pointer-events: none;
}

.announcement-badge[hidden] {
  display: none !important;
}

/* 面板容器 */
.announcement-panel {
  position: fixed;
  top: 80px;
  left: clamp(178px, calc(14vw + 10px), 235px);
  width: 468px;
  max-height: calc(100vh - 100px);
  background: #fff;
  border: 1px solid rgba(46, 25, 11, 0.12);
  border-radius: 23px;
  box-shadow: 0 8px 36px rgba(0, 0, 0, 0.16), 0 2px 8px rgba(0, 0, 0, 0.07);
  z-index: 700;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: box-shadow 150ms ease;
}

.announcement-panel[hidden] {
  display: none !important;
}

.announcement-panel-hd {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 21px 16px;
  border-bottom: 1px solid rgba(46, 25, 11, 0.07);
  flex-shrink: 0;
}

.announcement-panel-title {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 700;
  font-family: "Space Grotesk", sans-serif;
  color: var(--ink, #1a1008);
  flex: 1;
}

.announcement-new-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 16px;
  border-radius: 999px;
  border: 1px solid rgba(240, 111, 47, 0.4);
  background: rgba(240, 111, 47, 0.07);
  color: #c95820;
  font-size: 1.04rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 130ms ease, border-color 130ms ease;
  white-space: nowrap;
}

.announcement-new-btn:hover {
  background: rgba(240, 111, 47, 0.14);
  border-color: rgba(240, 111, 47, 0.7);
}

.announcement-panel-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 0;
  background: transparent;
  color: #aaa;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}

.announcement-panel-close svg {
  width: 18px;
  height: 18px;
}

.announcement-panel-close:hover {
  background: #f5f0eb;
  color: #555;
}

/* 公告列表 */
.announcement-list-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 12px 18px 18px;
}

.announcement-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.announcement-item {
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid rgba(46, 25, 11, 0.08);
  background: #faf8f6;
  position: relative;
}

.announcement-item-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: #1a1008;
  margin: 0 0 4px;
}

.announcement-item-content {
  font-size: 0.95rem;
  color: #5c4033;
  line-height: 1.65;
  margin: 0 0 8px;
  white-space: pre-wrap;
  word-break: break-word;
}

.announcement-item-meta {
  font-size: 0.82rem;
  color: #b08060;
  display: flex;
  align-items: center;
  gap: 10px;
}

.announcement-item-actions {
  display: flex;
  gap: 6px;
  margin-left: auto;
}

.announcement-action-btn {
  padding: 2px 10px;
  border-radius: 6px;
  border: 1px solid rgba(46, 25, 11, 0.12);
  background: transparent;
  color: #8c6a52;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}

.announcement-action-btn:hover {
  background: rgba(240, 111, 47, 0.1);
  color: #c95820;
  border-color: rgba(240, 111, 47, 0.3);
}

.announcement-action-btn.danger:hover {
  background: rgba(239, 68, 68, 0.08);
  color: #dc2626;
  border-color: rgba(239, 68, 68, 0.3);
}

.announcement-empty,
.announcement-loading {
  text-align: center;
  font-size: 0.95rem;
  color: #b08060;
  padding: 28px 0;
}

/* 编辑弹窗 overlay */
.announcement-edit-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.38);
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: ann-fade-in 0.15s ease-out;
}

.announcement-edit-modal[hidden] {
  display: none !important;
}

@keyframes ann-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.announcement-edit-modal-inner {
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
  width: 520px;
  max-width: calc(100vw - 32px);
  display: flex;
  flex-direction: column;
  animation: ann-slide-up 0.18s ease-out;
}

@keyframes ann-slide-up {
  from { transform: translateY(12px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.announcement-edit-hd {
  display: flex;
  align-items: center;
  padding: 20px 22px 14px;
  border-bottom: 1px solid rgba(46, 25, 11, 0.07);
}

.announcement-edit-hd h3 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  font-family: "Space Grotesk", sans-serif;
  color: #1a1008;
  flex: 1;
}

.announcement-edit-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 0;
  background: transparent;
  color: #aaa;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}

.announcement-edit-close:hover {
  background: #f5f0eb;
  color: #555;
}

.announcement-edit-body {
  padding: 16px 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.announcement-edit-label {
  font-size: 0.88rem;
  font-weight: 500;
  color: #7a5c44;
}

.announcement-edit-input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid rgba(46, 25, 11, 0.15);
  border-radius: 10px;
  font-size: 0.95rem;
  color: #1a1008;
  outline: none;
  box-sizing: border-box;
  transition: border-color 130ms ease;
}

.announcement-edit-input:focus {
  border-color: rgba(240, 111, 47, 0.5);
}

.announcement-edit-textarea {
  width: 100%;
  min-height: 140px;
  padding: 9px 12px;
  border: 1px solid rgba(46, 25, 11, 0.15);
  border-radius: 10px;
  font-size: 0.95rem;
  color: #1a1008;
  outline: none;
  resize: vertical;
  font-family: inherit;
  line-height: 1.65;
  box-sizing: border-box;
  transition: border-color 130ms ease;
}

.announcement-edit-textarea:focus {
  border-color: rgba(240, 111, 47, 0.5);
}

.announcement-edit-ft {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 22px 20px;
  border-top: 1px solid rgba(46, 25, 11, 0.07);
}

.announcement-edit-cancel {
  padding: 8px 20px;
  border-radius: 999px;
  border: 1px solid rgba(46, 25, 11, 0.15);
  background: transparent;
  color: #7a5c44;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 120ms ease;
}

.announcement-edit-cancel:hover {
  background: #f5f0eb;
}

.announcement-edit-submit {
  padding: 8px 24px;
  border-radius: 999px;
  border: 1px solid rgba(240, 111, 47, 0.5);
  background: rgba(240, 111, 47, 0.1);
  color: #c95820;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 130ms ease, border-color 130ms ease;
}

.announcement-edit-submit:hover {
  background: rgba(240, 111, 47, 0.2);
  border-color: rgba(240, 111, 47, 0.7);
}

.announcement-edit-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

@media (max-width: 1040px) {
  .announcement-panel {
    left: 12px;
    top: auto;
    bottom: 16px;
    max-height: 70vh;
    width: calc(100vw - 24px);
    max-width: 520px;
  }
}


