:root {
  color-scheme: light;
  --bg: #eef3f8;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --line: #d7dde5;
  --line-strong: #b8c1cc;
  --text: #16202a;
  --muted: #607080;
  --primary: #0f6f8d;
  --primary-dark: #071b33;
  --accent: #2aa7b8;
  --success: #237b4b;
  --danger: #a33a34;
  --shadow: 0 10px 28px rgba(22, 32, 42, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

html {
  overflow-x: hidden;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    "Microsoft YaHei",
    "PingFang SC",
    "Segoe UI",
    Arial,
    sans-serif;
  letter-spacing: 0;
  padding-top: 126px;
  overflow-x: hidden;
}

.tingting-header {
  position: fixed;
  top: 12px;
  left: max(12px, env(safe-area-inset-left));
  right: max(12px, env(safe-area-inset-right));
  z-index: 30;
  display: grid;
  grid-template-columns: minmax(0, 42%) minmax(0, 30%) minmax(120px, 28%);
  align-items: center;
  gap: 12px;
  min-height: 96px;
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px 22px;
  border: 1px solid rgba(125, 211, 252, 0.34);
  border-radius: 12px;
  background:
    linear-gradient(135deg, rgba(7, 27, 51, 0.98) 0%, rgba(15, 83, 112, 0.98) 52%, rgba(18, 89, 96, 0.98) 100%);
  box-shadow: 0 16px 38px rgba(7, 27, 51, 0.24);
  overflow: hidden;
}

.tingting-header::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(125, 211, 252, 0.16) 1px, transparent 1px),
    linear-gradient(90deg, rgba(125, 211, 252, 0.12) 1px, transparent 1px);
  background-size: 34px 34px;
  opacity: 0.45;
}

.tingting-left,
.tingting-mid,
.tingting-card {
  position: relative;
  min-width: 0;
}

.tingting-title,
.tingting-code,
.tingting-mid span,
.tingting-card span {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: clip;
  letter-spacing: 0;
}

.tingting-title {
  color: #f8fbff;
  font-size: 28px;
  font-weight: 800;
  line-height: 1.15;
}

.secret-badge {
  display: inline-block;
  margin: 0 5px;
  padding: 2px 7px;
  border: 1px solid rgba(186, 230, 253, 0.72);
  border-radius: 7px;
  background: rgba(14, 116, 144, 0.74);
  color: #e0f7ff;
  animation: secretBreath 2.8s ease-in-out infinite;
}

.tingting-code {
  margin-top: 8px;
  color: #a9d8e7;
  font-size: 13px;
  line-height: 1.3;
}

.tingting-mid,
.tingting-card {
  border: 0;
  text-align: center;
  background: rgba(255, 255, 255, 0.08);
  color: #d7eef7;
  padding: 12px 14px;
  border-radius: 10px;
  cursor: pointer;
}

.tingting-mid span {
  font-size: 14px;
  line-height: 1.6;
}

.tingting-mid strong,
.tingting-card strong {
  color: #67e8f9;
  font-weight: 800;
}

.tingting-card {
  display: grid;
  align-content: center;
  gap: 6px;
  min-height: 64px;
  border: 1px solid rgba(186, 230, 253, 0.38);
  border-radius: 10px;
  background: rgba(240, 249, 255, 0.12);
  padding: 12px 14px;
  text-align: left;
}

.tingting-card span {
  color: #d7eef7;
  font-size: 13px;
  line-height: 1.3;
}

.tingting-card strong {
  font-size: 17px;
}

@keyframes secretBreath {
  0%,
  100% {
    opacity: 0.72;
    transform: scale(0.98);
  }

  50% {
    opacity: 1;
    transform: scale(1.03);
  }
}

@media (max-width: 360px) {
  .tingting-header {
    left: 6px;
    right: 6px;
    gap: 4px;
    padding-left: 7px;
    padding-right: 7px;
  }

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

  .tingting-mid span,
  .tingting-card span {
    font-size: 10px;
  }
}

.login-body {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding-top: 0;
  background:
    linear-gradient(rgba(7, 27, 51, 0.7), rgba(7, 27, 51, 0.9)),
    linear-gradient(135deg, #071b33 0%, #0f4f68 48%, #123f48 100%);
}

.login-shell {
  width: min(460px, calc(100vw - 28px));
}

.login-card {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(186, 230, 253, 0.36);
  border-radius: 12px;
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.28);
  padding: 30px;
}

.login-brand {
  margin-bottom: 22px;
}

.login-form {
  display: grid;
  gap: 4px;
}

.login-hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  margin: 14px 0 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

#app {
  display: grid;
  grid-template-columns: minmax(680px, 1fr) 300px;
  grid-template-areas:
    "main side"
    "knowledge side";
  gap: 16px;
  min-height: 100vh;
  padding: 18px;
  width: 100%;
}

.sidebar {
  grid-area: knowledge;
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  min-width: 0;
}

.rightbar {
  grid-area: side;
  display: grid;
  align-content: start;
  gap: 12px;
  min-width: 0;
}

.workspace {
  grid-area: main;
  min-width: 0;
  overflow: visible;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  border-radius: 12px;
  background: linear-gradient(135deg, #071b33, #0e7490);
  color: white;
  font-weight: 800;
  box-shadow: 0 12px 24px rgba(7, 27, 51, 0.22);
}

.brand h1,
.topbar h2,
.panel h2,
.review-main h3,
.optimize-panel h3 {
  margin: 0;
}

.brand h1 {
  font-size: 18px;
}

.brand p,
.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  text-align: left;
}

.stat-card:hover,
.stat-card.active {
  border-color: var(--primary);
  background: rgba(15, 111, 141, 0.07);
}

.stat-card strong {
  display: block;
  font-size: 20px;
}

.stat-card span {
  color: var(--muted);
  font-size: 12px;
}

.stat-detail-list {
  display: grid;
  gap: 8px;
  max-height: 260px;
  margin-top: 10px;
  overflow: auto;
  padding-top: 2px;
}

.stat-detail-list.empty {
  display: grid;
  place-items: center;
  min-height: 56px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.stat-detail-head {
  color: var(--muted);
  font-size: 12px;
}

.stat-detail-item {
  display: grid;
  gap: 3px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 9px;
  text-align: left;
}

.stat-detail-item:hover {
  border-color: var(--primary);
}

.stat-detail-item strong {
  color: var(--text);
  font-size: 13px;
  line-height: 1.35;
}

.stat-detail-item span,
.stat-detail-item em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  line-height: 1.45;
}

.stat-detail-item em {
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.doc-item.flash {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 111, 141, 0.12);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  box-shadow: 0 2px 8px rgba(22, 32, 42, 0.03);
}

.upload-panel,
.doc-list-panel {
  margin-bottom: 0;
}

.doc-list-panel {
  min-height: 100%;
}

.stats-panel .panel-title {
  margin-bottom: 8px;
}

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

.panel h2 {
  font-size: 15px;
}

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

.field span {
  color: var(--muted);
  font-size: 13px;
}

.field input,
.field select,
.field textarea,
.optimize-panel textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--text);
  padding: 10px 11px;
  outline: none;
}

.field textarea,
.content-editor,
.optimize-panel textarea {
  resize: vertical;
  line-height: 1.6;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.content-editor:focus,
.optimize-panel textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(23, 107, 135, 0.12);
}

.quick-generate {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: -2px 0 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 2px 8px rgba(22, 32, 42, 0.03);
}

.quick-generate .primary {
  min-width: 156px;
}

.quick-generate .status {
  flex: 1;
  min-width: 0;
}

.upload-drop {
  display: grid;
  place-items: center;
  min-height: 74px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
  text-align: center;
  padding: 12px;
  margin-bottom: 10px;
}

.upload-drop input {
  display: none;
}

.primary,
.secondary,
.text-button,
.icon-button,
.tab {
  min-height: 38px;
  border-radius: 8px;
  padding: 0 14px;
  white-space: nowrap;
}

.primary {
  background: var(--primary);
  color: white;
}

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

.secondary {
  border: 1px solid var(--line);
  background: white;
  color: var(--text);
}

.secondary:hover {
  border-color: var(--line-strong);
}

.text-button,
.icon-button {
  background: transparent;
  color: var(--primary);
  padding: 0 6px;
}

.icon-button {
  width: 34px;
  padding: 0;
  font-size: 18px;
}

.full {
  width: 100%;
}

.doc-list,
.proposal-list,
.job-list,
.version-list,
.reference-list {
  display: grid;
  gap: 8px;
  max-height: 300px;
  overflow: auto;
}

.doc-list {
  max-height: 260px;
}

.proposal-list {
  max-height: 390px;
}

.job-list {
  max-height: 260px;
}

.refresh-meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  margin: -2px 0 8px;
}

.empty {
  color: var(--muted);
  font-size: 13px;
}

.doc-item,
.proposal-item,
.job-item,
.version-item,
.reference-item,
.suggestion-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 10px;
}

.proposal-item {
  display: grid;
  gap: 8px;
  text-align: left;
}

.proposal-item.active {
  border-color: var(--primary);
  background: rgba(23, 107, 135, 0.08);
}

.proposal-title {
  font-weight: 800;
  line-height: 1.45;
}

.proposal-meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.proposal-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.proposal-actions button {
  min-height: 30px;
  padding: 0 10px;
}

.job-item {
  display: grid;
  gap: 8px;
}

.job-item.done {
  border-color: rgba(35, 123, 75, 0.42);
}

.job-item.failed {
  border-color: rgba(163, 58, 52, 0.42);
}

.job-head,
.job-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.job-head strong {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 13px;
}

.job-head span,
.job-meta,
.job-error {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.job-error {
  color: var(--danger);
}

.job-bar {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: #e4e9ef;
}

.job-bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
}

.job-actions {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.job-actions a {
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
}

.doc-item {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 8px;
  align-items: start;
}

.doc-title,
.version-title,
.reference-title {
  font-weight: 700;
  line-height: 1.4;
}

.doc-meta,
.version-meta,
.reference-text,
.suggestion-detail {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  margin-top: 4px;
}

.delete-doc {
  background: transparent;
  color: var(--danger);
  min-height: 24px;
  padding: 0 4px;
}

.topbar {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 16px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.top-actions {
  display: flex;
  gap: 8px;
}

.form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(160px, 0.55fr) minmax(160px, 0.45fr);
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

.field.wide {
  grid-row: span 2;
}

.government-default {
  align-content: start;
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 10px 11px;
}

.government-default strong {
  color: var(--text);
  font-size: 15px;
}

.size-picker {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: -2px 0 14px;
}

.size-card {
  display: grid;
  gap: 4px;
  min-height: 82px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 12px;
  text-align: left;
}

.size-card strong {
  font-size: 16px;
}

.size-card span,
.size-card em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.size-card.active {
  border-color: var(--primary);
  background: rgba(23, 107, 135, 0.08);
  box-shadow: 0 0 0 3px rgba(23, 107, 135, 0.08);
}

.workflow {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 560px;
  box-shadow: var(--shadow);
}

.step-tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--line);
  padding: 10px 10px 0;
}

.tab {
  background: transparent;
  color: var(--muted);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.tab.active {
  background: var(--primary);
  color: white;
}

.tab-view {
  display: none;
  padding: 14px;
}

.tab-view.active {
  display: block;
}

.toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

.status {
  color: var(--muted);
  font-size: 13px;
}

.download-result {
  display: grid;
  gap: 5px;
  max-width: 100%;
  line-height: 1.45;
}

.download-path {
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 12px;
}

.download-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

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

.placeholder {
  display: grid;
  place-items: center;
  min-height: 420px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface-soft);
}

.outline-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.outline-section input,
.outline-section textarea {
  width: 100%;
  border: 0;
  outline: none;
  background: transparent;
}

.outline-title-row {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 8px;
  align-items: center;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--line);
  padding: 10px;
}

.outline-index {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: rgba(23, 107, 135, 0.12);
  color: var(--primary);
  font-weight: 800;
}

.outline-section textarea {
  padding: 10px 12px;
  min-height: 80px;
}

.content-editor {
  width: 100%;
  min-height: 520px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fcfdfe;
  color: var(--text);
  font-family:
    "Microsoft YaHei",
    "PingFang SC",
    "Segoe UI",
    Arial,
    sans-serif;
}

.review-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 14px;
}

.review-main,
.optimize-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface-soft);
}

.score-row {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.score {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 8px;
  background: var(--primary);
  color: white;
  font-weight: 800;
  font-size: 22px;
}

.review-main p {
  margin: 6px 0 0;
  color: var(--muted);
}

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

.suggestion-item {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 8px;
}

.suggestion-item input {
  margin-top: 4px;
}

.suggestion-title {
  font-weight: 700;
}

.severity {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 0 6px;
  margin-left: 6px;
  border-radius: 8px;
  background: #e7edf3;
  color: var(--muted);
  font-size: 12px;
}

.severity.high {
  background: #f7e3e1;
  color: var(--danger);
}

.severity.medium {
  background: #f5eadf;
  color: var(--accent);
}

.severity.low {
  background: #e4f0e9;
  color: var(--success);
}

.optimize-panel textarea {
  min-height: 126px;
  margin-bottom: 10px;
}

.version-item.active {
  border-color: var(--primary);
  background: rgba(23, 107, 135, 0.08);
}

dialog {
  width: min(520px, calc(100vw - 24px));
  border: 0;
  border-radius: 8px;
  box-shadow: 0 28px 80px rgba(22, 32, 42, 0.22);
  padding: 0;
}

dialog::backdrop {
  background: rgba(22, 32, 42, 0.36);
}

.settings-form {
  padding: 18px;
}

.dialog-head,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.dialog-head h2 {
  margin: 0;
  font-size: 18px;
}

.provider-settings {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  margin-bottom: 12px;
  padding: 12px;
}

.provider-settings h3 {
  margin: 0 0 10px;
  font-size: 14px;
}

.provider-settings em {
  color: var(--success);
  font-style: normal;
}

.settings-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  margin-bottom: 12px;
  padding: 10px 12px;
}

.settings-section summary {
  cursor: pointer;
  font-weight: 700;
}

.settings-section textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  resize: vertical;
}

.setting-note {
  color: var(--muted);
  font-size: 12px;
  margin: 10px 0;
}

.setting-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mini-form {
  display: grid;
  grid-template-columns: 1fr 1fr 110px auto;
  gap: 8px;
  margin-top: 10px;
}

.mini-form input,
.mini-form select {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 38px;
  padding: 0 10px;
}

.audit-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  max-height: 260px;
  overflow: auto;
}

.audit-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 8px;
  font-size: 12px;
}

.ops-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 72px;
  gap: 8px;
}

.compact-panel {
  padding: 0;
}

.compact-panel summary {
  cursor: pointer;
  list-style: none;
  padding: 13px 14px;
  font-weight: 800;
}

.compact-panel summary::-webkit-details-marker {
  display: none;
}

.compact-section {
  border-top: 1px solid var(--line);
  padding: 12px 14px 14px;
}

.small-title {
  margin-bottom: 8px;
}

.dialog-actions {
  justify-content: flex-end;
  margin-bottom: 0;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 420px;
  background: #15202b;
  color: white;
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: 0 14px 32px rgba(22, 32, 42, 0.25);
  transform: translateY(120%);
  transition: transform 180ms ease;
  z-index: 20;
}

.toast.show {
  transform: translateY(0);
}

@media (max-width: 1180px) {
  #app {
    grid-template-columns: 1fr;
    grid-template-areas:
      "main"
      "side"
      "knowledge";
  }

  .rightbar {
    display: grid;
    grid-template-columns: minmax(220px, 0.7fr) minmax(280px, 1fr) minmax(280px, 1fr);
    gap: 12px;
  }
}

@media (max-width: 860px) {
  body {
    padding-top: 118px;
  }

  .tingting-header {
    top: 8px;
    left: max(8px, env(safe-area-inset-left));
    right: max(8px, env(safe-area-inset-right));
    width: auto;
    max-width: none;
    grid-template-columns: minmax(0, 42%) minmax(0, 29%) minmax(112px, 29%);
    gap: 8px;
    min-height: 96px;
    padding: 14px 12px;
  }

  .tingting-title {
    font-size: 22px;
  }

  .tingting-code {
    margin-top: 7px;
    font-size: 11px;
  }

  .tingting-mid span,
  .tingting-card span {
    font-size: 11px;
  }

  .tingting-card {
    min-height: 62px;
    padding: 10px 9px;
  }

  .tingting-card strong {
    font-size: 15px;
  }

  .tingting-mid {
    padding: 10px 8px;
  }

  #app {
    grid-template-columns: 1fr;
    width: 100%;
    max-width: 100vw;
    gap: 10px;
    padding: 10px;
  }

  .workspace,
  .sidebar,
  .rightbar,
  .panel,
  .topbar,
  .form-grid,
  .size-picker,
  .quick-generate,
  .workflow,
  .compact-panel,
  .review-main,
  .optimize-panel {
    width: 100%;
    min-width: 0;
  }

  #app *,
  dialog * {
    max-width: 100%;
    min-width: 0;
  }

  .sidebar {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .workspace {
    padding: 0;
  }

  .form-grid,
  .size-picker,
  .review-layout,
  .rightbar {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .panel,
  .topbar,
  .form-grid,
  .quick-generate,
  .workflow {
    border-radius: 8px;
  }

  .panel,
  .tab-view,
  .compact-section {
    padding: 12px;
  }

  .compact-panel summary {
    padding: 12px;
  }

  .topbar,
  .form-grid,
  .quick-generate {
    margin-bottom: 10px;
  }

  .field.wide {
    grid-row: auto;
  }

  .topbar,
  .toolbar,
  .quick-generate,
  .score-row {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }

  .top-actions,
  .proposal-actions,
  .job-head,
  .job-actions,
  .download-actions,
  .dialog-actions,
  .setting-actions {
    flex-wrap: wrap;
  }

  .top-actions,
  .toolbar,
  .proposal-actions,
  .job-actions,
  .download-actions,
  .dialog-actions,
  .setting-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .top-actions button,
  .toolbar button,
  .quick-generate .primary,
  .proposal-actions button,
  .job-actions button,
  .job-actions a,
  .download-actions button,
  .dialog-actions button,
  .setting-actions button {
    width: 100%;
  }

  .job-head {
    align-items: flex-start;
  }

  .job-head strong {
    white-space: normal;
    overflow-wrap: anywhere;
  }

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

  .stat-card {
    padding: 9px 8px;
    min-width: 0;
  }

  .stat-card strong {
    font-size: 18px;
  }

  .stat-card span {
    display: block;
    white-space: nowrap;
  }

  .step-tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    padding: 8px 8px 0;
  }

  .tab {
    min-width: 0;
    padding: 0 6px;
    font-size: 13px;
  }

  .doc-list,
  .proposal-list,
  .job-list,
  .version-list,
  .reference-list,
  .audit-list {
    max-height: 240px;
  }

  .proposal-list {
    max-height: 320px;
  }

  .doc-item {
    grid-template-columns: 22px minmax(0, 1fr);
  }

  .doc-item .delete-doc {
    grid-column: 1 / -1;
    justify-self: end;
  }

  .proposal-title,
  .proposal-meta,
  .doc-title,
  .doc-meta,
  .version-title,
  .version-meta,
  .reference-title,
  .reference-text,
  .suggestion-detail,
  .job-meta,
  .job-error,
  .audit-item,
  .audit-item *,
  .status,
  .download-path {
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .doc-item,
  .proposal-item,
  .job-item,
  .version-item,
  .reference-item,
  .suggestion-item,
  .audit-item {
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
  }

  .outline-title-row,
  .suggestion-item {
    grid-template-columns: 32px minmax(0, 1fr);
  }

  .placeholder {
    min-height: 260px;
    padding: 18px;
    text-align: center;
  }

  .workflow {
    min-height: 0;
  }

  .content-editor {
    min-height: 360px;
    padding: 12px;
  }

  .score {
    width: 58px;
    height: 58px;
  }

  .mini-form,
  .ops-actions {
    grid-template-columns: 1fr;
  }

  dialog {
    width: calc(100vw - 20px);
    max-width: none;
  }

  .settings-form {
    padding: 14px;
  }

  .toast {
    left: 10px;
    right: 10px;
    bottom: 10px;
    max-width: none;
  }
}

@media (max-width: 520px) {
  .size-picker {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .size-card {
    min-height: 78px;
    padding: 10px;
  }

  .size-card strong {
    font-size: 15px;
  }

  .topbar h2,
  .panel h2 {
    font-size: 15px;
  }

  .topbar p {
    font-size: 12px;
  }
}

@media (max-width: 390px) {
  #app {
    padding: 8px;
  }

  .tingting-header {
    left: 6px;
    right: 6px;
    grid-template-columns: minmax(0, 41%) minmax(0, 28%) minmax(102px, 31%);
    gap: 4px;
    padding: 12px 8px;
  }

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

  .secret-badge {
    margin: 0 3px;
    padding: 1px 5px;
  }

  .tingting-code {
    font-size: 9px;
  }

  .tingting-mid,
  .tingting-card {
    padding: 8px 6px;
  }

  .tingting-mid span,
  .tingting-card span {
    font-size: 10px;
  }

  .tingting-card strong {
    font-size: 13px;
  }

  .panel,
  .form-grid,
  .topbar,
  .quick-generate,
  .tab-view {
    padding: 10px;
  }

  .primary,
  .secondary,
  .text-button,
  .icon-button,
  .tab {
    min-height: 36px;
  }

  .size-picker {
    gap: 8px;
  }

  .size-card {
    min-height: 74px;
    padding: 9px;
  }
}
