/* Layout fixes for the existing ceramic / graphite theme. */
.btn {
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  text-align: center;
}
.chip, .user-avatar, .logo-mark, .question-num {
  flex-shrink: 0;
}
.chip {
  white-space: nowrap;
}
.card-title {
  align-items: flex-start;
  flex-wrap: wrap;
}
.card-title > *, .list-main, .version-main, .message > div {
  min-width: 0;
}
.list-main, .version-main, .source-tag {
  overflow-wrap: anywhere;
}
.list-main h4:has(> .icon) {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.list-main h4 > .icon {
  margin-top: 3px;
}
.voice-tile > .row {
  align-items: flex-start;
}
.voice-tile .row > strong {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}
.grid > .field {
  margin-bottom: 0;
}
.asset-grid > .empty {
  grid-column: 1 / -1;
}
.asset-tile {
  display: flex;
  flex-direction: column;
}
.asset-tile > .btn:first-of-type {
  margin-top: auto;
}
.asset-tile img {
  margin-bottom: 8px;
}
.asset-tile .btn {
  flex-shrink: 0;
}
.asset-tile.selected {
  border-width: 1px;
  box-shadow: inset 0 0 0 1px #334a58;
}

/* Keep the account name from consuming the top navigation. */
.topbar #account {
  min-width: 0;
  max-width: 40%;
}
#profile-label {
  display: block;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.top-label {
  min-width: 0;
}
.sidebar {
  overflow-y: auto;
}
.sidebar .logo > div {
  min-width: 0;
}
.landing-main .mobile-menu {
  display: none;
}

/* The older welcome screen grid must not arrange the login hero's text. */
.auth-layout .welcome-hero {
  display: block;
  min-height: 440px;
}
.auth-layout .welcome-hero h1 {
  max-width: 75%;
  font-size: clamp(32px, 4vw, 48px);
}
.auth-layout .welcome-hero p {
  max-width: 55%;
}

/* A real logo image, with its outer whitespace cropped by object-fit. */
.co-brand {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 24px;
  margin-top: 26px;
  padding: 16px 22px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
}
.co-brand img {
  display: block;
  width: min(100%, 440px);
  height: 80px;
  object-fit: cover;
  flex-shrink: 0;
}
.co-brand span {
  flex: 1 1 320px;
  min-width: 0;
  color: var(--text);
  font-size: 13px;
  line-height: 1.8;
}

/* Native radio controls must not inherit full-width text input sizing. */
.q-options label {
  margin: 0;
  font-weight: 400;
}
.q-options input {
  width: 18px;
  height: 18px;
  min-height: 18px;
  flex: 0 0 18px;
  margin: 3px 0 0;
  padding: 0;
}
.q-options label > span {
  flex: 1;
  min-width: 0;
}

/* Give names and avatars their own space in previews and version records. */
.profile-preview {
  --preview-size: 110px;
  display: grid;
  grid-template-columns: var(--preview-size) minmax(0, 1fr);
  gap: 20px;
  align-items: center;
}
.shared-preview .profile-preview {
  --preview-size: 90px;
}
.profile-preview-avatar .avatar-cover {
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  margin: 0;
}
.profile-preview-main {
  min-width: 0;
}
.version {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  align-items: start;
}
.version > .actions {
  grid-column: 2;
  justify-content: flex-start;
}
.version-badge {
  width: 52px;
}

/* Chat actions and community actions keep their place as content grows. */
.chat-header {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
}
.chat-header > div {
  min-width: 0;
}
.chat-header-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}
.community-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
}
.community-card > .row {
  align-items: flex-start;
}
.community-card > .row h3 {
  flex: 1;
  min-width: 0;
}
.community-card > .actions {
  margin-top: auto;
  padding-top: 4px;
}
.modal-top > .btn {
  flex-shrink: 0;
}
.footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
}

@media (max-width: 1200px) {
  .chat-header {
    grid-template-columns: 34px minmax(0, 1fr);
  }
  .chat-header-actions {
    grid-column: 1 / -1;
  }
}
@media (max-width: 1100px) and (min-width: 761px) {
  .hero {
    grid-template-columns: minmax(0, 1fr);
  }
  .hero .hero-art {
    display: none;
  }
}
@media (max-width: 760px) {
  .tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .tab {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    text-align: center;
  }
  .auth-layout .welcome-hero {
    min-height: 0;
    padding-bottom: 0;
  }
  .auth-layout .welcome-hero h1,
  .auth-layout .welcome-hero p {
    max-width: 100%;
  }
  .auth-layout .welcome-hero h1 {
    font-size: clamp(28px, 8.3vw, 36px);
  }
  .auth-layout .welcome-hero img {
    position: static;
    display: block;
    width: 215px;
    height: 215px;
    margin: 16px auto 0;
  }
  .topbar .top-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .topbar #profile-label {
    max-width: 85px;
  }
  .co-brand {
    gap: 8px;
    padding: 12px 16px;
  }
  .co-brand img {
    height: 64px;
  }
  .co-brand span {
    font-size: 12px;
  }
  .chat-header {
    grid-template-columns: 34px minmax(0, 1fr);
  }
  .chat-header-actions {
    grid-column: 1 / -1;
  }
  .version {
    grid-template-columns: 43px minmax(0, 1fr);
  }
  .version-badge {
    width: 43px;
  }
  .profile-preview {
    --preview-size: 80px;
    gap: 16px;
  }
  .footer {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
}
@media (max-width: 380px) {
  .head-actions {
    flex-wrap: wrap;
  }
  .answer-progress {
    flex-wrap: wrap;
  }
  .workflow {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Review iteration: visible focus, explicit state, and readable frozen scopes. */
.file-row { position: relative; }
.file-row .sr-file { width: 1px !important; height: 1px !important; min-height: 1px; padding: 0; }
.file-row:focus-within { outline: 3px solid #79a8bf; outline-offset: 4px; border-radius: 12px; }
.answer-save-status { font-size: 13px; margin-top: 4px; }
.answer-save-status .btn { min-height: 28px; padding: 0 8px; font-size: 13px; }
.publish-readiness { border-top: 1px solid var(--border); padding-top: 20px; margin-top: 24px; }
.publish-readiness p { margin: 8px 0; }
.publication-scope { display: grid; gap: 20px; margin: 24px 0; }
.scope-group { padding: 20px; background: var(--soft); border: 1px solid var(--border); border-radius: 18px; }
.scope-group p { margin: 12px 0; font-size: 14px; }
.scope-group h5 { font-size: 14px; margin: 18px 0 8px; }
.scope-group ul, .impact-summary ul { padding-left: 20px; margin: 12px 0; }
.scope-group li { margin: 10px 0; overflow-wrap: anywhere; }
.scope-group .chip { display: inline-flex; margin-left: 6px; font-size: 12px; }
.release-readable dl { margin: 24px 0; }
.release-readable dt { font-weight: 650; margin-top: 18px; }
.release-readable dd { margin: 8px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.technical-details { border-top: 1px solid var(--border); padding-top: 18px; }
.technical-details summary { cursor: pointer; }
.evaluation-error { background: #fcf2f3; border: 1px solid #edd6db; border-radius: 18px; padding: 20px; margin: 20px 0; }
.evaluation-error p { margin-top: 10px; overflow-wrap: anywhere; }
.training-memories { min-width: 0; }
.training-memories > summary { cursor: pointer; font-weight: 650; margin-bottom: 14px; padding: 12px 16px; border: 1px solid var(--border); border-radius: 12px; }
.auth-mobile-title { display: none; }
.release-test-card { max-width: 980px; }

@media (max-width: 760px) {
  .landing-main #view > .page-head { display: none; }
  .auth-layout { display: flex; flex-direction: column; gap: 24px; }
  .auth-layout > * { width: 100%; }
  .auth-card { order: -1; padding: 24px; }
  .auth-mobile-title { display: block; font-size: 24px; line-height: 1.4; margin-bottom: 20px; }
  .auth-story .auth-info { margin-top: 18px; }
  .chat-focused .main { padding-top: 82px; }
  .chat-focused .page-head { margin-bottom: 12px; }
  .chat-focused .page-head h1 { font-size: 24px; line-height: 1.3; letter-spacing: -.5px; }
  .chat-focused .page-head .eyebrow,
  .chat-focused .page-head .subtitle,
  .chat-focused .page-head .head-actions .chip { display: none; }
  .chat-focused .page-head .head-actions:empty { display: none; }
  .chat-focused .chat-layout { display: block; }
  .chat-focused .chat-card { height: calc(100dvh - 174px); min-height: 340px; display: flex; flex-direction: column; overflow: hidden; }
  .chat-focused .chat-header { flex: 0 0 auto; padding: 12px 14px; gap: 8px; }
  .chat-focused .chat-header p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .chat-focused .chat-header-actions { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 4px; }
  .chat-focused .chat-header-actions .btn { min-height: 40px; padding: 4px 8px; font-size: 13px; }
  .chat-focused .chat-messages { flex: 1 1 0; height: auto; min-height: 0; overflow-y: auto; padding: 14px; }
  .chat-focused .chat-composer { flex: 0 0 auto; padding: 12px 14px max(12px,env(safe-area-inset-bottom)); }
  .chat-focused .chat-composer textarea { height: 64px; min-height: 64px; resize: none; margin-bottom: 8px; }
  .chat-focused .chat-composer .btn { min-height: 44px; }
  .training-memories { margin-top: 16px; }
  .scope-group { padding: 16px; }
  .chat-focused .release-test-card { height: calc(100dvh - 222px); }
}

/* 任务编号：紧跟在任务名称右侧，点击可复制完整编号 */
.job-id {
  margin-left: 8px;
  padding: 2px 6px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.5;
  letter-spacing: .02em;
  opacity: .55;
  vertical-align: middle;
  cursor: pointer;
}
.job-id:hover, .job-id:focus-visible {
  opacity: 1;
  background: rgba(127, 127, 127, .14);
}

/* 资料批量上传：单行拖拽框、待上传队列、按解析状态分组 */
.upload-block { display: grid; gap: 10px; margin-top: 20px; }
.upload-box {
  display: grid;
  gap: 3px;
  padding: 18px 16px;
  border: 1.5px dashed var(--border);
  border-radius: 14px;
  background: var(--soft);
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.upload-box:hover, .upload-box:focus-within { border-color: var(--cyan); }
.upload-box.drag-over { border-color: var(--cyan); background: rgba(94, 179, 197, .12); }
.upload-box-title { font-weight: 600; }
.upload-box-hint { font-size: 12.5px; color: var(--muted); }
.upload-queue { display: grid; gap: 6px; }
.upload-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--soft);
}
.upload-row.failed { border-color: rgba(190, 90, 90, .45); }
.upload-row .upload-main { display: grid; gap: 1px; min-width: 0; flex: 1 1 auto; }
.upload-row .upload-actions { display: flex; align-items: center; gap: 2px; flex: 0 0 auto; }
.upload-row .upload-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.upload-row.uploading .upload-name { opacity: .7; }
.doc-groups { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 18px; align-items: start; }
.doc-failed { display: grid; gap: 4px; margin-bottom: 10px; }
.doc-failed .doc-row { background: #fff8f9; border-color: #f3d6dc; }
.doc-row .icon-btn.doc-retry { width: 26px; height: 26px; border-radius: 8px; color: var(--muted); }
.doc-row .icon-btn.doc-retry:hover { background: #eef2f7; color: var(--text); }
.doc-group { display: grid; gap: 4px; min-width: 0; }
.doc-group-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.doc-group-title h4 { margin: 0; font-size: 13px; }
.doc-group-title .fine { font-size: 11.5px; }
.doc-group-empty { padding: 10px 2px; }
.doc-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--soft);
}
.doc-row-main { flex: 1 1 auto; min-width: 0; display: grid; gap: 0; }
.doc-row-main h4 {
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.4;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.doc-row-main p {
  font-size: 11px;
  line-height: 1.35;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.doc-row-actions { display: flex; align-items: center; gap: 2px; flex: 0 0 auto; }
.doc-meta { font-size: 11px; color: var(--muted); white-space: nowrap; flex: 0 0 auto; }
.doc-row .icon-btn.doc-del { width: 26px; height: 26px; border-radius: 8px; color: var(--danger); }
.doc-row .icon-btn.doc-del:hover { background: #fdecef; }
.switch.small .track { width: 30px; height: 18px; }
.switch.small .track:after { width: 12px; height: 12px; top: 3px; left: 3px; }
.switch.small input:checked + span.track:after { transform: translateX(12px); }
@media (max-width: 900px) { .doc-groups { grid-template-columns: 1fr; } }
