:root {
  color-scheme: light;
  --bg: #eef1f4;
  --surface: #ffffff;
  --surface-soft: #f7f8fa;
  --line: #dfe3e8;
  --line-strong: #c7cdd4;
  --text: #1c232b;
  --muted: #69737d;
  --accent: #087f5b;
  --accent-hover: #076b4d;
  --accent-soft: #e8f5ef;
  --blue: #2b65d9;
  --warning: #9a6700;
  --warning-bg: #fff6d8;
  --danger: #bd2c2c;
  --danger-bg: #fff0ef;
  --shadow: 0 8px 28px rgba(27, 36, 44, 0.08);
  font-family: Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  letter-spacing: 0;
}

.login-screen {
  min-height: 100vh;
  display: none;
  grid-template-rows: auto 1fr auto;
  padding: 28px 32px 20px;
  background: #f3f5f6;
}

body.auth-pending .login-screen,
body.auth-required .login-screen {
  display: grid;
}

body.auth-pending .app-header,
body.auth-pending .workspace,
body.auth-required .app-header,
body.auth-required .workspace {
  display: none;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 11px;
}

.login-brand > div:last-child {
  display: grid;
  gap: 2px;
}

.login-brand strong {
  font-size: 15px;
}

.login-brand span {
  color: var(--muted);
  font-size: 11px;
}

.login-panel {
  width: min(400px, 100%);
  align-self: center;
  justify-self: center;
  display: grid;
  gap: 20px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 12px 36px rgba(27, 36, 44, 0.1);
}

.login-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: var(--accent-soft);
  color: var(--accent);
}

.login-icon svg {
  width: 20px;
  height: 20px;
}

.login-heading h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.25;
}

.login-heading p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 12px;
}

#login-form {
  display: grid;
  gap: 14px;
}

.login-submit {
  width: 100%;
}

.login-error {
  margin: -3px 0 0;
  padding: 9px 10px;
  border: 1px solid #efc2bf;
  border-radius: 5px;
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 11px;
  line-height: 1.45;
}

.login-security {
  margin: -4px 0 0;
}

.login-footer {
  color: #89929b;
  font-size: 10px;
  text-align: center;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button,
select,
label[for] {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
label:focus-visible {
  outline: 3px solid rgba(43, 101, 217, 0.22);
  outline-offset: 1px;
}

.app-header {
  position: relative;
  z-index: 10;
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.97);
}

.brand-block,
.header-actions,
.document-actions,
.quality-summary,
.media-summary,
.dialog-heading,
.dialog-actions {
  display: flex;
  align-items: center;
}

.brand-block {
  min-width: 0;
  gap: 11px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: var(--text);
  color: #fff;
  font-size: 17px;
  font-weight: 750;
}

.brand-block h1,
.panel-heading h2,
.dialog-heading h2 {
  margin: 0;
  font-weight: 700;
}

.brand-block h1 {
  font-size: 16px;
}

.brand-block p {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #19a974;
  box-shadow: 0 0 0 3px rgba(25, 169, 116, 0.12);
}

.header-actions {
  gap: 8px;
}

.button,
.icon-button,
.format-button,
.tab {
  border: 0;
  background: transparent;
  color: inherit;
}

.button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 6px;
  font-weight: 650;
}

.button svg,
.button i,
.security-note svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.button-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.button-primary:hover {
  background: var(--accent-hover);
}

.button-primary:disabled {
  cursor: not-allowed;
  opacity: 0.64;
}

.button-primary.is-loading:disabled {
  cursor: progress;
}

.button-primary.is-loading svg {
  animation: button-spin 900ms linear infinite;
}

@keyframes button-spin {
  to { transform: rotate(360deg); }
}

.button-quiet {
  border: 1px solid var(--line);
  background: var(--surface);
  color: #39434d;
}

.button-quiet:hover,
.icon-button:hover,
.format-button:hover {
  background: #f0f2f5;
}

.icon-button {
  position: relative;
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.icon-button::before {
  content: attr(data-fallback);
  font-size: 18px;
  line-height: 1;
}

.icons-ready .icon-button::before {
  display: none;
}

.icon-button svg {
  width: 17px;
  height: 17px;
}

.icon-button.compact {
  width: 32px;
  height: 32px;
}

.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.workspace {
  height: calc(100vh - 68px);
  display: grid;
  grid-template-columns: minmax(320px, 360px) minmax(460px, 1fr);
  gap: 1px;
  background: var(--line);
}

body.has-douyin-output {
  overflow: auto;
}

.workspace.has-douyin-output {
  height: auto;
  min-height: calc(100vh - 68px);
  grid-template-rows: calc(100vh - 68px) auto;
}

.panel,
.editor-shell {
  min-width: 0;
  min-height: 0;
  background: var(--surface);
}

.panel {
  overflow-y: auto;
  padding: 20px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.eyebrow,
.document-kicker {
  display: block;
  margin-bottom: 4px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 750;
  text-transform: uppercase;
}

.panel-heading h2,
.dialog-heading h2 {
  font-size: 17px;
}

#generation-form {
  display: grid;
  gap: 15px;
}

.field-grid {
  display: grid;
  gap: 10px;
}

.two-columns {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field {
  min-width: 0;
  display: grid;
  gap: 7px;
}

.field > span,
.field-label,
.toggle-row strong {
  color: #424c56;
  font-size: 12px;
  font-style: normal;
  font-weight: 650;
}

.field-help {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
}

.field-help strong {
  color: var(--accent);
}

.douyin-jump-link {
  width: fit-content;
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border: 1px solid #abd7c7;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent-hover);
  font-size: 10px;
  font-weight: 700;
}

.douyin-jump-link:hover {
  border-color: var(--accent);
  background: #dcf0e7;
}

.douyin-jump-link svg {
  width: 14px;
  height: 14px;
}

.field em {
  margin-left: 4px;
  color: var(--danger);
  font-size: 10px;
  font-style: normal;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: #fff;
  color: var(--text);
}

.field input,
.field select {
  min-height: 38px;
  padding: 7px 10px;
}

.field textarea {
  min-height: 72px;
  resize: vertical;
  padding: 9px 10px;
  line-height: 1.55;
}

.field input::placeholder,
.field textarea::placeholder {
  color: #9aa2aa;
}

.field input:hover,
.field select:hover,
.field textarea:hover {
  border-color: #9fa8b2;
}

.media-multiselect {
  position: relative;
}

.media-multiselect-trigger {
  width: 100%;
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: #fff;
  color: var(--text);
  font: inherit;
  text-align: left;
}

.media-multiselect-trigger:hover,
.media-multiselect.open .media-multiselect-trigger {
  border-color: #9fa8b2;
}

.media-multiselect-trigger:focus-visible {
  outline: 3px solid rgba(43, 101, 217, 0.18);
  border-color: var(--accent);
}

.media-multiselect-trigger.has-value {
  color: #173f91;
}

.media-multiselect-trigger > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.media-multiselect-trigger svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  transition: transform 160ms ease;
}

.media-multiselect.open .media-multiselect-trigger svg {
  transform: rotate(180deg);
}

.media-multiselect-menu {
  position: absolute;
  z-index: 30;
  top: calc(100% + 5px);
  left: 0;
  width: 100%;
  max-height: 270px;
  overflow-y: auto;
  padding: 5px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(25, 35, 45, 0.14);
}

.media-option {
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 8px;
  border-radius: 4px;
  color: #38434d;
  cursor: pointer;
}

.media-option:hover {
  background: var(--surface-soft);
}

.media-option input {
  width: 16px;
  min-height: 16px;
  height: 16px;
  margin: 0;
  padding: 0;
  accent-color: var(--accent);
}

.media-option-all {
  margin-bottom: 4px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line);
  border-radius: 4px 4px 0 0;
  font-weight: 650;
}

.upload-field {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
}

.upload-settings-button {
  width: 100%;
}

.toggle-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 3px 12px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.toggle-row > span:first-child {
  display: grid;
  gap: 4px;
}

.toggle-row small {
  color: var(--muted);
  font-size: 11px;
}

.toggle-row input {
  position: relative;
  z-index: 2;
  grid-column: 2;
  grid-row: 1;
  width: 38px;
  height: 22px;
  margin: 0;
  opacity: 0;
}

.toggle {
  position: relative;
  z-index: 1;
  grid-column: 2;
  grid-row: 1;
  width: 38px;
  height: 22px;
  border-radius: 11px;
  background: #bec5cc;
  pointer-events: none;
  transition: background 160ms ease;
}

.toggle::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 160ms ease;
}

.toggle-row input:checked + .toggle {
  background: var(--accent);
}

.toggle-row input:checked + .toggle::after {
  transform: translateX(16px);
}

.toggle-row:has(input:focus-visible) .toggle {
  outline: 3px solid rgba(43, 101, 217, 0.22);
}

.generate-wide {
  width: 100%;
  min-height: 42px;
}

.editor-shell {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.editor-header {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 22px 10px;
  border-bottom: 1px solid var(--line);
}

.document-title-wrap {
  min-width: 0;
  flex: 1;
}

.document-title {
  width: min(100%, 680px);
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 20px;
  font-weight: 730;
  line-height: 1.25;
  text-overflow: ellipsis;
}

.document-title:focus {
  outline: 0;
}

.document-actions {
  gap: 6px;
}

.editor-tabs {
  display: flex;
  align-items: end;
  gap: 4px;
  height: 42px;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
}

.tab {
  position: relative;
  height: 42px;
  padding: 0 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.tab.active {
  color: var(--text);
}

.tab:disabled {
  cursor: not-allowed;
  color: #adb4bb;
}

.tab.active::after {
  content: "";
  position: absolute;
  right: 10px;
  bottom: -1px;
  left: 10px;
  height: 2px;
  background: var(--accent);
}

.format-toolbar {
  height: 44px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.format-button {
  min-width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 7px;
  border-radius: 4px;
  color: #4a5560;
  font-size: 12px;
}

.format-button svg {
  width: 15px;
  height: 15px;
}

.format-button.with-label {
  padding-inline: 9px;
}

.toolbar-divider {
  width: 1px;
  height: 18px;
  margin: 0 4px;
  background: var(--line);
}

.editor-view {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.outline-view {
  overflow-y: auto;
  background: #fafbfc;
}

.outline-empty {
  min-height: 100%;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  padding: 36px;
  text-align: center;
}

.outline-empty-icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
}

.outline-empty-icon svg {
  width: 23px;
  height: 23px;
}

.outline-empty h3 {
  margin: 6px 0 0;
  font-size: 16px;
}

.outline-empty p {
  max-width: 420px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.outline-editor {
  max-width: 840px;
  margin: 0 auto;
  padding: 22px clamp(18px, 4vw, 48px) 46px;
}

.outline-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 11px;
}

.outline-meta strong {
  flex: 0 0 auto;
  color: var(--text);
}

.outline-sections {
  display: grid;
  gap: 10px;
}

.outline-section {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 12px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.outline-number {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 5px;
  background: #edf1f4;
  color: #52606c;
  font-size: 11px;
  font-weight: 750;
}

.outline-section-body {
  min-width: 0;
  display: grid;
  gap: 10px;
}

.outline-section-header {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 30px;
  align-items: center;
  gap: 8px;
}

.outline-heading-input {
  width: 100%;
  padding: 2px 0 7px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: #192128;
  font-size: 15px;
  font-weight: 700;
}

.outline-heading-input:focus {
  outline: 0;
  border-color: var(--accent);
}

.outline-section-delete {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.outline-section-delete:hover:not(:disabled) {
  background: var(--danger-bg);
  color: var(--danger);
}

.outline-section-delete:disabled {
  cursor: not-allowed;
  opacity: 0.32;
}

.outline-section-delete svg {
  width: 16px;
  height: 16px;
}

.outline-add-row {
  display: flex;
  justify-content: center;
  padding-top: 12px;
}

.outline-add-row .button svg {
  width: 15px;
  height: 15px;
}

.outline-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.outline-fields .wide {
  grid-column: 1 / -1;
}

.outline-section .field textarea {
  min-height: 60px;
  font-size: 12px;
  line-height: 1.55;
}

.outline-section .field input[type="number"] {
  min-height: 34px;
}

#article-editor {
  width: 100%;
  height: 100%;
  resize: none;
  border: 0;
  outline: 0;
  padding: 28px clamp(24px, 6vw, 72px) 40px;
  background: var(--surface);
  color: #28313a;
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  font-size: 15px;
  line-height: 1.95;
}

.preview-view,
.json-view {
  overflow-y: auto;
}

.article-preview {
  max-width: 760px;
  margin: 0 auto;
  padding: 28px clamp(24px, 6vw, 72px) 54px;
  color: #2a333c;
  font-size: 15px;
  line-height: 1.95;
}

.article-preview h1,
.article-preview h2,
.article-preview h3 {
  margin: 1.65em 0 0.65em;
  color: #161d24;
  line-height: 1.4;
  font-weight: 700;
}

.article-preview h1 {
  margin-top: 0;
  font-size: 28px;
}

.article-preview h2 {
  font-size: 21px;
}

.article-preview h3 {
  font-size: 17px;
}

.article-preview p {
  margin: 0 0 1.15em;
}

.article-preview blockquote {
  margin: 18px 0;
  padding: 4px 0 4px 16px;
  border-left: 3px solid var(--accent);
  color: #53606b;
}

.article-preview ul {
  padding-left: 22px;
}

.article-preview strong {
  color: #15211d;
}

.article-preview .preview-image {
  margin: 24px 0;
}

.article-preview .preview-image img {
  width: 100%;
  max-height: 460px;
  display: block;
  object-fit: contain;
  border: 1px solid var(--line);
  background: #f4f6f7;
}

.article-preview .preview-image figcaption {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.article-preview .image-slot {
  min-height: 150px;
  display: grid;
  place-items: center;
  margin: 22px 0;
  border: 1px dashed #9da8b2;
  background: #f7f9fa;
  color: var(--muted);
  font-size: 12px;
}

.json-view pre {
  min-height: 100%;
  margin: 0;
  padding: 24px;
  overflow: auto;
  background: #1f252b;
  color: #e9edf1;
  font: 12px/1.7 Consolas, "Cascadia Code", monospace;
  white-space: pre-wrap;
}

.quality-strip {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 22px;
  border-top: 1px solid var(--line);
  background: var(--surface-soft);
}

.quality-summary {
  min-width: 0;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.quality-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
}

.quality-summary > span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quality-badge {
  flex: 0 0 auto;
  padding: 3px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 750;
}

.quality-badge.neutral {
  background: #e8ebee;
  color: #5f6871;
}

.quality-badge.good {
  background: var(--accent-soft);
  color: #08714f;
}

.quality-badge.warning {
  background: var(--warning-bg);
  color: var(--warning);
}

.quality-badge.error {
  background: #fde8e7;
  color: #a52a26;
}

.compact-text {
  min-height: 30px;
  padding: 5px 9px;
  font-size: 11px;
}

.advisories {
  max-height: 132px;
  overflow-y: auto;
  padding: 10px 22px 12px;
  border-top: 1px solid #f1dfaa;
  background: #fffaf0;
  color: #66521a;
  font-size: 12px;
  line-height: 1.55;
}

.advisories ul {
  margin: 0;
  padding-left: 18px;
}

.editor-footer {
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  border-top: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
}

.reference-manager,
.media-manager {
  display: grid;
  gap: 10px;
  padding-top: 15px;
  border-top: 1px solid var(--line);
}

.reference-manager-heading,
.media-manager-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.reference-manager-heading > div,
.media-manager-heading > div {
  display: grid;
  gap: 3px;
}

.reference-manager-heading small,
.media-manager-heading small {
  color: var(--muted);
  font-size: 10px;
}

.reference-manager-heading > strong {
  min-width: 24px;
  color: var(--accent);
  font-size: 12px;
  text-align: right;
}

.reference-upload-button {
  position: relative;
  width: 100%;
  overflow: hidden;
}

.reference-upload-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.reference-url-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px;
}

.reference-url-row input {
  min-width: 0;
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: #fff;
  color: var(--text);
}

.reference-url-row .button {
  min-height: 38px;
}

.reference-list {
  display: grid;
  gap: 8px;
}

.reference-empty {
  margin: 0;
  padding: 8px 0;
  color: var(--muted);
  font-size: 11px;
}

.reference-item {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 28px;
  gap: 8px;
  align-items: start;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.reference-kind {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
}

.reference-kind svg {
  width: 15px;
  height: 15px;
}

.reference-meta {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.reference-title {
  overflow: hidden;
  color: #303941;
  font-size: 11px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reference-detail {
  color: var(--muted);
  font-size: 10px;
}

.reference-remove {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
}

.reference-remove:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

.reference-remove svg {
  width: 15px;
  height: 15px;
}

.upload-zone {
  min-height: 144px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 20px;
  border: 1px dashed #aeb7c0;
  border-radius: 6px;
  background: #fafbfc;
  color: var(--muted);
  text-align: center;
  transition: border-color 150ms ease, background 150ms ease;
}

.compact-upload {
  min-height: 108px;
  padding: 14px;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.upload-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.upload-zone strong {
  color: #35404a;
  font-size: 13px;
}

.upload-zone > span:last-child {
  font-size: 11px;
}

.upload-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #edf0f3;
  color: var(--accent);
}

.upload-icon svg {
  width: 19px;
  height: 19px;
}

.media-summary {
  justify-content: space-between;
  margin: 14px 0 10px;
  color: var(--muted);
  font-size: 11px;
}

.media-summary strong {
  color: var(--text);
}

.media-list {
  display: grid;
  gap: 10px;
}

.media-empty {
  min-height: 92px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  color: #8a949e;
  text-align: center;
}

.media-empty svg {
  width: 28px;
  height: 28px;
}

.media-empty p {
  max-width: 220px;
  margin: 0;
  font-size: 12px;
  line-height: 1.6;
}

.media-item {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) 30px;
  gap: 10px;
  align-items: start;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.media-thumb {
  width: 72px;
  height: 64px;
  display: block;
  border-radius: 4px;
  object-fit: cover;
  background: #eef1f3;
}

.media-preview-button {
  width: 72px;
  height: 64px;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 4px;
  background: #eef1f3;
}

.media-preview-button:hover {
  box-shadow: 0 0 0 2px var(--accent);
}

.media-meta {
  min-width: 0;
  display: grid;
  gap: 6px;
}

.media-name {
  overflow: hidden;
  color: #303941;
  font-size: 12px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.media-size {
  color: var(--muted);
  font-size: 10px;
}

.slot-select {
  min-width: 0;
  width: 100%;
  height: 26px;
  padding: 2px 4px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: #fff;
  color: #4a5560;
  font-size: 10px;
}

.media-delete {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
}

.media-delete:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

.media-delete svg {
  width: 15px;
  height: 15px;
}

.douyin-output-shell {
  grid-column: 1 / -1;
  min-width: 0;
  min-height: calc(100vh - 68px);
  background: var(--surface);
}

.douyin-output-shell:focus {
  outline: none;
}

.douyin-output-header {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 15px 22px;
  border-bottom: 1px solid var(--line);
  background: #fcfcfd;
}

.douyin-output-header h2,
.douyin-section-heading h3,
.douyin-result-toolbar h3,
.douyin-result-empty h3,
.douyin-publication-copy h4,
.douyin-result-notices h4 {
  margin: 0;
}

.douyin-output-header h2 {
  font-size: 18px;
}

.douyin-status-badge {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #f3f5f7;
  color: #53606c;
  font-size: 11px;
  font-weight: 700;
}

.douyin-status-badge.running {
  border-color: #bfd0ef;
  background: #edf3ff;
  color: #2859ae;
}

.douyin-status-badge.good {
  border-color: #abd7c7;
  background: var(--accent-soft);
  color: var(--accent-hover);
}

.douyin-status-badge.warning {
  border-color: #e4c676;
  background: var(--warning-bg);
  color: var(--warning);
}

.douyin-status-badge.error {
  border-color: #efc2bf;
  background: var(--danger-bg);
  color: var(--danger);
}

.douyin-workspace {
  min-height: calc(100vh - 140px);
  display: grid;
  grid-template-columns: minmax(320px, 390px) minmax(0, 1fr);
}

.douyin-config-panel {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: 15px;
  padding: 20px;
  border-right: 1px solid var(--line);
  background: var(--surface-soft);
}

.douyin-section-heading h3,
.douyin-result-toolbar h3 {
  font-size: 15px;
}

.douyin-section-heading p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.douyin-field-grid {
  display: grid;
  gap: 10px;
}

.douyin-field-grid.two-columns {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.douyin-material-manager {
  display: grid;
  gap: 10px;
  padding-top: 15px;
  border-top: 1px solid var(--line);
}

.douyin-material-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.douyin-material-list .media-empty {
  grid-column: 1 / -1;
}

.douyin-material-item {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}

.douyin-material-preview {
  width: 100%;
  padding: 0;
  border: 0;
  background: #e9edf0;
}

.douyin-material-preview img {
  width: 100%;
  aspect-ratio: 4 / 3;
  display: block;
  object-fit: cover;
}

.douyin-material-caption {
  min-width: 0;
  display: grid;
  gap: 2px;
  padding: 7px 30px 8px 8px;
}

.douyin-material-caption strong {
  overflow: hidden;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.douyin-material-caption span {
  color: var(--muted);
  font-size: 9px;
}

.douyin-material-delete {
  position: absolute;
  right: 5px;
  bottom: 6px;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: #fff;
  color: var(--muted);
}

.douyin-material-delete:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

.douyin-material-delete svg {
  width: 13px;
  height: 13px;
}

.douyin-generate-button {
  width: 100%;
  min-height: 44px;
}

.douyin-result-panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: #fff;
}

.douyin-result-toolbar {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
}

.douyin-result-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.douyin-result-empty {
  min-height: 520px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 10px;
  padding: 32px;
  color: var(--muted);
  text-align: center;
}

.douyin-result-empty > span {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: var(--accent-soft);
  color: var(--accent);
}

.douyin-result-empty > span svg {
  width: 24px;
  height: 24px;
}

.douyin-result-empty p {
  max-width: 520px;
  margin: 0;
  font-size: 12px;
  line-height: 1.65;
}

.douyin-job-progress {
  width: min(520px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}

.douyin-job-progress[hidden] {
  display: none;
}

.douyin-job-progress progress {
  width: 100%;
  height: 10px;
  accent-color: var(--accent);
}

.douyin-job-progress span {
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  text-align: right;
}

.douyin-result {
  display: grid;
  gap: 18px;
  padding: 20px;
}

.douyin-result-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  padding: 11px 13px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
  color: #33403b;
  font-size: 11px;
}

.douyin-result-summary strong {
  color: var(--accent-hover);
}

.douyin-featured-preview {
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f7f9fa;
}

.douyin-featured-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.douyin-featured-heading h4 {
  max-width: 560px;
  margin: 3px 0 0;
  overflow: hidden;
  color: #26323b;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.douyin-featured-stage {
  width: 100%;
  min-height: 360px;
  display: grid;
  place-items: center;
  padding: 14px;
  overflow: hidden;
  border: 0;
  border-radius: 5px;
  background: #11161a;
  cursor: zoom-in;
}

.douyin-featured-stage img {
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: min(66vh, 760px);
  display: block;
  object-fit: contain;
}

.douyin-featured-meta {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  text-align: center;
}

.douyin-page-regenerator {
  display: grid;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.douyin-page-regenerator textarea {
  min-height: 92px;
  resize: vertical;
}

.douyin-page-regenerator-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.douyin-page-regenerator-actions > span {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.6;
}

.douyin-page-regenerator-actions > span.error {
  color: var(--danger);
}

.douyin-page-regenerator-actions > span.success {
  color: var(--accent-hover);
}

.douyin-page-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.douyin-page-item {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #11161a;
}

.douyin-page-item.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(30, 123, 87, 0.16);
}

.douyin-page-preview {
  width: 100%;
  display: block;
  padding: 0;
  border: 0;
  background: #11161a;
}

.douyin-page-preview img {
  width: 100%;
  aspect-ratio: 3 / 4;
  display: block;
  object-fit: contain;
}

.douyin-page-caption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  background: #fff;
  color: #36414a;
  font-size: 10px;
}

.douyin-page-caption strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.douyin-page-download,
.douyin-page-regenerate {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  color: var(--muted);
}

.douyin-page-download:hover,
.douyin-page-regenerate:hover {
  color: var(--accent);
  border-color: #a9cdbf;
}

.douyin-page-download svg,
.douyin-page-regenerate svg {
  width: 14px;
  height: 14px;
}

.douyin-page-caption-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 5px;
}

.douyin-publication-copy,
.douyin-result-notices {
  display: grid;
  gap: 10px;
  padding: 15px;
  border-top: 1px solid var(--line);
}

.douyin-publication-copy h4,
.douyin-result-notices h4 {
  font-size: 13px;
}

.douyin-publication-copy p,
.douyin-result-notices p,
.douyin-result-notices li {
  margin: 0;
  color: #4d5963;
  font-size: 11px;
  line-height: 1.65;
  white-space: pre-wrap;
}

.douyin-result-notices ul {
  display: grid;
  gap: 5px;
  margin: 0;
  padding-left: 18px;
}

.douyin-result-notices .passed {
  color: var(--accent-hover);
  font-weight: 700;
}

.douyin-result-notices .failed {
  color: var(--warning);
  font-weight: 700;
}

.settings-dialog {
  width: min(460px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.image-preview-dialog {
  width: min(880px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.image-preview-dialog::backdrop {
  background: rgba(16, 24, 31, 0.62);
}

.image-preview-heading {
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.image-preview-heading h2 {
  max-width: min(680px, calc(100vw - 130px));
  margin: 0;
  overflow: hidden;
  font-size: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-preview-stage {
  height: min(68vh, 660px);
  display: grid;
  place-items: center;
  padding: 18px;
  overflow: auto;
  background: #f2f4f6;
}

.image-preview-stage img {
  max-width: 100%;
  max-height: 100%;
  display: block;
  object-fit: contain;
}

.image-preview-meta {
  min-height: 42px;
  display: flex;
  align-items: center;
  margin: 0;
  padding: 0 18px;
  color: var(--muted);
  font-size: 11px;
}

.settings-dialog::backdrop {
  background: rgba(16, 24, 31, 0.38);
}

.settings-dialog form {
  display: grid;
  gap: 17px;
  padding: 22px;
}

.dialog-heading {
  justify-content: space-between;
  gap: 16px;
}

.password-field {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
}

.security-note {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.dialog-actions {
  justify-content: flex-end;
  gap: 8px;
  padding-top: 4px;
}

.toast-region {
  position: fixed;
  z-index: 100;
  right: 18px;
  bottom: 18px;
  display: grid;
  gap: 8px;
}

.toast {
  max-width: min(360px, calc(100vw - 36px));
  padding: 11px 14px;
  border: 1px solid #cbd2d9;
  border-radius: 6px;
  background: #1e272f;
  color: #fff;
  box-shadow: var(--shadow);
  font-size: 12px;
  line-height: 1.45;
  animation: toast-in 180ms ease-out;
}

.toast.error {
  border-color: #7f2828;
  background: #8d2d2d;
}

@keyframes toast-in {
  from { transform: translateY(8px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 310px minmax(400px, 1fr);
  }

  .douyin-page-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 960px) {
  body {
    overflow: auto;
  }

  .app-header {
    position: sticky;
    top: 0;
    height: 62px;
    padding: 0 14px;
  }

  .brand-block p,
  #load-demo,
  #generate-top {
    display: none;
  }

  .workspace {
    height: auto;
    min-height: calc(100vh - 62px);
    display: block;
    background: var(--bg);
  }

  .workspace.has-douyin-output {
    display: block;
  }

  .settings-panel,
  .editor-shell {
    display: block;
    overflow: visible;
  }

  .panel {
    padding: 18px 16px;
    border-bottom: 8px solid var(--bg);
  }

  .editor-shell {
    border-bottom: 8px solid var(--bg);
  }

  .douyin-output-shell {
    min-height: 0;
    border-bottom: 8px solid var(--bg);
  }

  .douyin-workspace {
    min-height: 0;
    grid-template-columns: 1fr;
  }

  .douyin-config-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 820px) {
  .app-header {
    padding: 0 14px;
  }

  .editor-header {
    padding-inline: 16px;
  }

  .document-title {
    font-size: 18px;
  }

  .editor-tabs,
  .format-toolbar,
  .quality-strip,
  .editor-footer {
    padding-inline: 16px;
  }

  .editor-view {
    height: 66vh;
    min-height: 480px;
  }

  #article-editor,
  .article-preview {
    padding: 22px 18px 36px;
  }

  .quality-strip {
    align-items: flex-start;
  }

  .quality-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .quality-summary > span:last-child {
    white-space: normal;
  }

  .douyin-page-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .douyin-featured-stage {
    min-height: 300px;
  }
}

@media (max-width: 460px) {
  .login-screen {
    padding: 18px 16px 14px;
  }

  .login-panel {
    padding: 22px 18px;
  }

  .header-actions .icon-button {
    width: 34px;
    height: 34px;
  }

  .two-columns {
    grid-template-columns: 1fr;
  }

  .douyin-field-grid.two-columns,
  .douyin-page-grid {
    grid-template-columns: 1fr;
  }

  .douyin-output-header,
  .douyin-result-toolbar,
  .douyin-featured-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .douyin-featured-heading .button {
    width: 100%;
  }

  .douyin-featured-stage {
    min-height: 260px;
    padding: 8px;
  }

  .douyin-result-actions {
    width: 100%;
  }

  .douyin-result-actions .button {
    flex: 1;
  }

  .document-actions {
    gap: 3px;
  }

  .format-button.with-label {
    font-size: 0;
  }

  .format-button.with-label svg {
    margin: 0;
  }

  .outline-section {
    grid-template-columns: 36px minmax(0, 1fr);
    padding: 12px;
  }

  .outline-number {
    width: 30px;
    height: 30px;
  }

  .outline-fields {
    grid-template-columns: 1fr;
  }

  .outline-fields .wide {
    grid-column: auto;
  }

  .editor-view {
    min-height: 420px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
