.open-tuna-page {
  --ot-bg-card: rgba(248, 251, 255, 0.9);
  --ot-bg-card-strong: rgba(255, 255, 255, 0.94);
  --ot-bg-soft: rgba(239, 245, 252, 0.78);
  --ot-border: rgba(44, 103, 161, 0.18);
  --ot-border-strong: rgba(44, 103, 161, 0.3);
  --ot-text-primary: #1f2b3a;
  --ot-text-secondary: #516179;
  --ot-accent: #2c80c8;
  --ot-accent-soft: rgba(44, 128, 200, 0.14);
  --ot-shadow: 0 14px 36px rgba(30, 70, 120, 0.12);
}

.open-tuna-nav-brand {
  gap: 0.9rem;
}

.open-tuna-nav-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.open-tuna-mark {
  height: 2.2rem;
  width: auto;
  object-fit: contain;
}

.open-tuna-page {
  min-height: 100vh;
  padding-top: 120px;
}

.open-tuna-footer-logos {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}

.open-tuna-footer-mark {
  height: 2.5rem;
  width: auto;
  object-fit: contain;
}

.open-tuna-shell {
  width: 100%;
  max-width: min(1180px, 100%);
  margin: 0 auto;
  padding: 0;
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 18px;
}

.open-tuna-history-card {
  position: relative;
  background: var(--ot-bg-card-strong);
  border: 1px solid var(--ot-border);
  border-radius: 24px;
  box-shadow: var(--ot-shadow);
  min-height: 620px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.open-tuna-agent-card {
  border-bottom: 1px solid var(--ot-border);
  padding: 0.9rem 0.85rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  background: rgba(255, 255, 255, 0.35);
}

.open-tuna-files-card {
  border-top: 1px solid var(--ot-border);
  padding: 0.9rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  background: rgba(255, 255, 255, 0.22);
}

.open-tuna-files-meta,
.open-tuna-files-feedback,
.open-tuna-files-empty {
  font-size: 0.8rem;
  color: var(--ot-text-secondary);
}

.open-tuna-agent-feedback,
.open-tuna-files-feedback,
.open-tuna-files-list-feedback,
.open-tuna-voice-status {
  min-height: 1.25rem;
  border-radius: 10px;
  color: var(--ot-text-secondary);
}

.open-tuna-agent-feedback:not(:empty),
.open-tuna-files-feedback:not(:empty),
.open-tuna-files-list-feedback:not(:empty),
.open-tuna-voice-status:not(:empty) {
  padding: 0.45rem 0.6rem;
}

.open-tuna-agent-feedback.is-loading:not(:empty),
.open-tuna-files-feedback.is-loading:not(:empty),
.open-tuna-files-list-feedback.is-loading:not(:empty),
.open-tuna-voice-status.is-loading:not(:empty) {
  color: #43617f;
  background: rgba(44, 128, 200, 0.08);
  border-color: rgba(44, 128, 200, 0.16);
}

.open-tuna-agent-feedback.is-success:not(:empty),
.open-tuna-files-feedback.is-success:not(:empty),
.open-tuna-files-list-feedback.is-success:not(:empty),
.open-tuna-voice-status.is-success:not(:empty) {
  color: #23684d;
  background: rgba(77, 169, 132, 0.12);
  border-color: rgba(77, 169, 132, 0.22);
}

.open-tuna-agent-feedback.is-error:not(:empty),
.open-tuna-files-feedback.is-error:not(:empty),
.open-tuna-files-list-feedback.is-error:not(:empty),
.open-tuna-voice-status.is-error:not(:empty) {
  color: #b94b63;
  background: rgba(255, 89, 89, 0.08);
  border-color: rgba(255, 110, 110, 0.2);
}

.open-tuna-files-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  color: var(--ot-text-secondary);
}

.open-tuna-files-crumb-btn {
  border: none;
  padding: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-decoration: underline;
}

.open-tuna-files-crumb-sep {
  opacity: 0.7;
}

.open-tuna-files-feedback.is-error {
  color: #ff8b8b;
}

.open-tuna-files-nav-btn,
.open-tuna-files-refresh {
  padding: 6px 10px;
  font-size: 0.8rem;
}

.open-tuna-files-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  max-height: 180px;
  overflow-y: auto;
}

.open-tuna-files-item {
  border: 1px solid var(--ot-border);
  background: var(--ot-bg-card-strong);
  border-radius: 10px;
  padding: 0.45rem 0.55rem;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.open-tuna-files-item.is-highlight {
  border-color: var(--ot-accent);
  box-shadow: 0 0 0 2px var(--ot-accent-soft);
  animation: open-tuna-highlight-fade 3s ease-out forwards;
}

@keyframes open-tuna-highlight-fade {
  0% {
    border-color: var(--ot-accent);
    box-shadow: 0 0 0 2px var(--ot-accent-soft);
  }
  80% {
    border-color: var(--ot-accent);
    box-shadow: 0 0 0 1px var(--ot-accent-soft);
  }
  100% {
    border-color: var(--ot-border);
    box-shadow: none;
  }
}

.open-tuna-files-item-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.open-tuna-files-item-name {
  color: var(--ot-text-primary);
  font-size: 0.84rem;
  font-weight: 600;
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.open-tuna-files-item-meta {
  color: var(--ot-text-secondary);
  font-size: 0.74rem;
}

.open-tuna-files-item-actions {
  display: inline-flex;
  gap: 0.35rem;
}

.open-tuna-files-item-btn {
  padding: 5px 9px;
  border-radius: 999px;
  border: 1px solid var(--ot-border);
  background: transparent;
  color: var(--ot-text-secondary);
  font-size: 0.76rem;
  cursor: pointer;
}

.open-tuna-files-upload-form {
  display: grid;
  gap: 0.45rem;
  margin-top: 0.2rem;
}

.open-tuna-files-upload-form h5 {
  margin: 0.1rem 0;
  color: var(--ot-text-primary);
  font-size: 0.82rem;
}

.open-tuna-files-upload-content {
  resize: vertical;
  min-height: 80px;
}

.open-tuna-files-upload-btn {
  justify-self: end;
  padding: 8px 14px;
  font-size: 0.84rem;
}

.open-tuna-agent-card[hidden] {
  display: none !important;
}

.open-tuna-agent-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.open-tuna-agent-header h4 {
  margin: 0;
  font-size: 0.9rem;
  color: var(--ot-text-primary);
}

.open-tuna-agent-refresh {
  padding: 6px 12px;
  font-size: 0.82rem;
}

.open-tuna-agent-form {
  display: grid;
  gap: 0.5rem;
}

.open-tuna-agent-input {
  border: 1px solid var(--ot-border);
  border-radius: 10px;
  background: var(--ot-bg-card-strong);
  color: var(--ot-text-primary);
  padding: 0.48rem 0.6rem;
  font-size: 0.84rem;
}

.open-tuna-agent-input:focus {
  outline: none;
  border-color: var(--ot-accent);
  box-shadow: 0 0 0 3px var(--ot-accent-soft);
}

.open-tuna-agent-submit {
  justify-self: end;
  padding: 8px 14px;
  font-size: 0.85rem;
}

.open-tuna-agent-feedback,
.open-tuna-agent-empty {
  font-size: 0.8rem;
  color: var(--ot-text-secondary);
}

.open-tuna-agent-purge-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--ot-text-secondary);
  font-size: 0.78rem;
  -webkit-user-select: none;
  user-select: none;
}

.open-tuna-agent-purge-toggle input {
  margin: 0;
}


.open-tuna-agent-list {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  max-height: 170px;
  overflow-y: auto;
}

.open-tuna-agent-item {
  border: 1px solid var(--ot-border);
  background: var(--ot-bg-card-strong);
  border-radius: 10px;
  padding: 0.5rem 0.55rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.open-tuna-agent-item-meta {
  min-width: 0;
}

.open-tuna-agent-name {
  font-size: 0.84rem;
  color: var(--ot-text-primary);
  font-weight: 600;
}

.open-tuna-agent-type {
  margin-top: 2px;
  font-size: 0.75rem;
  color: var(--ot-text-secondary);
}

.open-tuna-agent-delete {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--ot-border);
  background: transparent;
  color: #d66;
  cursor: pointer;
  flex-shrink: 0;
}

.open-tuna-agent-delete:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.open-tuna-history-header {
  padding: 1rem 1rem 0.85rem;
  border-bottom: 1px solid var(--ot-border);
}

.open-tuna-history-header h3 {
  margin: 0;
  color: var(--ot-text-primary);
  font-size: 0.96rem;
  font-weight: 600;
}

.open-tuna-history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0.9rem 0.8rem 0.8rem;
  overflow-y: auto;
}

.open-tuna-history-row {
  display: flex;
  align-items: stretch;
  gap: 6px;
}

.open-tuna-history-empty {
  padding: 0.8rem 1rem 1rem;
  font-size: 0.88rem;
  color: var(--ot-text-secondary);
}

.open-tuna-history-item {
  flex: 1 1 auto;
  min-width: 0;
  display: block;
  text-align: left;
  border: 1px solid var(--ot-border);
  background: var(--ot-bg-card-strong);
  color: var(--ot-text-primary);
  border-radius: 12px;
  padding: 0.65rem 0.75rem;
  font-size: 0.86rem;
  line-height: 1.35;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.open-tuna-history-item:hover {
  border-color: var(--ot-border-strong);
  background: #eef6ff;
  transform: translateY(-1px);
}

.open-tuna-history-item.is-active {
  border-color: var(--ot-accent);
  background: #e8f3ff;
}

.open-tuna-history-delete {
  flex: 0 0 44px;
  width: 44px;
  min-width: 44px;
  border: 1px solid var(--ot-border);
  border-radius: 10px;
  background: #ffffff;
  color: #6b7c93;
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
  font-weight: 600;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.open-tuna-history-delete:hover {
  background: rgba(255, 89, 89, 0.18);
  border-color: rgba(255, 110, 110, 0.52);
  color: #ffd6d6;
}

.open-tuna-history-delete.is-confirm {
  background: rgba(255, 89, 89, 0.25);
  border-color: rgba(255, 110, 110, 0.72);
  color: #ffe6e6;
}

.open-tuna-chat-card {
  position: relative;
  background: var(--ot-bg-card-strong);
  border: 1px solid var(--ot-border);
  border-radius: 24px;
  box-shadow: var(--ot-shadow);
}

.open-tuna-header-status-row {
  position: relative;
  z-index: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.open-tuna-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
}

.open-tuna-btn.secondary.open-tuna-stop-workflow-btn {
  pointer-events: auto;
  border: 1px solid rgba(237, 143, 176, 0.42);
  background: rgba(255, 232, 240, 0.96);
  color: #b84b75;
  box-shadow: 0 8px 18px rgba(234, 157, 184, 0.14);
}

.open-tuna-btn.secondary.open-tuna-stop-workflow-btn:hover {
  border-color: rgba(227, 118, 159, 0.52);
  background: rgba(255, 223, 234, 0.98);
  color: #a83f68;
  transform: translateY(-1px);
}

.open-tuna-btn.secondary.open-tuna-stop-workflow-btn:disabled,
.open-tuna-btn.secondary.open-tuna-stop-workflow-btn[aria-disabled='true'] {
  border-color: rgba(237, 143, 176, 0.26);
  background: rgba(255, 240, 245, 0.9);
  color: rgba(184, 75, 117, 0.62);
  box-shadow: none;
  transform: none;
}

.open-tuna-header-status {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 1rem;
}

.status-label {
  color: var(--ot-text-secondary);
  font-size: 0.95rem;
  font-weight: 600;
}

.status-dot {
  width: 12px;
  height: 12px;
  min-width: 12px;
  min-height: 12px;
  flex: 0 0 12px;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 0 3px rgba(44, 103, 161, 0.12);
}

.status-dot.online {
  background: #44f0a1;
  box-shadow: 0 0 12px rgba(68, 240, 161, 0.7);
}

.status-dot.checking {
  background: #ffd166;
  box-shadow: 0 0 12px rgba(255, 209, 102, 0.7);
}

.status-dot.offline {
  background: #ff8e8e;
  box-shadow: 0 0 12px rgba(255, 142, 142, 0.7);
}

.open-tuna-chat-card {
  display: flex;
  flex-direction: column;
  min-height: 620px;
  overflow: hidden;
}

/* 在输入框上方（composer 内第一项；隐藏时不占位） */
.open-tuna-receiving-leave-banner {
  flex-shrink: 0;
  width: 100%;
  box-sizing: border-box;
  margin: 0 0 0.65rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.82rem;
  line-height: 1.45;
  color: #2d4a3e;
  background: linear-gradient(135deg, rgba(210, 245, 220, 0.92), rgba(185, 235, 200, 0.65));
  border: 1px solid rgba(76, 175, 120, 0.35);
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(45, 90, 65, 0.06);
}

.open-tuna-receiving-leave-banner[hidden] {
  display: none !important;
}

.open-tuna-page[data-theme='dark'] .open-tuna-receiving-leave-banner {
  color: rgba(210, 235, 218, 0.92);
  background: linear-gradient(135deg, rgba(45, 95, 72, 0.55), rgba(35, 75, 58, 0.42));
  border-color: rgba(100, 190, 140, 0.35);
}

 .open-tuna-page-jump {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right, 0px) + 0.7rem);
  bottom: max(1rem, env(safe-area-inset-bottom, 0px) + 0.7rem);
  z-index: 70;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.open-tuna-page-jump-btn {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(125, 180, 235, 0.32);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.96);
  color: #6eaee8;
  font-size: 1rem;
  font-weight: 800;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.1);
}

.open-tuna-page-jump-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(96, 165, 250, 0.56);
  color: #60a5fa;
}

.open-tuna-chat-header {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.8rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--ot-border);
  background: rgba(255, 255, 255, 0.92);
}

.open-tuna-identity-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
  flex-wrap: wrap;
  justify-content: space-between;
}

.open-tuna-workflow-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
  flex-wrap: wrap;
}

.open-tuna-workflow-controls .open-tuna-stop-workflow-btn,
.open-tuna-workflow-controls .open-tuna-resume-workflow-btn {
  width: auto;
  order: 0;
  margin-bottom: 0;
}

.open-tuna-btn.secondary.open-tuna-resume-workflow-btn {
  border: 1px solid rgba(110, 164, 220, 0.34);
  background: rgba(232, 242, 255, 0.96);
  color: #3d6f9f;
  box-shadow: 0 8px 18px rgba(122, 170, 223, 0.12);
}

.open-tuna-btn.secondary.open-tuna-resume-workflow-btn:hover {
  border-color: rgba(88, 147, 211, 0.46);
  background: rgba(222, 236, 255, 0.98);
  color: #2f618f;
  transform: translateY(-1px);
}

.open-tuna-btn.secondary.open-tuna-resume-workflow-btn:disabled,
.open-tuna-btn.secondary.open-tuna-resume-workflow-btn[aria-disabled='true'] {
  border-color: rgba(110, 164, 220, 0.2);
  background: rgba(238, 245, 255, 0.9);
  color: rgba(61, 111, 159, 0.62);
  box-shadow: none;
  transform: none;
}

.open-tuna-workflow-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.4rem 0.48rem 0.4rem 0.88rem;
  border: 1px solid rgba(44, 128, 200, 0.16);
  border-radius: 999px;
  background: rgba(236, 245, 255, 0.96);
  color: #35638f;
  font-size: 0.88rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.open-tuna-workflow-toggle:hover {
  border-color: rgba(44, 128, 200, 0.28);
  box-shadow: 0 8px 18px rgba(44, 128, 200, 0.12);
}

.open-tuna-workflow-toggle-label {
  white-space: nowrap;
}

.open-tuna-workflow-toggle-switch {
  position: relative;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: linear-gradient(180deg, #d8e6f3, #bfd2e6);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
  transition: background 0.2s ease;
}

.open-tuna-workflow-toggle-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 2px 6px rgba(25, 73, 117, 0.18);
  transition: left 0.2s ease, right 0.2s ease, transform 0.2s ease;
}

.open-tuna-workflow-toggle[data-enabled='1'] {
  border-color: rgba(44, 128, 200, 0.24);
  background: rgba(236, 245, 255, 0.98);
  color: #2f638f;
}

.open-tuna-workflow-toggle[data-enabled='1'] .open-tuna-workflow-toggle-switch {
  background: linear-gradient(180deg, #5fb3f3, #2c80c8);
}

.open-tuna-workflow-toggle[data-enabled='1'] .open-tuna-workflow-toggle-knob {
  left: 21px;
}

.open-tuna-readonly-badge {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 0.5rem 0.78rem;
  border-radius: 999px;
  border: 1px solid rgba(208, 124, 54, 0.28);
  background: rgba(255, 243, 227, 0.92);
  color: #9a541e;
  font-size: 0.78rem;
  line-height: 1.2;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.open-tuna-identity-item {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--ot-border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
}

.open-tuna-identity-item--primary {
  flex: 1 1 auto;
}

.open-tuna-identity-label {
  font-size: 0.74rem;
  color: var(--ot-text-secondary);
  white-space: nowrap;
}

.open-tuna-identity-sep {
  color: rgba(81, 97, 121, 0.72);
  flex: 0 0 auto;
}

.open-tuna-identity-value {
  font-size: 0.88rem;
  line-height: 1.25;
  color: var(--ot-text-primary);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.open-tuna-identity-bar[data-main-user='1'] .open-tuna-identity-item,
.open-tuna-identity-bar[data-username='main'] .open-tuna-identity-item {
  border-color: rgba(201, 168, 74, 0.32);
  background: linear-gradient(180deg, rgba(255, 248, 224, 0.97), rgba(255, 252, 242, 0.94));
}

.open-tuna-identity-bar[data-role='Creator']:not([data-username='main']) .open-tuna-identity-item {
  border-color: rgba(162, 126, 223, 0.24);
  background: linear-gradient(180deg, rgba(247, 242, 255, 0.96), rgba(252, 248, 255, 0.94));
}

.open-tuna-identity-bar[data-role='SuperMax']:not([data-username='main']) .open-tuna-identity-item {
  border-color: rgba(148, 212, 206, 0.34);
  background: linear-gradient(180deg, rgba(234, 249, 247, 0.98), rgba(242, 252, 250, 0.96));
}

.open-tuna-chat-log {
  position: relative;
  flex: 1;
  padding: 1.4rem 1.25rem;
  overflow-y: auto;
  background: var(--ot-bg-soft);
}

.open-tuna-message + .open-tuna-message {
  margin-top: 18px;
}

.open-tuna-message.user {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.open-tuna-message.assistant {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: fit-content;
  max-width: 100%;
}

.message-meta {
  margin-bottom: 6px;
  color: #607089;
  font-size: 0.76rem;
  line-height: 1.2;
}

.open-tuna-message.assistant .message-meta {
  margin-bottom: 8px;
}

.message-time-bottom {
  margin-top: 6px;
  align-self: center;
  text-align: center;
  color: #607089;
  font-size: 0.76rem;
  line-height: 1.2;
}

.message-bubble {
  position: relative;
  max-width: min(76ch, 100%);
  padding: 0.95rem 1.1rem;
  border-radius: 20px;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.65;
  font-size: 0.98rem;
}

.message-bubble.is-streaming {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35em;
}

.message-bubble.is-streaming:has(.open-tuna-pending-dots.only-dots) {
  min-width: 72px;
  min-height: 48px;
  justify-content: center;
}

.message-bubble.is-streaming .message-bubble-text {
  min-width: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.open-tuna-message.assistant .message-bubble {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--ot-border);
  color: var(--ot-text-primary);
}

.open-tuna-message.assistant.workflow-assistant .message-bubble {
  background: rgba(248, 250, 253, 0.98);
  border: 1px solid rgba(206, 219, 232, 0.72);
  border-left: 4px solid #4e8fd8;
  border-radius: 22px;
  color: #21364d;
  box-shadow: 0 4px 12px rgba(61, 103, 150, 0.06);
}

.open-tuna-message.assistant[data-status='pending'] .message-bubble,
.open-tuna-message.assistant[data-status='submitting'] .message-bubble {
  border-color: rgba(61, 138, 214, 0.3);
  box-shadow: 0 0 0 3px rgba(61, 138, 214, 0.08);
}

.open-tuna-message.assistant.workflow-assistant[data-status='pending'] .message-bubble,
.open-tuna-message.assistant.workflow-assistant[data-status='submitting'] .message-bubble {
  border-color: rgba(116, 164, 221, 0.52);
  border-left-color: #4e8fd8;
  box-shadow: 0 0 0 3px rgba(78, 143, 216, 0.08);
}

.open-tuna-message.assistant[data-status='failed'] .message-bubble {
  border-color: rgba(214, 85, 85, 0.32);
  background: rgba(255, 246, 246, 0.98);
  box-shadow: 0 0 0 3px rgba(214, 85, 85, 0.08);
}

.message-actions {
  margin-top: 8px;
  display: flex;
  justify-content: center;
}

.open-tuna-message-retry {
  appearance: none;
  border: 1px solid rgba(61, 138, 214, 0.22);
  background: rgba(61, 138, 214, 0.08);
  color: #1f5f9f;
  border-radius: 999px;
  padding: 0.32rem 0.78rem;
  font-size: 0.78rem;
  line-height: 1.2;
  cursor: pointer;
  transition: background-color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.open-tuna-message-retry:hover:not(:disabled) {
  background: rgba(61, 138, 214, 0.14);
  border-color: rgba(61, 138, 214, 0.34);
  transform: translateY(-1px);
}

.open-tuna-message-retry:disabled {
  opacity: 0.52;
  cursor: not-allowed;
}

.open-tuna-message.user .message-bubble {
  background: #dcebfa;
  border: 1px solid rgba(44, 128, 200, 0.28);
  color: #1c334d;
  box-shadow: 0 6px 14px rgba(35, 100, 160, 0.08);
}

.workflow-qwen-message .workflow-qwen-bubble {
  position: relative;
  max-width: min(72ch, 100%);
  padding: 0.88rem 1rem;
  padding-right: 1.06rem;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.96) !important;
  border: 1px solid rgba(206, 219, 232, 0.72);
  color: #21364d;
  box-shadow: 0 4px 12px rgba(61, 103, 150, 0.05);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.62;
  font-size: 0.98rem;
  overflow: hidden;
}

.workflow-qwen-message .workflow-qwen-bubble::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 4px;
  height: 100%;
  background: #9a77d9;
}

.workflow-qwen-reasoning {
  margin-bottom: 0.7rem;
  padding: 0.56rem 0.72rem;
  background: rgba(154, 119, 217, 0.045);
  border: 1px solid rgba(154, 119, 217, 0.14);
  border-radius: 12px;
}

.workflow-qwen-reasoning-label {
  color: rgba(112, 72, 176, 0.78);
  font-weight: 600;
  margin-bottom: 0.3rem;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.35px;
}

.workflow-qwen-reasoning-text,
.workflow-qwen-answer {
  white-space: pre-wrap;
  word-break: break-word;
}

.workflow-qwen-reasoning-text {
  color: rgba(33, 54, 77, 0.84);
  font-size: 0.9rem;
  line-height: 1.55;
}

.workflow-qwen-answer {
  background: transparent;
  color: #21364d;
}

.workflow-qwen-bubble.is-streaming .workflow-qwen-answer::after {
  content: '▋';
  color: #8a68ca;
  animation: blink 1s infinite;
}

.open-tuna-page[data-theme='dark'] .workflow-qwen-message .workflow-qwen-bubble {
  background: rgba(22, 31, 44, 0.94) !important;
  border-color: rgba(108, 126, 160, 0.34);
  color: #e7efff;
  box-shadow: 0 10px 24px rgba(7, 16, 30, 0.24);
}

.open-tuna-page[data-theme='dark'] .workflow-qwen-message .workflow-qwen-bubble::after {
  background: #a785e5;
}

.open-tuna-page[data-theme='dark'] .workflow-qwen-reasoning {
  background: rgba(154, 119, 217, 0.10);
  border-color: rgba(154, 119, 217, 0.24);
}

.open-tuna-page[data-theme='dark'] .workflow-qwen-reasoning-label {
  color: rgba(204, 183, 245, 0.92);
}

.open-tuna-page[data-theme='dark'] .workflow-qwen-reasoning-text {
  color: rgba(220, 229, 246, 0.82);
}

.open-tuna-page[data-theme='dark'] .workflow-qwen-answer {
  color: #edf4ff;
}

.open-tuna-page[data-theme='dark'] .workflow-qwen-bubble.is-streaming .workflow-qwen-answer::after {
  color: #b694f1;
}

.open-tuna-composer {
  position: relative;
  padding: 1rem 1.25rem 1.2rem;
  border-top: 1px solid var(--ot-border);
  background: rgba(255, 255, 255, 0.92);
}

.open-tuna-input {
  width: 100%;
  resize: none;
  min-height: 88px;
  padding: 1rem 1.1rem;
  border-radius: 18px;
  border: 1px solid var(--ot-border-strong);
  background: #fff;
  color: var(--ot-text-primary);
  font: inherit;
  box-shadow: 0 4px 12px rgba(30, 80, 140, 0.06);
}

.open-tuna-input:focus {
  outline: none;
  border-color: var(--ot-accent);
  box-shadow: 0 0 0 3px var(--ot-accent-soft);
}

.open-tuna-composer[data-readonly='1'] {
  background: rgba(255, 255, 255, 0.92);
}

.open-tuna-composer[data-readonly='1'] .open-tuna-input {
  background: rgba(255, 255, 255, 0.96);
  border-color: var(--ot-border);
  color: var(--ot-text-secondary);
  box-shadow: none;
}

.open-tuna-composer[data-readonly='1'] .composer-actions {
  opacity: 0.9;
}

.open-tuna-voice-status {
  min-height: 1.25rem;
  margin-top: 0.7rem;
  color: var(--ot-text-secondary);
  font-size: 0.875rem;
  line-height: 1.4;
}


.composer-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  margin-top: 0.9rem;
}

.open-tuna-btn {
  border: none;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.open-tuna-btn:hover {
  transform: translateY(-1px);
}

.open-tuna-btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
  transform: none;
}

.open-tuna-btn.primary {
  color: #fff;
  background: linear-gradient(135deg, #49a1e2, #2c80c8);
  box-shadow: 0 10px 24px rgba(44, 128, 200, 0.28);
}

.open-tuna-btn.voice {
  width: 44px;
  height: 44px;
  padding: 0;
  color: #47627f;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--ot-border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.open-tuna-btn.voice:hover {
  border-color: var(--ot-accent);
  box-shadow: 0 8px 20px rgba(44, 128, 200, 0.18);
}

.open-tuna-btn.voice.is-recording {
  color: #fff;
  background: linear-gradient(135deg, #ff7a59, #ff3d71);
  border-color: transparent;
  box-shadow: 0 0 0 4px rgba(255, 61, 113, 0.18), 0 12px 30px rgba(255, 61, 113, 0.3);
}

.open-tuna-btn.secondary {
  color: #47627f;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--ot-border);
}

#openTunaClearBtn {
  position: relative;
  z-index: 1;
  flex-shrink: 0;
}

#openTunaThemeBtn {
  position: relative;
  z-index: 1;
  flex-shrink: 0;
}

.open-tuna-page[data-theme='dark'] {
  --ot-bg-card: rgba(10, 16, 28, 0.72);
  --ot-bg-card-strong: rgba(255, 255, 255, 0.04);
  --ot-bg-soft: rgba(7, 12, 22, 0.42);
  --ot-border: rgba(255, 255, 255, 0.1);
  --ot-border-strong: rgba(0, 212, 255, 0.4);
  --ot-text-primary: #e9f2ff;
  --ot-text-secondary: rgba(215, 231, 255, 0.75);
  --ot-accent: #00d4ff;
  --ot-accent-soft: rgba(0, 212, 255, 0.08);
  --ot-shadow: 0 18px 48px rgba(0, 0, 0, 0.32), 0 0 56px rgba(0, 212, 255, 0.12);
}

.open-tuna-page[data-theme='dark'] .open-tuna-history-item:hover {
  background: rgba(0, 212, 255, 0.1);
}

.open-tuna-page[data-theme='dark'] .open-tuna-identity-item {
  border-color: rgba(117, 140, 171, 0.34);
  background: rgba(22, 31, 44, 0.92);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.open-tuna-page[data-theme='dark'] .open-tuna-readonly-badge {
  border-color: rgba(255, 183, 94, 0.26);
  background: rgba(94, 58, 14, 0.88);
  color: #ffd89a;
}

.open-tuna-page[data-theme='dark'] .open-tuna-btn.secondary.open-tuna-stop-workflow-btn {
  border-color: rgba(223, 130, 165, 0.34);
  background: rgba(92, 38, 59, 0.9);
  color: #ffd5e3;
  box-shadow: 0 10px 22px rgba(77, 24, 46, 0.28);
}

.open-tuna-page[data-theme='dark'] .open-tuna-btn.secondary.open-tuna-stop-workflow-btn:hover {
  border-color: rgba(238, 154, 185, 0.44);
  background: rgba(108, 45, 69, 0.94);
  color: #ffe4ee;
}

.open-tuna-page[data-theme='dark'] .open-tuna-btn.secondary.open-tuna-stop-workflow-btn:disabled,
.open-tuna-page[data-theme='dark'] .open-tuna-btn.secondary.open-tuna-stop-workflow-btn[aria-disabled='true'] {
  border-color: rgba(223, 130, 165, 0.22);
  background: rgba(74, 36, 51, 0.82);
  color: rgba(255, 213, 227, 0.62);
  box-shadow: none;
}

.open-tuna-page[data-theme='dark'] .open-tuna-btn.secondary.open-tuna-resume-workflow-btn {
  border-color: rgba(119, 172, 231, 0.34);
  background: rgba(35, 56, 86, 0.9);
  color: #dbeaff;
  box-shadow: 0 10px 22px rgba(22, 40, 69, 0.28);
}

.open-tuna-page[data-theme='dark'] .open-tuna-btn.secondary.open-tuna-resume-workflow-btn:hover {
  border-color: rgba(142, 192, 245, 0.46);
  background: rgba(41, 67, 102, 0.94);
  color: #edf5ff;
}

.open-tuna-page[data-theme='dark'] .open-tuna-btn.secondary.open-tuna-resume-workflow-btn:disabled,
.open-tuna-page[data-theme='dark'] .open-tuna-btn.secondary.open-tuna-resume-workflow-btn[aria-disabled='true'] {
  border-color: rgba(119, 172, 231, 0.22);
  background: rgba(32, 49, 73, 0.82);
  color: rgba(219, 234, 255, 0.62);
  box-shadow: none;
}

.open-tuna-page[data-theme='dark'] .open-tuna-workflow-toggle {
  border-color: rgba(107, 166, 217, 0.24);
  background: rgba(23, 42, 64, 0.92);
  color: #d7e9fb;
}

.open-tuna-page[data-theme='dark'] .open-tuna-workflow-toggle:hover {
  border-color: rgba(122, 185, 238, 0.32);
  box-shadow: 0 10px 22px rgba(16, 44, 76, 0.28);
}

.open-tuna-page[data-theme='dark'] .open-tuna-workflow-toggle-switch {
  background: linear-gradient(180deg, #425a74, #34485f);
}

.open-tuna-page[data-theme='dark'] .open-tuna-workflow-toggle-knob {
  background: #f8fbff;
}

.open-tuna-page[data-theme='dark'] .open-tuna-workflow-toggle[data-enabled='1'] {
  border-color: rgba(122, 185, 238, 0.32);
  background: rgba(23, 42, 64, 0.96);
  color: #e3f0fd;
}

.open-tuna-page[data-theme='dark'] .open-tuna-workflow-toggle[data-enabled='1'] .open-tuna-workflow-toggle-switch {
  background: linear-gradient(180deg, #5aaaf0, #2c80c8);
}

.open-tuna-page[data-theme='dark'] .open-tuna-identity-label {
  color: rgba(191, 210, 231, 0.78);
}

.open-tuna-page[data-theme='dark'] .open-tuna-identity-value,
.open-tuna-page[data-theme='dark'] .open-tuna-identity-sep {
  color: rgba(244, 248, 255, 0.96);
}

.open-tuna-page[data-theme='dark'] .open-tuna-identity-bar[data-main-user='1'] .open-tuna-identity-item,
.open-tuna-page[data-theme='dark'] .open-tuna-identity-bar[data-username='main'] .open-tuna-identity-item {
  border-color: rgba(214, 183, 94, 0.4);
  background: linear-gradient(180deg, rgba(92, 72, 18, 0.92), rgba(70, 54, 12, 0.88));
  box-shadow: inset 0 1px 0 rgba(255, 238, 186, 0.08);
}

.open-tuna-page[data-theme='dark'] .open-tuna-identity-bar[data-main-user='1'] .open-tuna-identity-label,
.open-tuna-page[data-theme='dark'] .open-tuna-identity-bar[data-username='main'] .open-tuna-identity-label {
  color: rgba(255, 230, 160, 0.82);
}

.open-tuna-page[data-theme='dark'] .open-tuna-identity-bar[data-main-user='1'] .open-tuna-identity-value,
.open-tuna-page[data-theme='dark'] .open-tuna-identity-bar[data-main-user='1'] .open-tuna-identity-sep,
.open-tuna-page[data-theme='dark'] .open-tuna-identity-bar[data-username='main'] .open-tuna-identity-value,
.open-tuna-page[data-theme='dark'] .open-tuna-identity-bar[data-username='main'] .open-tuna-identity-sep {
  color: #fff1bf;
}

.open-tuna-page[data-theme='dark'] .open-tuna-identity-bar[data-role='Creator']:not([data-username='main']) .open-tuna-identity-item {
  border-color: rgba(162, 126, 223, 0.28);
  background: linear-gradient(180deg, rgba(74, 50, 116, 0.78), rgba(60, 40, 96, 0.72));
}

.open-tuna-page[data-theme='dark'] .open-tuna-identity-bar[data-role='Creator']:not([data-username='main']) .open-tuna-identity-label {
  color: rgba(222, 201, 255, 0.78);
}

.open-tuna-page[data-theme='dark'] .open-tuna-identity-bar[data-role='Creator']:not([data-username='main']) .open-tuna-identity-value,
.open-tuna-page[data-theme='dark'] .open-tuna-identity-bar[data-role='Creator']:not([data-username='main']) .open-tuna-identity-sep {
  color: #f1e6ff;
}

.open-tuna-page[data-theme='dark'] .open-tuna-identity-bar[data-role='SuperMax']:not([data-username='main']) .open-tuna-identity-item {
  border-color: rgba(226, 153, 186, 0.28);
  background: linear-gradient(180deg, rgba(108, 48, 78, 0.78), rgba(90, 38, 66, 0.72));
}

.open-tuna-page[data-theme='dark'] .open-tuna-identity-bar[data-role='SuperMax']:not([data-username='main']) .open-tuna-identity-label {
  color: rgba(255, 206, 225, 0.8);
}

.open-tuna-page[data-theme='dark'] .open-tuna-identity-bar[data-role='SuperMax']:not([data-username='main']) .open-tuna-identity-value,
.open-tuna-page[data-theme='dark'] .open-tuna-identity-bar[data-role='SuperMax']:not([data-username='main']) .open-tuna-identity-sep {
  color: #ffe4ee;
}

.open-tuna-page[data-theme='dark'] .open-tuna-history-item.is-active {
  background: rgba(0, 212, 255, 0.14);
}

.open-tuna-page[data-theme='dark'] .open-tuna-history-delete {
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.75);
}

.open-tuna-page[data-theme='dark'] .open-tuna-agent-card {
  background: rgba(255, 255, 255, 0.02);
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

.open-tuna-page[data-theme='dark'] .open-tuna-files-card {
  background: rgba(255, 255, 255, 0.02);
}

.open-tuna-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 10, 20, 0.52);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1100;
  padding: 1rem;
}

.open-tuna-modal-backdrop[hidden] {
  display: none !important;
}

.open-tuna-modal-backdrop#openTunaFilesModalBackdrop {
  /* 提高层级，避免被页面水印/底图覆盖 */
  z-index: 12000;
  align-items: center;
  justify-content: center;
}

/* 弹窗卡片不要被 flex 子项默认拉伸成整屏高 */
.open-tuna-modal-backdrop#openTunaFilesModalBackdrop .open-tuna-files-modal-card {
  flex: 0 1 auto;
  align-self: center;
}

.open-tuna-files-trigger {
  border-top: 1px solid var(--ot-border);
  padding: 0.85rem 0.85rem 0.9rem;
}

.open-tuna-files-trigger-btn {
  width: 100%;
}

.open-tuna-modal-card {
  width: min(420px, 100%);
  border: 1px solid var(--ot-border);
  border-radius: 16px;
  background: var(--ot-bg-card-strong);
  box-shadow: var(--ot-shadow);
  padding: 1rem;
}

.open-tuna-workflow-rounds-card {
  width: min(420px, 100%);
}

.open-tuna-workflow-rounds-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.open-tuna-workflow-rounds-input {
  min-height: 54px;
  border: 1.5px solid rgba(44, 103, 161, 0.28);
  background: rgba(255, 255, 255, 0.98);
  color: #1f2b3a;
  font-size: 1.05rem;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 6px 14px rgba(44, 103, 161, 0.06);
}

.open-tuna-workflow-rounds-input:focus {
  border-color: rgba(44, 128, 200, 0.56);
  box-shadow: 0 0 0 4px rgba(44, 128, 200, 0.12);
}

.open-tuna-workflow-rounds-hint {
  color: var(--ot-text-secondary);
  font-size: 0.82rem;
  line-height: 1.45;
}

.open-tuna-workflow-rounds-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

.open-tuna-files-modal-card {
  /* 随内容收缩高度；超高时整卡滚动，避免内层再套一层「假」滚动区 */
  height: auto;
  overscroll-behavior-y: contain;
  /* 文件弹窗内统一色板：浅灰底 + 白卡片 + 标准蓝主色 */
  --otfm-bg: #f0f2f5;
  --otfm-list-bg: #e8ecf1;
  --otfm-surface: #ffffff;
  --otfm-surface-item: #ffffff;
  --otfm-border: #e2e8f0;
  --otfm-input: #f7fafc;
  --otfm-text: #1a202c;
  --otfm-text-muted: #64748b;
  --otfm-titlebar: #ffffff;
  --otfm-primary: #3182ce;
  --otfm-primary-hover: #2c5282;

  width: min(980px, 96vw);
  max-height: 82vh;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0;
  display: flex;
  flex-direction: column;
  background: var(--otfm-bg);
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 20px;
  box-shadow:
    0 25px 50px -12px rgba(15, 23, 42, 0.18),
    0 0 0 1px rgba(255, 255, 255, 0.6) inset;
  position: relative;
  z-index: 12001;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

/*
 * modern-style.css 对全局 section 使用 padding: var(--section-padding)（约 8rem 上下），
 * 工作区文件弹窗主体也是 section，会继承该留白；在此强制清零。
 */
.open-tuna-files-modal-card #openTunaFilesCard.otfm {
  padding: 0;
  margin: 0;
}

/* ========== 工作区文件弹窗内容区 otfm（单列滚动 + 双列栅格，无嵌套 flex:1 链） ========== */
.otfm {
  flex: 0 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--otfm-bg, #eceff3);
  color: var(--otfm-text, #0f172a);
}

.otfm-meta {
  flex: 0 0 auto;
  padding: 0.6rem 1.2rem 0.15rem;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem 0.75rem;
  min-width: 0;
}

.open-tuna-files-meta-pill {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 0.38rem 0.72rem;
  border-radius: 999px;
  background: rgba(49, 130, 206, 0.1);
  border: 1px solid rgba(49, 130, 206, 0.14);
  color: #245b88;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.35;
  word-break: break-all;
}

/* 无顶部提示时仍保留路径/agent 信息胶囊，仅在两者都为空时隐藏 */
#openTunaFilesCard .otfm-meta:has(#openTunaFilesFeedback:empty):not(:has(.open-tuna-files-meta-pill:not(:empty))) {
  display: none;
}

/* path 左、面包屑右；反馈信息单独占下一行 */
#openTunaFilesCard .otfm-meta {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  column-gap: 0.7rem;
  row-gap: 0.45rem;
}

#openTunaFilesCard .otfm-breadcrumb-row {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  justify-content: flex-start;
}

#openTunaFilesCard .otfm-breadcrumb-row.is-empty {
  display: none;
}

#openTunaFilesCard .open-tuna-files-feedback {
  grid-column: 1 / -1;
}

/* 不在此层再套一层「接近视口高」的滚动区，避免短内容时出现大块空白 + 右侧假滚动条 */
.otfm-scroll {
  flex: 0 0 auto;
  flex-grow: 0;
  flex-shrink: 0;
  min-height: 0;
  overflow: visible;
  padding: 0.05rem 1.2rem 0.45rem;
}

/* 工作区文件弹窗：主内容与标题栏之间保留更紧的间距 */
.open-tuna-files-modal-card #openTunaFilesCard .otfm-scroll {
  padding-top: 0.7rem;
}

.open-tuna-files-modal-card #openTunaFilesCard .otfm-meta {
  padding: 0.1rem 1.2rem 0.06rem;
}

.otfm-main {
  display: grid;
  grid-template-columns: minmax(0, 1.28fr) minmax(320px, 0.82fr);
  gap: 1.2rem 1.5rem;
  align-items: start;
}

.otfm-col {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.otfm-col--files {
  padding-right: 0.1rem;
}

.otfm-col--side {
  gap: 1rem;
}

.otfm-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.otfm-panel-head:empty {
  display: none;
}

.otfm-panel-head--side {
  padding-top: 0.05rem;
}

/* 与右侧 otfm-card-h 对齐的列标题 */
.otfm-section-label {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  padding-bottom: 0.28rem;
  color: var(--otfm-text, #1a202c);
  line-height: 1.35;
}

.otfm-section-subtitle {
  margin: 0;
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--otfm-text-muted, #64748b);
}

.open-tuna-page[data-theme='dark'] .otfm-section-label {
  color: var(--otfm-text, #e5e7eb);
}

.open-tuna-page[data-theme='dark'] .otfm-section-subtitle,
.open-tuna-page[data-theme='dark'] .otfm-card-note {
  color: rgba(226, 232, 240, 0.72);
}

/* 列表外壳：保留 .open-tuna-files-list-wrapper 类名供 JS */
#openTunaFilesCard .open-tuna-files-list-wrapper {
  flex: 0 0 auto;
  min-height: 0;
  width: 100%;
  overflow: hidden;
  border-radius: 18px;
  border: 1px solid var(--otfm-border, #e2e8f0);
  background: linear-gradient(180deg, rgba(255,255,255,0.78), rgba(232,236,241,0.92));
  display: flex;
  flex-direction: column;
  align-self: stretch;
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 20px rgba(15, 23, 42, 0.04);
}

/* 空目录：保留一块占位，避免「暂无文件」太扁 */
#openTunaFilesCard .open-tuna-files-list-wrapper.is-empty-state {
  flex: 0 1 auto;
  min-height: min(22vh, 168px);
}

#openTunaFilesCard .open-tuna-files-list-wrapper.is-empty-state .open-tuna-files-list {
  display: none;
}

#openTunaFilesCard .open-tuna-files-list {
  flex: 0 0 auto;
  flex-grow: 0;
  min-height: 0;
  max-height: min(52vh, 440px);
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  overflow-y: auto;
}

#openTunaFilesCard .open-tuna-files-list-wrapper .open-tuna-files-empty {
  display: none;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 1.8rem 1.2rem;
  text-align: center;
  font-size: 0.88rem;
  color: var(--otfm-text-muted, #5c6b80);
  overflow: hidden;
}

.open-tuna-files-empty-icon {
  font-size: 1.9rem;
  line-height: 1;
}

.open-tuna-files-empty-title {
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--otfm-text, #1a202c);
}

.open-tuna-files-empty-text {
  max-width: 22rem;
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--otfm-text-muted, #64748b);
}

#openTunaFilesCard .open-tuna-files-list-wrapper.is-empty-state .open-tuna-files-empty {
  display: flex;
}

#openTunaFilesCard .open-tuna-files-list::-webkit-scrollbar {
  width: 8px;
}

#openTunaFilesCard .open-tuna-files-list::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.06);
  border-radius: 999px;
}

#openTunaFilesCard .open-tuna-files-list::-webkit-scrollbar-thumb {
  background: rgba(49, 130, 206, 0.4);
  border-radius: 999px;
}

#openTunaFilesCard .open-tuna-files-list::-webkit-scrollbar-thumb:hover {
  background: rgba(49, 130, 206, 0.6);
}

#openTunaFilesCard .open-tuna-files-meta,
#openTunaFilesCard .open-tuna-files-feedback,
#openTunaFilesCard .open-tuna-files-breadcrumb {
  color: var(--otfm-text-muted, #5c6b80);
}

#openTunaFilesCard .open-tuna-files-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
  min-width: 0;
  flex: 0 1 auto;
  justify-content: flex-start;
}

#openTunaFilesCard .open-tuna-files-feedback:empty {
  display: none;
}

#openTunaFilesCard .open-tuna-files-feedback:not(:empty) {
  flex: 0 0 auto;
  max-width: 100%;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.35;
}

#openTunaFilesCard .open-tuna-files-feedback.is-loading:not(:empty) {
  color: #43617f;
  background: rgba(49, 130, 206, 0.08);
  border-color: rgba(49, 130, 206, 0.2);
}

#openTunaFilesCard .open-tuna-files-feedback.is-success:not(:empty) {
  color: #14532d;
  background: rgba(34, 197, 94, 0.14);
  border-color: rgba(34, 197, 94, 0.28);
}

#openTunaFilesCard .open-tuna-files-feedback.is-error:not(:empty) {
  color: #991b1b;
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.28);
}

/* 「工作区文件」标题下方：列表加载 / 列表请求错误 */
#openTunaFilesCard .open-tuna-files-list-feedback:empty {
  display: none;
}

#openTunaFilesCard .open-tuna-files-list-feedback:not(:empty) {
  margin: -0.15rem 0 0.4rem;
  max-width: 100%;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.4;
}

#openTunaFilesCard .open-tuna-files-list-feedback.is-loading:not(:empty) {
  color: var(--otfm-text-muted, #64748b);
  background: rgba(49, 130, 206, 0.08);
  border-color: rgba(49, 130, 206, 0.2);
}

#openTunaFilesCard .open-tuna-files-list-feedback.is-success:not(:empty) {
  color: #14532d;
  background: rgba(34, 197, 94, 0.14);
  border-color: rgba(34, 197, 94, 0.28);
}

#openTunaFilesCard .open-tuna-files-list-feedback.is-error:not(:empty) {
  color: #991b1b;
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.28);
}

#openTunaFilesCard .open-tuna-files-crumb-btn {
  color: var(--otfm-text, #0f172a);
  text-decoration: underline;
}

#openTunaFilesCard .open-tuna-agent-input {
  background: var(--otfm-input, #f7fafc);
  border-color: var(--otfm-border, #e2e8f0);
  color: var(--otfm-text, #1a202c);
}

#openTunaFilesCard .open-tuna-agent-input::placeholder {
  color: rgba(15, 23, 42, 0.42);
}

#openTunaFilesCard .otfm-session-path.open-tuna-agent-input,
#openTunaFilesCard .otfm-session-json.open-tuna-agent-input {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

#openTunaFilesCard .open-tuna-btn.secondary {
  color: var(--otfm-text, #1a202c);
  background: #fff;
  border: 1px solid var(--otfm-border, #e2e8f0);
}

#openTunaFilesCard .open-tuna-btn.secondary:hover {
  background: #f7fafc;
  border-color: rgba(49, 130, 206, 0.45);
}

#openTunaFilesCard .open-tuna-files-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.7rem;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--otfm-border, #e2e8f0);
  border-radius: 16px;
  padding: 0.75rem 0.82rem;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.05);
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}

#openTunaFilesCard .open-tuna-files-item.is-highlight {
  animation: open-tuna-highlight-fade-otfm 3s ease-out forwards;
}

@keyframes open-tuna-highlight-fade-otfm {
  0% {
    border-color: var(--otfm-primary, #3182ce);
    box-shadow:
      0 0 0 2px rgba(49, 130, 206, 0.22),
      0 2px 8px rgba(49, 130, 206, 0.12);
  }
  80% {
    border-color: var(--otfm-primary, #3182ce);
    box-shadow:
      0 0 0 1px rgba(49, 130, 206, 0.12),
      0 1px 3px rgba(15, 23, 42, 0.06);
  }
  100% {
    border-color: var(--otfm-border, #e2e8f0);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
  }
}

#openTunaFilesCard .open-tuna-files-item-name {
  font-weight: 800;
  font-size: 0.92rem;
  color: var(--otfm-text, #1a202c);
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: break-word;
}

#openTunaFilesCard .open-tuna-files-item-meta {
  color: var(--otfm-text-muted, #5c6b80);
  font-size: 0.79rem;
  line-height: 1.45;
}

#openTunaFilesCard .open-tuna-files-item-actions {
  align-self: center;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-height: 100%;
  margin-right: 0.38rem;
}

#openTunaFilesCard .open-tuna-files-item-btn {
  flex-shrink: 0;
  align-self: center;
  border: 1px solid var(--otfm-border, #e2e8f0);
  color: var(--otfm-text, #1a202c);
  background: rgba(255,255,255,0.95);
  border-radius: 999px;
  padding: 0.44rem 0.98rem;
  font-size: 0.82rem;
  font-weight: 700;
}

#openTunaFilesCard .open-tuna-files-item-btn:hover {
  border-color: rgba(49, 130, 206, 0.55);
  background: rgba(49, 130, 206, 0.08);
  color: var(--otfm-primary, #3182ce);
  transform: translateY(-1px);
}

.otfm-card {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin: 0;
  padding: 1rem 1.05rem;
  border-radius: 16px;
  border: 1px solid var(--otfm-border, #e2e8f0);
  background: var(--otfm-surface, #ffffff);
  box-shadow:
    0 1px 3px rgba(15, 23, 42, 0.06),
    0 4px 14px rgba(15, 23, 42, 0.04);
}

.otfm-card-h {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--otfm-border, #e2e8f0);
  color: var(--otfm-text, #1a202c);
}

.otfm-card-body {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.otfm-card-note {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.55;
  color: var(--otfm-text-muted, #64748b);
}

.otfm-card-foot {
  flex-shrink: 0;
}

.otfm-submit {
  width: 100%;
  border-radius: 14px;
}

.otfm-session-box {
  border: 1px solid var(--otfm-border, #e2e8f0);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255,255,255,0.9), rgba(247,250,252,0.95));
  padding: 0.85rem 0.9rem;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.65);
}

.otfm-session-label {
  display: block;
  margin: 0 0 0.45rem;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--otfm-muted, #475569);
}

.otfm-session-select {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin: 0 0 0.75rem;
  padding: 0.6rem 0.85rem !important;
  border: 1px solid var(--otfm-border, #e2e8f0);
  border-radius: 12px;
  background: #fff;
  box-shadow: none;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.45;
  color: var(--otfm-text, #0f172a);
  -webkit-appearance: auto;
  appearance: auto;
}

.otfm-session-path {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin: 0 0 0.5rem;
  padding: 0 0 0.5rem !important;
  border: none;
  border-bottom: 1px solid var(--otfm-border, #e2e8f0);
  background: transparent;
  box-shadow: none;
  font-size: 0.8rem;
  font-weight: 600;
  word-break: break-all;
  line-height: 1.45;
  color: var(--otfm-text, #0f172a);
  -webkit-appearance: none;
  appearance: none;
}

.otfm-session-json {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin: 0;
  padding: 0 !important;
  border: none;
  background: transparent;
  box-shadow: none;
  min-height: 140px;
  height: 12rem;
  max-height: min(42vh, 280px);
  overflow-y: auto;
  resize: vertical;
  font-family: ui-monospace, 'Cascadia Code', 'Segoe UI Mono', 'Consolas', monospace;
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--otfm-text, #0f172a);
  -webkit-appearance: none;
  appearance: none;
}

/* 文件弹窗内：短 JSON 不再占一整块固定高度 */
.open-tuna-files-modal-card .otfm-session-json {
  min-height: 4rem;
  height: auto;
  max-height: min(36vh, 220px);
  resize: vertical;
}

.otfm-session-path:focus,
.otfm-session-json:focus {
  outline: none;
}

#openTunaFilesCard .open-tuna-file-field {
  width: 100%;
}

#openTunaFilesCard .open-tuna-file-field-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem 0.9rem;
}

#openTunaFilesCard .open-tuna-file-field-trigger {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  min-height: 40px;
  border-radius: 999px;
  overflow: hidden;
  cursor: pointer;
}

#openTunaFilesCard .open-tuna-file-field-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
  font-size: 0;
}

#openTunaFilesCard .open-tuna-file-field-btn {
  pointer-events: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1.05rem;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
  border: 1px solid var(--otfm-border, #e2e8f0);
  background: #fff;
  color: var(--otfm-text, #1a202c);
  transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

#openTunaFilesCard .open-tuna-file-field-trigger:hover .open-tuna-file-field-btn {
  background: #ebf8ff;
  border-color: rgba(49, 130, 206, 0.45);
}

#openTunaFilesCard .open-tuna-file-field-trigger:focus-within .open-tuna-file-field-btn {
  outline: none;
  box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.2);
  border-color: rgba(49, 130, 206, 0.55);
}

#openTunaFilesCard .open-tuna-file-field-name {
  flex: 1;
  min-width: 0;
  font-size: 0.82rem;
  color: var(--otfm-text-muted, #5c6b80);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 标题栏左侧：刷新 / 根目录 / 上一级 */
.open-tuna-files-modal-titlebar-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
  flex: 1;
}

.open-tuna-files-modal-titlebar-tools .open-tuna-btn.secondary {
  padding: 0.45rem 0.85rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--otfm-text, #1a202c);
  background: #f7fafc;
  border: 1px solid var(--otfm-border, #e2e8f0);
  box-shadow: none;
}

.open-tuna-files-modal-titlebar-tools .open-tuna-btn.secondary:hover {
  background: #edf2f7;
  border-color: rgba(49, 130, 206, 0.45);
  color: var(--otfm-text, #1a202c);
}

/* 标题栏关闭：沿用侧边入口按钮语义，但改成淡红提示 */
.open-tuna-files-modal-titlebar .open-tuna-files-modal-close-btn.open-tuna-btn.secondary {
  padding: 0.5rem 1rem;
  font-size: 0.88rem;
  font-weight: 600;
  background: linear-gradient(180deg, rgba(255, 244, 246, 0.96), rgba(255, 236, 240, 0.92));
  border: 1px solid rgba(214, 106, 132, 0.28);
  color: #b54768;
  box-shadow: 0 6px 16px rgba(214, 106, 132, 0.12);
  flex-shrink: 0;
}

.open-tuna-files-modal-titlebar .open-tuna-files-modal-close-btn.open-tuna-btn.secondary:hover {
  background: linear-gradient(180deg, rgba(255, 238, 242, 1), rgba(255, 228, 235, 0.98));
  border-color: rgba(214, 106, 132, 0.38);
  color: #9f3857;
}

@media (min-width: 901px) {
  .otfm {
    border-top: 1px solid var(--otfm-border, #e2e8f0);
  }

  /* 弹窗已有标题栏底边线，去掉 otfm 顶部分割线，避免多一条带 + 视觉留白 */
  .open-tuna-files-modal-card #openTunaFilesCard.otfm {
    border-top: none;
  }

  .otfm-main {
    align-items: start;
  }

  .otfm-col--files {
    padding-right: 1rem;
    margin-right: 0;
    border-right: 1px solid var(--otfm-border, #e2e8f0);
    align-self: start;
  }

  /* 不与左侧列表强行等高，避免会话卡片被 flex 撑出大块空白 */
  .otfm-col--side {
    min-height: 0;
    align-self: start;
  }

  .otfm-col--side > .otfm-card:first-of-type {
    flex: 0 0 auto;
  }

  .otfm-col--side > .otfm-card:last-of-type {
    flex: 0 1 auto;
    min-height: 0;
    max-height: min(58vh, 520px);
    display: flex;
    flex-direction: column;
  }

  .open-tuna-files-modal-card #openTunaFilesUploadForm .otfm-card-body {
    flex: 0 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: visible;
  }

  .open-tuna-files-modal-card #openTunaFilesUploadForm .otfm-session-box {
    flex: 0 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: visible;
  }

  .open-tuna-files-modal-card #openTunaFilesUploadForm .otfm-session-json {
    flex: 0 1 auto;
    min-height: 3.75rem;
    max-height: min(34vh, 260px);
    height: auto;
    resize: vertical;
  }
}

.open-tuna-page[data-theme='dark'] #openTunaFilesCard.otfm {
  background: #0a101c;
  color: #e5e7eb;
}

.open-tuna-page[data-theme='dark'] #openTunaFilesCard .open-tuna-files-meta,
.open-tuna-page[data-theme='dark'] #openTunaFilesCard .open-tuna-files-empty,
.open-tuna-page[data-theme='dark'] #openTunaFilesCard .open-tuna-files-breadcrumb {
  color: rgba(229, 231, 235, 0.78);
}

.open-tuna-page[data-theme='dark'] #openTunaFilesCard .otfm-breadcrumb-row {
  border-bottom-color: rgba(148, 163, 184, 0.22);
}

.open-tuna-page[data-theme='dark'] #openTunaFilesCard .open-tuna-files-feedback.is-loading:not(:empty),
.open-tuna-page[data-theme='dark'] #openTunaFilesCard .open-tuna-files-list-feedback.is-loading:not(:empty) {
  color: rgba(229, 231, 235, 0.78);
  background: rgba(66, 153, 225, 0.12);
  border-color: rgba(66, 153, 225, 0.28);
}

.open-tuna-page[data-theme='dark'] #openTunaFilesCard .open-tuna-files-feedback.is-success:not(:empty),
.open-tuna-page[data-theme='dark'] #openTunaFilesCard .open-tuna-files-list-feedback.is-success:not(:empty) {
  color: #86efac;
  background: rgba(34, 197, 94, 0.12);
  border-color: rgba(34, 197, 94, 0.28);
}

.open-tuna-page[data-theme='dark'] #openTunaFilesCard .open-tuna-files-feedback.is-error:not(:empty),
.open-tuna-page[data-theme='dark'] #openTunaFilesCard .open-tuna-files-list-feedback.is-error:not(:empty) {
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(248, 113, 113, 0.35);
}

.open-tuna-page[data-theme='dark'] #openTunaFilesCard .open-tuna-agent-input {
  background: var(--otfm-input, rgba(12, 18, 30, 0.92));
  border-color: var(--otfm-border, rgba(148, 163, 184, 0.35));
  color: var(--otfm-text, #e5e7eb);
}

.open-tuna-page[data-theme='dark'] #openTunaFilesCard .open-tuna-agent-input::placeholder {
  color: rgba(229, 231, 235, 0.35);
}

.open-tuna-page[data-theme='dark'] #openTunaFilesCard .otfm-session-path.open-tuna-agent-input,
.open-tuna-page[data-theme='dark'] #openTunaFilesCard .otfm-session-json.open-tuna-agent-input {
  background: transparent;
  border-color: transparent;
}

.open-tuna-page[data-theme='dark'] #openTunaFilesCard .open-tuna-btn.secondary {
  color: #e5e7eb;
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(148, 163, 184, 0.35);
}

.open-tuna-page[data-theme='dark'] #openTunaFilesCard .open-tuna-files-item {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(148, 163, 184, 0.35);
}

.open-tuna-page[data-theme='dark'] #openTunaFilesCard .open-tuna-files-item-name {
  color: #e5e7eb;
}

.open-tuna-page[data-theme='dark'] #openTunaFilesCard .open-tuna-files-item-meta {
  color: rgba(229, 231, 235, 0.78);
}

.open-tuna-page[data-theme='dark'] #openTunaFilesCard .open-tuna-files-item-btn {
  border-color: rgba(148, 163, 184, 0.35);
  color: #e5e7eb;
  background: rgba(255, 255, 255, 0.06);
}

.open-tuna-page[data-theme='dark'] #openTunaFilesCard .open-tuna-files-item-btn:hover {
  border-color: rgba(66, 153, 225, 0.55);
  background: rgba(66, 153, 225, 0.14);
  color: #e5e7eb;
}

.open-tuna-page[data-theme='dark'] #openTunaFilesCard .open-tuna-files-list-wrapper {
  border-color: var(--otfm-border, rgba(148, 163, 184, 0.35));
  background: var(--otfm-surface, rgba(255, 255, 255, 0.04));
}

.open-tuna-page[data-theme='dark'] #openTunaFilesCard .open-tuna-files-list-wrapper .open-tuna-files-empty {
  color: rgba(229, 231, 235, 0.55);
}

.open-tuna-page[data-theme='dark'] .open-tuna-files-modal-card .otfm-card {
  border-color: var(--otfm-border, rgba(148, 163, 184, 0.35));
  background: var(--otfm-surface, rgba(255, 255, 255, 0.04));
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.28);
}

.open-tuna-page[data-theme='dark'] .open-tuna-files-modal-card .otfm-card-h {
  border-bottom-color: rgba(148, 163, 184, 0.25);
  color: #e5e7eb;
}

.open-tuna-page[data-theme='dark'] #openTunaFilesCard .open-tuna-file-field-btn {
  border-color: rgba(148, 163, 184, 0.45);
  background: rgba(255, 255, 255, 0.08);
  color: #e5e7eb;
}

.open-tuna-page[data-theme='dark'] #openTunaFilesCard .open-tuna-file-field-trigger:hover .open-tuna-file-field-btn {
  background: rgba(0, 212, 255, 0.12);
  border-color: rgba(0, 212, 255, 0.45);
}

.open-tuna-page[data-theme='dark'] #openTunaFilesCard .open-tuna-file-field-trigger:focus-within .open-tuna-file-field-btn {
  box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.18);
  border-color: rgba(0, 212, 255, 0.55);
}

.open-tuna-page[data-theme='dark'] #openTunaFilesCard .open-tuna-file-field-name {
  color: rgba(229, 231, 235, 0.72);
}

.open-tuna-page[data-theme='dark'] .open-tuna-files-modal-card .otfm-session-box {
  border-color: var(--otfm-border, rgba(148, 163, 184, 0.35));
  background: var(--otfm-input, rgba(12, 18, 30, 0.92));
}

.open-tuna-page[data-theme='dark'] .open-tuna-files-modal-card .otfm-session-path,
.open-tuna-page[data-theme='dark'] .open-tuna-files-modal-card .otfm-session-json {
  color: #e5e7eb;
}

.open-tuna-page[data-theme='dark'] .open-tuna-files-modal-card .otfm-session-path {
  border-bottom-color: rgba(148, 163, 184, 0.28);
}

.open-tuna-page[data-theme='dark'] .open-tuna-files-modal-titlebar {
  background: var(--otfm-titlebar, #0c121f);
  border-bottom-color: var(--otfm-border, rgba(148, 163, 184, 0.22));
}

.open-tuna-page[data-theme='dark'] .open-tuna-files-modal-titlebar-tools .open-tuna-btn.secondary {
  color: #e5e7eb;
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(148, 163, 184, 0.35);
}

.open-tuna-page[data-theme='dark'] .open-tuna-files-modal-titlebar-tools .open-tuna-btn.secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(0, 212, 255, 0.45);
  color: #e5e7eb;
}

.open-tuna-page[data-theme='dark'] .open-tuna-files-modal-titlebar .open-tuna-files-modal-close-btn.open-tuna-btn.secondary {
  color: #ffc7d4;
  background: linear-gradient(180deg, rgba(108, 34, 56, 0.92), rgba(88, 24, 44, 0.88));
  border-color: rgba(255, 153, 180, 0.28);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.22);
}

.open-tuna-page[data-theme='dark'] .open-tuna-files-modal-titlebar .open-tuna-files-modal-close-btn.open-tuna-btn.secondary:hover {
  background: linear-gradient(180deg, rgba(128, 40, 67, 0.96), rgba(98, 28, 50, 0.92));
  border-color: rgba(255, 173, 196, 0.4);
  color: #ffe1e8;
}

@media (min-width: 901px) {
  .open-tuna-page[data-theme='dark'] #openTunaFilesCard.otfm {
    border-top-color: rgba(148, 163, 184, 0.22);
  }

  .open-tuna-page[data-theme='dark'] .otfm-col--files {
    border-right-color: rgba(148, 163, 184, 0.22);
  }
}

.open-tuna-files-modal-titlebar {
  display: block;
  padding: 1rem 1.15rem 0.7rem;
  border-bottom: 1px solid var(--otfm-border, #e2e8f0);
  background: linear-gradient(180deg, rgba(255,255,255,0.96), rgba(255,255,255,0.82));
  position: sticky;
  top: 0;
  z-index: 2;
  -webkit-backdrop-filter: blur(10px) saturate(140%);
  backdrop-filter: blur(10px) saturate(140%);
}

.open-tuna-files-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.open-tuna-files-modal-title-group {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
}

.open-tuna-files-modal-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.25;
  color: #0f172a;
}

.open-tuna-files-modal-subtitle {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.5;
  color: #64748b;
}

/* 弹窗内主按钮：标准蓝，暗色下由下方规则覆盖全局渐变 */
.open-tuna-files-modal-card .open-tuna-btn.primary {
  border-radius: 14px;
  background: var(--otfm-primary, #3182ce);
  box-shadow: 0 4px 14px rgba(49, 130, 206, 0.32);
}

.open-tuna-files-modal-card .open-tuna-btn.primary:hover:not(:disabled) {
  background: var(--otfm-primary-hover, #2c5282);
  box-shadow: 0 6px 18px rgba(49, 130, 206, 0.38);
}

.open-tuna-files-modal-card .open-tuna-files-card {
  border-top: none;
  padding: 0.95rem 0.85rem 1rem;
  flex: 1;
  overflow-y: auto;
  background: #f0f2f5;
}

.open-tuna-modal-title {
  margin: 0;
  color: var(--ot-text-primary);
  font-size: 1rem;
}

.open-tuna-modal-text {
  margin: 0.75rem 0 1rem;
  color: var(--ot-text-secondary);
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-line;
}

.open-tuna-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.55rem;
}

/* 离开/刷新确认弹窗：主按钮与取消一致为胶囊圆角 */
#openTunaUnloadConfirmModal .open-tuna-modal-actions .open-tuna-btn.primary {
  border-radius: 999px;
}

/* 离开/刷新确认弹窗：打开时主按钮会 focus，去掉系统青色焦点环，保留与常态一致的阴影 */
#openTunaUnloadConfirmModal .open-tuna-btn.primary:focus,
#openTunaUnloadConfirmModal .open-tuna-btn.primary:focus-visible {
  outline: none;
  box-shadow: 0 10px 24px rgba(44, 128, 200, 0.28);
}

.open-tuna-page[data-theme='dark'] #openTunaUnloadConfirmModal .open-tuna-btn.primary:focus,
.open-tuna-page[data-theme='dark'] #openTunaUnloadConfirmModal .open-tuna-btn.primary:focus-visible {
  box-shadow: 0 14px 34px rgba(0, 212, 255, 0.22);
}

.open-tuna-page[data-theme='dark'] .open-tuna-chat-header {
  background: rgba(255, 255, 255, 0.06);
}

.open-tuna-page[data-theme='dark'] .open-tuna-chat-log {
  background: var(--ot-bg-soft);
}

.open-tuna-page[data-theme='dark'] .message-meta {
  color: rgba(215, 231, 255, 0.66);
}

.open-tuna-page[data-theme='dark'] .message-time-bottom {
  color: rgba(215, 231, 255, 0.66);
}

.open-tuna-page[data-theme='dark'] .open-tuna-message.assistant .message-bubble {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #eef6ff;
}

.open-tuna-page[data-theme='dark'] .open-tuna-message.assistant[data-status='pending'] .message-bubble,
.open-tuna-page[data-theme='dark'] .open-tuna-message.assistant[data-status='submitting'] .message-bubble {
  border-color: rgba(0, 212, 255, 0.32);
  box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.08);
}

.open-tuna-page[data-theme='dark'] .open-tuna-message.assistant[data-status='failed'] .message-bubble {
  background: rgba(110, 34, 34, 0.28);
  border-color: rgba(255, 120, 120, 0.3);
  box-shadow: 0 0 0 3px rgba(255, 120, 120, 0.08);
}

.open-tuna-page[data-theme='dark'] .open-tuna-message-retry {
  border-color: rgba(0, 212, 255, 0.24);
  background: rgba(0, 212, 255, 0.1);
  color: #9fe9ff;
}

.open-tuna-page[data-theme='dark'] .open-tuna-message-retry:hover:not(:disabled) {
  background: rgba(0, 212, 255, 0.16);
  border-color: rgba(0, 212, 255, 0.34);
}

.open-tuna-page[data-theme='dark'] .open-tuna-message.user .message-bubble {
  background: rgba(0, 153, 204, 0.24);
  border: 1px solid rgba(0, 212, 255, 0.28);
  color: #fff;
  box-shadow: 0 8px 18px rgba(0, 140, 200, 0.12);
}

.open-tuna-page[data-theme='dark'] .open-tuna-composer {
  background: rgba(255, 255, 255, 0.03);
}

.open-tuna-page[data-theme='dark'] .open-tuna-input {
  background: rgba(30, 36, 44, 0.68);
  color: #fff;
  box-shadow: none;
}

.open-tuna-page[data-theme='dark'] .open-tuna-composer[data-readonly='1'] {
  background: linear-gradient(180deg, rgba(70, 48, 17, 0.24), rgba(255, 255, 255, 0.03));
}

.open-tuna-page[data-theme='dark'] .open-tuna-composer[data-readonly='1'] .open-tuna-input {
  background: rgba(64, 43, 18, 0.42);
  border-color: rgba(255, 183, 94, 0.22);
  color: #ffdca7;
}

.open-tuna-page[data-theme='dark'] .open-tuna-btn.primary {
  background: linear-gradient(135deg, #00d4ff, #0b8fd8);
  box-shadow: 0 14px 34px rgba(0, 212, 255, 0.22);
}

/* 工作区文件弹窗内主按钮保持实心蓝，不与聊天页渐变混用 */
.open-tuna-page[data-theme='dark'] .open-tuna-files-modal-card .open-tuna-btn.primary {
  background: var(--otfm-primary, #4299e1);
  box-shadow: 0 4px 16px rgba(66, 153, 225, 0.28);
}

.open-tuna-page[data-theme='dark'] .open-tuna-files-modal-card .open-tuna-btn.primary:hover:not(:disabled) {
  background: var(--otfm-primary-hover, #63b3ed);
  box-shadow: 0 6px 20px rgba(66, 153, 225, 0.35);
}

.open-tuna-page[data-theme='dark'] .open-tuna-btn.voice {
  color: #eef6ff;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.open-tuna-page[data-theme='dark'] .open-tuna-btn.voice:hover {
  border-color: rgba(0, 212, 255, 0.45);
  box-shadow: 0 10px 30px rgba(0, 212, 255, 0.18);
}

.open-tuna-page[data-theme='dark'] .open-tuna-btn.secondary {
  color: #d7e7ff;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

@media (max-width: 900px) {
  .open-tuna-page {
    padding-top: 108px;
  }

  .open-tuna-shell {
    grid-template-columns: 1fr;
  }

  .open-tuna-history-card {
    min-height: 200px;
  }

  .otfm-meta,
  .otfm-scroll {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  .otfm-scroll {
    overscroll-behavior-y: contain;
    padding-top: 0.25rem;
    padding-bottom: max(0.75rem, calc(0.45rem + env(safe-area-inset-bottom, 0px)));
  }

  .open-tuna-files-modal-card #openTunaFilesCard .otfm-scroll {
    padding-top: 0.5rem;
  }

  .open-tuna-files-modal-card #openTunaFilesCard .otfm-meta {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
    padding-top: 0.12rem;
    padding-bottom: 0.1rem;
  }

  .otfm-meta {
    flex-direction: column;
    align-items: stretch;
    padding-top: 0.28rem;
    padding-bottom: 0.22rem;
  }

  .otfm-main {
    grid-template-columns: 1fr;
    gap: 0.85rem;
    align-items: start;
  }

  /* 窄屏：路径可横向滑动，避免被 flex/换行压没或挤出视口 */
  #openTunaFilesCard .otfm-breadcrumb-row {
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
  }

  #openTunaFilesCard .otfm-breadcrumb-row .open-tuna-files-breadcrumb {
    flex-wrap: nowrap;
    width: max-content;
    max-width: none;
    padding-bottom: 0.15rem;
  }

  .otfm-section-label {
    font-size: 0.82rem;
    padding-bottom: 0.38rem;
  }

  /* 弹窗多占一些可视高度，底部留白交给 safe-area */
  .open-tuna-modal-backdrop#openTunaFilesModalBackdrop {
    padding: 0.5rem;
    padding-bottom: max(0.5rem, env(safe-area-inset-bottom, 0px));
  }

  .open-tuna-files-modal-card {
    width: 100%;
    max-width: 100%;
    max-height: min(90vh, calc(100vh - 1rem));
    max-height: min(90dvh, calc(100vh - 1rem));
    border-radius: 14px;
    overscroll-behavior-y: contain;
  }

  .open-tuna-files-modal-titlebar {
    padding: 0.65rem 0.75rem;
    gap: 0.5rem;
  }

  .open-tuna-files-modal-titlebar-tools {
    gap: 0.35rem;
  }

  .open-tuna-files-modal-titlebar-tools .open-tuna-btn.secondary {
    padding: 0.38rem 0.62rem;
    font-size: 0.76rem;
  }

  .open-tuna-files-modal-titlebar .open-tuna-files-modal-close-btn.open-tuna-btn.secondary {
    padding: 0.38rem 0.7rem;
    font-size: 0.8rem;
  }

  .open-tuna-files-modal-card .otfm-card {
    padding: 0.72rem 0.8rem;
    gap: 0.55rem;
  }

  .open-tuna-files-modal-card .otfm-card-h {
    font-size: 0.82rem;
    padding-bottom: 0.38rem;
  }

  #openTunaFilesCard .open-tuna-files-list-wrapper.is-empty-state {
    min-height: min(20vh, 148px);
  }

  #openTunaFilesCard .open-tuna-files-list {
    min-height: 0;
    max-height: min(46vh, 340px);
  }

  .open-tuna-files-list-wrapper.is-empty-state,
  .open-tuna-files-list-wrapper.is-empty-state .open-tuna-files-empty {
    overflow: hidden;
  }

  /* 右侧：上传固定高度，会话卡片内滚动 + 底部保存按钮常驻 */
  .otfm-col--side {
    min-height: 0;
    gap: 0.75rem;
  }

  .otfm-col--side > .otfm-card:first-of-type {
    flex: 0 0 auto;
  }

  .otfm-col--side > .otfm-card:last-of-type {
    flex: 0 1 auto;
    min-height: 0;
    max-height: min(46vh, 360px);
    display: flex;
    flex-direction: column;
  }

  .open-tuna-files-modal-card #openTunaFilesUploadForm .otfm-card-body {
    flex: 0 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: visible;
  }

  .open-tuna-files-modal-card #openTunaFilesUploadForm .otfm-session-box {
    flex: 0 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: visible;
  }

  .open-tuna-files-modal-card #openTunaFilesUploadForm .otfm-session-json {
    flex: 0 1 auto;
    min-height: 5rem;
    max-height: min(32vh, 220px);
    height: auto;
    resize: none;
  }

  .open-tuna-files-modal-card .open-tuna-btn.primary {
    box-shadow: 0 4px 14px rgba(49, 130, 206, 0.28);
  }

  /* 主要操作更易点按 */
  .open-tuna-files-modal-card .otfm-submit.open-tuna-btn.primary {
    min-height: 44px;
    padding-top: 0.55rem;
    padding-bottom: 0.55rem;
  }

  #openTunaFilesCard .open-tuna-files-item-btn {
    min-height: 40px;
    padding: 0.45rem 0.75rem;
  }

  #openTunaFilesCard .open-tuna-files-breadcrumb {
    word-break: break-word;
    overflow-wrap: anywhere;
  }
}

/* 手机横屏等矮视口：压缩列表与会话区，避免整页挤爆 */
@media (max-width: 900px) and (max-height: 520px) {
  .open-tuna-files-modal-card {
    max-height: min(96dvh, calc(100vh - 0.5rem));
    max-height: min(96vh, calc(100vh - 0.5rem));
  }

  #openTunaFilesCard .open-tuna-files-list-wrapper.is-empty-state {
    min-height: min(14vh, 112px);
  }

  #openTunaFilesCard .open-tuna-files-list {
    max-height: min(40vh, 280px);
  }

  .otfm-col--side > .otfm-card:last-of-type {
    max-height: min(36vh, 240px);
  }

  .open-tuna-files-modal-titlebar {
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
  }
}

@media (max-width: 640px) {
  .open-tuna-page {
    padding-top: 96px;
  }

  .open-tuna-nav-title {
    gap: 0.45rem;
  }

  .open-tuna-mark {
    height: 1.7rem;
  }

  .open-tuna-footer-mark {
    height: 2rem;
  }

  .open-tuna-chat-header {
    padding-left: 18px;
    padding-right: 18px;
  }

  .open-tuna-header-status-row {
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: nowrap;
  }

  .open-tuna-header-actions {
    margin-left: auto;
    width: 100%;
    gap: 0.45rem;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: stretch;
  }

  .open-tuna-stop-workflow-btn {
    width: 100%;
    justify-content: center;
    order: -1;
    margin-bottom: 0.15rem;
  }

  #openTunaThemeBtn,
  #openTunaClearBtn {
    flex: 0 0 auto;
  }

  .open-tuna-identity-bar {
    align-items: stretch;
    justify-content: flex-start;
    gap: 0.65rem;
    margin-top: 0.15rem;
  }

  .open-tuna-identity-item {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    padding: 0.5rem 0.68rem;
    flex-wrap: wrap;
    row-gap: 0.25rem;
  }

  .open-tuna-identity-item--primary {
    flex: 1 1 100%;
  }

  .open-tuna-workflow-controls {
    width: 100%;
    margin-left: 0;
    justify-content: flex-end;
    align-items: center;
    padding-top: 0.1rem;
    gap: 0.45rem;
  }

  .open-tuna-workflow-controls .open-tuna-stop-workflow-btn,
  .open-tuna-workflow-controls .open-tuna-resume-workflow-btn {
    width: auto;
    order: 0;
    margin-bottom: 0;
    flex: 0 0 auto;
  }

  .open-tuna-workflow-toggle {
    margin-left: 0;
  }

  .open-tuna-identity-label {
    font-size: 0.7rem;
  }

  .open-tuna-identity-value {
    font-size: 0.84rem;
  }

  .open-tuna-header-status {
    gap: 0.65rem;
    min-width: 0;
  }

  .status-label {
    font-size: 0.9rem;
    white-space: nowrap;
  }

  #openTunaClearBtn,
  #openTunaThemeBtn {
    padding: 8px 12px;
    font-size: 0.88rem;
    line-height: 1.2;
    white-space: nowrap;
  }

  .open-tuna-chat-log,
  .open-tuna-composer {
    padding-left: 18px;
    padding-right: 18px;
  }

  .open-tuna-modal-backdrop#openTunaFilesModalBackdrop {
    padding: 0.35rem;
    padding-bottom: max(0.35rem, env(safe-area-inset-bottom, 0px));
  }

  .open-tuna-files-modal-card {
    max-height: min(94vh, calc(100vh - 0.7rem));
    max-height: min(94dvh, calc(100vh - 0.7rem));
    border-radius: 12px;
  }

  .open-tuna-files-modal-titlebar {
    padding: 0.7rem 0.78rem 0.55rem;
  }

  .open-tuna-files-modal-head {
    flex-direction: column;
    align-items: stretch;
    gap: 0.65rem;
  }

  .open-tuna-files-modal-title {
    font-size: 0.94rem;
  }

  .open-tuna-files-modal-subtitle {
    font-size: 0.75rem;
    line-height: 1.45;
  }

  .open-tuna-files-modal-titlebar-tools {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.4rem;
  }

  .open-tuna-files-modal-titlebar-tools .open-tuna-btn.secondary,
  .open-tuna-files-modal-titlebar .open-tuna-files-modal-close-btn.open-tuna-btn.secondary {
    width: 100%;
    padding: 0.44rem 0.4rem;
    font-size: 0.72rem;
    line-height: 1.2;
  }

  .open-tuna-files-modal-card #openTunaFilesCard .otfm-scroll {
    padding-top: 0.95rem;
    padding-left: 0.78rem;
    padding-right: 0.78rem;
    padding-bottom: 0.7rem;
  }

  .open-tuna-files-modal-card #openTunaFilesCard .otfm-meta {
    padding: 0.55rem 0.78rem 0.12rem;
  }

  .open-tuna-files-meta-pill {
    width: 100%;
    justify-content: flex-start;
    border-radius: 14px;
  }

  .otfm-main {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.95rem;
  }

  .otfm-col--files,
  .otfm-col--side {
    padding-right: 0;
  }

  #openTunaFilesCard .open-tuna-files-list-wrapper.is-empty-state {
    min-height: min(18vh, 132px);
  }

  #openTunaFilesCard .open-tuna-files-list {
    max-height: min(34vh, 220px);
  }

  .open-tuna-files-modal-card .otfm-card {
    padding: 0.72rem 0.74rem;
  }

  .open-tuna-files-modal-card #openTunaFilesUploadForm {
    max-height: none;
  }

  .open-tuna-files-modal-card #openTunaFilesUploadForm .otfm-card-body,
  .open-tuna-files-modal-card #openTunaFilesUploadForm .otfm-session-box {
    overflow: visible;
  }

  .open-tuna-files-modal-card #openTunaFilesUploadForm .otfm-session-json {
    min-height: 6.5rem;
    max-height: none;
    height: 8.5rem;
    resize: vertical;
  }

  .otfm-card-foot {
    position: static;
  }
}

@media (max-width: 640px) and (max-height: 520px) {
  .otfm-col--side > .otfm-card:last-of-type {
    max-height: min(32vh, 200px);
  }
}

/* 暗色模式下提升对比度 */
.open-tuna-page[data-theme='dark'] .open-tuna-files-modal-card {
  --otfm-bg: #0a101c;
  --otfm-list-bg: rgba(15, 23, 42, 0.55);
  --otfm-surface: rgba(255, 255, 255, 0.045);
  --otfm-surface-item: rgba(255, 255, 255, 0.07);
  --otfm-border: rgba(148, 163, 184, 0.32);
  --otfm-input: rgba(12, 18, 30, 0.92);
  --otfm-text: #e5e7eb;
  --otfm-text-muted: rgba(229, 231, 235, 0.72);
  --otfm-titlebar: #0c121f;
  --otfm-primary: #4299e1;
  --otfm-primary-hover: #63b3ed;

  background: var(--otfm-bg);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.open-tuna-page[data-theme='dark'] .open-tuna-files-modal-card #openTunaFilesCard.otfm {
  background: var(--otfm-bg);
}

/* 等待回复时的基础三点动画 */
.open-tuna-pending-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 6px;
  vertical-align: middle;
}

.open-tuna-pending-dots.only-dots {
  margin-left: 0;
}

.open-tuna-pending-dots span {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: open-tuna-dot 1.4s ease-in-out infinite both;
}

.open-tuna-pending-dots span:nth-child(1) { animation-delay: 0s; }
.open-tuna-pending-dots span:nth-child(2) { animation-delay: 0.2s; }
.open-tuna-pending-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes open-tuna-dot {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}
