:root {
  --bg: #b8ab9a;
  --panel: #ede6dc;
  --panel-2: #e4dbcf;
  --metal: #2c2520;
  --metal-deep: #1a1612;
  --line: #9a8b78;
  --line-soft: rgba(90,75,61,.26);
  --text: #241f19;
  --muted: #6b5d4d;
  --dim: #8b7b68;
  --accent: #b55233;
  --accent-2: #6f7d1f;
  --warn: #a66c24;
  --danger: #b23b32;
  --ok: #4f7d44;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,.12);
  --checker: repeating-conic-gradient(#d7ccbc 0% 25%, #f3ece2 0% 50%) 50% / 18px 18px;
  --font: "Segoe UI", "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  --mono: Consolas, "Cascadia Code", "Courier New", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    linear-gradient(180deg, rgba(201,191,176,.86), rgba(184,171,154,.96)),
    var(--checker);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  letter-spacing: 0;
}

body { overflow: hidden; }

[hidden] { display: none !important; }

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

button {
  border: 1px solid rgba(72,58,47,.34);
  border-radius: 6px;
  min-height: 34px;
  padding: 0 12px;
  cursor: pointer;
  color: #f0e6d4;
  background: linear-gradient(180deg, #4a3728, #2c2520);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
}

button:hover { border-color: var(--accent); background: linear-gradient(180deg, #5a402d, #352a22); }

button.primary { background: linear-gradient(180deg, #c45c3e, var(--accent)); color: #fffaf0; border-color: #8e3f27; }
button.primary:hover { background: linear-gradient(180deg, #d26745, #a9472c); }
button.secondary { background: linear-gradient(180deg, #7b6a58, #5d4f42); color: #fff7ea; }
button.danger { background: rgba(178,59,50,.18); color: #7e211b; border-color: rgba(178,59,50,.42); }
button.ghost-btn {
  min-height: 26px;
  padding: 0 9px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  box-shadow: none;
}

input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f7f1e8;
  color: var(--text);
  padding: 8px 10px;
  outline: none;
}

textarea { min-height: 88px; resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(181,82,51,.16); }

.app-shell {
  height: 100vh;
  display: grid;
  grid-template-rows: auto 46px minmax(0, 1fr);
}

.auth-locked .app-shell {
  visibility: hidden;
  pointer-events: none;
}

.app-header {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 68px;
  gap: 16px;
  padding: 10px 22px;
  border-bottom: 1px solid rgba(61,52,48,.8);
  background:
    linear-gradient(125deg, transparent 0%, transparent 40%, rgba(181,82,51,.08) 60%, transparent 80%),
    linear-gradient(135deg, #1a1612 0%, #2c2520 25%, #3d2f24 45%, #4a3728 65%, #3d2f24 85%, #2c2520 100%);
  box-shadow:
    0 4px 20px rgba(0,0,0,.35),
    inset 0 1px 0 rgba(255,255,255,.06),
    inset 0 -1px 0 rgba(0,0,0,.2);
}
.app-header::before {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, transparent, transparent 2px, rgba(0,0,0,.06) 2px, rgba(0,0,0,.06) 4px);
  pointer-events: none;
}

.brand-block { position: relative; z-index: 1; min-width: 0; display: flex; align-items: center; gap: 13px; }
.brand-block > div:last-child { min-width: 0; }
.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(232,220,200,.2);
  border-radius: 6px;
  background: linear-gradient(135deg, var(--accent), #6f3d2b);
  color: #fffaf0;
  font-weight: 800;
  image-rendering: pixelated;
}

h1 { margin: 0; font-size: 18px; font-weight: 700; }
p { margin: 3px 0 0; color: var(--muted); }
.app-header h1 { color: #f0e6d4; text-shadow: 0 1px 3px rgba(0,0,0,.4); }
.app-header p { color: rgba(200,190,175,.88); }

.header-meta { position: relative; z-index: 1; min-width: 0; display: flex; flex: 1 1 auto; justify-content: flex-end; gap: 8px; align-items: center; }
.pipeline-progress {
  width: clamp(220px, 32vw, 520px);
  min-width: 220px;
  display: grid;
  grid-template-columns: minmax(170px, 1fr) auto;
  align-items: center;
  gap: 10px;
  color: #e7edf6;
  font-size: 13px;
  font-weight: 700;
}
.pipeline-progress-bar {
  height: 14px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 999px;
  background: rgba(0,0,0,.18);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.18);
}
.pipeline-progress-bar span {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #d3a15f);
  transition: width .22s ease;
}
.pipeline-progress.running {
  color: #ffffff;
}
.pipeline-progress.running .pipeline-progress-bar {
  border-color: rgba(181,82,51,.72);
  box-shadow: 0 0 0 3px rgba(181,82,51,.16), inset 0 0 0 1px rgba(0,0,0,.20);
}
#pipeline-progress-text {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.global-auto-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid rgba(181,82,51,.5);
  background: rgba(181,82,51,.18);
  color: #f4e6d4;
  border-radius: 999px;
  font-size: 12px;
  white-space: nowrap;
}
.global-auto-control input { width: auto; }
.meta-pill {
  border: 1px solid rgba(181,82,51,.45);
  background: rgba(181,82,51,.16);
  color: #f0e6d4;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
}
.meta-pill.muted {
  border-color: rgba(154,139,120,.5);
  background: rgba(0,0,0,.18);
  color: rgba(232,220,200,.72);
}
.user-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.user-control .meta-pill {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  grid-template-columns: minmax(min(300px, 100%), 360px);
  align-content: center;
  gap: 16px;
  padding: 24px;
  background: rgba(36,31,25,.72);
  backdrop-filter: blur(8px);
  overflow-x: hidden;
  overflow-y: auto;
}
.login-screen[hidden] { display: none; }
.login-panel[hidden] { display: none; }
.login-panel-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.login-card {
  width: min(360px, calc(100vw - 32px));
  display: grid;
  gap: 12px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #ede6dc, #e4dbcf);
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
}
.register-card {
  border-color: rgba(181,82,51,.42);
}
.login-card .brand-mark { margin-bottom: 4px; }
.login-card h2 { margin: 0; font-size: 20px; }
.login-card p { margin: -6px 0 4px; }
.login-card label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}
.form-error {
  min-height: 18px;
  color: #ffb8b8;
  font-size: 12px;
}

.app-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(44,37,32,.94);
  overflow-x: auto;
}

.app-tabs button {
  min-width: 72px;
  background: transparent;
  color: rgba(232,220,200,.76);
  border: 1px solid transparent;
}
.app-tabs button.active {
  background: rgba(181,82,51,.26);
  border-color: var(--accent);
  color: #fff4e4;
}

.app-main {
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
}

.workspace {
  min-height: 0;
  overflow: auto;
  padding: 16px 18px;
}

.app-view {
  width: 100%;
  margin: 0 auto;
}

.module-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}
.module-title { display: flex; align-items: center; gap: 10px; }
.module-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  border: 1px solid rgba(154,139,120,.55);
  background: linear-gradient(180deg, #4a3728, #2c2520);
  color: #f0e6d4;
  font-weight: 700;
}
.module-head h2 { margin: 0; font-size: 20px; }
.module-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.list-actions,
.filter-bar {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 10px;
  align-items: end;
  margin-bottom: 12px;
}
.list-actions {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
}
.switch-line {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  color: var(--muted);
}
.switch-line input,
th input,
td input[type="checkbox"] {
  width: auto;
}

.grid-2 {
  display: grid;
  grid-template-columns: minmax(280px, 390px) minmax(0, 1fr);
  gap: 14px;
}
.stacked-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.panel {
  background: linear-gradient(180deg, #ede6dc 0%, #e4dbcf 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--text);
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.panel-head strong { font-size: 14px; }
.panel-body { padding: 14px; }

.form-grid { display: grid; gap: 11px; }
.member-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}
.project-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}
.project-form-main {
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
}
.project-name-grid,
.project-options-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 11px;
}
.project-options-grid {
  grid-template-columns: repeat(3, minmax(220px, 1fr));
}
.project-form-main > button {
  justify-self: start;
}
.member-admin-grid {
  display: grid;
  grid-template-columns: minmax(420px, 1.3fr) minmax(320px, .7fr);
  gap: 14px;
}
.member-form-main {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
}
.member-form-main button {
  justify-self: start;
}
.note-wide {
  grid-column: 1 / -1;
}
.field-label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}
.project-checkbox-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px 12px;
}
.project-checkbox-list label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 7px 9px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgba(255,255,255,.025);
}
.field label {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}
.field .hint { margin-top: 4px; color: var(--dim); font-size: 12px; }

.table-wrap {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  overflow-y: visible;
}
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 0;
}
th, td {
  border-bottom: 1px solid var(--line-soft);
  padding: 9px 10px;
  text-align: left;
  vertical-align: top;
  overflow-wrap: anywhere;
  word-break: break-word;
}
th {
  position: sticky;
  top: 0;
  background: #d8ccbb;
  color: #5a4c3f;
  font-size: 12px;
  z-index: 1;
}
td { color: #2f281f; }
.muted-text { color: var(--muted); }
.mono { font-family: var(--mono); }
.db-value {
  display: block;
  max-width: 360px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.db-value.compact {
  max-width: 260px;
  max-height: 58px;
  overflow: hidden;
}
.nowrap { white-space: nowrap; }
.narrow { max-width: 150px; }
.one-line-ellipsis {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* 调节方案、资产、绘图、日志表格列宽时，改下面这几段 table class。 */
.table-pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}
.table-pager label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.table-pager select {
  min-height: 30px;
  padding: 4px 28px 4px 8px;
}
.cell-link {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: #2f281f;
  text-align: left;
  cursor: pointer;
}
.project-table,
.plan-table,
.asset-table,
.draw-table,
.log-table,
.save-table,
.ui-table {
  table-layout: auto;
  width: 100%;
  min-width: 0;
}
.table-fit {
  width: 1%;
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.table-fill {
  width: auto;
  min-width: 0;
  white-space: normal;
}
.prompt-fill,
.plan-content-cell,
.asset-prompt-cell,
.draw-prompt-cell,
.plan-warning-cell,
.save-name-cell {
  min-width: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.55;
}
.log-action-cell {
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
}
.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.project-table-actions {
  flex-wrap: nowrap;
  white-space: nowrap;
}
.project-table-actions button {
  flex: 0 0 auto;
}
.plan-warning {
  display: grid;
  gap: 4px;
  color: var(--danger);
  font-size: 12px;
}
.save-table {
  table-layout: fixed;
}
.save-col-project { width: 9%; }
.save-col-plan { width: 12%; }
.save-col-name { width: 18%; }
.save-col-creator { width: 10%; }
.save-col-time { width: 18%; }
.save-col-count { width: 8%; }
.save-col-status { width: 16%; }
.save-col-action { width: 9%; }
.save-nowrap {
  white-space: nowrap;
  word-break: keep-all;
  overflow: hidden;
  text-overflow: ellipsis;
}
.save-name-cell {
  white-space: normal;
}
.save-action-cell {
  text-align: right;
}
.log-message-cell {
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.image-hover-trigger {
  color: var(--accent);
  cursor: zoom-in;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.image-hover-preview {
  position: fixed;
  z-index: 1200;
  width: min(512px, calc(100vw - 16px));
  height: min(512px, calc(100vh - 16px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--checker);
  box-shadow: var(--shadow);
  pointer-events: none;
}
.image-hover-preview[hidden] { display: none; }
.image-hover-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  image-rendering: pixelated;
}
.db-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-bottom: 10px;
  color: var(--muted);
}
.asset-type-row {
  display: grid;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line-soft);
}
.asset-type-row:last-child { border-bottom: 0; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(36,31,25,.72);
}
.modal-backdrop[hidden] { display: none; }
.plan-content-modal,
.project-edit-modal {
  align-items: center;
}
.modal-card {
  width: min(760px, 96vw);
  max-height: 92vh;
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.modal-card-wide {
  width: min(980px, 96vw);
}
.project-edit-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.modal-raw {
  max-height: 70vh;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #2c2520;
  color: #f0e6d4;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
  border: 1px solid var(--line);
  color: var(--muted);
}
.status-badge.idle { color: var(--muted); }
.status-badge.draft { color: #5f4a2e; border-color: rgba(181,82,51,.32); background: rgba(181,82,51,.1); }
.status-badge.pending, .status-badge.review_pending { color: #7b4f16; border-color: rgba(166,108,36,.36); background: rgba(166,108,36,.13); }
.status-badge.approved, .status-badge.success, .status-badge.done, .status-badge.ai_completed { color: #315f31; border-color: rgba(79,125,68,.36); background: rgba(79,125,68,.13); }
.status-badge.failed, .status-badge.rejected { color: #7e211b; border-color: rgba(178,59,50,.4); background: rgba(178,59,50,.12); }

.summary-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.summary-card {
  background: linear-gradient(180deg, #ede6dc 0%, #e4dbcf 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow);
}
.summary-card span { color: var(--muted); font-size: 12px; }
.summary-card strong { display: block; margin-top: 6px; font-size: 22px; }

.debug-dock {
  height: 250px;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr 360px;
  gap: 10px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  background: rgba(44,37,32,.94);
}
.debug-dock.compact {
  height: 28px;
  min-height: 28px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  cursor: pointer;
}
.debug-dock.compact::before {
  content: "发出 / 返回 / 预览";
  color: var(--muted);
  font-size: 12px;
}
.debug-dock.compact .debug-panel { display: none; }
.debug-dock.compact .debug-collapse { display: none; }
.debug-panel {
  min-width: 0;
  background: linear-gradient(180deg, #ede6dc 0%, #e4dbcf 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.debug-head {
  height: 36px;
  padding: 0 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}
.debug-head-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
pre {
  margin: 0;
  height: calc(100% - 36px);
  overflow: auto;
  padding: 10px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: #2f281f;
  font-family: var(--mono);
  font-size: 12px;
}
.preview-box {
  height: calc(100% - 36px);
  display: grid;
  place-items: center;
  padding: 10px;
  color: var(--dim);
  background: var(--checker);
  overflow: auto;
}
.preview-box img { max-width: 100%; max-height: 180px; border-radius: 6px; image-rendering: pixelated; }

.empty-state {
  padding: 30px 16px;
  text-align: center;
  color: var(--muted);
}
.empty-state.small {
  min-width: 256px;
  min-height: 256px;
  display: grid;
  place-items: center;
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--checker);
}

.draft-plan-doc {
  display: grid;
  gap: 6px;
  line-height: 1.7;
}
.draft-doc-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 4px;
}
.markdown-preview {
  display: grid;
  gap: 10px;
  color: var(--text);
}
.markdown-preview h1,
.markdown-preview h2,
.markdown-preview h3,
.markdown-preview h4 {
  margin: 8px 0 2px;
  line-height: 1.3;
  color: var(--text);
}
.markdown-preview h1 { font-size: 22px; }
.markdown-preview h2 { font-size: 19px; }
.markdown-preview h3 { font-size: 16px; }
.markdown-preview h4 { font-size: 14px; color: #5f4a2e; }
.markdown-preview p,
.markdown-preview ul { margin: 0; }
.markdown-preview ul { padding-left: 20px; }
.markdown-preview li { margin: 3px 0; }
.markdown-preview code {
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(181,82,51,.1);
  color: #7e3c26;
}
.markdown-raw,
.md-asset-block {
  max-height: 520px;
  overflow: auto;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f7f1e8;
  color: #2f281f;
  white-space: pre-wrap;
  font-family: var(--mono);
  font-size: 12px;
}
.md-asset-block {
  border-color: rgba(181,82,51,.34);
  background: rgba(181,82,51,.07);
}
.md-table {
  width: max-content;
  max-width: 100%;
  min-width: 0;
  border-collapse: collapse;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
}
.md-table th,
.md-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
}
.md-table th { background: #d8ccbb; }
.draft-plan-doc h3,
.draft-plan-doc h4,
.draft-plan-doc h5 {
  margin: 8px 0 2px;
  color: var(--text);
}
.draft-plan-doc h3 { font-size: 20px; }
.draft-plan-doc h4 { font-size: 16px; color: #6f7d1f; }
.draft-plan-doc h5 { font-size: 14px; color: #8a5a22; }
.draft-plan-doc p { margin: 0; color: #2f281f; }
.draft-bullet { padding-left: 12px; }
.draft-space { height: 4px; }
.draft-divider {
  height: 1px;
  background: var(--line-soft);
  margin: 6px 0;
}
.draft-asset-line {
  display: grid;
  grid-template-columns: minmax(160px, .7fr) minmax(140px, .5fr) minmax(0, 1fr);
  gap: 10px;
  padding: 6px 8px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: rgba(255,255,255,.32);
}
.draft-gallery {
  display: grid;
  gap: 14px;
}
.draft-asset-row {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line-soft);
}
.draft-asset-row:last-child { border-bottom: 0; }
.draft-asset-meta {
  display: grid;
  align-content: start;
  gap: 6px;
}
.draft-asset-meta span { color: var(--muted); }
.draft-image-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, 256px);
  gap: 12px;
  align-items: start;
  overflow: visible;
  padding-bottom: 4px;
}
.draft-image-card {
  position: relative;
  width: 256px;
  min-width: 256px;
  height: 256px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--checker);
}
.draft-image-card.empty {
  display: grid;
  place-items: center;
  border-style: dashed;
  background:
    linear-gradient(135deg, rgba(255,255,255,.62), rgba(255,255,255,.18)),
    var(--checker);
}
.draft-image-card.status-failed {
  border-color: rgba(186, 49, 49, .68);
  background:
    linear-gradient(135deg, rgba(186,49,49,.12), rgba(255,255,255,.16)),
    var(--checker);
}
.draft-image-card.status-running,
.draft-image-card.status-pending {
  border-color: rgba(190, 124, 44, .58);
}
.draft-image-card img {
  width: 256px;
  height: 256px;
  object-fit: cover;
  display: block;
  image-rendering: pixelated;
}
.draft-slot-empty {
  display: grid;
  place-items: center;
  gap: 7px;
  padding: 18px;
  text-align: center;
  color: var(--muted);
}
.draft-slot-empty strong {
  color: var(--text);
  font-size: 15px;
}
.draft-slot-empty span,
.draft-slot-empty small {
  font-size: 12px;
}
.discard-mask {
  display: none;
  position: absolute;
  inset: 0;
  place-items: center;
  background: rgba(8, 12, 18, .58);
  color: #f5c8c8;
  font-weight: 700;
}
.draft-image-card.not-kept .discard-mask { display: grid; }
.zoom-btn,
.keep-btn {
  position: absolute;
  right: 8px;
  min-height: 28px;
  padding: 0 8px;
  background: rgba(15, 20, 28, .82);
  border: 1px solid rgba(255,255,255,.16);
}
.zoom-btn {
  bottom: 8px;
  width: 30px;
  font-size: 18px;
  line-height: 1;
}
.keep-btn {
  left: 8px;
  right: auto;
  bottom: 8px;
}
.draft-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  background: rgba(0,0,0,.72);
  padding: 42px;
}
.draft-modal[hidden] { display: none; }
.draft-modal img {
  max-width: min(96vw, 1200px);
  max-height: 90vh;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--checker);
  image-rendering: pixelated;
}
.draft-modal-close {
  position: fixed;
  top: 18px;
  right: 18px;
  width: 36px;
  min-height: 36px;
  font-size: 20px;
  background: #263243;
}

.toast-root {
  position: fixed;
  right: 16px;
  top: 82px;
  display: grid;
  gap: 8px;
  z-index: 999;
}
.toast {
  padding: 9px 13px;
  border-radius: 8px;
  background: #2c2520;
  color: #f0e6d4;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

@media (max-width: 1180px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
    padding: 12px 16px;
  }
  .header-meta {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }
  .pipeline-progress {
    flex: 1 1 320px;
    width: auto;
    min-width: 0;
  }
}

@media (max-width: 980px) {
  body { overflow: auto; }
  .app-shell { min-height: 100vh; height: auto; }
  .app-main { grid-template-rows: auto auto; }
  .grid-2, .grid-3, .summary-row, .debug-dock, .member-admin-grid, .member-form-main, .project-name-grid, .project-options-grid { grid-template-columns: 1fr; }
  .note-wide { grid-column: auto; }
  .filter-bar, .list-actions, .draft-asset-row, .draft-asset-line { grid-template-columns: 1fr; }
  .debug-dock { height: auto; }
  .debug-panel { min-height: 180px; }
  .app-header { align-items: flex-start; height: auto; padding: 14px; gap: 12px; flex-direction: column; }
  .header-meta { width: 100%; flex-wrap: wrap; }
  .pipeline-progress { width: 100%; min-width: 0; }
}

@media (max-width: 760px) {
  .save-table,
  .save-table tbody,
  .save-table tr,
  .save-table td {
    display: grid;
  }
  .save-table colgroup,
  .save-table thead {
    display: none;
  }
  .save-table {
    gap: 10px;
  }
  .save-table tbody {
    gap: 10px;
  }
  .save-table tr {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line-soft);
  }
  .save-table td {
    grid-template-columns: 76px minmax(0, 1fr);
    gap: 8px;
    align-items: start;
    border-bottom: 0;
    padding: 2px 0;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }
  .save-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
  }
  .save-table .save-name-cell,
  .save-table .save-action-cell {
    grid-column: 1 / -1;
  }
  .save-action-cell {
    text-align: left;
  }
}

@media (max-height: 720px), (max-width: 640px) {
  .login-screen {
    align-content: center;
    place-items: center;
    padding: 16px;
  }
  .login-card {
    width: min(360px, 100%);
  }
}

@media (hover: none), (pointer: coarse) {
  .image-hover-trigger { cursor: pointer; }
  .image-hover-preview { display: none !important; }
}
