* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  color: #202124;
  background: #f6f7fb;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  overflow: hidden;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.workspace {
  height: 100vh;
  display: grid;
  grid-template-columns: 176px minmax(0, 1fr) minmax(420px, 1fr);
  overflow: hidden;
}

.conversation-sidebar {
  height: 100vh;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 10px 14px;
  border-right: 1px solid #e1e5ec;
  background: #fff;
  overflow: hidden;
}

.conversation-sidebar header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
}

.conversation-sidebar strong {
  display: block;
  color: #202124;
  font-size: 18px;
  font-weight: 900;
}

.conversation-sidebar span {
  display: block;
  margin-top: 3px;
  color: #69707d;
  font-size: 11px;
}

.new-conversation-btn {
  width: 100%;
  border: 0;
  border-radius: 8px;
  padding: 11px 12px;
  color: #b72a2a;
  background: #fff0f0;
  font-weight: 900;
}

.new-conversation-btn:hover {
  background: #ffe5e5;
}

.new-conversation-btn:disabled {
  cursor: not-allowed;
  color: #9aa1ad;
  background: #f1f3f6;
}

.conversation-list {
  flex: 0 1 auto;
  height: calc(100vh - 132px);
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 8px;
  max-height: calc(100vh - 132px);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding: 2px 3px 4px 0;
  scrollbar-gutter: stable;
}

.conversation-list::-webkit-scrollbar {
  width: 6px;
}

.conversation-list::-webkit-scrollbar-track {
  background: transparent;
}

.conversation-list::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: #d6dce6;
}

.conversation-list::-webkit-scrollbar-thumb:hover {
  background: #b8c0ce;
}

.conversation-empty {
  border: 1px dashed #d8dde6;
  border-radius: 8px;
  padding: 12px;
  color: #8a91a0;
  background: #fafbfc;
  font-size: 12px;
  line-height: 1.5;
}

.conversation-item {
  position: relative;
  border: 1px solid #ebe0e0;
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.conversation-item.active {
  border-color: #f0b6b6;
  background: #fff6f6;
}

.conversation-open {
  width: 100%;
  min-height: 42px;
  display: flex;
  align-items: center;
  min-width: 0;
  border: 0;
  padding: 9px 32px 9px 10px;
  color: #202124;
  background: transparent;
  text-align: left;
}

.conversation-open > strong {
  flex: 1 1 auto;
}

.conversation-open strong {
  min-width: 0;
  overflow: hidden;
  color: #202124;
  font-size: 13px;
  font-weight: 900;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-open span {
  overflow: hidden;
  margin: 0;
  color: #7a8290;
  font-size: 11px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-delete {
  position: absolute;
  top: 50%;
  right: 7px;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 6px;
  padding: 0;
  color: #8a2830;
  background: transparent;
  font-size: 14px;
  font-weight: 900;
  opacity: 0;
  transform: translateY(-50%);
}

.conversation-item:hover .conversation-delete,
.conversation-delete:focus {
  opacity: 1;
}

.conversation-delete:hover {
  color: #fff;
  background: #b72a2a;
}

.main-panel {
  position: relative;
  min-width: 0;
  height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  border-right: 1px solid #e1e5ec;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 24px 12px;
  border-bottom: 1px solid #e1e5ec;
  background: rgba(246, 247, 251, 0.96);
  backdrop-filter: blur(10px);
}

.conversation-title-input {
  width: min(560px, 100%);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 3px 6px;
  color: #202124;
  background: transparent;
  font-size: 22px;
  font-weight: 900;
  outline: none;
}

.conversation-title-input:hover,
.conversation-title-input:focus {
  border-color: #d8dde6;
  background: #fff;
}

.topbar p {
  margin: 6px 0 0;
  color: #69707d;
  font-size: 13px;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

.avatar,
.topbar-action {
  min-width: 72px;
  border: 1px solid #d8dde6;
  border-radius: 8px;
  padding: 9px 13px;
  color: #202124;
  background: #fff;
  font-weight: 800;
}

.topbar-action.active {
  color: #fff;
  border-color: #b72a2a;
  background: #b72a2a;
}

.account {
  position: fixed;
  top: 18px;
  right: 24px;
  z-index: 120;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.eye-care-toggle {
  min-width: 72px;
  border: 1px solid #d8dde6;
  border-radius: 8px;
  padding: 9px 13px;
  color: #202124;
  background: #fff;
  font-weight: 900;
}

.eye-care-toggle.active {
  border-color: #4b5565;
  color: #f2f5f8;
  background: #171a20;
}

.account-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 300px;
  display: none;
  gap: 12px;
  padding: 14px;
  border: 1px solid #e1e5ec;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 18px 50px rgba(28, 33, 42, 0.16);
}

.account-menu.open {
  display: grid;
}

.user-info {
  display: grid;
  gap: 4px;
  color: #69707d;
  font-size: 13px;
}

.login-box,
.redeem-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.login-box {
  grid-template-columns: 1fr;
}

.account-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.ledger-panel {
  border: 1px solid #eef0f4;
  border-radius: 8px;
  padding: 10px;
  background: #fbfcff;
}

.ledger-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(15, 18, 24, 0.38);
}

.ledger-modal.hidden {
  display: none;
}

.ledger-dialog {
  width: min(760px, 100%);
  max-height: min(720px, calc(100vh - 44px));
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  border: 1px solid #e3e8f0;
  border-radius: 12px;
  padding: 16px;
  background: #fff;
  box-shadow: 0 24px 80px rgba(20, 24, 31, 0.22);
}

.ledger-dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid #edf1f6;
}

.ledger-dialog-head strong {
  display: block;
  color: #202124;
  font-size: 18px;
  font-weight: 900;
}

.ledger-dialog-head span {
  display: block;
  margin-top: 4px;
  color: #69707d;
  font-size: 12px;
}

.ledger-dialog-actions {
  display: flex;
  gap: 8px;
}

.ledger-dialog-actions button,
.ledger-tabs button {
  border: 1px solid #dfe5ee;
  border-radius: 8px;
  padding: 8px 11px;
  color: #303642;
  background: #fff;
  font-weight: 800;
  cursor: pointer;
}

.ledger-dialog-actions button:hover,
.ledger-tabs button:hover {
  border-color: #cfd7e4;
  background: #f8fafc;
}

.ledger-dialog-actions button:last-child {
  width: 36px;
  padding: 8px 0;
  color: #b72a2a;
}

.ledger-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 0;
}

.ledger-tabs button.active {
  border-color: #b72a2a;
  color: #fff;
  background: #b72a2a;
}

.ledger-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.ledger-head strong {
  font-size: 13px;
  font-weight: 900;
}

.ledger-head span {
  color: #69707d;
  font-size: 11px;
}

.ledger-list {
  max-height: 330px;
  overflow-y: auto;
  display: grid;
  gap: 10px;
}

.ledger-dialog-list {
  max-height: none;
  min-height: 180px;
  padding-right: 4px;
}

.ledger-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  border: 1px solid #edf1f6;
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
}

.ledger-title-row {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
}

.ledger-tag {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 2px 7px;
  color: #1769e0;
  background: #eaf2ff;
  font-size: 10px;
  font-weight: 900;
  line-height: 1.4;
}

.ledger-tag.image {
  color: #7c2bd6;
  background: #f0e7ff;
}

.ledger-tag.recharge {
  color: #18864b;
  background: #e9f8ef;
}

.ledger-item strong {
  display: block;
  overflow: hidden;
  color: #202124;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ledger-item small {
  display: block;
  margin-top: 3px;
  color: #7a8290;
  font-size: 10px;
  line-height: 1.35;
}

.ledger-amount {
  min-width: 74px;
  text-align: right;
}

.ledger-amount b {
  display: block;
  font-size: 15px;
}

.ledger-amount span {
  display: block;
  margin-top: 3px;
  color: #8a91a0;
  font-size: 10px;
}

.ledger-amount.positive b {
  color: #18864b;
}

.ledger-amount.negative b {
  color: #b72a2a;
}

.ledger-empty {
  border: 1px dashed #dfe5ee;
  border-radius: 7px;
  padding: 14px 10px;
  color: #8a91a0;
  background: #fff;
  font-size: 12px;
  text-align: center;
}

.account-menu input,
.composer textarea,
.image-panel input,
.image-panel textarea,
.batch-card textarea {
  width: 100%;
  border: 1px solid #d8dde6;
  border-radius: 8px;
  padding: 10px 11px;
  color: #202124;
  background: #fff;
  outline: none;
}

.account-menu button,
.composer button,
.module-actions button,
.image-panel button,
.batch-actions button,
.image-download,
.image-batch-actions button {
  border: 0;
  border-radius: 8px;
  padding: 9px 12px;
  color: #fff;
  background: #b72a2a;
  font-weight: 800;
}

.plain,
.batch-actions button.secondary {
  color: #b72a2a !important;
  background: #fff1f1 !important;
}

.batch-actions button.danger {
  color: #69707d !important;
  background: #f1f3f7 !important;
}

.batch-panel {
  position: absolute;
  top: 78px;
  left: 24px;
  right: 24px;
  z-index: 19;
  padding: 0;
  background: transparent;
  pointer-events: none;
}

.batch-card {
  max-height: min(430px, calc(100vh - 180px));
  overflow: auto;
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid #e1e5ec;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 18px 52px rgba(28, 33, 42, 0.18);
  pointer-events: auto;
}

.batch-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  align-items: flex-start;
  gap: 14px;
}

.batch-head > div:first-child {
  min-width: 0;
}

.batch-head strong {
  font-size: 16px;
}

.batch-head span,
.batch-empty {
  color: #69707d;
  font-size: 12px;
}

.batch-head span {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.batch-actions {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
}

.batch-actions::-webkit-scrollbar {
  display: none;
}

.batch-actions button {
  flex: 0 0 auto;
  min-width: 58px;
  height: 40px;
  padding: 0 13px;
}

.batch-actions button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}

.batch-queue {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.batch-item {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  border: 1px solid #e1e5ec;
  border-radius: 999px;
  padding: 6px 9px;
  background: #fbfcfe;
  font-size: 12px;
}

.batch-item.running,
.batch-item.error {
  border-color: #e5b7b7;
  background: #fff1f1;
}

.batch-item.done {
  border-color: #cfe7d7;
  background: #f1fbf4;
}

.batch-item.existing {
  border-color: #d7dee9;
  background: #f4f6fa;
}

.batch-item.paused {
  color: #9a5a13;
  border-color: #ead2a8;
  background: #fff7e8;
}

.batch-item.stopping {
  color: #8a3b3b;
  border-color: #e5b7b7;
  background: #fff1f1;
}

.batch-item.stopped {
  color: #69707d;
  border-color: #d7dee9;
  background: #f4f6fa;
}

.messages {
  min-height: 0;
  overflow: auto;
  padding: 24px 24px 126px;
}

.empty-state {
  width: min(560px, 100%);
  margin: 10vh auto 0;
  padding: 26px;
  border: 1px solid #e1e5ec;
  border-radius: 12px;
  background: #fff;
  text-align: center;
}

.message {
  display: flex;
  margin: 18px 0;
}

.message.user {
  justify-content: flex-end;
}

.message.assistant {
  justify-content: flex-start;
}

.bubble {
  max-width: min(760px, 94%);
  border: 1px solid #e1e5ec;
  border-radius: 14px;
  padding: 14px;
  background: #fff;
  box-shadow: 0 8px 28px rgba(28, 33, 42, 0.05);
}

.message.user .bubble {
  position: relative;
  max-width: min(560px, 72%);
  color: #fff;
  border-color: #b72a2a;
  background: #b72a2a;
}

.message.user.editing-user-message .bubble {
  width: min(560px, 72%);
  max-width: min(560px, 72%);
}

.editable-user-bubble {
  padding-bottom: 42px;
}

.editable-user-bubble .user-bubble-char-count {
  position: absolute;
  right: 64px;
  bottom: 10px;
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 1px 7px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 999px;
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  pointer-events: none;
  white-space: nowrap;
}

.message.user .user-bubble-char-count {
  position: absolute;
  right: 64px;
  bottom: 10px;
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 1px 7px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 999px;
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  pointer-events: none;
  white-space: nowrap;
}

.message.user.editing-user-message .user-bubble-char-count {
  right: 64px;
  bottom: 10px;
}

.user-bubble-editor {
  position: absolute;
  inset: 14px 14px 42px 14px;
  display: block;
  border: 1px solid rgba(255, 255, 255, 0.44);
  border-radius: 10px;
  padding: 10px 12px;
  color: #fff;
  background: rgba(0, 0, 0, 0.08);
  line-height: 1.75;
  outline: none;
  resize: none;
  overflow: auto;
  white-space: pre-wrap;
}

.user-bubble-placeholder {
  opacity: 0;
  pointer-events: none;
}

.user-bubble-actions {
  position: absolute;
  right: 12px;
  bottom: 10px;
  display: flex;
  gap: 8px;
}

.user-bubble-icon {
  display: inline-grid;
  width: 28px;
  height: 28px;
  min-width: 0;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 999px;
  padding: 0;
  color: #b72a2a;
  background: rgba(255, 255, 255, 0.92);
  font-size: 14px;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 8px 20px rgba(80, 10, 10, 0.16);
}

.user-bubble-icon:hover {
  background: #fff;
}

.user-bubble-icon.send,
.user-bubble-icon.active {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(101, 18, 18, 0.78);
}

.bubble p {
  margin: 0;
  line-height: 1.75;
  white-space: pre-wrap;
}

.pending-generation .bubble {
  width: min(520px, 94%);
  border-color: #ead0d0;
  background: #fffafa;
}

.pending-storyboard {
  display: grid;
  gap: 12px;
}

.pending-storyboard header,
.result-module header,
.image-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.pending-progress {
  position: relative;
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #f0dede;
}

.pending-progress span {
  position: absolute;
  inset: 0 auto 0 0;
  width: 38%;
  border-radius: inherit;
  background: linear-gradient(90deg, #b72a2a, #e06b6b, #b72a2a);
  animation: pending 1.2s ease-in-out infinite;
}

@keyframes pending {
  from { transform: translateX(-110%); }
  to { transform: translateX(280%); }
}

.result-module {
  position: relative;
  display: grid;
  gap: 10px;
}

.module-title-group {
  display: flex;
  min-width: 0;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.storyboard-version-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  border: 1px solid #e2e6ee;
  border-radius: 999px;
  color: #6b7280;
  background: #f6f8fb;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.storyboard-version-badge.regenerated {
  border-color: #f0b5b5;
  color: #b72a2a;
  background: #fff2f2;
}

.module-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.char-count-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  border: 1px solid #e2e6ee;
  border-radius: 999px;
  color: #7a8290;
  background: #f8fafc;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.char-count-badge.is-warning {
  border-color: #f1c4a9;
  color: #b95b17;
  background: #fff6ef;
}

.char-count-badge.is-danger {
  border-color: #f0b5b5;
  color: #b72a2a;
  background: #fff2f2;
}

.module-actions button.generating {
  cursor: wait;
  opacity: 0.85;
}

.result-module pre {
  max-height: 520px;
  margin: 0;
  padding: 14px;
  overflow: auto;
  border: 1px solid #eceff4;
  border-radius: 10px;
  color: #30343b;
  background: #fbfcfe;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

.script-result-module pre {
  max-height: 620px;
  background: #fff;
}

.pending-script p {
  color: #5f6b7a;
}

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

.storyboard-edit-form textarea {
  width: 100%;
  min-height: 300px;
  max-height: 520px;
  border: 1px solid #d8dde6;
  border-radius: 10px;
  padding: 14px;
  color: #202124;
  background: #fff;
  line-height: 1.65;
  outline: none;
}

.storyboard-edit-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.storyboard-edit-actions span {
  color: #7a8290;
  font-size: 12px;
}

.storyboard-edit-actions div {
  display: flex;
  gap: 8px;
}

.storyboard-edit-actions button {
  border: 0;
  border-radius: 8px;
  padding: 9px 12px;
  color: #fff;
  background: #b72a2a;
  font-weight: 800;
}

.message.user .storyboard-edit-actions span {
  color: #ffe1e1;
}

.message.user .storyboard-edit-actions .plain {
  color: #b72a2a;
  background: #fff5f5;
}

.image-panel {
  position: absolute;
  top: 44px;
  left: 18px;
  right: 18px;
  z-index: 12;
  display: none;
  gap: 10px;
  max-height: min(440px, calc(100vh - 210px));
  overflow: auto;
  padding: 14px;
  border: 1px solid #e1e5ec;
  border-radius: 12px;
  background: rgba(250, 251, 254, 0.98);
  box-shadow: 0 18px 50px rgba(28, 33, 42, 0.16);
}

.image-panel * {
  box-sizing: border-box;
}

.image-panel.open {
  display: grid;
}

.image-panel-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.image-panel-controls label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #69707d;
  font-size: 12px;
}

.image-panel-controls select {
  height: 28px;
  min-width: 108px;
  border: 1px solid #d8dde6;
  border-radius: 7px;
  padding: 0 8px;
  color: #30343b;
  background: #fff;
  font-size: 12px;
}

.image-quantity {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #69707d;
  font-size: 12px;
}

.image-quantity button {
  width: 26px;
  height: 26px;
  border-radius: 7px !important;
  padding: 0 !important;
  color: #b72a2a !important;
  background: #fff1f1 !important;
}

.image-panel-hint,
.image-status {
  color: #69707d;
  font-size: 12px;
}

.reference-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 10px;
  min-width: 0;
}

.reference-row input[type="file"] {
  display: none;
}

.reference-add {
  width: 72px;
  min-height: 72px;
  border: 1px dashed #d8bcc0 !important;
  border-radius: 10px !important;
  padding: 0 !important;
  color: #b72a2a !important;
  background: #fff5f5 !important;
  font-size: 34px !important;
}

.reference-add.dragging {
  border-color: #b72a2a !important;
  background: #ffe8e8 !important;
}

.selected-refs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(86px, 96px));
  align-content: start;
  align-items: start;
  gap: 8px;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 72px;
  overflow: visible;
}

.selected-ref,
.selected-ref-empty {
  border-radius: 10px;
  color: #4b5563;
  background: #eef1f6;
  font-size: 12px;
}

.selected-ref {
  position: relative;
  display: grid;
  grid-template-rows: 76px auto;
  gap: 5px;
  min-width: 0;
  max-width: 96px;
  padding: 6px;
}

.selected-ref img {
  width: 100%;
  height: 76px;
  object-fit: cover;
  border-radius: 8px;
}

.selected-ref span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selected-ref-empty {
  display: grid;
  place-items: center;
  padding: 10px;
  border: 1px dashed #d8dde6;
  background: #fff;
  text-align: center;
}

.selected-ref button {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 999px;
  background: rgba(32, 33, 36, 0.72);
}

.composer {
  position: sticky;
  bottom: 0;
  z-index: 18;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 54px;
  align-items: end;
  gap: 14px;
  padding: 14px 24px 22px;
  border-top: 1px solid rgba(225, 229, 236, 0.72);
  background: linear-gradient(180deg, rgba(246, 247, 251, 0), #f6f7fb 22%);
}

.composer-main {
  min-width: 0;
  display: grid;
  gap: 8px;
}

.storyboard-selector-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.storyboard-selector-row label {
  position: relative;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid rgba(215, 222, 232, 0.92);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  color: #667085;
  font-size: 12px;
  white-space: nowrap;
}

.storyboard-selector-row span {
  flex: 0 0 auto;
  font-weight: 700;
}

.storyboard-selector-row select {
  width: min(240px, 34vw);
  min-width: 130px;
  height: 28px;
  padding: 0 24px 0 8px;
  border: 0;
  background: transparent;
  color: #242832;
  font: inherit;
  font-weight: 700;
}

.storyboard-selector-row select:disabled {
  opacity: 1;
  cursor: default;
}

.storyboard-selector-row select.native-select-hidden {
  display: none;
}

.composer .upward-select-button {
  position: relative;
  width: min(240px, 34vw);
  min-width: 130px;
  height: 28px;
  padding: 0 24px 0 8px;
  border: 0;
  border-radius: 0;
  color: #242832;
  background: transparent;
  box-shadow: none;
  font: inherit;
  font-weight: 700;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.composer .upward-select-button::after {
  content: "";
  position: absolute;
  right: 10px;
  top: 50%;
  width: 7px;
  height: 7px;
  border-top: 2px solid #667085;
  border-left: 2px solid #667085;
  transform: translateY(-25%) rotate(45deg);
}

.storyboard-selector-row label.disabled .upward-select-button {
  opacity: 1;
  cursor: default;
}

.upward-select-menu {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 45;
  display: none;
  max-height: 230px;
  overflow: auto;
  padding: 5px;
  border: 1px solid #d8dde6;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 16px 36px rgba(28, 33, 42, 0.18);
}

.upward-select.open .upward-select-menu {
  display: grid;
  gap: 3px;
}

.composer .upward-select-menu button {
  width: 100%;
  height: auto;
  min-height: 30px;
  padding: 7px 9px;
  border: 0;
  border-radius: 6px;
  color: #30343b;
  background: transparent;
  box-shadow: none;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
  text-align: left;
}

.composer .upward-select-menu button:hover,
.composer .upward-select-menu button.selected {
  color: #b72a2a;
  background: #fff1f1;
}

.composer textarea {
  min-height: 50px;
  max-height: min(168px, 24vh);
  padding-right: 14px;
  overflow-y: auto;
  resize: none;
  box-shadow: 0 10px 30px rgba(28, 33, 42, 0.05);
}

.composer button {
  width: 52px;
  height: 52px;
  border-radius: 999px;
  padding: 0;
  font-size: 22px;
  box-shadow: 0 12px 26px rgba(183, 42, 42, 0.2);
}

.composer button.generating {
  opacity: 0.75;
}

.asset-panel {
  height: 100vh;
  display: grid;
  grid-template-rows: auto minmax(0, 0.92fr) minmax(0, 1.08fr);
  gap: 0;
  padding: 20px 18px;
  background: #fff;
  overflow: hidden;
}

.asset-panel > header,
.asset-section-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.asset-panel > header {
  align-items: center;
  min-height: 52px;
}

.asset-panel span,
.asset-section-title span {
  color: #747b88;
  font-size: 12px;
}

.asset-section {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 10px;
  padding: 8px 0 18px;
}

.result-section {
  grid-template-rows: auto minmax(0, 1fr);
  margin-top: 8px;
  padding-top: 22px;
  border-top: 1px solid #e1e5ec;
  box-shadow: inset 0 1px 0 #fff;
}

.asset-uploader {
  display: flex;
  flex-wrap: wrap;
  align-items: start;
  gap: 10px;
  min-height: 132px;
}

.asset-uploader.dragging {
  border-radius: 14px;
  background: rgba(255, 232, 232, 0.46);
}

.asset-file-input {
  position: fixed;
  left: -9999px;
  opacity: 0;
}

.asset-add-tile {
  width: 132px;
  aspect-ratio: 1 / 1;
  border: 2px dashed #d8dde6;
  border-radius: 14px;
  color: #b72a2a;
  background: #fff7f7;
  font-size: 54px;
  font-weight: 800;
}

.asset-add-tile.dragging {
  border-color: #b72a2a;
  background: #ffe8e8;
}

.asset-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  align-content: start;
  gap: 10px;
  overflow: auto;
}

.asset-uploader .asset-grid {
  display: contents;
  overflow: visible;
}

.asset-uploader .asset-grid.empty {
  display: none;
}

.asset-grid.empty {
  display: grid;
  place-items: center;
  min-height: 132px;
  border: 1px dashed #d8dde6;
  border-radius: 10px;
  color: #8a92a0;
  font-size: 13px;
}

.asset-card {
  position: relative;
  width: 150px;
  min-width: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) 32px 32px;
  gap: 7px;
  padding: 7px;
  border: 1px solid #e1e5ec;
  border-radius: 8px;
  background: #fff;
}

.asset-delete {
  position: absolute;
  top: 5px;
  right: 5px;
  z-index: 2;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: rgba(183, 42, 42, 0.92);
  opacity: 0;
}

.asset-card:hover .asset-delete {
  opacity: 1;
}

.asset-thumb {
  width: 100%;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: zoom-in;
}

.asset-thumb img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 8px;
  background: #eef1f6;
}

.asset-rename-input,
.asset-name-button {
  min-width: 0;
  border: 1px solid #d8dde6;
  border-radius: 7px;
  padding: 6px 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.asset-name-button {
  color: #b72a2a;
  background: #fff1f1;
  font-weight: 800;
  text-align: left;
}

.asset-card.result {
  grid-template-rows: auto minmax(0, 1fr) 32px;
}

.image-select {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #4b5563;
  font-size: 15px;
  font-weight: 800;
}

.result-carousel {
  position: relative;
  min-width: 0;
}

.result-generating-overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(255, 250, 250, 0.78);
}

.broken-result-thumb {
  display: grid;
  place-items: center;
  min-height: 134px;
  border-radius: 8px;
  color: #9a3030;
  background: #fff1f1;
  font-size: 12px;
  font-weight: 800;
}

.result-nav {
  position: absolute;
  top: 50%;
  z-index: 3;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 999px;
  padding: 0;
  color: #fff;
  background: #b72a2a;
  transform: translateY(-50%);
}

.result-nav.prev { left: 5px; }
.result-nav.next { right: 5px; }

.image-counter {
  position: absolute;
  right: 7px;
  bottom: 7px;
  border-radius: 999px;
  padding: 3px 7px;
  color: #fff;
  background: rgba(32, 33, 36, 0.68);
  font-size: 11px;
}

.image-download {
  align-self: end;
  justify-self: start;
  width: 48px;
  height: 32px;
  padding: 0;
  font-size: 12px;
}

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

.empty-result {
  min-height: 220px;
  grid-template-rows: auto minmax(0, 1fr) !important;
}

.empty-result-box {
  display: grid;
  place-items: center;
  min-height: 134px;
  border-radius: 8px;
  color: #9aa1ad;
  background: #f3f5f8;
  font-size: 12px;
}

.generating-result {
  border-color: #e5b7b7;
  background: #fffafa;
}

.result-pending {
  width: 112px;
  display: grid;
  gap: 7px;
  justify-items: center;
  color: #b72a2a;
}

.result-pending.failed {
  color: #7d2a2a;
  text-align: center;
}

.result-pending.failed em {
  max-width: 120px;
  max-height: 92px;
  overflow: auto;
  font-style: normal;
  font-size: 11px;
  line-height: 1.4;
}

.failed-overlay {
  background: rgba(255, 241, 241, 0.92);
}

.result-pending.failed button {
  border: 1px solid #efb8b8;
  border-radius: 7px;
  padding: 5px 10px;
  color: #b72a2a;
  background: #fff;
  font-weight: 800;
}

.result-pending span {
  position: relative;
  width: 100%;
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #edd5d5;
}

.result-pending span::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 42%;
  border-radius: inherit;
  background: linear-gradient(90deg, #b72a2a, #e06b6b, #b72a2a);
  animation: pending 1.1s ease-in-out infinite;
}

.image-batch-actions {
  display: grid;
  gap: 5px;
}

.image-batch-actions button {
  padding: 6px 9px;
  font-size: 12px;
}

.image-viewer {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: grid;
  place-items: center;
  padding: 34px;
  background: rgba(16, 18, 24, 0.72);
}

.image-viewer.hidden {
  display: none;
}

.image-viewer img {
  max-width: min(92vw, 1400px);
  max-height: 90vh;
  border-radius: 12px;
  background: #fff;
  object-fit: contain;
}

.image-viewer-stage {
  position: relative;
  display: inline-grid;
  place-items: center;
  max-width: min(92vw, 1400px);
  max-height: 90vh;
}

.image-viewer-close,
.image-viewer-download,
.image-viewer-nav {
  position: absolute;
  z-index: 2;
  border: 0;
  border-radius: 999px;
  color: #202124;
  background: #fff;
  font-weight: 900;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
}

.image-viewer-close {
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  font-size: 20px;
}

.image-viewer-download {
  top: 10px;
  right: 52px;
  padding: 9px 14px;
}

.image-viewer-nav {
  top: 50%;
  width: 38px;
  height: 58px;
  font-size: 30px;
  transform: translateY(-50%);
}

.image-viewer-nav.prev { left: 10px; }
.image-viewer-nav.next { right: 10px; }

body.eye-care-mode {
  color: #e8edf2;
  background: #0f1115;
}

body.eye-care-mode .workspace,
body.eye-care-mode .main-panel {
  background: #0f1115;
}

body.eye-care-mode .conversation-sidebar,
body.eye-care-mode .asset-panel,
body.eye-care-mode .account-menu,
body.eye-care-mode .empty-state,
body.eye-care-mode .bubble,
body.eye-care-mode .image-panel,
body.eye-care-mode .batch-card,
body.eye-care-mode .asset-card {
  border-color: #303642;
  background: #171a20;
}

body.eye-care-mode .topbar {
  border-color: #303642;
  background: rgba(15, 17, 21, 0.96);
}

body.eye-care-mode .batch-panel {
  background: transparent;
}

body.eye-care-mode .composer {
  border-color: rgba(48, 54, 66, 0.9);
  background: linear-gradient(180deg, rgba(15, 17, 21, 0), #0f1115 22%);
}

body.eye-care-mode .storyboard-selector-row label {
  border-color: #343b49;
  color: #9aa4b2;
  background: rgba(16, 19, 24, 0.92);
}

body.eye-care-mode .storyboard-selector-row select {
  color: #e8edf2;
}

body.eye-care-mode .upward-select-menu {
  border-color: #303642;
  background: #151922;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.42);
}

body.eye-care-mode .composer .upward-select-menu button {
  color: #e8edf7;
}

body.eye-care-mode .composer .upward-select-menu button:hover,
body.eye-care-mode .composer .upward-select-menu button.selected {
  color: #ff8b8b;
  background: #2a1f24;
}

body.eye-care-mode .avatar,
body.eye-care-mode .topbar-action,
body.eye-care-mode .eye-care-toggle,
body.eye-care-mode input,
body.eye-care-mode textarea,
body.eye-care-mode select,
body.eye-care-mode .result-module pre,
body.eye-care-mode .asset-rename-input,
body.eye-care-mode .asset-name-button {
  border-color: #343b49;
  color: #e8edf2;
  background: #101318;
}

body.eye-care-mode input::placeholder,
body.eye-care-mode textarea::placeholder {
  color: #737f8e;
}

body.eye-care-mode .storyboard-edit-form textarea {
  border-color: #343b49;
  color: #e8edf2;
  background: #101318;
}

body.eye-care-mode .storyboard-edit-actions span {
  color: #9aa4b2;
}

body.eye-care-mode .storyboard-version-badge {
  border-color: #3a414f;
  color: #aab4c2;
  background: #101318;
}

body.eye-care-mode .storyboard-version-badge.regenerated {
  border-color: rgba(197, 52, 52, 0.55);
  color: #ffb3b3;
  background: rgba(183, 42, 42, 0.16);
}

body.eye-care-mode .conversation-sidebar strong,
body.eye-care-mode .conversation-open strong,
body.eye-care-mode .conversation-title-input,
body.eye-care-mode .image-panel h3,
body.eye-care-mode .asset-panel h2,
body.eye-care-mode .asset-section-title strong,
body.eye-care-mode .empty-state strong,
body.eye-care-mode .message-card h3 {
  color: #f2f5f8;
}

body.eye-care-mode .conversation-sidebar span,
body.eye-care-mode .conversation-open span,
body.eye-care-mode .topbar p,
body.eye-care-mode .asset-panel small,
body.eye-care-mode .asset-section-title span,
body.eye-care-mode .image-panel small,
body.eye-care-mode .image-panel-controls label,
body.eye-care-mode .empty-state p,
body.eye-care-mode .ledger-head span,
body.eye-care-mode .ledger-item small {
  color: #9aa4b2;
}

body.eye-care-mode .conversation-item {
  border-color: #303642;
  background: #14171d;
}

body.eye-care-mode .conversation-item.active {
  border-color: #5a6474;
  background: #20242c;
}

body.eye-care-mode .batch-head span,
body.eye-care-mode .batch-empty {
  color: #9aa4b2;
}

body.eye-care-mode .batch-item {
  border-color: #3b4352;
  color: #dfe6ee;
  background: #20242c;
}

body.eye-care-mode .batch-item.existing,
body.eye-care-mode .batch-item.stopped {
  border-color: #465063;
  color: #d7dee9;
  background: #252a33;
}

body.eye-care-mode .batch-item.done {
  border-color: #385443;
  color: #bfe8c9;
  background: #18251d;
}

body.eye-care-mode .batch-item.running,
body.eye-care-mode .batch-item.error,
body.eye-care-mode .batch-item.stopping {
  border-color: #704145;
  color: #ffc7c7;
  background: #291a1d;
}

body.eye-care-mode .batch-item.paused {
  border-color: #6b5834;
  color: #f1d49a;
  background: #282213;
}

body.eye-care-mode .plain,
body.eye-care-mode .batch-actions button.secondary {
  color: #ffc7c7 !important;
  background: #2a1b1e !important;
}

body.eye-care-mode .batch-actions button.danger {
  color: #b7c0cd !important;
  background: #252a33 !important;
}

body.eye-care-mode .new-conversation-btn {
  color: #f2f5f8;
  background: #252a33;
}

body.eye-care-mode .new-conversation-btn:hover {
  background: #303642;
}

body.eye-care-mode .topbar-action.active {
  border-color: #b72a2a;
  background: #b72a2a;
}

body.eye-care-mode .asset-section,
body.eye-care-mode .asset-add-tile,
body.eye-care-mode .asset-grid.empty,
body.eye-care-mode .empty-result-box,
body.eye-care-mode .selected-ref,
body.eye-care-mode .ledger-panel,
body.eye-care-mode .ledger-dialog,
body.eye-care-mode .ledger-item,
body.eye-care-mode .ledger-empty {
  border-color: #303642;
  background: #12151b;
}

body.eye-care-mode .ledger-modal {
  background: rgba(0, 0, 0, 0.62);
}

body.eye-care-mode .ledger-dialog {
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
}

body.eye-care-mode .ledger-dialog-head {
  border-color: #303642;
}

body.eye-care-mode .ledger-dialog-head strong,
body.eye-care-mode .ledger-item strong {
  color: #f2f5f8;
}

body.eye-care-mode .ledger-dialog-actions button,
body.eye-care-mode .ledger-tabs button {
  border-color: #303642;
  color: #dfe6ee;
  background: #181c23;
}

body.eye-care-mode .ledger-dialog-actions button:hover,
body.eye-care-mode .ledger-tabs button:hover {
  border-color: #485163;
  background: #20242c;
}

body.eye-care-mode .ledger-tabs button.active {
  border-color: #8b4cff;
  color: #fff;
  background: #6d33d8;
}

body.eye-care-mode .generating-result {
  border-color: #60423f;
  background: #211819;
}

body.eye-care-mode .empty-result-box,
body.eye-care-mode .asset-grid.empty {
  color: #858f9f;
}

body.eye-care-mode .asset-name-button {
  color: #ffb4b4;
}

body.eye-care-mode .broken-result-thumb,
body.eye-care-mode .failed-overlay {
  background: #211819;
}

body.eye-care-mode .result-pending span {
  background: #3b2930;
}

body.eye-care-mode .result-pending.failed button {
  background: #171a20;
}

body.eye-care-mode .image-viewer-close,
body.eye-care-mode .image-viewer-download,
body.eye-care-mode .image-viewer-nav {
  color: #f2f5f8;
  background: #171a20;
}

body.eye-care-mode * {
  scrollbar-color: #5c6575 #11151b;
}

body.eye-care-mode *::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

body.eye-care-mode *::-webkit-scrollbar-track {
  background: #11151b;
}

body.eye-care-mode *::-webkit-scrollbar-thumb {
  border: 2px solid #11151b;
  border-radius: 999px;
  background: #5c6575;
}

body.eye-care-mode *::-webkit-scrollbar-thumb:hover {
  background: #727d90;
}

@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .asset-panel {
    height: auto;
    min-height: 70vh;
  }
}

@media (max-width: 700px) {
  .batch-panel {
    left: 12px;
    right: 12px;
  }

  .batch-head {
    grid-template-columns: 1fr;
  }

  .batch-actions {
    justify-content: flex-start;
    max-width: 100%;
  }

  .composer {
    grid-template-columns: minmax(0, 1fr) 50px;
    gap: 10px;
    padding: 12px 12px 16px;
  }

  .storyboard-selector-row label {
    flex: 1 1 150px;
  }

  .storyboard-selector-row select {
    width: 100%;
    min-width: 0;
  }

  .composer .upward-select-button {
    width: 100%;
    min-width: 0;
  }

  .ledger-modal {
    align-items: stretch;
    padding: 10px;
  }

  .ledger-dialog {
    max-height: calc(100vh - 20px);
    padding: 12px;
  }

  .ledger-dialog-head {
    align-items: stretch;
    flex-direction: column;
  }

  .ledger-dialog-actions {
    justify-content: flex-end;
  }

  .ledger-tabs {
    gap: 6px;
  }

  .ledger-tabs button {
    padding: 7px 9px;
    font-size: 12px;
  }

  .ledger-item {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .ledger-amount {
    text-align: left;
  }

  .image-viewer {
    padding: 16px;
  }

  .image-viewer-close {
    top: 8px;
    right: 8px;
    width: 30px;
    height: 30px;
    font-size: 18px;
  }

  .image-viewer-download {
    top: 8px;
    right: 44px;
    padding: 7px 11px;
    font-size: 12px;
  }

  .image-viewer-nav {
    width: 32px;
    height: 48px;
    font-size: 24px;
  }
}
