:root {
  --bg: #F5F1E8;
  --bg-deep: #EDE6DA;
  --panel: #FFFFFF;
  --panel-soft: #FAF7F0;
  --text: #1F1F1D;
  --text-secondary: #6F6A61;
  --text-muted: #9A9388;
  --border: #DED6C8;
  --border-soft: #E9E1D4;
  --accent: #1F1C17;
  --accent-soft: #E8DFD2;
  --rust: #A04732;
  --rust-soft: #F1DED7;
  --warning: #B08A3C;
  --warning-soft: #F4EAD2;
  --success: #5D7A60;
  --success-soft: #E1E9DF;
  --danger: #8F3D2E;
  --danger-soft: #F0D8D2;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-soft: 0 10px 30px rgba(31, 28, 23, 0.06);
  --line: var(--border);
  --muted: var(--text-secondary);
  --panel-2: var(--panel-soft);
  --radius: var(--radius-md);
  --shadow: var(--shadow-soft);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

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

button {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  border-radius: 999px;
  min-height: 34px;
  padding: 6px 13px;
  cursor: pointer;
  transition: border-color .16s ease, background .16s ease, color .16s ease;
}
button:hover { border-color: var(--accent); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.active { background: var(--accent); border-color: var(--accent); color: #fff; }
button.ghost { background: transparent; }
button.danger { color: var(--danger); border-color: var(--danger-soft); background: var(--danger-soft); }
button.small { min-height: 28px; padding: 4px 9px; font-size: 12px; }

input, select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  min-height: 38px;
  padding: 7px 10px;
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 28, 23, .06);
}
textarea { min-height: 110px; resize: vertical; }

label { display: grid; gap: 6px; color: var(--text-secondary); font-size: 12px; }
label span { color: var(--text-secondary); }
label.checkline {
  align-self: end; min-height: 40px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
label.checkline span { width: 100%; }
label.checkline input { width: 16px; height: 16px; accent-color: var(--accent); min-height: auto; padding: 0; }
label.checkline em { font-style: normal; color: var(--text-secondary); font-size: 13px; }

/* ── Layout ── */
.app { min-height: 100vh; display: flex; flex-direction: column; }
.layout {
  display: grid;
  grid-template-columns: clamp(240px, 19vw, 272px) minmax(0, 1fr);
  gap: 0; padding: 0; min-height: 0;
}
.sidebar {
  background: var(--bg-deep);
  border-right: 1px solid var(--border);
  padding: 16px;
  height: 100vh;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  overflow: hidden;
}
.sidebar-main {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}
.sidebar-header { padding-bottom: 10px; }
.sidebar-brand { margin-bottom: 10px; }
.sidebar-brand h1 { margin: 0; font-size: 18px; line-height: 1.22; font-weight: 600; }
.sidebar-brand p { margin: 3px 0 0; color: var(--text-secondary); font-size: 10px; letter-spacing: .08em; }
#settingsBtn { margin-bottom: 8px; width: 100%; min-height: 36px; }
#workbenchBtn { margin-bottom: 10px; width: 100%; min-height: 36px; }
.sidebar-bottom { padding-top: 12px; border-top: 1px solid var(--border-soft); display: grid; gap: 8px; }
.sidebar-bottom button { width: 100%; }
.beian {
  display: grid; gap: 2px; padding-top: 4px;
  border-top: 1px solid var(--border-soft);
}
.beian a {
  font-size: 10px; color: var(--text-muted); text-decoration: none;
  white-space: nowrap;
}
.beian a:hover { color: var(--text-secondary); }

.main {
  min-height: 100vh;
  overflow: hidden;
  padding: 14px 24px 24px;
}
.page {
  width: min(1240px, calc(100vw - 64px));
  margin: 28px auto;
  background: transparent;
}

/* ── Search & Filters ── */
.search { display: grid; gap: 10px; margin-bottom: 12px; }
.search input { min-height: 38px; }
.sidebar-add { width: 100%; min-height: 40px; }
.filter-row { display: flex; flex-wrap: wrap; gap: 6px; }
.filter-row button { min-height: 28px; padding: 4px 9px; font-size: 12px; }
.filter-row button.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ── Product List ── */
.product-list { display: grid; gap: 8px; overflow: auto; padding-right: 2px; align-content: start; }
.product-item {
  display: flex; align-items: flex-start; gap: 10px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  background: #fff;
  padding: 12px 13px;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, transform .15s ease, box-shadow .15s ease;
  user-select: none;
}
.product-item:hover { border-color: var(--border); }
.product-item.active { border-color: var(--accent); background: var(--panel-soft); }
.product-item .drag-handle {
  flex: 0 0 auto; width: 16px; height: 28px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; cursor: grab; color: var(--text-muted); opacity: 0; font-size: 6px;
  transition: opacity .15s ease; letter-spacing: 2px; line-height: 1;
  margin-top: 2px;
}
.product-item:hover .drag-handle { opacity: 0.5; }
.product-item .drag-handle:hover { opacity: 1; color: var(--accent); }
.product-item .drag-handle:active { cursor: grabbing; }
.product-item.dragging { opacity: 0.4; background: var(--bg); border-style: dashed; }
.product-item.drag-over-before {
  border-color: var(--accent);
  border-top: 3px solid var(--accent);
  box-shadow: 0 -4px 8px -4px var(--accent-soft);
}
.product-item.drag-over-after {
  border-color: var(--accent);
  border-bottom: 3px solid var(--accent);
  box-shadow: 0 4px 8px -4px var(--accent-soft);
}
.product-item .item-body { flex: 1 1 auto; min-width: 0; }
.product-item .item-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
  margin-bottom: 4px;
}
.product-item .item-head h3 {
  margin: 0; font-size: 14px; font-weight: 600; line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.product-item .item-status {
  flex: 0 0 auto; white-space: nowrap; cursor: pointer; user-select: none;
}
.product-item .item-status:hover { filter: brightness(0.92); }
.product-item .item-row {
  font-size: 11px; color: var(--text-secondary); line-height: 1.6;
  min-height: 18px;  /* reserve space even when empty */
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.product-item .item-row .placeholder { color: var(--text-muted); }
.product-item .item-updated {
  color: var(--text-muted); font-size: 10px;
  margin-top: 2px;
}
.meta { color: var(--text-secondary); font-size: 11px; display: flex; flex-wrap: wrap; gap: 5px 8px; }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  border-radius: 999px;
  padding: 3px 8px;
  background: var(--panel-soft);
  border: 1px solid var(--border-soft);
  color: var(--text-secondary);
  font-size: 11px;
  white-space: nowrap;
}
.badge.warn { background: var(--warning-soft); color: #7D6128; border-color: #E3D0A2; }
.badge.danger { background: var(--danger-soft); color: var(--danger); border-color: #DFBFB8; }
.badge.ok { background: var(--success-soft); color: var(--success); border-color: #C7D5C4; }
.badge.draft { background: var(--accent-soft); color: var(--text-secondary); }

/* ── Detail Head ── */
.detail-head {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center; gap: 12px;
  min-height: 52px;
  padding: 0 0 10px;
  border-bottom: 1px solid var(--border-soft);
  background: transparent;
  box-shadow: none;
}
.detail-head h2 { margin: 0 0 4px; font-size: 26px; line-height: 1.18; font-weight: 600; }
.detail-head p { margin: 0 0 8px; color: var(--text-secondary); }
.actions { display: flex; flex-wrap: wrap; align-content: start; justify-content: flex-end; gap: 8px; }
.detail-head .actions button { min-height: 32px; padding: 5px 11px; }
.detail-title-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* ── Product Notes ── */
.note-panel-list { display: grid; gap: 10px; }
.note-item {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  background: var(--panel-soft);
  padding: 12px;
}
.note-item.converted { opacity: .78; }
.note-strip {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 8px 0 4px;
  border-bottom: 1px solid var(--border-soft);
}
.note-strip-label { color: var(--text-secondary); font-size: 12px; }
.note-chip {
  display: inline-flex; align-items: center; gap: 6px;
  max-width: 360px;
  border: 1px solid var(--border-soft);
  border-radius: 999px;
  background: var(--warning-soft);
  color: #6E5623;
  padding: 5px 8px 5px 10px;
  font-size: 12px;
}
.note-chip-text {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  border: 0; background: transparent; padding: 0;
  min-height: auto; color: inherit; max-width: 240px; text-align: left;
}
.note-chip-action {
  border: 0; background: transparent; padding: 0 2px;
  min-height: auto; color: inherit; font-size: 12px; line-height: 1;
}
.note-chip-delete { color: var(--danger); font-size: 15px; }

/* ── Tabs ── */
.tabs {
  display: flex; gap: 8px; overflow-x: auto;
  padding: 12px 0 0;
  border-bottom: 0; background: transparent;
  scrollbar-width: thin;
}
.tabs button {
  flex: 0 0 auto; min-width: 118px; min-height: 36px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: var(--panel-soft);
  color: var(--text-secondary);
  padding: 6px 12px; font-size: 13px; text-align: center;
}
.tabs button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.subtabs { display: flex; gap: 8px; margin-bottom: 16px; }
.subtabs button.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.material-nav {
  display: flex; gap: 8px; overflow-x: auto; white-space: nowrap;
  padding-bottom: 8px; margin-bottom: 12px;
  scrollbar-width: thin;
}
.material-nav button { flex: 0 0 auto; min-height: 34px; padding: 5px 11px; }
.material-nav button.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.content { padding: 14px 0 0; max-height: calc(100vh - 126px); overflow: auto; }

/* ── Grid & Cards ── */
.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  background: #fff;
  padding: 18px;
  box-shadow: none;
}
.card-head {
  display: flex; justify-content: space-between; gap: 12px; align-items: flex-start;
  margin-bottom: 12px; padding-bottom: 10px;
  border-bottom: 1px solid var(--border-soft);
}
.card h3 { margin: 0; font-size: 16px; line-height: 1.35; font-weight: 600; }
.card-note { margin: 4px 0 0; color: var(--text-secondary); font-size: 13px; }

.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.field { min-height: 43px; }
.field b { display: block; color: var(--text-secondary); font-size: 12px; font-weight: 500; }
.field div { white-space: pre-wrap; word-break: break-word; margin-top: 3px; }
.full { grid-column: 1 / -1; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-bottom: 14px; }
.toolbar label { min-width: 145px; }

/* ── Table ── */
table {
  width: 100%; border-collapse: collapse;
  background: #fff;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md); overflow: hidden;
}
th, td {
  text-align: left; border-bottom: 1px solid var(--border-soft);
  padding: 12px; vertical-align: top; font-size: 13px;
}
th {
  background: var(--panel-soft); color: var(--text-secondary);
  font-size: 12px; font-weight: 600;
}
tr:last-child td { border-bottom: 0; }

/* ── Lifecycle Table ── */
.life-module-head {
  display: grid; gap: 10px;
  margin-bottom: 12px; padding-bottom: 10px;
  border-bottom: 1px solid var(--border-soft);
}
.life-module-head h3 { margin: 0; font-size: 18px; font-weight: 600; }
.life-table-wrap { overflow-x: auto; border-radius: var(--radius-md); }
.life-table { min-width: 1040px; table-layout: fixed; }
.life-table th, .life-table td { padding: 8px 10px; }
.life-table col.time { width: 88px; }
.life-table col.title { width: 190px; }
.life-table col.progress { width: 300px; }
.life-table col.result { width: 240px; }
.life-table col.status { width: 112px; }
.life-table col.owner { width: 138px; }
.life-table col.material { width: 96px; }
.life-table col.ops { width: 86px; }
.life-table col.product { width: 120px; }

.life-row-title { color: var(--text); font-weight: 600; line-height: 1.45; }
.life-owner-cell { white-space: normal; word-break: keep-all; overflow-wrap: normal; }
.life-owner-cell .card-note { display: block; white-space: nowrap; }
.life-complete-cell {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--text-secondary); font-size: 13px; white-space: nowrap;
}
.life-complete-cell input { width: 15px; height: 15px; accent-color: var(--accent); }
.life-complete-cell.done { color: var(--success); }

[data-life-inline] { cursor: text; border-radius: var(--radius-sm); }
[data-life-inline]:hover { background: var(--panel-soft); box-shadow: inset 0 0 0 1px var(--border-soft); }

.inline-editor { display: grid; gap: 6px; }
.inline-editor input, .inline-editor select, .inline-editor textarea {
  min-height: 30px; font-size: 13px; padding: 5px 7px;
}
.inline-editor textarea { min-height: 54px; }
.inline-editor-actions { display: flex; gap: 6px; }
.inline-editor-actions button { min-height: 26px; padding: 3px 8px; font-size: 12px; }

/* ── Life Action Menu ── */
.life-actions { position: relative; }
.life-menu-button { width: 100%; min-height: 28px; padding: 4px 8px; }
.life-action-menu {
  position: fixed; z-index: 80; width: 138px;
  display: grid; gap: 4px; padding: 6px;
  border: 1px solid var(--border-soft); border-radius: var(--radius-sm);
  background: var(--panel);
  box-shadow: 0 12px 28px rgba(31, 28, 23, .12);
}
.life-action-menu button {
  width: 100%; justify-content: flex-start; text-align: left;
  border: 0; border-radius: var(--radius-sm); background: transparent;
  min-height: 30px; padding: 5px 9px;
}
.life-action-menu button:hover { background: var(--panel-soft); border-color: transparent; }
.life-action-menu button.danger { color: var(--danger); background: transparent; }
.life-action-menu button.danger:hover { background: var(--danger-soft); }

/* ── Status popover ── */
.status-popover {
  position: fixed; z-index: 80;
  display: grid; gap: 2px; padding: 6px;
  border: 1px solid var(--border-soft); border-radius: var(--radius-sm);
  background: var(--panel);
  box-shadow: 0 12px 28px rgba(31, 28, 23, .12);
  max-height: 320px; overflow: auto;
}
.status-popover button {
  width: 100%; justify-content: flex-start; text-align: left;
  border: 0; border-radius: var(--radius-sm); background: transparent;
  min-height: 30px; padding: 5px 10px; font-size: 13px;
  white-space: nowrap;
}
.status-popover button:hover { background: var(--panel-soft); }
.status-popover button.active {
  background: var(--accent-soft); color: var(--accent); font-weight: 600;
}

.life-row-done { background: #F1EDE5; color: var(--text-muted); }
.life-row-done td { color: var(--text-muted); }
.life-row-done .life-row-title,
.life-row-done .line-clamp-2 { color: var(--text-secondary); }
.life-row-done .badge { opacity: .82; }
.life-row-done:hover { background: #EFE9DF; }

/* ── Lists ── */
.issue-list, .asset-list, .pending-list, .oral-list, .generation-grid { display: grid; gap: 14px; }
.generation-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.asset-card-quiet { display: grid; gap: 10px; }
.asset-title-row {
  display: flex; justify-content: space-between; gap: 14px; align-items: flex-start;
}
.asset-title-row h3 { margin: 0; font-size: 16px; line-height: 1.45; font-weight: 600; color: var(--text); }
.asset-title-row .badges { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; flex: 0 0 auto; }
.asset-summary { color: var(--text); line-height: 1.6; }
.asset-foot {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; flex-wrap: wrap;
}
.asset-source-weak { color: var(--text-muted); font-size: 12px; }
.asset-materials { display: grid; gap: 8px; margin-top: 2px; }
.asset-thumbs, .asset-attach-pills {
  display: flex; flex-wrap: wrap; gap: 7px; align-items: center;
}
.asset-thumb {
  width: 58px; height: 58px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
  background: var(--panel-soft);
  object-fit: cover; display: block;
}
.asset-attach-pill {
  max-width: 210px; min-height: 28px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: var(--panel-soft);
  color: var(--text-secondary);
  font-size: 12px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.asset-attach-pill:hover { border-color: var(--border); color: var(--text); background: #fff; }
.asset-more-count {
  display: inline-flex; align-items: center;
  min-height: 28px; padding: 0 9px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  color: var(--text-muted); font-size: 12px;
  background: var(--panel-soft);
}
.asset-more-grid { display: grid; gap: 12px; }

.summary { color: var(--text-secondary); font-size: 14px; white-space: pre-wrap; }
.summary a, .field a, .line-clamp-2 a, .answer-direct a, .life-row-title a, .asset-summary a {
  color: #2B6CB0; text-decoration: underline; text-underline-offset: 2px;
}
.summary a:hover, .field a:hover, .line-clamp-2 a:hover, .answer-direct a:hover, .life-row-title a:hover, .asset-summary a:hover {
  color: #1A4F8A;
}
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--text-secondary);
  line-height: 1.5;
}

.progress-detail {
  background: var(--panel-soft);
  border-left: 3px solid var(--accent-soft);
  border-radius: var(--radius-md);
  padding: 18px;
}

/* ── Deposit Modal ── */
.deposit-modal {
  display: grid;
  grid-template-columns: minmax(280px, .85fr) minmax(360px, 1.15fr);
  gap: 16px; align-items: start;
}
.deposit-source {
  background: var(--panel-soft);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 16px;
}
.deposit-editor {
  background: #fff;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 16px;
}

.warning {
  border: 1px solid #E3D0A2;
  background: var(--warning-soft);
  color: #71551D;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  margin-top: 12px;
}

.empty {
  padding: 34px; text-align: center; color: var(--text-secondary);
  border: 1px dashed var(--border); border-radius: var(--radius-md);
  background: var(--panel-soft);
}

/* ── Dialog ── */
dialog {
  width: min(1040px, calc(100vw - 26px));
  max-height: calc(100vh - 28px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 22px 60px rgba(0,0,0,.22);
  padding: 0; background: var(--panel);
}
dialog::backdrop { background: rgba(31, 28, 23, .28); }
.modal-head, .modal-foot {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-soft);
  display: flex; justify-content: space-between; gap: 10px; align-items: center;
}
.modal-foot {
  border-top: 1px solid var(--border-soft); border-bottom: 0;
  justify-content: flex-end; flex-wrap: wrap;
  position: sticky; bottom: 0; background: var(--panel);
}
.modal-head h3 { margin: 0; }
.modal-body {
  padding: 22px; overflow: auto;
  max-height: calc(100vh - 160px);
}

.oral-modal { grid-template-columns: 1fr 1fr; align-items: start; }
.oral-modal textarea#oRaw { min-height: 190px; }
.result-box {
  background: var(--panel-soft);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 18px;
  white-space: pre-wrap;
}

/* ── Upload Zone ── */
.upload-zone {
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  background: var(--panel-soft);
  padding: 18px; text-align: center;
  color: var(--text-secondary); cursor: pointer;
}
.upload-zone.dragover { border-color: var(--accent); background: var(--accent-soft); }
.upload-zone:focus, .upload-zone.paste-focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 28, 23, .06);
  outline: none;
}

.attachment-list { display: grid; gap: 10px; margin-top: 12px; }
.attachment-item {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  align-items: center; gap: 12px;
  border: 1px solid var(--border-soft); border-radius: var(--radius-sm);
  background: #fff; padding: 10px;
}
.attachment-note { margin-top: 7px; min-height: 32px; font-size: 12px; padding: 5px 8px; }
.attachment-thumb {
  width: 48px; height: 48px;
  border-radius: var(--radius-sm);
  background: var(--panel-soft);
  border: 1px solid var(--border-soft);
  object-fit: cover;
  display: grid; place-items: center;
  color: var(--text-muted); font-size: 12px;
}

/* ── Image strip & preview ── */
.image-strip { display: flex; flex-wrap: wrap; gap: 10px; }
.image-strip a { display: inline-flex; }
.image-strip img {
  width: 86px; height: 86px;
  border-radius: var(--radius-sm); object-fit: cover;
  border: 1px solid var(--border-soft);
  background: #fff;
}

.image-preview {
  position: fixed; inset: 0; z-index: 120;
  display: none; place-items: center;
  padding: 28px;
  background: rgba(31, 28, 23, .30);
}
.image-preview.open { display: grid; }
.image-preview-panel {
  max-width: min(1040px, calc(100vw - 48px));
  max-height: calc(100vh - 48px);
  display: grid; gap: 10px;
  padding: 14px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: 0 20px 60px rgba(31, 28, 23, .18);
}
.image-preview-head, .image-preview-actions {
  display: flex; justify-content: space-between; align-items: center;
  gap: 10px; color: var(--text-secondary); font-size: 13px;
}
.image-preview img {
  max-width: 100%; max-height: calc(100vh - 190px);
  object-fit: contain; border-radius: var(--radius-sm);
  background: var(--panel-soft);
}

/* ── Toast ── */
.toast {
  position: fixed; right: 24px; bottom: 24px; z-index: 60;
  background: var(--accent); color: #fff;
  border-radius: 999px; padding: 10px 16px;
  box-shadow: var(--shadow-soft);
  font-size: 13px;
  opacity: 0; transform: translateY(8px);
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ── Launch Groups ── */
.launch-groups { display: grid; gap: 14px; }
.launch-group {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 16px;
  background: var(--panel-soft);
}
.launch-group h4 { margin: 0 0 12px; font-size: 14px; font-weight: 600; }

/* ── Fact Dossier ── */
.fact-dossier { display: grid; gap: 0; }
.fact-dossier-head { padding: 0 0 10px; border-bottom: 1px solid var(--border-soft); }
.fact-dossier-head h3 { margin: 0 0 4px; font-size: 18px; }
.fact-board { display: grid; grid-template-columns: 1fr; gap: 0; }
.fact-section {
  padding: 18px 0;
  border-bottom: 1px solid var(--border-soft);
}
.fact-section-head {
  display: flex; justify-content: space-between; gap: 16px;
  align-items: flex-start; margin-bottom: 12px;
}
.fact-section-head h3 { margin: 0; font-size: 16px; font-weight: 600; }
.fact-fixed { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px 18px; }
.fact-value b { display: block; color: var(--text-secondary); font-size: 12px; font-weight: 500; }
.fact-value div { min-height: 20px; margin-top: 2px; white-space: pre-wrap; word-break: break-word; }
.fact-images { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.fact-images figure { margin: 0; width: 72px; }
.image-thumb-button {
  border: 0; background: transparent; padding: 0;
  min-height: auto; display: inline-flex; cursor: zoom-in;
}
.fact-images img {
  width: 72px; height: 72px; object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
  background: #fff;
}
.fact-images figcaption {
  margin-top: 3px; color: var(--text-secondary); font-size: 11px;
  line-height: 1.3; overflow: hidden; text-overflow: ellipsis;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.fact-detail-list { display: grid; gap: 0; margin-top: 12px; border-top: 1px solid var(--border-soft); }
.fact-detail-row { display: flex; flex-direction: column; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--border-soft); }
.fact-detail-main { min-width: 0; }
.fact-detail-media-row { display: flex; gap: 20px; align-items: flex-start; }
.fact-detail-attachments { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.fact-detail-title {
  border: 0; background: transparent; padding: 0;
  min-height: auto; color: var(--text-secondary);
  font-size: 12px; font-weight: 500;
  text-align: left; text-decoration: none;
  text-decoration-thickness: 1px; text-underline-offset: 3px;
}
.fact-detail-title:hover { text-decoration: underline; }
.fact-detail-summary,
.fact-detail-summary.line-clamp-2 {
  margin-top: 2px; color: var(--text);
  font-size: 14px; font-weight: 400; line-height: 1.5;
}
.fact-detail-images { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.fact-detail-images img {
  width: 56px; height: 56px; object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
  background: #fff;
}
.fact-detail-more { color: var(--text-secondary); font-size: 12px; }
.fact-detail-attachments { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.fact-img-fig { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.fact-img-fig figcaption { font-size: 10px; color: var(--text-secondary); max-width: 56px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fact-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }

/* ── QA ── */
.qa-search {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px; align-items: end;
}
.qa-search input { min-height: 48px; font-size: 15px; }
.quick-questions, .history-list { display: flex; flex-wrap: wrap; gap: 8px; }
.answer-panel { display: grid; gap: 16px; }
.answer-direct {
  border-left: 3px solid var(--accent);
  padding: 14px 16px;
  background: var(--panel-soft);
  border-radius: var(--radius-sm);
  white-space: pre-wrap;
}
.result-card { display: grid; gap: 10px; }
.result-card mark { background: var(--warning-soft); color: var(--text); padding: 0 2px; }

/* ── Utilities ── */
.hidden { display: none !important; }
.setting-actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* ── Responsive ── */
@media (max-width: 1320px) {
  .layout { grid-template-columns: clamp(240px, 20vw, 260px) minmax(0, 1fr); }
  .main { padding: 14px 22px 24px; }
  .detail-head { padding: 0 0 10px; }
  .detail-head h2 { font-size: 25px; }
}
@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { height: auto; display: block; }
  .main { min-height: 60vh; }
  .grid.two, .grid.three, .fields, .generation-grid, .oral-modal { grid-template-columns: 1fr; }
  .fact-board, .fact-fixed { grid-template-columns: 1fr; }
  .deposit-modal { grid-template-columns: 1fr; }
  .qa-search { grid-template-columns: 1fr; }
  .content { max-height: none; }
}
