:root {
  color-scheme: light;
  font: 100%/1.55 Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: #20251f;
  background: #f5f6f3;
  --ink: #20251f;
  --muted: #626b61;
  --line: #d8ded6;
  --surface: #f5f7f3;
  --accent: #9c4026;
  --mono: "IBM Plex Mono", Consolas, monospace;
}
*, *::before, *::after { box-sizing: border-box; }
body, h1, h2, p, dl, dd, pre { margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; }
button, summary, select { cursor: pointer; }
button { border: 0; background: transparent; }
button:disabled, input:disabled, select:disabled { cursor: default; opacity: .55; }
a { color: inherit; text-underline-offset: 4px; }
[hidden] { display: none !important; }
:focus-visible, .drop:focus-within, .slot-pick:focus-within { outline: 3px solid #bc5938; outline-offset: 2px; }
small { color: var(--muted); font-size: .8125rem; }
header { background: white; border-bottom: 1px solid var(--line); }
.bar, main { width: min(1176px, calc(100% - 64px)); margin-inline: auto; }
.bar, .brand, .bar nav, .section-head, .field-head, .monitor-head, .readout, .actions, .dialogtitle, .adminactions {
  display: flex; align-items: center; gap: 12px;
}
.bar { min-height: 60px; justify-content: space-between; }
.brand { gap: 9px; text-decoration: none; font-size: 1.2rem; }
.brand img { width: 30px; height: 30px; }
.bar nav { align-self: stretch; gap: 20px; }
.bar nav :is(button,a) {
  display: inline-flex; align-items: center; padding: 0 3px; border-block: 2px solid transparent;
  font-size: .9375rem; color: var(--muted); text-decoration: none;
}
.bar nav [aria-current] { color: var(--ink); font-weight: 650; border-bottom-color: #cd643e; }
main { padding-block: clamp(22px, 4vw, 48px) 48px; }
.heading { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 16px; margin-bottom: 20px; }
h1 { font-size: clamp(1.6rem, 3vw, 2.45rem); line-height: 1.2; letter-spacing: -.035em; }
.heading p { font-size: .9375rem; color: var(--muted); }
h2 { font-size: 1.125rem; line-height: 1.35; font-weight: 670; }
.layout { display: grid; grid-template-columns: minmax(0, 1.06fr) minmax(0, 1fr); align-items: start; gap: 22px; }
.panel, dialog, .job, .empty { min-width: 0; border: 1px solid var(--line); border-radius: 13px; background: white; }
.editor, dialog { padding: clamp(18px, 2.5vw, 30px); }
.section-head, .field-head, .dialogtitle, .readout { justify-content: space-between; }
.section-head { flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.field-head { flex-wrap: wrap; gap: 0 12px; min-height: 40px; }
label, .field-head label { font-size: .9375rem; font-weight: 600; }
.format { display: flex; padding: 3px; background: #eef1eb; border-radius: 8px; }
.format button { padding: 5px 12px; border-radius: 6px; color: var(--muted); font-size: .875rem; }
.format button[aria-pressed="true"] { color: var(--ink); background: white; box-shadow: 0 1px 3px #20251f24; font-weight: 650; }
textarea, select, #secretInput {
  width: 100%; min-width: 0; border: 1px solid #cbd2c8; border-radius: 8px; background: #fff; font-size: 1rem;
}
textarea { display: block; padding: 11px 13px; resize: vertical; line-height: 1.6; }
textarea::placeholder, input::placeholder { color: #687266; opacity: 1; }
#section-summary, #prompt { background: #fafbf9; }
.textbtn { padding: 7px 3px; color: var(--accent); font-size: .875rem; }
.textbtn:hover, .bar a:hover, .bar button:hover { text-decoration: underline; text-underline-offset: 4px; }
.form-group { margin-top: 16px; padding-top: 17px; border-top: 1px solid var(--line); }
summary { list-style: none; }
summary::-webkit-details-marker { display: none; }
.fold > summary, .compiled > summary, .monitor-head { display: flex; align-items: center; gap: 9px; min-height: 42px; }
.fold > summary::after, .compiled > summary::after, .monitor-head::after {
  content: ""; width: 7px; height: 7px; border: solid currentColor; border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg); margin: -3px 4px 0 auto; flex: none;
}
details[open] > summary::after { transform: rotate(225deg); margin-top: 3px; }
.fold { border-bottom: 1px solid #e7eae4; }
.fold > summary { font-size: .9375rem; font-weight: 550; }
#sections > .fold { margin-top: 8px; }
.fold textarea { margin-bottom: 10px; }
#extraSections { padding-inline-start: 12px; margin: 0 0 8px 3px; border-inline-start: 2px solid var(--line); }
#extraSections .fold:last-child { border: 0; }
.compiled { color: var(--muted); font-size: .875rem; }
.compiled > summary { justify-content: flex-start; }
.compiled > summary::after { margin-left: 0; width: 6px; height: 6px; }
.compiled pre { padding: 12px; background: var(--surface); border-radius: 7px; font: .875rem/1.55 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 16rem; overflow-y: auto; }
.asset-grid, .settings { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; }
.drop, .slot-pick { position: relative; border: 1px solid #bcc7b8; border-radius: 7px; cursor: pointer; }
.drop { display: flex; flex-wrap: wrap; gap: 2px 6px; align-items: center; justify-content: center; min-height: 48px; padding: 5px 3px; }
.drop::before { content: "+"; color: var(--accent); font-weight: 500; font-size: 1.1rem; }
.drop:hover, .slot-pick:hover { background: var(--surface); border-color: #81907d; }
.drop small { font: .75rem/1.4 var(--mono); white-space: nowrap; }
.drop:has(input:disabled), .drop input:disabled { cursor: not-allowed; }
.drop:has(input:disabled) { color: var(--muted); background: var(--surface); border-style: dashed; }
#audioNotice { margin: 8px 0 0; font-size: .875rem; color: var(--muted); }
.drop input, .slot-pick input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
#thumbs:not(:empty) { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.thumb { display: grid; gap: 3px; justify-items: center; }
.thumb img, .subject-upload img { width: 48px; height: 48px; object-fit: cover; border-radius: 5px; }
.thumb button { font-size: .8125rem; }
.asset-list > div, .subject-upload { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 5px 0; border-bottom: 1px solid var(--line); }
.asset-list span, .subject-upload > div, .job div { min-width: 0; overflow-wrap: anywhere; }
.asset-list button { flex-shrink: 0; }
.subject-upload { flex-wrap: wrap; font-size: .875rem; }
.subject-upload > div { flex: 1 1 100px; }
.subject-upload b, .subject-upload small { display: block; }
.slot-pick { display: inline-grid; align-items: center; min-height: 36px; padding: 4px 9px; font-size: .875rem; }
#mobileSubjects:not(:empty) { margin-block: 8px; }
.mentions { display: grid; gap: 3px; padding: 4px; border: 1px solid var(--line); border-radius: 7px; max-height: 180px; overflow-y: auto; }
.mentions button { text-align: left; padding: 8px; overflow-wrap: anywhere; }
.mentions button:is(:hover,:focus-visible) { background: var(--surface); }
.settings select {
  display: block; appearance: none; margin-top: 5px; min-height: 44px; padding: 7px 23px 7px 9px;
  background: white url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='m1 1 4 4 4-4' fill='none' stroke='%23566054' stroke-width='1.4'/%3E%3C/svg%3E") right 8px center/10px no-repeat;
}
.primary, .secondary { padding: 9px 18px; min-height: 44px; border-radius: 8px; font-weight: 650; }
.primary { background: #253027; color: white; }
.primary:hover:enabled { background: #394b3c; }
.secondary { background: #eef1eb; }
.secondary:hover:enabled { background: #e0e6dc; }
#generate { width: 100%; margin-top: 18px; }
#message:not(:empty), #feedback:not(:empty) { margin-top: 10px; color: var(--accent); overflow-wrap: anywhere; }
.monitor { overflow: clip; position: sticky; top: 20px; }
.monitor-head { padding: 14px 18px; font-weight: 650; }
.monitor-head small { margin-left: auto; font-weight: 400; }
.monitor-head::after { margin-left: 0; }
.screen { aspect-ratio: 16/10; position: relative; background: #161c18; }
.screen img, .screen video { display: block; width: 100%; height: 100%; object-fit: cover; }
.screen video, .screen .reference { object-fit: contain; }
.readout { padding: 11px 18px; color: var(--muted); font-size: .875rem; font-variant-numeric: tabular-nums; }
#length { font-family: var(--mono); }
#jobProgress { position: absolute; inset: 0; display: grid; place-content: center; padding: 18px; text-align: center; color: white; pointer-events: none; }
.screen:has(video:not([hidden])) #jobProgress { display: none; }
#original { display: block; padding: 0 18px 14px; color: var(--accent); }
dialog { color: var(--ink); width: min(460px, calc(100% - 24px)); max-height: calc(100dvh - 32px); overflow-y: auto; }
dialog::backdrop { background: #18211abb; }
.close { min-width: 40px; min-height: 40px; font-size: 1.6rem; }
#summary, #confirmSubjects p { margin-block: 8px; color: var(--muted); overflow-wrap: anywhere; }
.actions { justify-content: end; flex-wrap: wrap; padding-top: 14px; border-top: 1px solid var(--line); }
.job, .empty { padding: 16px 20px; margin-block: 10px; }
.job { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.job small, .job strong { display: block; }
.job strong { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.job button { flex-shrink: 0; }
.empty { color: var(--muted); }
.adminmain { max-width: 940px; }
.authmain { max-width: 420px; padding-top: clamp(32px,10vh,104px); }
.authcard h1 { font-size: 1.6rem; margin-bottom: 8px; }
#loginForm, .accountform { display: grid; gap: 8px; margin-top: 20px; }
#loginForm input, .accountform input { width: 100%; padding: 10px 12px; border: 1px solid #cbd2c8; border-radius: 8px; background: white; }
#loginForm input[readonly] { color: var(--muted); background: var(--surface); }
#repeatField input { margin-top: 6px; }
#loginForm button { margin-top: 8px; }
.accountform button { justify-self: start; }
#inviteLabel { margin-top: 10px; }
#inviteUrl { display: block; width: 100%; margin-top: 6px; padding: 8px; user-select: all; }
#membersList { list-style: none; padding: 0; }
#membersList li { display: flex; align-items: center; justify-content: space-between; gap: 8px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
#membersList button { flex-shrink: 0; }
#memberStatus:not(:empty), #loginStatus:not(:empty) { margin-top: 10px; color: var(--accent); }
.adminhint, #connectionStatus { color: var(--muted); font-size: .9rem; overflow-wrap: anywhere; }
#settings, .quotes { margin-block: 16px; }
#secretInput { margin-block: 6px; padding: 10px 12px; }
#save { margin-top: 16px; }
.adminactions { flex-wrap: wrap; padding-top: 14px; border-top: 1px solid var(--line); }
.quotes dt { font-size: .875rem; color: var(--muted); }
.quotes dd { margin: 4px 0 14px; padding-bottom: 14px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
@media (max-width: 799px), (max-width: 900px) and (orientation: portrait) {
  .bar, main { width: min(680px, calc(100% - 32px)); }
  .layout { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .monitor { position: static; }
  .screen { aspect-ratio: 16/9; }
  .bar { min-height: 54px; }
  .heading { margin-bottom: 16px; }
  .format button, .textbtn, .slot-pick, .thumb button, .mentions button { min-height: 44px; }
  .fold > summary, .compiled > summary { min-height: 44px; }
  .adminmain #save { width: 100%; }
}
@media (max-width: 500px) {
  .bar, main { width: calc(100% - 24px); }
  .heading { display: grid; gap: 3px; }
  .heading p { font-size: .875rem; }
  .editor, dialog { padding: 16px; }
  .section-head { margin-bottom: 6px; }
  .form-group { margin-top: 12px; padding-top: 13px; }
  .format button { padding-inline: 8px; }
  .asset-grid, .settings { gap: 6px; }
  .drop { column-gap: 3px; }
  .drop small { flex-basis: 100%; text-align: center; }
  .job { align-items: flex-start; flex-direction: column; }
  .settings select { padding-left: 6px; padding-right: 19px; background-position: right 5px center; }
}
@media (max-width: 360px) {
  .bar, main { width: calc(100% - 16px); }
  .editor { padding: 12px; }
  .brand { gap: 6px; }
  .bar nav { gap: 12px; }
}

.mobile-only { display: none; }
.subject-pick { display: none; }
@media (max-width: 799px), (max-width: 900px) and (orientation: portrait) {
  #editorTab[aria-current="page"] { display: none; }
  #workspace { max-width: 32rem; margin: 0 auto; }
  #workspace .heading { margin: 4px 5px 18px; }
  #workspace .heading h1 { font-size: 1.65rem; }
  #workspace .heading p { margin-top: 3px; font-size: .8125rem; }
  #workspace .editor { padding: 16px; border-radius: 12px; }
  #editor .mobile-only { display: block; }
  #editor .mobile-caption { margin-bottom: 8px; }
  #editor .mobile-caption label { font-weight: 650; }
  #editor:not([data-panel="details"]) > .section-head,
  #editor:not([data-panel="details"]) .field-head,
  #editor:not([data-panel="details"]) #sections > details,
  #editor:not([data-panel="details"]) #morePrompt,
  #editor:not([data-panel="details"]) #splitPrompt,
  #editor[data-panel="details"] .mobile-caption,
  #editor:not([data-panel="output"]) #outputPanel,
  #workspace .monitor:not(:has(.reference, #jobProgress:not([hidden]))) { display: none; }
  #editor:not([data-panel="details"]) :is(#prompt,#section-summary) {
    min-height: 8rem; padding: 12px; background: #f7f8f5; resize: vertical;
  }
  #editor .mobile-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 7px; }
  .mobile-tools button {
    display: inline-flex; align-items: center; justify-content: center; gap: 3px;
    min-height: 44px; padding: 4px 7px; border-radius: 7px; color: var(--muted); font-size: .875rem;
  }
  .mobile-tools button:first-child { margin-left: -4px; }
  .mobile-tools button:last-child { margin-left: auto; gap: 7px; }
  .mobile-tools button[aria-expanded="true"] { background: var(--surface); color: var(--ink); }
  .mobile-tools .chevron { width: 7px; height: 7px; margin-top: -3px; transform: rotate(45deg); border: solid currentColor; border-width: 0 1.5px 1.5px 0; }
  .mobile-tools [aria-expanded="true"] .chevron { transform: rotate(225deg); margin-top: 3px; }
  #assetPanel { margin: 12px 0 0; padding: 0; border: 0; }
  #outputPanel { margin: 6px 0 12px; padding-top: 12px; }
  #assetPanel .asset-grid, #editor #mobileSubjects:not(:empty), #thumbs:not(:empty) {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px;
  }
  #assetPanel .drop, .subject-pick { min-height: 48px; font-size: .9375rem; }
  #assetPanel .drop small { flex-basis: auto; }
  .subject-pick {
    display: flex; align-items: center; justify-content: center; gap: 4px;
    border: 1px solid #bcc7b8; border-radius: 7px; font-weight: 600;
  }
  .subject-pick::before { content: "+"; color: var(--accent); font-size: 1.1rem; font-weight: 500; }
  .subject-pick:hover { background: var(--surface); border-color: #81907d; }
  #mobileSubjects:not(:empty) { margin-top: 10px; }
  #mobileSubjects .subject-upload { min-width: 0; align-content: start; padding: 8px; border: 1px solid var(--line); border-radius: 7px; }
  #mobileSubjects .subject-upload > div { flex-basis: 100%; }
  #mobileSubjects .slot-pick { flex: 1 1 auto; text-align: center; }
  #generate { margin-top: 8px; min-height: 46px; }
}
