:root {
  color-scheme: light;
  --navy: #142833;
  --navy-dark: #10222c;
  --navy-line: #2b404b;
  --navy-text: #d9e6eb;
  --navy-muted: #a1b5bf;
  --ink: #102e39;
  --muted: #4e6671;
  --line: #d5e2df;
  --accent: #126c60;
  --accent-dark: #09554b;
  --cream: #f7faf8;
  --thread: #eaf2ef;
  --green: #dcefe6;
  --red: #963e35;
  font-family: "DM Sans", system-ui, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  color: var(--ink);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--cream); }
button, input, select { font: inherit; }
button, .button { cursor: pointer; }
button:disabled { cursor: default; opacity: .52; }
:focus-visible { outline: 2px solid #2aa995; outline-offset: 3px; }
input[type="checkbox"] { accent-color: var(--accent); flex: none; width: 18px; height: 18px; margin: 0; }
h1, h2, h3, p { margin: 0; }
.app { display: grid; grid-template-columns: 318px minmax(0, 1fr); height: 100vh; height: 100dvh; }
.sidebar { display: flex; flex-direction: column; min-height: 0; background: var(--navy); color: var(--navy-text); }
.brand { display: flex; align-items: center; gap: 13px; padding: 24px 19px 19px; }
.brand h1 { font-size: 19px; font-weight: 760; letter-spacing: -.02em; }
.brand p { font-size: 12px; color: var(--navy-muted); margin-top: 4px; }
.brand-mark { display: grid; width: 42px; height: 42px; flex: none; place-items: center; border-radius: 14px; background: #ade8d2; color: #15463d; font-size: 23px; padding-bottom: 2px; }
.icon { border: 0; background: transparent; color: inherit; border-radius: 9px; width: 42px; height: 42px; font-size: 24px; flex: none; }
.icon:hover { background: #899d9e2b; }
.refresh { margin-left: auto; color: var(--navy-muted); }
.chat-tools { padding: 0 16px 10px; }
input[type="search"], select { min-width: 0; border: 1px solid var(--line); border-radius: 9px; padding: 9px 10px; color: var(--ink); background: #fff; }
#chatSearch { width: 100%; border-color: var(--navy-line); background: var(--navy-dark); color: var(--navy-text); }
#chatSearch::placeholder { color: var(--navy-muted); }
.chat-filters { display: flex; gap: 6px; margin-top: 10px; }
.chat-filters button { border: 0; color: var(--navy-text); background: transparent; border-radius: 7px; padding: 7px 10px; font-size: 13px; }
.chat-filters button:hover { background: var(--navy-line); }
.chat-filters button[aria-pressed="true"] { background: #294b4d; color: #c8f4e2; font-weight: 660; }
.chat-list { padding: 0 9px 10px; min-height: 0; flex: 1; overflow-y: auto; scrollbar-color: #45606a transparent; }
.sidebar-empty { padding: 20px 14px; color: var(--navy-muted); line-height: 1.5; }
.chat-row { width: 100%; display: flex; align-items: center; text-align: left; gap: 11px; border: 1px solid transparent; background: transparent; color: inherit; padding: 10px 9px; border-radius: 10px; }
.chat-row:hover { background: #213b46; }
.chat-row[aria-current="true"] { color: #fff; background: #264753; border-color: #426471; }
.avatar { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 50%; font-size: 15px; font-weight: 700; background: #cae8df; color: #18574e; }
.avatar.tone-1 { background: #cbdcf1; color: #1a4a6a; }
.avatar.tone-2 { background: #f3d9c8; color: #744429; }
.avatar.tone-3 { background: #e2d9f2; color: #563a70; }
.avatar.tone-4 { background: #e9e3bc; color: #665616; }
.avatar.tone-5 { background: #d2e9c6; color: #3b5b25; }
.chat-copy { flex: 1; min-width: 0; }
.chat-name, .chat-kind, .topbar-title h2, .topbar-title p { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.chat-name { font-size: 14px; font-weight: 650; }
.chat-kind { color: var(--navy-muted); font-size: 12px; margin-top: 4px; }
.chat-picked, .queue-count { background: #b6e9d7; color: #153b33; border-radius: 9px; padding: 2px 6px; font-size: 11px; font-weight: 700; flex: none; }
.sidebar-footer { display: grid; grid-template-columns: 1.23fr 1fr; gap: 6px; border-top: 1px solid var(--navy-line); padding: 12px 12px max(12px, env(safe-area-inset-bottom)); }
.sidebar-footer button { border: 1px solid #3b515d; background: transparent; color: var(--navy-text); padding: 9px 6px; border-radius: 9px; font-size: 12px; }
.sidebar-footer button:hover, .sidebar-footer button[aria-current="true"] { background: #264753; color: white; }
.queue-count { margin-left: 3px; }
.workspace { min-width: 0; min-height: 0; background: var(--thread); }
.welcome { height: 100%; display: flex; align-items: center; justify-content: center; flex-direction: column; text-align: center; padding: 22px; }
.welcome-icon { display: flex; flex-direction: column; justify-content: center; gap: 6px; width: 62px; height: 56px; margin-bottom: 18px; border: 1px solid #b8d3cc; background: #d7e9e3; border-radius: 18px 18px 18px 5px; padding: 14px; }
.welcome-icon span { height: 3px; background: #458477; border-radius: 3px; }
.welcome-icon span:nth-child(2) { width: 74%; }
.welcome-icon span:nth-child(3) { width: 55%; }
.welcome h2 { font-size: 24px; margin-bottom: 9px; }
.welcome p { color: var(--muted); line-height: 1.7; }
.thread, .queue { display: flex; flex-direction: column; height: 100%; }
.topbar { min-height: 75px; display: flex; align-items: center; gap: 12px; padding: 11px 24px; background: var(--cream); border-bottom: 1px solid var(--line); }
.topbar-title { flex: 1; min-width: 0; }
.topbar-title h2 { font-size: 19px; line-height: 1.34; }
.topbar-title p { color: var(--muted); font-size: 12px; margin-top: 4px; }
.back { display: none; margin-left: -9px; }
.button { display: inline-flex; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: 8px; color: inherit; font-weight: 650; text-decoration: none; padding: 9px 13px; line-height: 1.35; font-size: 13px; white-space: nowrap; }
.primary { color: white; background: var(--accent); }
.primary:hover:not(:disabled) { background: var(--accent-dark); }
.secondary { background: #fff; border-color: #c4d7d1; color: var(--accent-dark); }
.secondary:hover:not(:disabled), .quiet:hover:not(:disabled) { background: #e2eee9; }
.quiet { background: transparent; color: var(--accent-dark); }
.thread-tools { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px 18px; padding: 8px 24px; background: var(--cream); border-bottom: 1px solid var(--line); }
.segments { display: flex; padding: 3px; gap: 3px; background: #e8f0ee; border-radius: 9px; }
.segments button { border: 0; border-radius: 6px; color: var(--muted); background: transparent; padding: 7px 12px; font-size: 13px; font-weight: 650; }
.segments button[aria-pressed="true"] { background: #fff; color: var(--accent-dark); box-shadow: 0 1px 3px #1d42381c; }
.message-search { display: flex; flex: 0 1 285px; gap: 4px; min-width: 0; }
.message-search input { flex: 1; width: 0; padding-block: 6px; font-size: 13px; }
.timeline { flex: 1; min-height: 0; overflow: auto; overflow-anchor: none; overscroll-behavior: contain; scrollbar-color: #a9bfb8 transparent; }
.message-area { width: min(100%, 870px); margin-inline: auto; padding: 15px 24px 18px; }
.message-list { display: grid; gap: 9px; }
.more-row { display: flex; justify-content: center; margin-bottom: 10px; }
.more-row .button, .date-label { border-radius: 20px; background: #d9e8e2; color: #3c5a56; }
.more-row .button:hover:not(:disabled) { background: #cee1d9; }
.timeline-state { color: var(--muted); text-align: center; padding: 18px 8px; line-height: 1.6; }
.date-label { justify-self: center; font-size: 12px; padding: 4px 10px; margin: 5px 0 2px; }
.msg { max-width: min(85%, 540px); min-width: 0; justify-self: start; border: 1px solid #d4e4de; border-radius: 4px 14px 14px 14px; background: #fff; padding: 9px 11px 7px; box-shadow: 0 1px 2px #16362e0b; }
.msg.out { justify-self: end; background: var(--green); border-radius: 14px 4px 14px 14px; }
.msg .sender { color: var(--accent-dark); font-size: 12px; font-weight: 680; margin-bottom: 4px; }
.msg .message-text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.46; }
.msg .stamp { font-size: 11px; text-align: right; color: var(--muted); margin-top: 4px; }
.file-card { display: flex; align-items: center; gap: 10px; color: var(--ink); padding: 8px 9px; margin-top: 6px; border: 1px solid #cbded8; border-radius: 9px; background: #f7faf9; }
.file-card:has(input:not(:disabled)) { cursor: pointer; }
.file-card:has(input:checked) { border-color: #478d7f; background: #e1f3ea; }
.file-card:has(input:not(:disabled)):hover { border-color: #478d7f; }
.file-list-row { max-width: min(100%, 660px); width: 100%; justify-self: center; margin: 0; background: white; }
.file-art { display: grid; width: 46px; height: 42px; flex: none; place-items: center; overflow: hidden; border-radius: 7px; color: var(--accent-dark); background: #dceee8; font-size: 10px; font-weight: 750; }
.file-art.has-thumb img { width: 100%; height: 100%; object-fit: cover; }
.file-art.video { background: #e5e1f2; color: #563f75; }
.file-art.audio { background: #d8e8f4; color: #244d6c; }
.file-copy { flex: 1; min-width: 100px; }
.file-copy strong { display: block; font-size: 13px; font-weight: 680; overflow-wrap: anywhere; }
.file-copy small { display: block; color: var(--muted); font-size: 11px; line-height: 1.4; margin-top: 3px; }
.file-card .state { font-size: 11px; padding: 3px 6px; max-width: 9em; text-align: center; white-space: normal; }
.state { background: #e9efed; border-radius: 6px; padding: 5px 8px; color: #36525b; white-space: nowrap; font-size: 12px; }
.state[data-state="uploaded"], .state[data-state="done"] { background: #d9eee1; color: #1c5e4b; }
.state[data-state="failed"], .state[data-state="retry"] { background: #f6e6e2; color: var(--red); }
.selection-bar { background: var(--cream); border-top: 1px solid var(--line); padding: 11px 24px max(11px, env(safe-area-inset-bottom)); display: flex; align-items: center; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; }
.selection-info { min-width: 130px; flex: 1; font-size: 13px; }
.selection-feedback { display: block; font-size: 12px; color: var(--muted); }
.selection-feedback:not(:empty) { margin-top: 3px; }
.selection-actions { display: flex; gap: 4px; flex-wrap: wrap; }
.queue-content { flex: 1; min-height: 0; overflow: auto; padding: 24px; }
.queue-stats, .queue-section { width: min(100%, 900px); margin: 0 auto 18px; }
.queue-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.queue-stats div { border: 1px solid var(--line); padding: 13px 15px; border-radius: 11px; background: #fff; }
.queue-stats strong, .queue-stats span { display: block; }
.queue-stats strong { font-size: 23px; color: var(--accent-dark); }
.queue-stats span { font-size: 12px; color: var(--muted); margin-top: 4px; }
.queue-section { padding: 15px; border: 1px solid var(--line); background: #fff; border-radius: 11px; }
.queue-section h3 { font-size: 15px; padding-bottom: 8px; }
.section-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.task-row { display: flex; align-items: flex-start; flex-wrap: wrap; gap: 8px; padding: 11px 0; border-top: 1px solid #edf2ef; }
.task-copy { min-width: 170px; flex: 1; overflow-wrap: anywhere; }
.task-copy strong { font-size: 13px; }
.task-copy small, .queue-empty { display: block; font-size: 12px; color: var(--muted); line-height: 1.5; }
.task-copy .queue-error { color: var(--red); }
.task-row .button { padding: 5px 8px; font-size: 12px; }
dialog { color: var(--ink); width: min(560px, calc(100% - 28px)); max-height: min(740px, calc(100dvh - 26px)); border: 1px solid var(--line); border-radius: 16px; background: var(--cream); padding: 0; box-shadow: 0 24px 90px #0a282e55; }
dialog::backdrop { background: #0c243288; }
#batchForm { display: grid; grid-template-rows: auto auto minmax(80px, 1fr) auto auto; max-height: min(730px, calc(100dvh - 28px)); }
.dialog-heading, .batch-controls, .batch-scope, .dialog-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 16px; }
.dialog-heading { padding-top: 15px; }
.dialog-heading h2 { font-size: 19px; margin-bottom: 5px; }
.dialog-heading p { color: var(--muted); font-size: 13px; }
.batch-controls input { flex: 1; }
.batch-list { min-height: 80px; overflow-y: auto; padding: 0 16px; }
.batch-row { display: flex; gap: 10px; align-items: center; padding: 8px 4px; cursor: pointer; border-top: 1px solid #e0eae6; }
.batch-row .avatar { width: 32px; height: 32px; font-size: 13px; }
.batch-row .chat-kind { color: var(--muted); }
.batch-scope { justify-content: flex-start; font-size: 13px; }
.dialog-footer { border-top: 1px solid var(--line); font-size: 13px; }
@media (max-width: 850px) {
  .app { grid-template-columns: 265px minmax(0, 1fr); }
  .topbar, .thread-tools, .selection-bar { padding-inline: 14px; }
  .message-area, .queue-content { padding-inline: 14px; }
  .chat-tools { padding-inline: 12px; }
}
@media (max-width: 660px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .app[data-page="list"] .workspace, .app:not([data-page="list"]) .sidebar { display: none; }
  .sidebar-footer button { min-height: 42px; }
  .back { display: block; }
  .topbar { min-height: 63px; gap: 7px; }
  .topbar-title h2 { font-size: 17px; }
  .topbar .avatar { width: 34px; height: 34px; font-size: 13px; }
  .thread-tools { gap: 6px 9px; }
  .message-search { flex: 1 1 155px; }
  .selection-actions { width: 100%; justify-content: space-between; }
  .selection-actions .button { padding-inline: 8px; }
  .selection-actions .primary { padding-inline: 12px; }
  .msg { max-width: 93%; }
  .queue-stats { gap: 5px; }
  .queue-stats div { padding: 10px 8px; }
}

.brand form { margin-left: -9px; }
.sign-out { color: var(--navy-muted); font-size: 20px; }
.sidebar-footer { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.thread-tools > .select-all { margin-right: auto; }
.state[data-state="saved"] { background: #d9eee1; color: #1c5e4b; }
.archive-list:empty { display: none; }
.archive-list .task-row:first-child { border-top: 0; }
.archive-list .task-row { align-items: center; }
.archive-actions { display: flex; flex-wrap: wrap; gap: 5px; }
.archive-actions .archive-trash { color: var(--red); }
.archive-list .queue-empty { padding: 12px 2px; }
.login-page { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; background: var(--thread); padding: 18px; }
.login-card { width: min(100%, 370px); padding: 28px; border: 1px solid var(--line); border-radius: 16px; background: #fff; box-shadow: 0 12px 30px #1d42381a; }
.login-card h1 { font-size: 23px; margin: 14px 0 18px; }
.login-card form { display: grid; gap: 9px; }
.login-card form input { width: 100%; border: 1px solid #becfc9; background: var(--cream); border-radius: 8px; padding: 10px; }
.login-card button { justify-self: start; min-width: 98px; }
.login-error { color: var(--red); font-size: 13px; }
.login-error:empty { display: none; }
@media (max-width: 660px) {
  .archive-actions { width: 100%; }
  .thread-tools > .message-search { flex-basis: 100%; }
}
