:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --line: #dbe4f0;
  --line-strong: #cbd5e1;
  --text: #14213d;
  --muted: #64748b;
  --primary: #1e40af;
  --primary-2: #2563eb;
  --primary-soft: #dbeafe;
  --green: #047857;
  --green-soft: #d1fae5;
  --red: #dc2626;
  --amber: #b45309;
  --amber-soft: #fef3c7;
  --shadow: 0 14px 34px rgba(15, 23, 42, .10);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: .5;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  position: relative;
  background: #eef4ff url("/1.jpg") center / cover no-repeat;
}

.login-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(248, 250, 252, .96), rgba(248, 250, 252, .82) 48%, rgba(219, 234, 254, .58));
}

.login-panel {
  position: relative;
  width: min(420px, calc(100vw - 36px));
  padding: 34px;
  border: 1px solid rgba(203, 213, 225, .9);
  border-radius: 8px;
  background: rgba(255, 255, 255, .94);
  box-shadow: var(--shadow);
}

.login-shell {
  position: relative;
  width: min(1040px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(340px, 420px);
  gap: 28px;
  align-items: stretch;
}

.login-intro {
  padding: 28px 10px 28px 8px;
  color: #10233f;
}

.login-intro .login-brand {
  margin-bottom: 18px;
}

.login-intro-copy {
  max-width: 560px;
  margin: 0 0 22px;
  color: #52637d;
  font-size: 16px;
  line-height: 1.75;
}

.login-features {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  max-width: 680px;
}

.login-features article {
  display: flex;
  gap: 12px;
  min-height: 88px;
  padding: 14px;
  border: 1px solid rgba(148, 163, 184, .28);
  border-radius: 8px;
  background: rgba(255, 255, 255, .72);
  box-shadow: 0 12px 28px rgba(15, 23, 42, .06);
}

.login-feature-icon {
  display: inline-grid;
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 9px;
  background: #dbeafe;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 800;
}

.login-features strong,
.login-features small {
  display: block;
}

.login-features strong {
  margin: 1px 0 5px;
  font-size: 14px;
}

.login-features small {
  color: #60708a;
  line-height: 1.55;
}

.login-panel-head {
  display: grid;
  gap: 5px;
  margin-bottom: 20px;
}

.login-panel-head span {
  color: #10233f;
  font-size: 20px;
  font-weight: 800;
}

.login-panel-head small,
.login-hint {
  color: var(--muted);
}

.login-hint {
  margin: 16px 0 0;
  font-size: 12px;
  line-height: 1.6;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}

.login-brand img,
.brand img,
.topbar-brand img {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  object-fit: contain;
}

.login-brand strong {
  display: block;
  font-size: 22px;
  line-height: 1.2;
}

.login-brand span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 16px;
}

.layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 246px minmax(0, 1fr);
}

.sidebar {
  background: linear-gradient(180deg, #ffffff, #f8fbff);
  border-right: 1px solid var(--line);
  padding: 18px 12px;
}

.brand {
  min-height: 58px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
  color: var(--primary);
}

.brand strong {
  display: block;
  font-size: 15px;
  line-height: 1.25;
}

.brand span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.nav {
  margin-top: 14px;
  display: grid;
  gap: 4px;
}

.nav button {
  width: 100%;
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: #334155;
  background: transparent;
  text-align: left;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 9px;
  transition: background .18s ease, color .18s ease, border-color .18s ease;
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  color: #64748b;
}

.nav button.active .nav-icon,
.nav button:hover .nav-icon {
  color: var(--primary);
}

.nav button:hover {
  background: #edf4ff;
  border-color: #d6e5ff;
}

.nav button.active {
  color: var(--primary);
  background: var(--primary-soft);
  border-color: #bfdbfe;
  font-weight: 700;
}

.main {
  min-width: 0;
  display: grid;
  grid-template-rows: 62px minmax(0, 1fr);
}

.topbar {
  background: rgba(255, 255, 255, .94);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
}

.topbar strong {
  font-size: 17px;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #334155;
  white-space: nowrap;
}

.topbar-brand img {
  width: 28px;
  height: 28px;
}

.content {
  min-width: 0;
  padding: 22px;
  overflow: auto;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.stat,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
}

.stat {
  min-height: 102px;
  padding: 16px;
}

.stat span,
.stat small {
  color: var(--muted);
}

.stat strong {
  display: inline-block;
  margin-top: 10px;
  margin-right: 6px;
  font-size: 28px;
  line-height: 1;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.dashboard-grid.lower {
  margin-top: 14px;
}

.panel {
  padding: 16px;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 15px;
  line-height: 1.3;
}

.chart-panel canvas {
  width: 100%;
  min-height: 220px;
  display: block;
}

.field {
  display: grid;
  gap: 7px;
  color: #344054;
  font-weight: 700;
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 8px 10px;
  outline: none;
}

.input.large,
.btn.large {
  min-height: 44px;
}

.select.compact {
  min-height: 32px;
  width: auto;
  padding: 4px 8px;
}

.textarea {
  min-height: 110px;
  resize: vertical;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--primary-2);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .14);
}

.btn {
  min-height: 36px;
  border-radius: 6px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: #eef3f8;
  color: var(--text);
  border: 1px solid transparent;
  transition: background .18s ease, border-color .18s ease, color .18s ease, transform .12s ease;
}

.btn:hover {
  border-color: var(--line-strong);
}

.btn:active {
  transform: translateY(1px);
}

.btn.primary {
  color: #fff;
  background: var(--primary);
}

.btn.primary:hover {
  background: var(--primary-2);
}

.btn.danger {
  color: #fff;
  background: var(--red);
}

.btn.ghost {
  background: #fff;
  border-color: var(--line);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.toolbar .left,
.toolbar .right {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.toolbar .input,
.toolbar .select {
  width: 230px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
}

.info-table {
  min-width: 0;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  background: #f8fafc;
  color: #475467;
  font-size: 13px;
  font-weight: 700;
}

tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover td {
  background: #fbfdff;
}

tbody tr.card-self-row td {
  background: #eff6ff;
  border-bottom-color: #bfdbfe;
}

tbody tr.card-self-row:hover td {
  background: #dbeafe;
}

.own-card-badge {
  display: inline-flex;
  min-height: 22px;
  align-items: center;
  margin-left: 8px;
  border-radius: 999px;
  padding: 0 8px;
  background: #dbeafe;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.pill {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border-radius: 999px;
  padding: 0 8px;
  font-size: 12px;
  background: #e0f2fe;
  color: #075985;
  white-space: nowrap;
}

.pill.green {
  background: var(--green-soft);
  color: var(--green);
}

.pill.amber {
  background: var(--amber-soft);
  color: var(--amber);
}

.pill.red {
  background: #fee2e2;
  color: #b91c1c;
}

.muted {
  color: var(--muted);
  font-size: 12px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.empty {
  padding: 28px;
  text-align: center;
  color: var(--muted);
}

.pager {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  margin-top: 12px;
  color: var(--muted);
}

.pager label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.feed-list {
  display: grid;
  gap: 12px;
}

.feed-item {
  display: grid;
  gap: 10px;
}

.feed-title {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.preline {
  white-space: pre-wrap;
  line-height: 1.75;
  color: #334155;
}

.message-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 10px;
  background: #fff;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
}

.table-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.table-head h3 {
  margin: 0;
  font-size: 16px;
}

.segmented {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  margin: 0 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.segmented button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  padding: 0 14px;
  background: transparent;
  color: var(--muted);
}

.segmented button.active {
  background: #fff;
  color: var(--primary);
  box-shadow: 0 1px 2px rgba(15, 23, 42, .08);
}

.segmented .ai-rewrite-icon,
.btn .ai-rewrite-icon {
  width: 15px;
  height: 15px;
}

.ai-rewrite {
  display: grid;
  gap: 16px;
  position: relative;
}

.ai-rewrite-notice {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
  color: #1e3a8a;
}

.ai-rewrite-notice strong {
  white-space: nowrap;
}

.ai-rewrite-hero {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 18px;
  padding: 22px;
  border: 1px solid #d6e4f6;
  border-radius: 8px;
  background:
    radial-gradient(circle at 14% 18%, rgba(37, 99, 235, .12), transparent 28%),
    linear-gradient(135deg, #ffffff 0%, #f4f8ff 55%, #f8fbff 100%);
  box-shadow: 0 14px 34px rgba(15, 23, 42, .07);
  overflow: hidden;
}

.ai-rewrite-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ai-rewrite-hero h2 {
  margin: 0 0 8px;
  font-size: 30px;
  letter-spacing: 0;
}

.ai-rewrite-eyebrow {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  color: #5b6b86;
  font-size: 12px;
  font-weight: 700;
}

.ai-rewrite-hero p {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.ai-rewrite-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.ai-rewrite-title-icon {
  width: 48px;
  height: 48px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, #1d4ed8, #7c3aed);
  color: #fff;
  box-shadow: 0 12px 26px rgba(37, 99, 235, .24);
}

.ai-rewrite-title-icon .ai-rewrite-icon {
  width: 25px;
  height: 25px;
}

.ai-rewrite-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.ai-rewrite-steps span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid #dbeafe;
  border-radius: 8px;
  background: rgba(255,255,255,.78);
  color: #1e3a8a;
  font-size: 12px;
  font-weight: 700;
}

.ai-rewrite-meter {
  min-width: 160px;
  display: grid;
  align-content: center;
  gap: 3px;
  padding: 16px;
  border: 1px solid #dbeafe;
  border-radius: 8px;
  background: rgba(255,255,255,.86);
  text-align: right;
  box-shadow: 0 10px 24px rgba(15,23,42,.06);
}

.ai-rewrite-meter span,
.ai-rewrite-meter small {
  color: var(--muted);
}

.ai-rewrite-meter strong {
  font-size: 26px;
  color: var(--primary);
}

.ai-rewrite-modes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.ai-rewrite-modes button {
  min-height: 88px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 15px;
  border: 1px solid #dbe4f0;
  border-radius: 8px;
  background: linear-gradient(180deg, #fff, #fbfdff);
  color: var(--text);
  text-align: left;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease, transform .18s ease;
}

.ai-rewrite-modes button:hover {
  transform: translateY(-1px);
  border-color: #93c5fd;
  box-shadow: 0 10px 22px rgba(15, 23, 42, .06);
}

.ai-rewrite-modes button strong,
.ai-rewrite-modes button span {
  display: block;
}

.ai-rewrite-modes .mode-icon {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  margin-bottom: 10px;
  border-radius: 8px;
  background: #eef2ff;
  color: #1d4ed8;
}

.ai-rewrite-modes .mode-icon .ai-rewrite-icon {
  width: 19px;
  height: 19px;
}

.ai-rewrite-modes .mode-description {
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.45;
}

.ai-rewrite-modes button.active {
  border-color: #60a5fa;
  background: linear-gradient(180deg, #eff6ff, #fff);
  box-shadow: 0 12px 24px rgba(37, 99, 235, .13);
}

.ai-rewrite-modes button.active .mode-icon {
  background: #1d4ed8;
  color: #fff;
}

.ai-rewrite-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.ai-rewrite-workbench {
  min-width: 0;
  position: relative;
  overflow: hidden;
  border-color: #d6e4f6;
  box-shadow: 0 12px 28px rgba(15, 23, 42, .06);
}

.ai-rewrite-workbench::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: linear-gradient(90deg, #2563eb, #7c3aed, #06b6d4);
}

.ai-rewrite-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 18px 8px;
}

.ai-rewrite-panel-head h3 {
  margin: 0;
  font-size: 18px;
}

.ai-rewrite-api-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 8px;
  background: #ecfeff;
  color: #0e7490;
  font-size: 12px;
  font-weight: 800;
}

.ai-rewrite-controls {
  justify-content: flex-start;
  display: grid;
  grid-template-columns: minmax(140px, .75fr) minmax(150px, .75fr) minmax(260px, 1.6fr);
  gap: 10px;
  padding: 8px 18px 4px;
}

.ai-rewrite-control-card {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 5px 8px;
  align-items: center;
  padding: 10px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fbfdff;
}

.ai-rewrite-control-card > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.ai-rewrite-control-card .select {
  grid-column: 1 / -1;
  width: 100%;
  background: #fff;
}

.ai-rewrite-textarea {
  min-height: 230px;
  border-color: #dbeafe;
  background: linear-gradient(180deg, #fff, #fbfdff);
  resize: vertical;
  line-height: 1.7;
}

.ai-rewrite-form-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
}

.ai-rewrite-form-foot span {
  color: var(--muted);
}

.ai-rewrite-upload {
  display: grid;
  place-items: center;
  gap: 9px;
  min-height: 188px;
  padding: 24px;
  border: 2px dashed #93c5fd;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.95), rgba(248,251,255,.95)),
    repeating-linear-gradient(135deg, rgba(37,99,235,.06) 0 10px, transparent 10px 20px);
  text-align: center;
  transition: border-color .18s ease, background .18s ease, box-shadow .18s ease;
}

.ai-rewrite-upload:hover {
  border-color: #2563eb;
  background: #f8faff;
  box-shadow: inset 0 0 0 1px rgba(37,99,235,.08);
}

.ai-rewrite-upload input {
  max-width: 260px;
}

.ai-rewrite-upload span {
  color: var(--muted);
  max-width: 920px;
  line-height: 1.65;
}

.ai-rewrite-upload-mark {
  width: 46px;
  height: 46px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, #dbeafe, #eef2ff);
  color: #1d4ed8 !important;
  box-shadow: 0 8px 18px rgba(37,99,235,.12);
}

.ai-rewrite-upload-mark .ai-rewrite-icon {
  width: 24px;
  height: 24px;
}

.ai-file-estimate {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--panel-soft);
}

.ai-file-estimate.ready {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: #166534;
}

.ai-file-estimate.loading {
  border-color: #bfdbfe;
  background: #eff6ff;
  color: #1e40af;
}

.ai-file-estimate.error {
  border-color: #fecaca;
  background: #fff1f2;
  color: #b91c1c;
}

.ai-history-preview {
  max-width: 240px;
  display: grid;
  gap: 2px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.ai-history-preview strong {
  color: var(--primary);
  font-size: 12px;
}

.ai-history-preview span,
.ai-history-file {
  color: var(--muted);
  line-height: 1.45;
  word-break: break-word;
}

.ai-rewrite-result {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.ai-rewrite-side {
  display: grid;
  gap: 12px;
}

.ai-rewrite-side h3,
.ai-rewrite-side p {
  margin: 0;
}

.ai-rewrite-side p {
  color: var(--muted);
  line-height: 1.7;
}

.ai-rewrite-side div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.ai-rewrite-side span {
  color: var(--muted);
}

.ai-rewrite-float {
  position: fixed;
  right: 18px;
  top: 45%;
  z-index: 18;
  width: 48px;
  min-height: 92px;
  border: 0;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow);
}

.ai-rewrite-hero-actions {
  min-width: 180px;
  display: grid;
  align-content: center;
  gap: 10px;
}

.ai-rewrite-guide-trigger {
  width: 100%;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border-color: #bfdbfe;
  background: rgba(255,255,255,.88);
  color: #1d4ed8;
}

.modal-mask.ai-rewrite-guide-mask {
  z-index: 70;
  padding: 12px;
  background: rgba(15,23,42,.58);
  backdrop-filter: blur(2px);
}

.modal.ai-rewrite-guide-modal {
  width: min(980px, 100%);
  max-height: min(94vh, 900px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  border-color: #cbd5e1;
  box-shadow: 0 28px 70px rgba(15,23,42,.28);
}

.ai-rewrite-guide-modal .modal-head {
  min-height: 82px;
  padding: 16px 22px;
  background: #fff;
}

.ai-rewrite-guide-heading {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 13px;
}

.ai-rewrite-guide-heading > .ai-rewrite-icon {
  width: 34px;
  height: 34px;
  color: #2563eb;
}

.ai-rewrite-guide-heading span {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.ai-rewrite-guide-heading b {
  color: #172033;
  font-size: 22px;
  line-height: 1.25;
}

.ai-rewrite-guide-heading small {
  color: #64748b;
  font-size: 13px;
  font-weight: 500;
}

.ai-rewrite-guide-close {
  width: 36px;
  height: 36px;
  min-width: 36px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #475569;
  font-size: 27px;
  font-weight: 400;
  line-height: 1;
}

.ai-rewrite-guide-modal .modal-body {
  min-height: 0;
  overflow: auto;
  padding: 0 22px 20px;
  scrollbar-gutter: stable;
}

.ai-rewrite-guide {
  display: grid;
  gap: 14px;
}

.ai-rewrite-guide-banner {
  position: relative;
  min-height: 204px;
  overflow: hidden;
  padding: 22px;
  border: 1px solid #738cf2;
  border-radius: 8px;
  background: linear-gradient(135deg, #7893f3 0%, #8796ef 52%, #6f7ee6 100%);
  color: #fff;
  box-shadow: 0 12px 26px rgba(67,86,190,.22);
}

.ai-rewrite-guide-banner::after {
  content: "";
  position: absolute;
  width: 250px;
  height: 250px;
  right: -76px;
  bottom: -118px;
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 50%;
  box-shadow: 0 0 0 22px rgba(255,255,255,.05), 0 0 0 46px rgba(255,255,255,.04);
}

.ai-rewrite-guide-badges {
  display: flex;
  gap: 7px;
  margin-bottom: 13px;
}

.ai-rewrite-guide-badges span {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  padding: 0 11px;
  border: 1px solid rgba(255,255,255,.68);
  border-radius: 8px;
  background: rgba(255,255,255,.12);
  font-size: 12px;
  font-weight: 700;
}

.ai-rewrite-guide-banner > strong {
  display: block;
  margin-bottom: 7px;
  font-size: 21px;
}

.ai-rewrite-guide-banner > p {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0;
  color: rgba(255,255,255,.95);
  line-height: 1.65;
}

.ai-rewrite-guide-banner > b {
  position: absolute;
  z-index: 1;
  right: 28px;
  top: 18px;
  color: #fff;
  font-size: 68px;
  font-style: italic;
  line-height: 1;
  text-shadow: 0 5px 18px rgba(42,53,139,.28);
}

.ai-rewrite-guide-highlights {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 5px;
  margin-top: 14px;
  max-width: 760px;
}

.ai-rewrite-guide-highlights span {
  min-width: 0;
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 8px;
  background: rgba(255,255,255,.12);
  font-size: 12px;
  font-weight: 600;
}

.ai-rewrite-guide-highlights .ai-rewrite-icon {
  width: 15px;
  height: 15px;
}

.ai-rewrite-guide-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 12px;
}

.ai-rewrite-guide-card {
  min-width: 0;
  display: grid;
  grid-template-columns: 42px minmax(0,1fr);
  align-items: start;
  gap: 12px;
  padding: 18px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 5px 14px rgba(15,23,42,.05);
}

.ai-rewrite-guide-card.wide {
  grid-column: 1 / -1;
}

.ai-rewrite-guide-card-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
}

.ai-rewrite-guide-card-icon .ai-rewrite-icon {
  width: 24px;
  height: 24px;
}

.ai-rewrite-guide-card-icon.blue { color: #2563eb; background: #eff6ff; }
.ai-rewrite-guide-card-icon.cyan { color: #0891b2; background: #ecfeff; }
.ai-rewrite-guide-card-icon.green { color: #059669; background: #ecfdf5; }
.ai-rewrite-guide-card-icon.amber { color: #d97706; background: #fffbeb; }
.ai-rewrite-guide-card-icon.rose { color: #e11d48; background: #fff1f2; }

.ai-rewrite-guide-card h3 {
  margin: 1px 0 8px;
  color: #172033;
  font-size: 16px;
  letter-spacing: 0;
}

.ai-rewrite-guide-card h3 em {
  margin-right: 7px;
  color: #2563eb;
  font-size: 13px;
  font-style: normal;
}

.ai-rewrite-guide-card p {
  margin: 0;
  color: #475569;
  font-size: 13px;
  line-height: 1.75;
}

.ai-rewrite-guide-card p strong {
  color: #172033;
}

.ai-rewrite-guide-platforms {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 10px;
}

.ai-rewrite-guide-platforms span {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 700;
}

.ai-rewrite-guide-card .ai-rewrite-guide-note {
  padding: 10px 12px;
  border-left: 3px solid #f43f5e;
  background: #f8fafc;
}

.ai-rewrite-guide-reminder {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 15px;
  border: 1px solid #fde68a;
  border-radius: 8px;
  background: #fffbeb;
  color: #713f12;
  line-height: 1.65;
}

.ai-rewrite-guide-reminder strong {
  flex: 0 0 auto;
}

.ai-rewrite-guide-modal .modal-foot {
  gap: 14px;
  padding: 13px 22px;
  background: #fff;
}

.ai-rewrite-guide-foot-note {
  color: #64748b;
  font-size: 13px;
}

@media (max-width: 820px) {
  .ai-rewrite-hero-actions {
    width: 100%;
  }

  .modal-mask.ai-rewrite-guide-mask {
    padding: 6px;
  }

  .modal.ai-rewrite-guide-modal {
    max-height: calc(100dvh - 12px);
  }

  .ai-rewrite-guide-modal .modal-head {
    min-height: 72px;
    padding: 12px 15px;
  }

  .ai-rewrite-guide-modal .modal-body {
    padding: 0 14px 16px;
  }

  .ai-rewrite-guide-modal .modal-foot {
    padding: 11px 14px;
  }

  .ai-rewrite-guide-banner {
    padding: 18px;
  }

  .ai-rewrite-guide-banner > b {
    right: 18px;
    top: 18px;
    font-size: 52px;
  }
}

@media (max-width: 640px) {
  .ai-rewrite-guide-heading b {
    font-size: 18px;
  }

  .ai-rewrite-guide-heading small {
    font-size: 12px;
  }

  .ai-rewrite-guide-banner {
    min-height: 0;
    padding-top: 74px;
  }

  .ai-rewrite-guide-banner > b {
    left: 18px;
    right: auto;
    top: 14px;
    font-size: 46px;
  }

  .ai-rewrite-guide-highlights,
  .ai-rewrite-guide-grid {
    grid-template-columns: 1fr;
  }

  .ai-rewrite-guide-card.wide {
    grid-column: auto;
  }

  .ai-rewrite-guide-card {
    padding: 14px;
  }

  .ai-rewrite-guide-reminder,
  .ai-rewrite-guide-modal .modal-foot {
    align-items: stretch;
    flex-direction: column;
  }

  .ai-rewrite-guide-modal .modal-foot .btn {
    width: 100%;
  }
}

.paper-agent {
  display: grid;
  grid-template-columns: minmax(0,1fr);
  gap: 14px;
}

.software-paper {
  display: grid;
  gap: 14px;
}

.software-paper-hero {
  background: linear-gradient(135deg,#ffffff,#eefdf7);
}

.software-paper .paper-agent-price {
  border-color: #bbf7d0;
}

.software-paper .paper-agent-price strong {
  color: #047857;
}

.software-paper .paper-agent-price em {
  font-style: normal;
  color: var(--text);
}

.paper-agent-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: linear-gradient(135deg,#ffffff,#eef6ff);
}

.paper-agent-eyebrow {
  display: inline-flex;
  margin-bottom: 8px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
}

.paper-agent-hero h2 {
  margin: 0;
  font-size: 24px;
}

.paper-agent-hero p {
  max-width: 760px;
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.paper-agent-price {
  min-width: 190px;
  padding: 14px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #fff;
}

.paper-agent-price span,
.paper-agent-price small {
  display: block;
  color: var(--muted);
}

.paper-agent-price strong {
  display: block;
  margin: 7px 0;
  color: var(--primary);
  font-size: 18px;
}

.paper-agent-models {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.paper-agent-models label {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px 10px;
  align-items: center;
  min-height: 78px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.paper-agent-models label.active {
  border-color: #93c5fd;
  background: #eff6ff;
}

.paper-agent-models span {
  grid-column: 2 / 4;
  color: var(--muted);
  line-height: 1.5;
}

.paper-agent-models b {
  color: var(--primary);
}

.paper-agent-grid {
  display: grid;
  grid-template-columns: minmax(0,1fr) 180px;
  gap: 12px;
}

.paper-agent-grid .wide {
  grid-column: 1 / -1;
}

.software-source-panel {
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fbfa;
}

.software-source-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.software-source-heading span {
  font-weight: 700;
}

.software-source-heading small,
.software-source-note {
  color: var(--muted);
}

.software-source-grid {
  display: grid;
  grid-template-columns: repeat(3,minmax(0,1fr));
  gap: 10px;
}

.paper-cs-hint-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  font-size: 13px;
  color: #1e40af;
  line-height: 1.5;
}

.paper-cs-hint-banner strong {
  color: #1e3a8a;
}

.paper-cs-hint-banner .link-btn {
  background: none;
  border: none;
  padding: 0 2px;
  color: #2563eb;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  font-size: inherit;
}

.paper-cs-hint-banner .link-btn:hover {
  color: #1d4ed8;
}

.software-mechanical-panel {
  border-color: #b9d8ce;
  background: #f5faf8;
}

.software-mechanical-grid {
  display: grid;
  grid-template-columns: repeat(3,minmax(0,1fr));
  gap: 10px;
}

.software-mechanical-grid .field {
  min-width: 0;
}

.cad-health-ok {
  color: #16734b !important;
  font-weight: 700;
}

.cad-health-error {
  color: #b42318 !important;
  font-weight: 700;
}

.software-source-upload {
  min-width: 0;
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px solid #d5e2de;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.software-source-upload span {
  min-height: 36px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.software-source-upload input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.software-source-upload em {
  overflow: hidden;
  color: var(--primary);
  font-size: 13px;
  font-style: normal;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.paper-companion-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 22px;
  padding: 11px 12px;
  border: 1px solid #d5e2de;
  border-radius: 6px;
  background: #fff;
}

.paper-companion-options .check-row {
  margin: 0;
}

.software-result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 190px;
}

.paper-agent-options {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.paper-agent-options > span {
  font-weight: 800;
}

.college-writing-config {
  padding: 12px;
  border: 1px solid #ffa940;
  border-left: 4px solid #ffa940;
  border-radius: 8px;
  background: #fff7e6;
}
.college-writing-config > span {
  font-weight: 800;
  color: #d46b08;
}
.college-writing-config [data-college-bachelor-tip] {
  display: block;
  margin-top: 6px;
  color: #d46b08;
  font-weight: 600;
}

.software-template-field {
  position: relative;
}

.software-template-menu {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  z-index: 14;
  max-height: 260px;
  overflow: auto;
  margin-top: 4px;
  padding: 6px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 38px rgba(15, 23, 42, .16);
}

.software-template-menu.open {
  display: grid;
  gap: 4px;
}

.software-template-option {
  width: 100%;
  min-height: 36px;
  padding: 7px 9px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
}

.software-template-option:hover,
.software-template-option:focus {
  background: #edf4ff;
  color: var(--primary);
  outline: none;
}

.software-template-option span,
.software-template-empty {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.software-template-empty {
  padding: 8px 9px;
}

.software-paper-outline textarea {
  min-height: 220px;
  line-height: 1.65;
}

.software-paper-outline small {
  color: var(--muted);
  line-height: 1.55;
}

.software-paper-outline .field-error {
  padding: 10px 12px;
  border: 1px solid #fecaca;
  border-radius: 8px;
  background: #fff1f2;
  color: #b91c1c;
  font-weight: 800;
}

.software-paper-outline textarea.invalid,
.software-paper-outline textarea.invalid:focus {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239,68,68,.12);
}

.software-outline-preview {
  min-height: 104px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  color: var(--text);
}

.software-outline-preview.invalid {
  border-color: #fecaca;
  background: #fff7f7;
}

.software-outline-preview-row {
  display: grid;
  grid-template-columns: 72px minmax(0,1fr);
  gap: 8px;
  align-items: start;
  min-height: 28px;
  line-height: 1.55;
}

.software-outline-preview-row b {
  color: #0f766e;
}

.software-outline-preview-row.level-2 {
  padding-left: 22px;
}

.software-outline-preview-row.level-3 {
  padding-left: 44px;
}

.software-outline-preview-row.level-4 {
  padding-left: 66px;
}

.paper-outline-markdown {
  min-height: 132px;
}

.paper-outline-markdown-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.paper-outline-markdown-head small {
  color: var(--muted);
}

.paper-outline-markdown pre {
  min-height: 88px;
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: #164e63;
  font: 600 13px/1.65 Consolas, "Courier New", monospace;
}

.software-paper-outline .field-error > div + div {
  margin-top: 6px;
}

.chapter-workspace {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-soft, #f8fafc);
}

.chapter-workspace-head,
.chapter-workspace-row-head,
.chapter-workspace-output-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.chapter-workspace-head strong {
  display: block;
  color: var(--text);
}

.chapter-workspace-head small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.5;
}

.chapter-workspace-list {
  display: grid;
  gap: 12px;
}

.chapter-workspace-row {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface, #fff);
}

.chapter-workspace-row-head strong {
  color: var(--text);
  line-height: 1.45;
}

.chapter-workspace-row-head span,
.chapter-workspace-output-head span {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.chapter-workspace-row textarea {
  min-height: 76px;
  resize: vertical;
}

.chapter-workspace-output {
  display: grid;
  gap: 8px;
  padding-top: 4px;
  border-top: 1px dashed var(--line);
}

.chapter-workspace-output-head > div {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.chapter-workspace-output textarea {
  min-height: 130px;
  background: #fbfdff;
}

.paper-upload-zone {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 150px;
  padding: 20px;
  border: 2px dashed #93c5fd;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.96), rgba(248,251,255,.96)),
    repeating-linear-gradient(135deg, rgba(37,99,235,.06) 0 10px, transparent 10px 20px);
  color: var(--muted);
  text-align: center;
  cursor: pointer;
  transition: border-color .18s ease, background .18s ease, box-shadow .18s ease;
}

.paper-upload-zone:hover,
.paper-upload-zone.dragging {
  border-color: #2563eb;
  background: #f8faff;
  box-shadow: inset 0 0 0 1px rgba(37,99,235,.1);
}

.paper-upload-zone input {
  width: 1px;
  height: 1px;
  opacity: 0;
  position: absolute;
  pointer-events: none;
}

.paper-upload-zone strong {
  color: var(--text);
  font-size: 15px;
}

.paper-upload-zone small {
  max-width: 720px;
  line-height: 1.6;
}

.paper-upload-zone-compact {
  min-height: 124px;
  padding: 16px;
}

.paper-upload-file-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.paper-upload-file-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 46px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.paper-upload-file-card strong {
  display: block;
  max-width: 620px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
  font-size: 14px;
}

.paper-upload-file-card small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
}

.paper-upload-mark {
  width: 46px;
  height: 46px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, #dbeafe, #eef2ff);
  color: #1d4ed8;
  box-shadow: 0 8px 18px rgba(37,99,235,.12);
}

.paper-upload-mark svg {
  width: 25px;
  height: 25px;
  fill: none;
  stroke: currentColor;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.check-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.check-row label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}

.paper-agent-note {
  padding: 10px 12px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
  color: #1d4ed8;
  line-height: 1.6;
}

.paper-agent-advanced {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  overflow: visible;
}

.paper-agent-advanced summary {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 0 14px;
  color: var(--text);
  font-weight: 900;
  cursor: pointer;
  user-select: none;
}

.paper-agent-advanced-body {
  display: grid;
  gap: 12px;
  padding: 12px;
  border-top: 1px solid var(--line);
  background: #f8fafc;
  border-radius: 0 0 8px 8px;
}

.paper-agent-heading-row {
  display: grid;
  grid-template-columns: repeat(3,minmax(0,1fr));
  gap: 12px;
}

.paper-agent-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  color: var(--muted);
}

.reference-source-panel,
.reference-external-panel {
  display: grid;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.reference-source-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.reference-source-heading strong,
.reference-source-heading span {
  display: block;
}

.reference-source-heading span:not(.pill) {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.reference-source-grid {
  display: grid;
  grid-template-columns: repeat(4,minmax(0,1fr));
  gap: 8px;
}

.reference-source-option {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.reference-source-option:has(input:checked) {
  border-color: #86b9a5;
  background: #f0f9f5;
}

.reference-source-option.disabled {
  opacity: .58;
  cursor: not-allowed;
}

.reference-source-option input {
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
  accent-color: var(--primary);
}

.reference-source-option span,
.reference-source-option strong,
.reference-source-option small {
  display: block;
  min-width: 0;
}

.reference-source-option strong {
  font-size: 13px;
}

.reference-source-option small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.reference-external-links,
.reference-source-stats {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
}

.reference-external-links a {
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  background: #fff;
  font-size: 12px;
  text-decoration: none;
}

.reference-external-links a:hover {
  border-color: #86b9a5;
  background: #f0f9f5;
}

.reference-source-stats {
  padding: 0 2px;
}

.reference-search-link-modal {
  display: grid;
  gap: 14px;
}

.reference-search-link-modal p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.reference-search-link-grid {
  display: grid;
  grid-template-columns: repeat(3,minmax(0,1fr));
  gap: 8px;
}

.reference-search-link-grid a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
}

.reference-search-link-grid a:hover {
  border-color: #86b9a5;
  background: #f0f9f5;
}

.reference-search-link-grid span {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.reference-history {
  display: grid;
  gap: 12px;
}

.reference-history-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 14px;
}

.reference-history-head,
.reference-history-progress {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.reference-history-head strong {
  display: block;
  margin-bottom: 4px;
  line-height: 1.35;
}

.reference-history-head span,
.reference-history-progress span,
.reference-history-meta {
  color: var(--muted);
  font-size: 13px;
}

.reference-history-meta {
  display: flex;
  gap: 10px;
  white-space: nowrap;
}

.reference-history-progress {
  margin-top: 10px;
  justify-content: space-between;
  flex-wrap: wrap;
}

.reference-history-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.reference-citation-list {
  margin: 12px 0 0;
  padding-left: 22px;
  display: grid;
  gap: 8px;
}

.reference-citation-list li {
  line-height: 1.65;
  word-break: break-word;
}

.reference-detail-modal {
  display: grid;
  gap: 16px;
}

.reference-detail-summary {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr .8fr;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.reference-detail-summary span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
}

.reference-detail-summary strong {
  display: block;
  line-height: 1.35;
  word-break: break-word;
}

.reference-detail-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
  counter-reset: reference-item;
}

.reference-detail-list li {
  counter-increment: reference-item;
  position: relative;
  padding: 12px 14px 12px 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  line-height: 1.75;
  word-break: break-word;
}

.reference-detail-list li::before {
  content: counter(reference-item);
  position: absolute;
  left: 14px;
  top: 14px;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  color: #2563eb;
  background: #eff6ff;
  font-size: 12px;
  font-weight: 700;
}

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .42);
  display: grid;
  place-items: center;
  z-index: 20;
  padding: 18px;
}

.modal {
  width: min(760px, 100%);
  max-height: 88vh;
  overflow: auto;
  background: #fff;
  border-radius: 8px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.modal-head,
.modal-foot {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.modal-foot {
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.modal-body {
  padding: 16px;
}

.modal-section {
  min-height: 120px;
}

.revision-workbench {
  display: grid;
  gap: 16px;
}

.revision-state-note {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border-left: 3px solid var(--primary);
  background: var(--soft);
}

.revision-state-note span,
.revision-issue-list small,
.revision-submit-status {
  color: var(--muted);
}

.revision-issue-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 22px;
}

.revision-issue-list li {
  padding-left: 4px;
}

.revision-issue-list li strong,
.revision-issue-list li span,
.revision-issue-list li small {
  display: block;
}

.revision-issue-list li strong {
  margin-bottom: 3px;
  font-size: 12px;
  color: var(--danger);
}

.revision-submit-status {
  min-height: 20px;
  margin: 8px 0;
}

.btn.compact {
  min-height: 32px;
  padding: 6px 10px;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.section-heading h2,
.section-heading p {
  margin: 0;
}

.section-heading p {
  margin-top: 5px;
  color: var(--muted);
}

.recharge-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.recharge-summary > div {
  min-height: 116px;
  padding: 20px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--green);
  border-radius: 8px;
  background: var(--panel);
  display: grid;
  align-content: center;
  gap: 5px;
}

.recharge-summary > div:last-child {
  border-left-color: var(--primary-2);
}

.recharge-summary span,
.recharge-summary small {
  color: var(--muted);
}

.recharge-summary strong {
  font-size: 26px;
}

.profile-layout {
  display: grid;
  grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.profile-summary {
  display: grid;
  gap: 8px;
}

.profile-avatar {
  width: 62px;
  height: 62px;
  margin-bottom: 8px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--green);
  color: #163014;
}

.profile-avatar .nav-icon {
  width: 30px;
  height: 30px;
}

.profile-summary h2,
.profile-summary p {
  margin: 0;
}

.profile-summary p,
.profile-password-heading span {
  color: var(--muted);
}

.profile-facts {
  margin: 18px 0 0;
  border-top: 1px solid var(--line);
}

.profile-facts > div {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.profile-facts dt {
  color: var(--muted);
}

.profile-facts dd {
  min-width: 0;
  max-width: 68%;
  margin: 0;
  text-align: right;
  overflow-wrap: anywhere;
  font-weight: 700;
}

.profile-facts dd code { white-space: normal; overflow-wrap: anywhere; }

.profile-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.profile-password-heading,
.profile-form .form-actions {
  grid-column: 1 / -1;
}

.profile-password-heading {
  margin-top: 4px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

@media (max-width: 800px) {
  .profile-layout,
  .profile-form {
    grid-template-columns: 1fr;
  }
}

.recharge-contact-workbench {
  overflow: hidden;
}

.recharge-contact-card {
  display: grid;
  grid-template-columns: 56px minmax(180px, .8fr) minmax(340px, 1.5fr);
  gap: 18px;
  align-items: center;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbf6;
}

.recharge-contact-icon {
  width: 56px;
  height: 56px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--green);
  color: #163014;
}

.recharge-contact-icon .nav-icon {
  width: 26px;
  height: 26px;
}

.recharge-contact-main {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.recharge-contact-main span,
.recharge-contact-main small {
  color: var(--muted);
}

.recharge-contact-main strong {
  overflow-wrap: anywhere;
  font-size: 22px;
}

.recharge-contact-details {
  min-width: 0;
  margin: 0;
  border-left: 1px solid var(--line);
  padding-left: 20px;
  display: grid;
  gap: 10px;
}

.recharge-contact-details > div {
  min-width: 0;
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.recharge-contact-details dt {
  color: var(--muted);
}

.recharge-contact-details dd {
  min-width: 0;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  overflow-wrap: anywhere;
  font-weight: 700;
}

.recharge-contact-note {
  margin-top: 16px;
  padding: 15px 17px;
  border-left: 4px solid var(--primary-2);
  background: var(--primary-soft);
}

.recharge-contact-note p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

@media (max-width: 900px) {
  .recharge-contact-card {
    grid-template-columns: 56px minmax(0, 1fr);
  }

  .recharge-contact-details {
    grid-column: 1 / -1;
    border-left: 0;
    border-top: 1px solid var(--line);
    padding: 16px 0 0;
  }
}

.recharge-packages {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.recharge-package {
  min-height: 118px;
  padding: 16px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  text-align: left;
  display: grid;
  gap: 6px;
}

.recharge-package:hover,
.recharge-package.selected {
  border-color: var(--primary-2);
  background: var(--primary-soft);
  box-shadow: inset 0 0 0 1px var(--primary-2);
}

.recharge-package strong {
  font-size: 23px;
}

.recharge-package small {
  color: var(--muted);
}

.recharge-custom {
  width: min(420px, 100%);
  margin-top: 18px;
}

.input-affix {
  display: flex;
  align-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.input-affix > span {
  padding: 0 12px;
  color: var(--muted);
  font-weight: 700;
}

.input-affix .input {
  border: 0;
  border-left: 1px solid var(--line);
  border-radius: 0;
}

.recharge-methods {
  margin: 20px 0 0;
  padding: 0;
  border: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.recharge-methods legend {
  grid-column: 1 / -1;
  margin-bottom: 8px;
  font-weight: 700;
}

.recharge-method {
  min-height: 72px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.recharge-method:has(input:checked) {
  border-color: var(--primary-2);
  background: var(--primary-soft);
}

.recharge-method input {
  accent-color: var(--primary);
}

.recharge-method-mark,
.recharge-pay-mark {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--green-soft);
  color: var(--green);
  font-weight: 800;
}

.recharge-method span:last-child {
  display: grid;
  gap: 3px;
}

.recharge-method small {
  color: var(--muted);
}

.recharge-submit-row {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.recharge-submit-row > div {
  display: grid;
  gap: 4px;
}

.recharge-submit-row span {
  color: var(--muted);
}

.recharge-submit-row strong {
  font-size: 20px;
}

.recharge-order-detail {
  display: grid;
  justify-items: center;
  gap: 16px;
}

.recharge-pay-mark {
  width: 56px;
  height: 56px;
  font-size: 21px;
}

.recharge-order-amount {
  display: grid;
  justify-items: center;
  gap: 5px;
}

.recharge-order-amount span,
.recharge-order-detail dt {
  color: var(--muted);
}

.recharge-order-amount strong {
  font-size: 30px;
}

.recharge-order-detail dl {
  width: 100%;
  margin: 0;
  border-top: 1px solid var(--line);
}

.recharge-order-detail dl > div {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 20px;
}

.recharge-order-detail dd {
  margin: 0;
  text-align: right;
  overflow-wrap: anywhere;
}

.recharge-channel-warning {
  width: 100%;
  margin: 0 0 18px;
  padding: 13px 15px;
  border: 1px solid color-mix(in srgb, var(--amber) 42%, transparent);
  border-radius: 8px;
  background: color-mix(in srgb, var(--amber) 12%, transparent);
  color: inherit;
  display: grid;
  gap: 4px;
}

.recharge-channel-warning strong {
  color: var(--amber);
}

.recharge-channel-warning span {
  color: inherit;
  opacity: .78;
}

.recharge-method-empty {
  grid-column: 1 / -1;
  min-height: 72px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.recharge-payment-panel {
  width: 100%;
  padding: 16px;
  border: 1px solid color-mix(in srgb, currentColor 18%, transparent);
  border-radius: 8px;
  background: color-mix(in srgb, currentColor 5%, transparent);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 18px;
}

.recharge-qr-code {
  display: grid;
  justify-items: center;
  gap: 7px;
  color: inherit;
  font-size: 13px;
}

.recharge-qr-code img {
  width: 176px;
  height: 176px;
  padding: 8px;
  border: 1px solid rgba(127, 127, 127, .26);
  border-radius: 8px;
  background: #fff;
  object-fit: contain;
}

.recharge-payment-entry {
  min-width: 0;
  display: grid;
  justify-items: start;
  gap: 9px;
}

.recharge-payment-entry > span {
  color: inherit;
  opacity: .72;
  line-height: 1.6;
}

.recharge-payment-entry .btn {
  margin-top: 3px;
}

.recharge-order-actions {
  display: flex;
  gap: 10px;
}

@media (max-width: 900px) {
  .recharge-packages {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .recharge-summary,
  .recharge-packages,
  .recharge-methods {
    grid-template-columns: 1fr;
  }

  .section-heading,
  .recharge-submit-row,
  .recharge-order-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .recharge-submit-row .btn,
  .recharge-order-actions .btn {
    width: 100%;
  }

  .recharge-payment-panel {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .recharge-payment-entry {
    width: 100%;
    justify-items: stretch;
    text-align: center;
  }
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border-radius: 8px;
  color: #fff;
  background: #111827;
  box-shadow: var(--shadow);
  z-index: 30;
  animation: toast-slide-in .18s ease;
  transition: bottom .18s ease, opacity .2s, transform .2s;
}

.toast.error {
  background: var(--red);
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

@media (max-width: 1100px) {
  .summary-strip,
  .dashboard-grid,
  .ai-rewrite-grid,
  .paper-agent-models {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 820px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
  }

  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .main {
    grid-template-rows: auto minmax(0, 1fr);
  }

  .topbar {
    min-height: 62px;
    gap: 12px;
    align-items: flex-start;
    flex-direction: column;
    padding: 12px 16px;
  }

  .topbar-brand {
    flex-wrap: wrap;
  }

  .summary-strip,
  .dashboard-grid,
  .ai-rewrite-grid,
  .ai-rewrite-modes,
  .paper-agent-models,
  .paper-agent-grid,
  .paper-agent-heading-row {
    grid-template-columns: 1fr;
  }

  .reference-source-grid,
  .reference-search-link-grid {
    grid-template-columns: repeat(2,minmax(0,1fr));
  }

  .software-source-grid {
    grid-template-columns: 1fr;
  }

  .software-mechanical-grid {
    grid-template-columns: 1fr;
  }

  .software-source-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .ai-rewrite-hero,
  .ai-rewrite-form-foot,
  .ai-rewrite-notice,
  .paper-agent-hero,
  .paper-agent-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .ai-rewrite-meter {
    width: 100%;
    text-align: left;
  }

  .content {
    padding: 16px;
  }
}

@media (max-width: 520px) {
  .login-features {
    grid-template-columns: 1fr;
  }

  .login-panel {
    padding: 24px;
  }

  .toolbar .input,
  .toolbar .select,
  .ai-rewrite-controls .select,
  .toolbar .left,
  .toolbar .right,
  .toolbar .btn {
    width: 100%;
  }
}


/* Agent sidebar grouped tech polish - 2026-06-14 */
.sidebar {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 0%, rgba(56, 189, 248, .22), transparent 34%),
    linear-gradient(180deg, #07111f 0%, #0b1730 52%, #081120 100%);
  border-right: 1px solid rgba(125, 211, 252, .22);
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, .04), 18px 0 42px rgba(15, 23, 42, .08);
  padding: 18px 12px;
}

.sidebar::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(148, 163, 184, .08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, .06) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(180deg, rgba(0,0,0,.7), transparent 72%);
}

.brand,
.nav {
  position: relative;
  z-index: 1;
}

.brand {
  min-height: 62px;
  gap: 11px;
  padding: 0 10px 14px;
  color: #e0f2fe;
  border-bottom: 1px solid rgba(125, 211, 252, .14);
}

.brand img {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: rgba(255, 255, 255, .08);
  box-shadow: 0 0 0 1px rgba(125, 211, 252, .25), 0 12px 28px rgba(2, 6, 23, .32);
}

.brand strong {
  color: #f8fafc;
  font-size: 15px;
  letter-spacing: .2px;
}

.brand span {
  color: #93c5fd;
}

.nav {
  margin-top: 16px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
}

.nav button {
  width: 100%;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 12px;
  color: #cbd5e1;
  background: rgba(15, 23, 42, .28);
  text-align: left;
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  position: relative;
  transition: background .18s ease, color .18s ease, border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

.nav button span {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  color: #7dd3fc;
  filter: drop-shadow(0 0 8px rgba(56, 189, 248, .18));
  transition: color .18s ease, transform .18s ease, filter .18s ease;
}

.nav button:hover {
  color: #f8fafc;
  background: rgba(30, 64, 175, .28);
  border-color: rgba(96, 165, 250, .32);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06);
}

.nav button:hover .nav-icon {
  color: #bae6fd;
  transform: translateX(1px);
  filter: drop-shadow(0 0 10px rgba(56, 189, 248, .42));
}

.nav .nav-link.active {
  color: #ffffff;
  background: linear-gradient(135deg, #1d4ed8 0%, #0284c7 100%);
  border-color: rgba(125, 211, 252, .72);
  box-shadow: 0 12px 28px rgba(2, 132, 199, .22), inset 0 1px 0 rgba(255, 255, 255, .18);
  font-weight: 700;
}

.nav .nav-link.active::after {
  content: '';
  position: absolute;
  right: 9px;
  top: 50%;
  width: 5px;
  height: 18px;
  border-radius: 999px;
  background: #bfdbfe;
  transform: translateY(-50%);
  box-shadow: 0 0 14px rgba(191, 219, 254, .75);
}

.nav .nav-link.active .nav-icon {
  color: #ffffff;
  filter: drop-shadow(0 0 10px rgba(255, 255, 255, .35));
}

.nav-group {
  display: grid;
  gap: 5px;
}

.nav-group-toggle {
  font-weight: 650;
}

.nav-parent-active,
.nav-group.open .nav-group-toggle {
  color: #e0f2fe;
  background: rgba(37, 99, 235, .18);
  border-color: rgba(56, 189, 248, .34);
  box-shadow: inset 3px 0 0 rgba(56, 189, 248, .8);
}

.nav-chevron {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  color: #7dd3fc;
  opacity: .78;
  transition: transform .18s ease, opacity .18s ease;
}

.nav-group.open .nav-chevron {
  transform: rotate(90deg);
  opacity: 1;
}

.nav-sub {
  display: grid;
  gap: 5px;
  margin: 2px 0 7px 20px;
  padding-left: 12px;
  border-left: 1px solid rgba(125, 211, 252, .22);
}

.nav-sub[hidden] {
  display: none !important;
}

.nav-sub .nav-link {
  min-height: 36px;
  border-radius: 10px;
  padding: 0 12px 0 10px;
  font-size: 13px;
  background: rgba(2, 6, 23, .18);
}

.nav-sub .nav-icon {
  width: 16px;
  height: 16px;
  flex-basis: 16px;
}

@media (max-width: 820px) {
  .sidebar {
    border-right: 0;
    border-bottom: 1px solid rgba(125, 211, 252, .22);
  }

  .nav {
    grid-template-columns: 1fr;
  }
}

/* 开发 API 对接页面 */
.dev-api {
  display: grid;
  gap: 16px;
}

.dev-api h3 {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

.dev-api-note {
  margin: 0 0 12px;
  color: var(--muted);
  line-height: 1.6;
}

.dev-api-note code,
.dev-api code {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 6px;
}

.dev-api-scope-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.dev-api-check {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.dev-api-check.inline {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding: 0;
  border: 0;
  background: transparent;
}

.dev-api-check span {
  font-weight: 600;
  color: var(--text);
}

.dev-api-check small {
  color: var(--muted);
  font-size: 12px;
}

.dev-api-security-grid,
.dev-api-debug-fields,
.dev-api-code-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.dev-api-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.dev-api-field.wide {
  grid-column: 1 / -1;
}

.dev-api-field .input,
.dev-api-field textarea {
  width: 100%;
}

.dev-api-docs-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.dev-api-docs-tabs .btn.active {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: #93c5fd;
}

.dev-api-doc-panel {
  display: grid;
  gap: 10px;
}

.dev-api-code-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

.dev-api-code,
.dev-api-response {
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f172a;
  color: #e2e8f0;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 320px;
  overflow: auto;
}

.dev-api-debug-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: end;
  margin-bottom: 12px;
}

.dev-api-debug-bar label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.dev-api-debug-bar .select {
  min-width: 220px;
}

.info-table.compact th,
.info-table.compact td {
  padding: 8px 10px;
  font-size: 13px;
}

.empty.warn {
  color: var(--amber);
  background: var(--amber-soft);
  border: 1px solid #fcd34d;
  border-radius: 8px;
  padding: 10px 12px;
}

@media (max-width: 900px) {
  .dev-api-security-grid,
  .dev-api-debug-fields,
  .dev-api-code-grid {
    grid-template-columns: 1fr;
  }
}

.mobile-nav-toggle,
.nav-backdrop {
  display: none;
}

.mobile-nav-toggle svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

@media (max-width: 820px) {
  .login-shell {
    grid-template-columns: 1fr;
    max-width: 620px;
  }

  .login-intro {
    padding: 8px 0 0;
  }

  .layout {
    display: block;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 31;
    width: min(300px, 84vw);
    height: 100vh;
    overflow-y: auto;
    transform: translateX(-102%);
    transition: transform .2s ease;
  }

  .layout.nav-open .sidebar {
    transform: translateX(0);
  }

  .nav-backdrop {
    position: fixed;
    inset: 0;
    z-index: 30;
    width: 100%;
    height: 100%;
    border: 0;
    background: rgba(15, 23, 42, .48);
  }

  .layout.nav-open .nav-backdrop {
    display: block;
  }

  .mobile-nav-toggle {
    display: inline-grid;
    place-items: center;
    width: 38px;
    min-width: 38px;
    padding: 0;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    min-height: 62px;
    flex-direction: row;
    align-items: center;
    padding: 10px 14px;
  }

  .topbar > #page-title {
    margin-right: auto;
  }

  .topbar-brand > img,
  .topbar-brand > span:not(.pill) {
    display: none;
  }

  .topbar-brand {
    flex-wrap: nowrap;
  }
}

@media (max-width: 520px) {
  .topbar-brand .pill {
    display: none;
  }
}

.skill-center-head {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.skill-center-head > div {
  min-height: 108px;
  padding: 18px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--green);
  border-radius: 8px;
  background: var(--panel);
  display: grid;
  align-content: center;
  gap: 4px;
}

.skill-center-head span,
.skill-center-head small {
  color: var(--muted);
}

.skill-center-head strong {
  font-size: 22px;
  overflow-wrap: anywhere;
}

.skill-form-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 14px;
}

.skill-description {
  margin: 16px 0;
  padding: 14px 16px;
  border-left: 3px solid var(--primary-2);
  background: var(--panel-soft);
}

.skill-description p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.65;
}

.skill-prompt {
  min-height: 190px;
  resize: vertical;
}

.skill-upload {
  margin-top: 14px;
}

.skill-upload small,
.skill-submit-row span {
  color: var(--muted);
}

.skill-submit-row {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.truncate-cell {
  max-width: 260px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 820px) {
  .skill-center-head,
  .skill-form-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .skill-submit-row {
    align-items: stretch;
    flex-direction: column;
  }

  .skill-submit-row .btn {
    width: 100%;
  }
}

.chat-relay {
  height: calc(100vh - 106px);
  min-height: 620px;
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.chat-sessions {
  min-width: 0;
  padding: 14px;
  border-right: 1px solid var(--line);
  background: #f8fafc;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
}

.chat-session-list {
  min-height: 0;
  overflow-y: auto;
  display: grid;
  align-content: start;
  gap: 6px;
}

.chat-session {
  width: 100%;
  min-height: 58px;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  display: grid;
  gap: 4px;
  text-align: left;
}

.chat-session:hover,
.chat-session.active {
  border-color: var(--line);
  background: #fff;
}

.chat-session strong,
.chat-session span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

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

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

.chat-head > div:first-child {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.chat-head > div:first-child strong,
.chat-head > div:first-child span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-head > div:first-child span {
  color: var(--muted);
  font-size: 11px;
}

.chat-head-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.chat-model-picker {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.chat-model-picker .chat-model-select {
  width: auto;
  min-width: 150px;
  min-height: 32px;
  padding-top: 5px;
  padding-bottom: 5px;
}

.chat-mode {
  flex: 0 0 auto;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-soft);
  display: flex;
}

.chat-mode button {
  min-height: 32px;
  padding: 5px 10px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
}

.chat-mode button.active {
  background: #fff;
  color: var(--primary);
  box-shadow: 0 1px 4px rgba(15, 23, 42, .1);
  font-weight: 700;
}

.chat-membership-button {
  min-height: 34px;
  padding: 6px 11px;
  border: 1px solid #b8d85d;
  border-radius: 6px;
  background: #f5ffd9;
  color: #284515;
  font-size: 12px;
  font-weight: 700;
}

.chat-membership-button.active {
  border-color: #15803d;
  background: #ecfdf3;
  color: #166534;
}

.chat-membership-bar {
  min-height: 38px;
  padding: 7px 16px;
  border-bottom: 1px solid var(--line);
  background: #f8faf8;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
}

.chat-membership-bar strong { color: var(--text); white-space: nowrap; }
.chat-membership-bar > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-membership-dot { width: 8px; height: 8px; border-radius: 50%; background: #cbd5e1; flex: 0 0 auto; }
.chat-membership-dot.active { background: #16a34a; box-shadow: 0 0 0 3px rgba(22,163,74,.12); }

.chat-plan-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.chat-plan-card {
  min-width: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  display: grid;
  gap: 12px;
}

.chat-plan-card.current {
  border-color: #15803d;
  box-shadow: inset 0 0 0 1px #15803d;
}

.chat-plan-card > div:first-child,
.chat-plan-price {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.chat-plan-card > div:first-child span,
.chat-plan-price span,
.chat-plan-card p,
.chat-plan-card li {
  color: var(--muted);
  font-size: 12px;
}

.chat-plan-card > div:first-child strong { font-size: 20px; }
.chat-plan-price strong { font-size: 28px; }
.chat-plan-card p { margin: 0; line-height: 1.6; }
.chat-plan-card ul { margin: 0; padding-left: 18px; display: grid; gap: 6px; }
.chat-plan-card .btn { width: 100%; }

.chat-messages {
  min-height: 0;
  overflow-y: auto;
  padding: 22px clamp(16px, 5vw, 64px);
  background: #fbfcfd;
}

.chat-message {
  max-width: 900px;
  margin: 0 auto 18px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.chat-message.user {
  flex-direction: row-reverse;
}

.chat-avatar {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}

.chat-message.user .chat-avatar {
  background: var(--green);
}

.chat-bubble {
  max-width: min(78%, 760px);
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.chat-message.user .chat-bubble {
  border-color: #a7f3d0;
  background: #ecfdf5;
}

.chat-markdown {
  min-width: 0;
  color: inherit;
  line-height: 1.75;
}

.chat-markdown > :first-child { margin-top: 0; }
.chat-markdown > :last-child { margin-bottom: 0; }

.chat-markdown p {
  margin: 0 0 0.9em;
}

.chat-markdown h1,
.chat-markdown h2,
.chat-markdown h3,
.chat-markdown h4,
.chat-markdown h5,
.chat-markdown h6 {
  margin: 1.15em 0 0.55em;
  color: inherit;
  line-height: 1.35;
  letter-spacing: 0;
}

.chat-markdown h1 { font-size: 22px; }
.chat-markdown h2 { font-size: 19px; }
.chat-markdown h3 { font-size: 17px; }
.chat-markdown h4,
.chat-markdown h5,
.chat-markdown h6 { font-size: 15px; }

.chat-markdown ol,
.chat-markdown ul {
  margin: 0.45em 0 0.95em;
  padding-inline-start: 1.75em;
  list-style-position: outside;
}

.chat-markdown ol { list-style-type: decimal; }
.chat-markdown ul { list-style-type: disc; }

.chat-markdown li {
  margin: 0.3em 0;
  padding-inline-start: 0.2em;
}

.chat-markdown li::marker {
  color: #64748b;
  font-weight: 600;
}

.chat-markdown strong { font-weight: 700; }

.chat-markdown a {
  color: #2563eb;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.chat-markdown code {
  padding: 0.16em 0.38em;
  border-radius: 4px;
  background: #f1f5f9;
  color: #be123c;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 0.9em;
}

.chat-markdown pre {
  margin: 0.75em 0 1em;
  padding: 14px 16px;
  overflow-x: auto;
  border: 1px solid #293241;
  border-radius: 7px;
  background: #171a21;
  color: #f8fafc;
  line-height: 1.6;
  white-space: pre;
}

.chat-markdown pre code {
  padding: 0;
  background: transparent;
  color: inherit;
  font-size: 13px;
}

.chat-markdown blockquote {
  margin: 0.65em 0 0.95em;
  padding: 0.35em 0 0.35em 0.9em;
  border-left: 3px solid #94a3b8;
  color: #64748b;
}

.chat-markdown hr {
  margin: 1em 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.chat-markdown-table {
  width: 100%;
  margin: 0.75em 0 1em;
  overflow-x: auto;
}

.chat-markdown-table table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.chat-markdown-table th,
.chat-markdown-table td {
  padding: 8px 10px;
  border: 1px solid var(--line);
  vertical-align: top;
}

.chat-markdown-table th { background: #f8fafc; }
.chat-align-center { text-align: center; }
.chat-align-right { text-align: right; }
.chat-align-left { text-align: left; }

.chat-message-actions {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-top: 7px;
}

.chat-message-actions button {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  font-size: 17px;
}

.chat-message-actions button:hover,
.chat-message-actions button.is-done {
  background: #f1f5f9;
  color: #0f172a;
}

.chat-bubble footer {
  margin-top: 9px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  font-size: 11px;
}

.chat-thinking {
  margin: 0 0 10px;
  color: #475569;
}

.chat-thinking summary {
  width: fit-content;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #475569;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.chat-thinking summary::-webkit-details-marker {
  display: none;
}

.chat-thinking summary strong {
  font-size: 13px;
  font-weight: 600;
}

.chat-thinking-symbol {
  width: 16px;
  height: 16px;
  display: inline-block;
  border: 2px solid #94a3b8;
  border-radius: 50%;
  position: relative;
}

.chat-thinking-symbol::after {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: #64748b;
}

.chat-thinking-chevron {
  color: #94a3b8;
  font-size: 14px;
  transition: transform .18s ease;
}

.chat-thinking[open] .chat-thinking-chevron {
  transform: rotate(180deg);
}

.chat-thinking ol {
  margin: 10px 0 2px 7px;
  padding: 0 0 0 17px;
  border-left: 1px solid #d7dfdc;
  list-style: none;
}

.chat-thinking li {
  min-height: 27px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #94a3b8;
  font-size: 12px;
}

.chat-thinking li.done,
.chat-thinking li.active {
  color: #475569;
}

.chat-thinking-mark {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #16836f;
  font-size: 11px;
  font-weight: 800;
}

.chat-thinking li.active .chat-thinking-mark {
  border: 2px solid #b8ccc6;
  border-top-color: #16836f;
  animation: chat-thinking-spin .8s linear infinite;
}

.chat-thinking.is-live .chat-thinking-symbol {
  border-color: #b8ccc6;
  border-top-color: #16836f;
  animation: chat-thinking-spin .9s linear infinite;
}

.chat-thinking.is-live .chat-thinking-symbol::after {
  display: none;
}

.chat-message-thinking .chat-bubble {
  min-width: 280px;
}

.chat-stop-symbol {
  font-size: 11px;
  line-height: 1;
}

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

@media (prefers-reduced-motion: reduce) {
  .chat-thinking.is-live .chat-thinking-symbol,
  .chat-thinking li.active .chat-thinking-mark {
    animation: none;
  }
}

.chat-empty {
  height: 100%;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 5px;
  color: var(--muted);
}

.chat-empty strong {
  color: var(--text);
  font-size: 20px;
}

.chat-composer {
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.chat-composer textarea {
  width: 100%;
  min-height: 72px;
  max-height: 180px;
  resize: vertical;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  outline: 0;
}

.chat-composer textarea:focus {
  border-color: var(--primary-2);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .1);
}

.chat-composer > div {
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

@media (max-width: 900px) {
  .chat-relay {
    height: auto;
    min-height: calc(100vh - 100px);
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(620px, 1fr);
  }

  .chat-sessions {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-rows: auto;
  }

  .chat-session-list {
    grid-auto-flow: column;
    grid-auto-columns: minmax(150px, 210px);
    overflow-x: auto;
    overflow-y: hidden;
  }

  .chat-delete {
    align-self: stretch;
  }
}

@media (max-width: 620px) {
  .chat-sessions {
    grid-template-columns: 1fr auto;
  }

  .chat-sidebar-label {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .chat-session-list {
    grid-column: 1 / -1;
    grid-row: 3;
  }

  .chat-sidebar-note,
  .chat-delete {
    grid-column: 1 / -1;
    grid-row: 4;
  }

  .chat-head {
    align-items: stretch;
    flex-direction: column;
  }

  .chat-head-actions {
    width: 100%;
    align-items: stretch;
    flex-direction: column;
  }

  .chat-model-picker,
  .chat-model-picker .chat-model-select {
    width: 100%;
  }

  .chat-mode,
  .chat-mode button,
  .chat-membership-button {
    width: 100%;
  }

  .chat-plan-grid {
    grid-template-columns: 1fr;
  }

  .chat-bubble {
    max-width: 88%;
  }

  .chat-composer > div {
    align-items: stretch;
    flex-direction: column;
  }

  .chat-composer .btn {
    width: 100%;
  }
}

.chat-sidebar-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
}

.chat-new-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.chat-new-button span,
.chat-send-button span {
  font-size: 18px;
  line-height: 1;
}

.chat-sidebar-note {
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.chat-composer-input {
  position: relative;
}

.chat-composer > .chat-composer-tool-row {
  min-height: 34px;
  margin-top: 0;
  justify-content: flex-start;
  gap: 8px;
}

.chat-image-tool,
.chat-image-size {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
}

.chat-image-tool {
  padding: 5px 10px;
  cursor: pointer;
}

.chat-image-tool:hover,
.chat-image-tool.active {
  border-color: var(--primary-2);
  background: #eff6ff;
  color: var(--primary);
}

.chat-image-tool:disabled {
  cursor: not-allowed;
  opacity: .48;
}

.chat-image-tool .chat-action-icon {
  width: 17px;
  height: 17px;
}

.chat-image-size {
  padding: 0 4px 0 9px;
}

.chat-image-size > span,
.chat-image-model {
  white-space: nowrap;
}

.chat-image-size select {
  min-height: 27px;
  border: 0;
  outline: 0;
  background: transparent;
  color: inherit;
  font: inherit;
}

.chat-image-model {
  color: var(--muted);
  font-size: 11px;
}

.chat-composer-input textarea {
  padding-right: 88px;
}

.chat-attach-button {
  position: absolute;
  right: 10px;
  bottom: 10px;
  min-height: 31px;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
}

.chat-attach-button:hover {
  border-color: var(--primary-2);
  color: var(--primary);
}

.chat-attach-button > span:first-child {
  font-size: 18px;
  line-height: 1;
}

.chat-attachment-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 8px;
}

.chat-attachment-preview.is-empty {
  display: none;
}

.chat-upload-preview,
.chat-file-chip {
  min-width: 0;
  max-width: 260px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  background: #f8fafc;
  color: #334155;
  font-size: 12px;
}

.chat-upload-preview-icon,
.chat-file-chip-icon {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  border-radius: 5px;
  background: #e0e7ff;
  color: #3730a3;
  display: grid;
  place-items: center;
  font-size: 16px;
  line-height: 1;
}

.chat-upload-preview-thumb {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  overflow: hidden;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #eef2f7;
}

.chat-upload-preview-thumb img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.chat-upload-preview.has-image {
  max-width: 320px;
  padding: 5px 7px 5px 5px;
}

.chat-upload-preview-name,
.chat-file-chip > span:nth-child(2) {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-upload-preview small,
.chat-file-chip small {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 10px;
}

.chat-upload-remove {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 17px;
  line-height: 1;
}

.chat-upload-remove:hover {
  background: #e2e8f0;
  color: var(--text);
}

.chat-message-files {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.chat-file-chip {
  max-width: 300px;
  background: #f1f5f9;
}

.chat-generated-image {
  width: min(100%, 640px);
  margin: 0 0 10px;
}

.chat-generated-image-preview {
  position: relative;
  width: 100%;
  min-height: 220px;
  padding: 0;
  display: block;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f1f5f9;
  cursor: zoom-in;
}

.chat-generated-image-preview img {
  width: 100%;
  max-height: 560px;
  display: block;
  object-fit: contain;
}

.chat-generated-image-preview > span {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: rgba(15, 23, 42, .78);
  color: #fff;
  opacity: 0;
  transition: opacity .16s ease;
}

.chat-generated-image-preview:hover > span,
.chat-generated-image-preview:focus-visible > span {
  opacity: 1;
}

.chat-generated-image-preview .chat-action-icon {
  width: 17px;
  height: 17px;
}

.chat-generated-image figcaption {
  min-height: 34px;
  padding: 7px 2px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 11px;
}

.chat-generated-image figcaption a {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: inherit;
  font-weight: 600;
  text-decoration: none;
}

.chat-generated-image figcaption .chat-action-icon {
  width: 15px;
  height: 15px;
}

.chat-image-pending {
  width: min(100%, 520px);
  min-height: 120px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.chat-image-pending-icon {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #e0e7ff;
  color: #4338ca;
  animation: chat-image-pulse 1.35s ease-in-out infinite;
}

.chat-image-pending-icon .chat-action-icon {
  width: 22px;
  height: 22px;
}

.chat-image-pending strong,
.chat-image-pending span {
  display: block;
}

.chat-image-pending strong {
  margin-bottom: 4px;
  font-size: 14px;
}

.chat-image-pending div span {
  color: var(--muted);
  font-size: 12px;
}

.chat-image-modal {
  display: grid;
  justify-items: center;
  gap: 14px;
}

.chat-image-modal img {
  width: auto;
  max-width: min(100%, 1100px);
  max-height: 72vh;
  display: block;
  object-fit: contain;
  border-radius: 8px;
}

.chat-image-modal .chat-action-icon {
  width: 17px;
  height: 17px;
}

@keyframes chat-image-pulse {
  0%, 100% { opacity: .62; transform: scale(.96); }
  50% { opacity: 1; transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .chat-image-pending-icon { animation: none; }
}

.literature-review-layout {
  display: grid;
  gap: 16px;
}

.literature-review-hero {
  border-left: 4px solid #2563eb;
}

.literature-review-form-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.literature-review-form-grid .wide {
  grid-column: 1 / -1;
}

.literature-review-upload {
  margin-top: 14px;
}

.literature-review-guide {
  background: #f8fafc;
}

.literature-review-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.literature-review-steps > div {
  min-height: 112px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  display: grid;
  align-content: start;
  gap: 5px;
}

.literature-review-steps strong {
  color: #2563eb;
  font-size: 22px;
}

.literature-review-steps span {
  font-weight: 800;
}

.literature-review-steps small {
  color: var(--muted);
  line-height: 1.5;
}

.literature-review-history-list {
  display: grid;
  gap: 12px;
}

.literature-review-history-item {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.literature-review-history-head,
.literature-review-history-progress {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.literature-review-history-head strong {
  display: block;
  margin-bottom: 4px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.literature-review-history-head span,
.literature-review-history-progress > span:nth-child(2) {
  color: var(--muted);
  font-size: 13px;
}

.literature-review-history-progress {
  margin-top: 11px;
  flex-wrap: wrap;
}

.literature-review-detail {
  display: grid;
  gap: 16px;
}

.literature-review-output {
  max-height: 520px;
  overflow: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.literature-review-output strong {
  display: block;
  margin-bottom: 10px;
}

@media (max-width: 620px) {
  .chat-composer > .chat-composer-tool-row {
    align-items: center;
    flex-direction: row;
    flex-wrap: wrap;
  }

  .chat-image-model {
    display: none;
  }

  .chat-attach-button {
    right: 8px;
    bottom: 8px;
  }

  .chat-composer-input textarea {
    padding-right: 78px;
  }

  .chat-upload-preview,
  .chat-file-chip {
    max-width: 100%;
  }

  .chat-upload-preview.has-image {
    width: 100%;
  }

  .literature-review-form-grid,
  .literature-review-steps {
    grid-template-columns: 1fr;
  }

  .literature-review-history-head,
  .literature-review-history-progress {
    align-items: stretch;
    flex-direction: column;
  }

  .literature-review-history-progress .reference-history-actions {
    width: 100%;
    margin-left: 0;
    flex-wrap: wrap;
  }
}

.register-panel {
  max-width: 480px;
}

.invite-code-field {
  display: flex;
  gap: 8px;
  align-items: center;
}

.invite-code-field .input {
  min-width: 0;
  flex: 1;
}

.invite-preview {
  margin: -4px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.invite-form {
  align-items: end;
}

.invite-form label > span {
  display: block;
  margin-top: 6px;
}

.invite-form .form-actions {
  align-self: end;
}

.invite-metrics {
  margin-bottom: 16px;
}

.invite-create-panel {
  margin-bottom: 16px;
}

.analysis-hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  padding: 22px 24px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(135deg, #f6fbff, #ffffff 65%);
}

.analysis-hero h2 {
  margin: 5px 0 8px;
  font-size: 24px;
}

.analysis-hero p {
  max-width: 720px;
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.analysis-hero .eyebrow {
  color: var(--primary-2);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.analysis-hero-meta {
  display: grid;
  gap: 7px;
  min-width: 145px;
  color: var(--muted);
  font-size: 12px;
}

.analysis-hero-meta strong {
  color: var(--text);
  font-size: 16px;
}

.analysis-type-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 16px;
}

.analysis-type-strip span {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
}

.data-analysis-workbench {
  margin-bottom: 16px;
}

.provincial-data-workbench {
  margin-bottom: 16px;
}

.provincial-data-notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--primary);
  border-radius: 7px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.provincial-data-notice strong {
  flex: 0 0 auto;
  color: var(--text);
}

.provincial-data-form {
  display: grid;
  gap: 12px;
}

.provincial-data-form .skill-form-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.provincial-data-form .skill-upload small a {
  margin-left: 8px;
  color: var(--primary);
}

.provincial-data-result {
  margin-top: 18px;
}

.provincial-data-table {
  max-height: 360px;
  overflow: auto;
}

.result-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 900px) {
  .provincial-data-form .skill-form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .provincial-data-form .skill-form-grid {
    grid-template-columns: 1fr;
  }
  .provincial-data-notice {
    display: grid;
  }
}

.bioinformatics-workbench,
.bioinformatics-history {
  margin-bottom: 16px;
}

.bio-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

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

.bio-wide-field {
  grid-column: 1 / -1;
}

.bio-schema-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 12px;
}

.bio-schema-note a {
  color: var(--primary-2);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.bio-schema-note a:hover {
  text-decoration: underline;
}

.bio-groups {
  min-height: 68px;
  resize: vertical;
}

.bio-result-summary {
  display: grid;
  gap: 16px;
}

.bio-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
}

.bio-summary-grid span {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
}

.bio-summary-grid strong {
  font-size: 20px;
}

.bio-summary-grid small {
  color: var(--muted);
}

.bio-result-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.bio-result-figures {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.bio-result-figures figure {
  margin: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.bio-result-figures img {
  display: block;
  width: 100%;
  height: auto;
}

.bio-result-figures figcaption {
  padding-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  padding: 18px 24px 24px;
  color: var(--muted);
  font-size: 12px;
}

.site-footer-title {
  color: var(--text);
  font-weight: 700;
}

.site-footer-email {
  color: var(--muted);
  text-decoration: none;
}

.site-footer-email:hover {
  color: var(--primary-2);
  text-decoration: underline;
}

.site-footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.site-footer-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--muted);
  text-decoration: none;
}

.site-footer-link img,
.site-footer-fallback {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  border-radius: 4px;
  object-fit: contain;
}

.site-footer-fallback {
  display: grid;
  place-items: center;
  background: var(--primary-2);
  color: #fff;
  font-size: 9px;
  font-weight: 800;
}

.site-footer-link:hover {
  border-color: var(--primary-2);
  color: var(--primary-2);
  text-decoration: none;
}

@media (max-width: 720px) {
  .analysis-hero {
    display: grid;
    gap: 14px;
    padding: 18px;
  }

  .site-footer {
    padding: 16px 18px 22px;
  }

  .bio-form-grid,
  .bio-upload-grid,
  .bio-parameter-grid,
  .bio-summary-grid,
  .bio-result-figures {
    grid-template-columns: 1fr;
  }

  .bio-schema-note {
    align-items: flex-start;
    flex-direction: column;
  }
}

.aigc-page {
  display: grid;
  gap: 16px;
}

.aigc-hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  padding: 24px;
  background: linear-gradient(135deg, #f8f7ff, #ffffff 62%, #f0fdf4);
}

.aigc-eyebrow {
  color: #6846c7;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.aigc-hero h2 {
  margin: 6px 0 8px;
  font-size: 26px;
}

.aigc-hero p {
  max-width: 700px;
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.aigc-hero-meta {
  min-width: 165px;
  padding: 12px 14px;
  border: 1px solid #ddd6fe;
  border-radius: 10px;
  background: #ffffffb8;
}

.aigc-hero-meta span,
.aigc-hero-meta small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.aigc-hero-meta strong {
  display: block;
  margin: 5px 0;
  color: #5b34ba;
  font-size: 20px;
}

.aigc-info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.aigc-info-grid .panel {
  min-height: 112px;
}

.aigc-info-grid h3 {
  margin: 0 0 12px;
  font-size: 15px;
}

.aigc-levels {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  color: var(--muted);
  font-size: 12px;
}

.aigc-levels span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.aigc-levels i {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.aigc-levels i.high { background: #dc2626; }
.aigc-levels i.medium { background: #f59e0b; }
.aigc-levels i.low { background: #16a34a; }

.aigc-input-tabs {
  margin: 0 0 16px;
}

.aigc-form {
  display: grid;
  gap: 14px;
}

.aigc-dropzone {
  display: grid;
  justify-items: center;
  gap: 7px;
  min-height: 190px;
  padding: 30px 18px;
  border: 1px dashed #c4b5fd;
  border-radius: 10px;
  background: #faf9ff;
  text-align: center;
  cursor: pointer;
}

.aigc-dropzone:hover {
  border-color: #7c3aed;
  background: #f5f3ff;
}

.aigc-dropzone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.aigc-upload-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: #ede9fe;
  color: #6d28d9;
  font-size: 25px;
  font-weight: 700;
}

.aigc-dropzone strong {
  color: var(--text);
}

.aigc-dropzone small,
.aigc-form-foot span {
  color: var(--muted);
  font-size: 12px;
}

.aigc-form-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.aigc-textarea {
  min-height: 240px;
  resize: vertical;
}

.aigc-history .table-wrap {
  margin-top: 10px;
}

.aigc-history td:first-child strong,
.aigc-history td:first-child small {
  display: block;
}

.aigc-history td:first-child small {
  margin-top: 4px;
}

.aigc-rate {
  font-variant-numeric: tabular-nums;
}

.aigc-rate.high { color: #dc2626; }
.aigc-rate.medium { color: #d97706; }
.aigc-rate.low { color: #15803d; }

.aigc-detail {
  display: grid;
  gap: 16px;
}

.aigc-detail-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.aigc-detail-metrics > div {
  display: grid;
  gap: 5px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.aigc-detail-metrics span {
  color: var(--muted);
  font-size: 11px;
}

.aigc-detail-metrics strong {
  font-size: 18px;
}

.aigc-detail-summary {
  margin: 0;
  padding: 12px 14px;
  border-left: 3px solid #7c3aed;
  background: #faf9ff;
  color: var(--muted);
  line-height: 1.6;
}

.aigc-segment-list {
  display: grid;
  gap: 8px;
  max-height: 420px;
  overflow: auto;
}

.aigc-segment {
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-left: 3px solid #94a3b8;
  border-radius: 7px;
  background: var(--panel);
}

.aigc-segment.high { border-left-color: #dc2626; }
.aigc-segment.medium { border-left-color: #f59e0b; }
.aigc-segment.low { border-left-color: #16a34a; }

.aigc-segment > div {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 11px;
}

.aigc-segment p {
  margin: 7px 0 4px;
  color: var(--text);
  line-height: 1.6;
}

.aigc-segment small {
  color: var(--muted);
}

@media (max-width: 720px) {
  .aigc-hero,
  .aigc-form-foot {
    display: grid;
  }

  .aigc-hero-meta {
    width: 100%;
  }

  .aigc-info-grid,
  .aigc-detail-metrics {
    grid-template-columns: 1fr;
  }
}
.notice-image{display:block;max-width:100%;max-height:360px;object-fit:contain;margin:12px 0;border:1px solid var(--line,#dce2e8);border-radius:6px;background:#f8fafc}
.software-paper-action-buttons{display:flex;gap:10px;align-items:center;justify-content:flex-end;flex-wrap:wrap}
.custom-program-contact{display:grid;justify-items:center;gap:14px;text-align:center;color:#475569}
.custom-program-contact p{margin:0;max-width:520px;line-height:1.7}
.custom-program-contact img{width:min(280px,72vw);aspect-ratio:1;object-fit:contain;background:#fff;border:1px solid #dce6e2;border-radius:6px;padding:10px}

/* Four-step quick delivery workflow */
.quick-delivery{display:grid;gap:16px}
.quick-delivery-hero{display:flex;align-items:stretch;justify-content:space-between;gap:24px;padding:26px 28px;background:linear-gradient(135deg,var(--panel),var(--primary-soft));border-color:color-mix(in srgb,var(--primary) 18%,var(--line))}
.quick-delivery-hero h2{margin:6px 0 8px;font-size:clamp(24px,3vw,34px);letter-spacing:0}
.quick-delivery-hero p{max-width:720px;margin:0;color:var(--muted);line-height:1.7}
.quick-delivery-hero-meta{display:grid;align-content:center;justify-items:end;min-width:150px;padding-left:20px;border-left:1px solid var(--line)}
.quick-delivery-hero-meta strong{font-size:28px;color:var(--primary)}
.quick-delivery-hero-meta span{font-size:13px;color:var(--text)}
.quick-delivery-hero-meta small{margin-top:6px;color:var(--muted);text-align:right}
.quick-delivery-workbench{padding:0;overflow:hidden}
.quick-delivery-steps{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));border-bottom:1px solid var(--line);background:var(--panel-soft)}
.quick-step{display:grid;grid-template-columns:auto 1fr;grid-template-rows:auto auto;gap:2px 9px;align-items:center;padding:15px 18px;border:0;border-right:1px solid var(--line);background:transparent;color:var(--muted);text-align:left;cursor:pointer}
.quick-step:last-child{border-right:0}
.quick-step>span{grid-row:1 / span 2;display:grid;place-items:center;width:30px;height:30px;border:1px solid var(--line-strong);border-radius:50%;font-size:12px;font-weight:700}
.quick-step strong{font-size:13px;color:var(--text)}
.quick-step small{font-size:11px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.quick-step.active{background:var(--panel);box-shadow:inset 0 -3px var(--primary)}
.quick-step.active>span{border-color:var(--primary);background:var(--primary);color:#fff}
.quick-step.active strong{color:var(--primary)}
.quick-step-panel{padding:26px 28px 10px}
.quick-panel-heading{display:flex;gap:13px;align-items:flex-start;margin-bottom:22px}
.quick-panel-number{display:grid;place-items:center;width:36px;height:36px;border-radius:10px;background:var(--primary);color:#fff;font-size:12px;font-weight:800}
.quick-panel-heading h3{margin:0 0 4px;font-size:19px}
.quick-panel-heading p{margin:0;color:var(--muted);font-size:13px}
.quick-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px}
.quick-grid .wide{grid-column:1 / -1}
.quick-recommend-field{display:grid;grid-template-columns:auto auto;align-content:start;gap:7px 10px}
.quick-recommend-field>span{font-weight:600;color:var(--text)}
.quick-recommend-field small{grid-column:1 / -1;color:var(--muted);line-height:1.5}
.quick-deliverables{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:9px;margin-top:9px}
.quick-deliverable{display:flex;gap:9px;align-items:flex-start;padding:11px 12px;border:1px solid var(--line);border-radius:8px;background:var(--panel);cursor:pointer}
.quick-deliverable:hover{border-color:var(--primary)}
.quick-deliverable.selected{border-color:color-mix(in srgb,var(--primary) 55%,var(--line));background:var(--primary-soft)}
.quick-deliverable input{margin-top:3px;accent-color:var(--primary)}
.quick-deliverable span{display:grid;gap:3px;min-width:0}
.quick-deliverable strong{font-size:13px;color:var(--text)}
.quick-deliverable small{font-size:11px;color:var(--muted);line-height:1.4}
.quick-upload{display:grid;gap:6px;align-content:start;min-height:128px;padding:15px;border:1px dashed var(--line-strong);border-radius:9px;background:var(--panel-soft);cursor:pointer}
.quick-upload:hover{border-color:var(--primary);background:var(--primary-soft)}
.quick-upload strong{font-size:14px;color:var(--text)}
.quick-upload span{font-size:12px;color:var(--muted);line-height:1.5}
.quick-upload input{width:100%;font-size:12px}
.quick-upload em{font-style:normal;color:var(--primary);font-size:12px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.quick-export-options{display:grid;gap:8px;align-content:start}
.quick-export-options>span{font-weight:600;color:var(--text)}
.quick-source-note{margin:4px 0 0;padding:10px 12px;border-left:3px solid var(--amber);background:var(--amber-soft);color:var(--muted);font-size:12px;line-height:1.6}
.quick-summary{min-height:150px;padding:16px;border:1px solid var(--line);border-radius:9px;background:var(--panel-soft)}
.quick-summary-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px 18px;margin:0}
.quick-summary-grid>div{display:grid;gap:4px;min-width:0}
.quick-summary-grid>div.wide{grid-column:1 / -1}
.quick-summary-grid dt{font-size:11px;color:var(--muted)}
.quick-summary-grid dd{margin:0;color:var(--text);font-size:14px;overflow-wrap:anywhere}
.quick-summary-requirements{margin:16px 0 0;padding-top:12px;border-top:1px solid var(--line);color:var(--muted);font-size:12px;line-height:1.6;white-space:pre-wrap}
.quick-confirm-note{display:grid;gap:6px;margin-top:16px;padding:14px 16px;border:1px solid var(--line);border-radius:8px;background:var(--primary-soft);color:var(--muted);font-size:12px;line-height:1.6}
.quick-confirm-note strong{color:var(--text);font-size:13px}
.quick-delivery-actions{display:flex;align-items:center;justify-content:flex-end;gap:12px;padding:18px 28px 24px;border-top:1px solid var(--line)}
.quick-delivery-status{margin-right:auto;color:var(--muted);font-size:12px}
.quick-delivery-help{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:16px 20px}
.quick-delivery-help>div:first-child{display:grid;gap:4px}
.quick-delivery-help>div:first-child span{color:var(--muted);font-size:12px}
.quick-delivery-help-actions{display:flex;gap:8px;flex-wrap:wrap;justify-content:flex-end}
@media (max-width: 760px){
  .quick-delivery-hero{display:grid;padding:20px}
  .quick-delivery-hero-meta{justify-items:start;min-width:0;padding:14px 0 0;border-top:1px solid var(--line);border-left:0}
  .quick-delivery-hero-meta small{text-align:left}
  .quick-delivery-steps{grid-template-columns:repeat(2,minmax(0,1fr))}
  .quick-step:nth-child(2){border-right:0}
  .quick-step:nth-child(-n+2){border-bottom:1px solid var(--line)}
  .quick-step-panel{padding:20px 16px 8px}
  .quick-grid,.quick-deliverables,.quick-summary-grid{grid-template-columns:1fr}
  .quick-grid .wide,.quick-summary-grid>div.wide{grid-column:auto}
  .quick-delivery-actions{padding:16px;flex-wrap:wrap}
  .quick-delivery-status{width:100%;margin:0}
  .quick-delivery-help{display:grid}
  .quick-delivery-help-actions{justify-content:flex-start}
}
.custom-program-contact strong{color:#17202a}

/* User usage dashboard, aligned with the admin overview. */
.dashboard-redesign {
  margin: -22px;
  padding: 22px;
  min-width: 0;
  min-height: calc(100vh - 62px);
  background: #eef8f8;
  display: grid;
  gap: 18px;
}

.dashboard-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.dashboard-stat {
  min-width: 0;
  min-height: 104px;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  background: #fff;
  border: 1px solid #e0e8ec;
  border-radius: 14px;
  box-shadow: 0 6px 18px rgba(39, 75, 91, .08);
}

.dashboard-stat > div:last-child {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.dashboard-stat span,
.dashboard-stat small {
  color: #5f6c7c;
}

.dashboard-stat strong {
  min-width: 0;
  color: #111827;
  font-size: 23px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.dashboard-stat small {
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dashboard-stat-icon {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border-radius: 9px;
  display: grid;
  place-items: center;
}

.dashboard-stat-icon svg {
  width: 21px;
  height: 21px;
}

.dashboard-stat-green .dashboard-stat-icon { background: #d7f8e5; color: #008c51; }
.dashboard-stat-blue .dashboard-stat-icon { background: #dceaff; color: #1d5fe9; }
.dashboard-stat-purple .dashboard-stat-icon { background: #f0ddff; color: #7c1bd1; }
.dashboard-stat-amber .dashboard-stat-icon { background: #fff0bf; color: #c97900; }
.dashboard-stat-violet .dashboard-stat-icon { background: #e9ddff; color: #5f25c7; }
.dashboard-stat-red .dashboard-stat-icon { background: #ffe0e1; color: #d22c40; }

.dashboard-surface {
  min-width: 0;
  max-width: 100%;
  padding: 20px;
  background: #fff;
  border: 1px solid #e0e8ec;
  border-radius: 14px;
  box-shadow: 0 6px 18px rgba(39, 75, 91, .07);
}

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

.dashboard-section-title > div {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.dashboard-section-title strong {
  color: #172033;
  font-size: 15px;
}

.dashboard-section-title small,
.dashboard-section-title > span,
.dashboard-range-summary {
  color: #5f6c7c;
  font-size: 12px;
}

.dashboard-feature-list {
  display: grid;
}

.dashboard-feature-list > div:not(.empty-state) {
  min-width: 0;
  min-height: 44px;
  display: grid;
  grid-template-columns: minmax(120px, .75fr) minmax(150px, 2fr) 100px 48px;
  align-items: center;
  gap: 12px;
  border-top: 1px solid #edf1f4;
}

.dashboard-feature-list > div:first-child {
  border-top: 0;
}

.dashboard-feature-list strong,
.dashboard-feature-list span,
.dashboard-feature-list small {
  min-width: 0;
}

.dashboard-feature-list > div > span:nth-child(3),
.dashboard-feature-list small {
  text-align: right;
  color: #5f6c7c;
  white-space: nowrap;
}

.dashboard-feature-track {
  height: 8px;
  border-radius: 4px;
  background: #e8edf1;
  overflow: hidden;
}

.dashboard-feature-track i {
  display: block;
  width: var(--feature-share);
  height: 100%;
  border-radius: inherit;
  background: #10a36b;
}

.dashboard-filter-surface {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
}

.dashboard-filter-surface > div {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #344054;
}

.dashboard-select {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 9px;
  background: #fff;
  border: 1px solid #d5dee6;
  border-radius: 8px;
}

.dashboard-select svg,
.dashboard-filter-surface .btn svg {
  width: 16px;
  height: 16px;
}

.dashboard-select select {
  min-height: 38px;
  padding: 0 5px;
  color: #344054;
  background: #fff;
  border: 0;
  outline: 0;
}

.dashboard-chart-grid,
.dashboard-account-grid {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
}

.dashboard-chart-grid > *,
.dashboard-account-grid > * {
  min-width: 0;
}

.dashboard-model-layout {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  align-items: center;
  gap: 20px;
}

.dashboard-donut {
  width: 190px;
  height: 190px;
  border-radius: 50%;
  display: grid;
  place-items: center;
}

.dashboard-donut > div {
  width: 112px;
  height: 112px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 2px;
  background: #fff;
  text-align: center;
}

.dashboard-donut strong {
  color: #162033;
  font-size: 21px;
}

.dashboard-donut span {
  color: #64748b;
  font-size: 12px;
}

.dashboard-model-table {
  min-width: 0;
  display: grid;
}

.dashboard-model-head,
.dashboard-model-row {
  display: grid;
  grid-template-columns: minmax(110px, 1.6fr) repeat(3, minmax(54px, .75fr));
  align-items: center;
  gap: 8px;
  padding: 9px 0;
  border-bottom: 1px solid #edf1f4;
  font-size: 12px;
}

.dashboard-model-head {
  color: #64748b;
  font-weight: 700;
}

.dashboard-model-row > span:not(:first-child) {
  text-align: right;
}

.dashboard-model-row > span:first-child {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dashboard-model-row > span:first-child i {
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
}

.dashboard-legend {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  color: #475569;
  font-size: 11px;
  font-weight: 400;
}

.dashboard-legend span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.dashboard-legend i {
  width: 9px;
  height: 9px;
  display: inline-block;
  border: 1px solid currentColor;
  border-radius: 50%;
}

.legend-input { color: #2563eb; }
.legend-output { color: #10b981; }

.dashboard-trend-svg {
  width: 100%;
  height: 245px;
  display: block;
}

.dashboard-trend-svg line {
  stroke: #e3e9ef;
  stroke-width: 1;
}

.dashboard-trend-svg polyline {
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.dashboard-trend-svg .dashboard-trend-input { stroke: #2563eb; }
.dashboard-trend-svg .dashboard-trend-output { stroke: #10b981; }

.dashboard-trend-svg text {
  fill: #64748b;
  font-size: 11px;
  text-anchor: middle;
}

.dashboard-trend-total {
  margin-top: -25px;
  color: #64748b;
  font-size: 12px;
  text-align: right;
}

.dashboard-quick-actions {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.dashboard-quick-actions button {
  min-width: 0;
  min-height: 58px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #24415e;
  background: #f6fafc;
  border: 1px solid #dbe5eb;
  border-radius: 8px;
  font-weight: 700;
}

.dashboard-quick-actions button:hover {
  color: #14532d;
  background: #ecfdf5;
  border-color: #a7d7bf;
}

.dashboard-quick-actions svg {
  width: 19px;
  height: 19px;
  flex: 0 0 19px;
}

.dashboard-account-list {
  margin: 0;
  display: grid;
}

.dashboard-account-list > div {
  min-width: 0;
  min-height: 43px;
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  border-top: 1px solid #edf1f4;
}

.dashboard-account-list > div:first-child {
  border-top: 0;
}

.dashboard-account-list dt {
  color: #64748b;
}

.dashboard-account-list dd {
  min-width: 0;
  margin: 0;
  text-align: right;
  overflow-wrap: anywhere;
}

.dashboard-recent-list {
  display: grid;
}

.dashboard-recent-list > div:not(.empty-state) {
  min-width: 0;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid #edf1f4;
}

.dashboard-recent-list > div:first-child {
  border-top: 0;
}

.dashboard-recent-list > div > span {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.dashboard-recent-list > div > span:last-child {
  flex: 0 0 auto;
  justify-items: end;
}

.dashboard-recent-list strong,
.dashboard-recent-list small {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dashboard-recent-list small {
  color: #64748b;
  font-size: 11px;
}

.dashboard-redesign .empty-state {
  padding: 18px;
}

@media (max-width: 1100px) {
  .dashboard-stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-chart-grid,
  .dashboard-account-grid { grid-template-columns: minmax(0, 1fr); }
  .dashboard-quick-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .dashboard-redesign {
    margin: -14px;
    padding: 14px;
  }

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

  .dashboard-stat {
    min-height: 94px;
    padding: 14px 12px;
    gap: 9px;
  }

  .dashboard-stat-icon {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
  }

  .dashboard-stat strong { font-size: 18px; }
  .dashboard-stat small { font-size: 11px; }

  .dashboard-feature-list > div:not(.empty-state) {
    grid-template-columns: minmax(90px, .7fr) minmax(100px, 1.5fr) 84px;
  }

  .dashboard-feature-list small { display: none; }

  .dashboard-filter-surface {
    align-items: flex-start;
    flex-direction: column;
  }

  .dashboard-filter-surface > div {
    width: 100%;
    flex-wrap: wrap;
  }

  .dashboard-filter-surface .dashboard-select { flex: 1; }
  .dashboard-model-layout { grid-template-columns: 1fr; }
  .dashboard-donut { margin: auto; }
  .dashboard-model-table { overflow: auto; }
  .dashboard-model-head,
  .dashboard-model-row { min-width: 440px; }
  .dashboard-legend { gap: 7px; }

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

@media (max-width: 480px) {
  .dashboard-stat-grid { grid-template-columns: 1fr; }
  .dashboard-stat { min-height: 88px; }
  .dashboard-chart-grid,
  .dashboard-account-grid { gap: 12px; }
  .dashboard-surface { padding: 14px; }
  .dashboard-section-title {
    align-items: flex-start;
    flex-direction: column;
  }

  .dashboard-feature-list > div:not(.empty-state) {
    grid-template-columns: minmax(84px, .8fr) minmax(72px, 1fr) 74px;
    gap: 8px;
  }

  .dashboard-feature-list > div > span:nth-child(3) {
    font-size: 11px;
  }

  .dashboard-quick-actions { grid-template-columns: 1fr; }
  .dashboard-account-list > div { grid-template-columns: 86px minmax(0, 1fr); }
}

/* ── UI polish: spinner / toast animation / loading states ── */
@keyframes ui-spin {
  to { transform: rotate(360deg); }
}
@keyframes toast-slide-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.view-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 64px 28px;
  color: var(--muted);
  font-size: 14px;
}
.view-loading-spinner {
  width: 26px;
  height: 26px;
  border: 3px solid var(--line);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: ui-spin .65s linear infinite;
}
.empty-retry { margin-top: 10px; }

/* ── Dark mode support ── */
html.workspace-theme-dark,
html.workspace-theme-dark body {
  --bg: #0d0f12;
  --panel: #171a1f;
  --panel-soft: #1d2127;
  --line: #2b313a;
  --line-strong: #3a424d;
  --text: #f2f4f7;
  --muted: #949da9;
  --primary: #f39a4a;
  --primary-2: #ff9d4f;
  --primary-soft: rgba(243, 154, 74, .12);
  --green: #4fd0a2;
  --green-soft: rgba(79, 208, 162, .12);
  --red: #ef4444;
  --amber: #fbbf24;
  --amber-soft: rgba(251, 191, 36, .12);
  --shadow: 0 14px 34px rgba(0, 0, 0, .4);
  background: var(--bg);
  color: var(--text);
  color-scheme: dark;
}

/* ── Dark mode input elements ── */
html.workspace-theme-dark input,
html.workspace-theme-dark textarea,
html.workspace-theme-dark select {
  background: #20242b;
  border-color: var(--line);
  color: var(--text);
}

html.workspace-theme-dark input::placeholder,
html.workspace-theme-dark textarea::placeholder {
  color: var(--muted);
}

/* ── Dark mode buttons ── */
html.workspace-theme-dark .btn {
  background: var(--panel-soft);
  border-color: var(--line);
  color: var(--text);
}

html.workspace-theme-dark .btn:hover {
  background: #232830;
  border-color: var(--line-strong);
}

html.workspace-theme-dark .btn.primary {
  background: var(--primary);
  border-color: var(--primary-2);
  color: #0d0f12;
}

html.workspace-theme-dark .btn.primary:hover {
  background: var(--primary-2);
  border-color: #ff9d4f;
}

/* ── Dark mode panels and cards ── */
html.workspace-theme-dark .panel,
html.workspace-theme-dark .card,
html.workspace-theme-dark .login-panel {
  background: var(--panel);
  border-color: var(--line);
  color: var(--text);
}

/* ── Dark mode links ── */
html.workspace-theme-dark a {
  color: var(--primary);
}

html.workspace-theme-dark a:hover {
  color: var(--primary-2);
}

/* ── Dark mode code blocks ── */
html.workspace-theme-dark pre,
html.workspace-theme-dark code {
  background: #20242b;
  border-color: var(--line);
  color: var(--text);
}

/* ── Dark mode tables ── */
html.workspace-theme-dark table {
  border-color: var(--line);
}

html.workspace-theme-dark th,
html.workspace-theme-dark td {
  border-color: var(--line);
  color: var(--text);
}

html.workspace-theme-dark th {
  background: var(--panel-soft);
}

html.workspace-theme-dark tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

/* ── Dark mode toast notifications ── */
html.workspace-theme-dark .toast {
  background: var(--panel);
  border-color: var(--line-strong);
  color: var(--text);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

/* ── Dark mode modals ── */
html.workspace-theme-dark .modal {
  background: var(--panel);
  border-color: var(--line-strong);
}

html.workspace-theme-dark .modal-overlay {
  background: rgba(0, 0, 0, 0.7);
}

html.workspace-theme-dark .ai-rewrite-guide-modal .modal-head,
html.workspace-theme-dark .ai-rewrite-guide-modal .modal-foot,
html.workspace-theme-dark .ai-rewrite-guide-card {
  background: var(--panel);
  border-color: var(--line);
}

html.workspace-theme-dark .ai-rewrite-guide-heading b,
html.workspace-theme-dark .ai-rewrite-guide-card h3,
html.workspace-theme-dark .ai-rewrite-guide-card p strong {
  color: var(--text);
}

html.workspace-theme-dark .ai-rewrite-guide-heading small,
html.workspace-theme-dark .ai-rewrite-guide-card p,
html.workspace-theme-dark .ai-rewrite-guide-foot-note {
  color: var(--muted);
}

html.workspace-theme-dark .ai-rewrite-guide-card .ai-rewrite-guide-note {
  background: var(--panel-soft);
}

html.workspace-theme-dark .ai-rewrite-guide-reminder {
  border-color: #854d0e;
  background: #2b2418;
  color: #fde68a;
}

/* ── Dark mode nav and sidebar ── */
html.workspace-theme-dark .nav a,
html.workspace-theme-dark .sidebar a {
  color: var(--muted);
}

html.workspace-theme-dark .nav a:hover,
html.workspace-theme-dark .sidebar a:hover,
html.workspace-theme-dark .nav a.active,
html.workspace-theme-dark .sidebar a.active {
  color: var(--text);
  background: var(--panel-soft);
}

.paper-mechanical-hint-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: linear-gradient(135deg, #FFF3E0 0%, #FFE0B2 100%);
  border: 1px solid #FFB74D;
  border-radius: 8px;
  font-size: 13px;
  color: #E65100;
  line-height: 1.5;
}

.paper-mechanical-hint-banner strong {
  color: #BF360C;
}

.paper-mechanical-hint-banner .link-btn {
  background: none;
  border: none;
  padding: 0 2px;
  color: #F57C00;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  font-size: inherit;
}

.paper-mechanical-hint-banner .link-btn:hover {
  color: #E65100;
}

/* Gallery View Styles */
.gallery-view {
  max-width: 1200px;
  margin: 0 auto;
}

.gallery-hero {
  text-align: center;
  padding: 48px 24px;
  background: linear-gradient(135deg, #F7F4EF 0%, #FBF9F5 100%);
  border-radius: 16px;
  margin-bottom: 32px;
}

.gallery-eyebrow {
  display: inline-block;
  background: #F2E3D6;
  color: #C4612F;
  padding: 6px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 16px;
}

.gallery-hero h2 {
  font-size: 32px;
  font-weight: 600;
  color: #1F2421;
  margin: 16px 0 8px;
}

.gallery-hero p {
  font-size: 16px;
  color: #5C635D;
  margin: 0;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 24px;
  padding: 24px 0;
}

.gallery-card {
  background: #FFFFFF;
  border: 1px solid #E7E1D7;
  border-radius: 12px;
  padding: 24px;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.gallery-card:hover {
  box-shadow: 0 4px 12px rgba(31, 36, 33, 0.08);
  transform: translateY(-2px);
}

.gallery-card-header h3 {
  font-size: 18px;
  font-weight: 600;
  color: #1F2421;
  margin: 0 0 8px;
  line-height: 1.4;
}

.gallery-meta {
  display: inline-block;
  background: #F7F4EF;
  color: #5C635D;
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 13px;
}

.gallery-card-body {
  flex: 1;
}

.gallery-card-body p {
  font-size: 14px;
  color: #5C635D;
  line-height: 1.6;
  margin: 0 0 16px;
}

.gallery-stats {
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: #5C635D;
}

.gallery-card-actions {
  display: flex;
  gap: 8px;
  padding-top: 16px;
  border-top: 1px solid #E7E1D7;
}

.gallery-card-actions .btn {
  flex: 1;
  justify-content: center;
}

.empty-state {
  text-align: center;
  color: #5C635D;
  padding: 48px;
  font-size: 15px;
}

/* Gallery Dark Mode Styles */
html.workspace-theme-dark .gallery-hero {
  background: linear-gradient(135deg, var(--panel) 0%, var(--panel-soft) 100%);
}

html.workspace-theme-dark .gallery-eyebrow {
  background: var(--primary-soft);
  color: var(--primary);
}

html.workspace-theme-dark .gallery-hero h2 {
  color: var(--text);
}

html.workspace-theme-dark .gallery-hero p {
  color: var(--muted);
}

html.workspace-theme-dark .gallery-card {
  background: var(--panel);
  border-color: var(--line);
}

html.workspace-theme-dark .gallery-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  border-color: var(--line-strong);
}

html.workspace-theme-dark .gallery-card-header h3 {
  color: var(--text);
}

html.workspace-theme-dark .gallery-meta {
  background: var(--panel-soft);
  color: var(--muted);
}

html.workspace-theme-dark .gallery-card-body p {
  color: var(--muted);
}

html.workspace-theme-dark .gallery-stats {
  color: var(--muted);
}

html.workspace-theme-dark .gallery-card-actions {
  border-top-color: var(--line);
}

html.workspace-theme-dark .empty-state {
  color: var(--muted);
}

/* Software Paper Mode Tabs */
.software-paper-mode-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  border-bottom: 1px solid #E7E1D7;
  padding: 0;
}

.mode-tab {
  padding: 12px 24px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: #5C635D;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background-color 0.2s;
}

.mode-tab:hover {
  color: #1F2421;
}

.mode-tab.active {
  color: #C4612F;
  border-bottom-color: #C4612F;
}

.mode-content {
  animation: fadeIn 0.3s;
}

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

/* Dark Mode for Software Paper Tabs */
html.workspace-theme-dark .software-paper-mode-tabs {
  border-bottom-color: var(--line);
}

html.workspace-theme-dark .mode-tab {
  color: var(--muted);
}

html.workspace-theme-dark .mode-tab:hover {
  color: var(--text);
}

html.workspace-theme-dark .mode-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* Production gap workspaces - 2026-08-17 */
.gap-page {
  display: grid;
  min-width: 0;
  gap: 18px;
}

.gap-page-head,
.gap-section-head,
.gap-form-actions,
.gap-filter-row,
.gap-search-bar,
.gap-import-row,
.gap-capability-strip,
.paper-editor-toolbar {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.gap-page-head {
  padding: 4px 0 18px;
  border-bottom: 1px solid var(--line);
}

.gap-page-head > div,
.gap-section-head > div,
.paper-editor-toolbar > div {
  min-width: 0;
}

.gap-page-head h2,
.gap-section-head h3,
.gap-detail-pane h3,
.gap-list-pane h3,
.market-product h3,
.paper-editor-layout h3 {
  margin: 0;
  color: var(--text);
  letter-spacing: 0;
}

.gap-page-head h2 {
  margin-top: 4px;
  font-size: 24px;
  line-height: 1.3;
}

.gap-page-head p,
.gap-section-head p,
.gap-detail-pane p,
.gap-list-pane p {
  margin: 5px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.gap-eyebrow {
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
}

.gap-page-head .nav-icon,
.gap-form-actions .nav-icon {
  width: 16px;
  height: 16px;
}

.gap-metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.gap-metric {
  min-width: 0;
  min-height: 112px;
  padding: 15px;
  border: 1px solid var(--line);
  border-top: 3px solid #2563eb;
  border-radius: 8px;
  background: var(--panel);
}

.gap-metric > span,
.gap-metric > small,
.gap-metric > strong {
  display: block;
  overflow-wrap: anywhere;
}

.gap-metric > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.gap-metric > strong {
  margin: 10px 0 7px;
  font-size: 24px;
  line-height: 1;
}

.gap-metric > small {
  color: var(--muted);
  line-height: 1.4;
}

.gap-tone-green { border-top-color: #059669; }
.gap-tone-blue { border-top-color: #2563eb; }
.gap-tone-amber { border-top-color: #d97706; }
.gap-tone-purple { border-top-color: #7c3aed; }
.gap-tone-teal { border-top-color: #0f766e; }

.gap-section,
.gap-list-pane,
.gap-detail-pane {
  min-width: 0;
  padding: 18px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: transparent;
}

.gap-section-head {
  margin-bottom: 14px;
}

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

.gap-form-grid .wide,
.gap-form-grid .gap-form-actions {
  grid-column: 1 / -1;
}

.gap-form-actions {
  justify-content: flex-end;
  flex-wrap: wrap;
}

.gap-form-actions > span {
  margin-right: auto;
  color: var(--muted);
}

.gap-table {
  min-width: 740px;
}

.gap-wrap-cell {
  min-width: 180px;
  white-space: normal;
  overflow-wrap: anywhere;
}

.gap-scope-note,
.gap-capability-strip {
  padding: 14px 16px;
  border-left: 3px solid #0f766e;
  background: rgba(15, 118, 110, .08);
}

.gap-scope-note {
  display: flex;
  gap: 12px;
  line-height: 1.6;
}

.gap-scope-note strong {
  flex: 0 0 auto;
}

.gap-scope-note span,
.gap-capability-strip span {
  color: var(--muted);
}

.gap-capability-strip > div {
  display: grid;
  gap: 4px;
}

.gap-split-layout {
  display: grid;
  grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
  min-height: 480px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.gap-list-pane,
.gap-detail-pane {
  border-top: 0;
  border-bottom: 0;
}

.gap-list-pane {
  padding-right: 16px;
  border-right: 1px solid var(--line);
}

.gap-detail-pane {
  padding-left: 18px;
}

.gap-select-list {
  display: grid;
  gap: 6px;
}

.gap-select-list > button {
  display: flex;
  width: 100%;
  min-width: 0;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.gap-select-list > button:hover,
.gap-select-list > button.active {
  border-color: #bfdbfe;
  background: #eff6ff;
}

.gap-select-list > button > span {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.gap-select-list strong,
.gap-select-list small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gap-select-list small {
  color: var(--muted);
}

.gap-empty-state {
  display: grid;
  min-height: 240px;
  place-content: center;
  gap: 7px;
  color: var(--muted);
  text-align: center;
}

.gap-empty-state strong {
  color: var(--text);
  font-size: 16px;
}

.gap-import-row {
  margin-bottom: 14px;
  align-items: flex-end;
}

.gap-import-row .field {
  flex: 1 1 340px;
}

.gap-quote-result {
  display: flex;
  min-height: 54px;
  margin-top: 14px;
  padding: 12px 14px;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
}

.gap-quote-result strong {
  flex: 0 0 auto;
}

.gap-quote-result span,
.gap-quote-result small {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.gap-search-bar .input {
  flex: 1 1 300px;
}

.gap-search-bar .select {
  width: min(220px, 100%);
}

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

.market-product {
  display: grid;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.market-product-preview {
  display: grid;
  aspect-ratio: 16 / 9;
  place-content: center;
  gap: 7px;
  overflow: hidden;
  background: #edf2f7;
  color: #475569;
  text-align: center;
}

.market-product-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.market-product-preview .nav-icon {
  width: 30px;
  height: 30px;
  margin: auto;
}

.market-product-body {
  display: grid;
  min-width: 0;
  gap: 10px;
  padding: 14px;
}

.market-product h3,
.market-product p {
  display: -webkit-box;
  overflow: hidden;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
}

.market-product h3 {
  font-size: 15px;
  -webkit-line-clamp: 2;
}

.market-product p {
  min-height: 42px;
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
  -webkit-line-clamp: 2;
}

.market-product-meta,
.market-product-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.market-product-meta {
  color: var(--muted);
  font-size: 12px;
}

.market-product-foot strong {
  font-size: 19px;
}

.gap-choice-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.gap-choice {
  min-width: 0;
}

.gap-choice > input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.gap-choice > span {
  display: grid;
  min-height: 116px;
  align-content: start;
  gap: 7px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  cursor: pointer;
}

.gap-choice > span .nav-icon {
  width: 22px;
  height: 22px;
  color: var(--primary);
}

.gap-choice > span small {
  color: var(--muted);
  line-height: 1.45;
}

.gap-choice > input:checked + span {
  border-color: #2563eb;
  background: #eff6ff;
  box-shadow: inset 0 0 0 1px #2563eb;
}

.gap-choice.disabled > span {
  cursor: not-allowed;
  opacity: .55;
}

.ticket-thread {
  display: grid;
  max-height: 520px;
  margin-bottom: 16px;
  padding-right: 4px;
  gap: 10px;
  overflow-y: auto;
}

.ticket-message {
  max-width: min(720px, 88%);
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.ticket-message.is-user {
  justify-self: end;
  border-color: #bfdbfe;
  background: #eff6ff;
}

.ticket-message > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.ticket-message time,
.ticket-message p {
  color: var(--muted);
}

.ticket-message p {
  margin: 8px 0 0;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.gap-reply-form {
  display: grid;
  gap: 12px;
}

.gap-payment-result {
  display: grid;
  place-items: center;
  gap: 12px;
  text-align: center;
}

.gap-payment-result img {
  width: min(240px, 100%);
  aspect-ratio: 1;
  object-fit: contain;
}

.paper-billing-switch {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.paper-billing-switch > label {
  min-width: 0;
}

.paper-billing-switch input {
  position: absolute;
  opacity: 0;
}

.paper-billing-switch label > span {
  display: grid;
  min-height: 76px;
  align-content: center;
  gap: 5px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  cursor: pointer;
}

.paper-billing-switch label.active > span {
  border-color: #2563eb;
  background: #eff6ff;
  box-shadow: inset 0 0 0 1px #2563eb;
}

.paper-billing-switch small,
.paper-billing-note small,
.paper-billing-note span {
  color: var(--muted);
  line-height: 1.5;
}

.paper-billing-note {
  display: flex;
  margin-bottom: 14px;
  padding: 12px 14px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-left: 3px solid #0f766e;
  background: rgba(15, 118, 110, .08);
}

.paper-billing-note.is-draft {
  border-left-color: #d97706;
  background: rgba(217, 119, 6, .08);
}

.paper-billing-note > div {
  display: grid;
  flex: 0 0 auto;
  gap: 3px;
}

.paper-billing-note > small {
  max-width: 680px;
}

.paper-editor-mask .modal {
  width: min(1220px, calc(100vw - 32px));
  max-width: none;
}

.paper-editor-workbench {
  display: grid;
  min-width: 0;
  gap: 14px;
}

.paper-editor-toolbar {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.paper-editor-toolbar > div:first-child {
  display: grid;
  gap: 4px;
}

.paper-editor-toolbar span {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.paper-editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(230px, 290px);
  gap: 16px;
}

.paper-editor-layout > main {
  display: grid;
  min-width: 0;
  gap: 12px;
}

.paper-editor-layout > aside {
  min-width: 0;
  padding-left: 14px;
  border-left: 1px solid var(--line);
}

.paper-editor-text {
  min-height: 50vh;
  max-height: 64vh;
  resize: vertical;
  font-family: "Microsoft YaHei", sans-serif;
  line-height: 1.75;
}

.paper-version-list {
  display: grid;
  max-height: 62vh;
  margin-top: 10px;
  gap: 8px;
  overflow-y: auto;
}

.paper-version-list article {
  padding: 10px;
  border-bottom: 1px solid var(--line);
}

.paper-version-list article > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.paper-version-list span,
.paper-version-list small {
  color: var(--muted);
  font-size: 11px;
  overflow-wrap: anywhere;
}

.paper-version-list p {
  margin: 7px 0;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.paper-editor-quality {
  padding: 12px;
  border-left: 3px solid #64748b;
  background: var(--panel-soft);
}

.paper-editor-quality.passed {
  border-left-color: #059669;
  background: rgba(5, 150, 105, .08);
}

.paper-editor-quality.failed {
  border-left-color: #dc2626;
  background: rgba(220, 38, 38, .07);
}

.paper-editor-quality > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.paper-editor-quality p,
.paper-editor-quality ul {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.paper-editor-status {
  min-height: 22px;
  color: var(--muted);
}

.modal-mask {
  z-index: 80;
}

.market-author-mask .modal {
  width: min(1080px, calc(100vw - 32px));
  max-height: min(900px, calc(100vh - 32px));
}

.market-author-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
  min-width: 0;
}

.market-author-workspace > *,
.market-author-section,
.market-author-section .gap-form-grid,
.market-author-section .field,
.market-author-section .table-wrap {
  min-width: 0;
  max-width: 100%;
}

.market-author-section .input,
.market-author-section .select,
.market-author-section .textarea {
  min-width: 0;
  max-width: 100%;
}

.market-author-balances {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 0;
}

.market-author-balances > div {
  min-width: 0;
}

.market-author-section {
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.market-author-section:first-of-type {
  padding-top: 0;
  border-top: 0;
}

.market-author-section .compact-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
  align-items: end;
}

.market-author-section .compact-grid .gap-form-actions {
  align-self: end;
  min-height: 42px;
}

.market-author-section .nav-icon,
.market-page .actions .nav-icon {
  width: 16px;
  height: 16px;
}

html.workspace-theme-dark .gap-select-list > button:hover,
html.workspace-theme-dark .gap-select-list > button.active,
html.workspace-theme-dark .gap-choice > input:checked + span,
html.workspace-theme-dark .paper-billing-switch label.active > span,
html.workspace-theme-dark .ticket-message.is-user {
  border-color: #2563eb;
  background: rgba(37, 99, 235, .16);
}

html.workspace-theme-dark .market-product-preview {
  background: #162032;
}

@media (max-width: 1180px) {
  .gap-metric-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .market-product-grid,
  .gap-choice-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .gap-split-layout,
  .paper-editor-layout {
    grid-template-columns: 1fr;
  }

  .gap-list-pane {
    padding-right: 0;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .gap-detail-pane {
    padding-left: 0;
  }

  .paper-editor-layout > aside {
    padding: 14px 0 0;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .paper-version-list {
    max-height: 280px;
  }

  .paper-editor-toolbar,
  .paper-billing-note {
    align-items: flex-start;
    flex-direction: column;
  }

  .market-author-balances,
  .market-author-section .compact-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 680px) {
  .gap-page-head,
  .gap-section-head,
  .gap-form-actions,
  .gap-search-bar,
  .gap-import-row,
  .gap-capability-strip {
    align-items: stretch;
    flex-direction: column;
  }

  .gap-page-head .btn,
  .gap-form-actions .btn,
  .gap-search-bar .btn,
  .gap-search-bar .select,
  .gap-import-row .btn {
    width: 100%;
  }

  .gap-metric-grid,
  .gap-form-grid,
  .market-product-grid,
  .gap-choice-grid,
  .paper-billing-switch {
    grid-template-columns: 1fr;
  }

  .gap-scope-note,
  .gap-quote-result {
    align-items: flex-start;
    flex-direction: column;
  }

  .gap-filter-row .select {
    width: 100%;
  }

  .ticket-message {
    max-width: 96%;
  }

  .paper-editor-mask .modal {
    width: calc(100vw - 16px);
  }

  .paper-editor-toolbar .actions,
  .paper-editor-toolbar .btn {
    width: 100%;
  }

  .paper-editor-toolbar .btn {
    flex: 1 1 140px;
  }

  .market-author-mask .modal {
    width: 100%;
    max-height: calc(100vh - 16px);
  }

  .market-author-balances,
  .market-author-section .compact-grid {
    grid-template-columns: 1fr;
  }

  .market-author-section .compact-grid .gap-form-actions,
  .market-author-section .compact-grid .btn {
    width: 100%;
  }
}

.engineering-structured-fields {
  display: grid;
  gap: 16px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line, #dde3e8);
}

.engineering-input-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

.engineering-check-grid {
  grid-template-columns: repeat(2, minmax(0, 240px));
}

.engineering-check {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
  border: 1px solid var(--line, #dde3e8);
  border-radius: 6px;
  background: var(--panel, #fff);
  color: var(--text, #202832);
}

.engineering-check input {
  width: 17px;
  height: 17px;
  margin: 0;
}

.engineering-row-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.engineering-edit-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr)) 36px;
  gap: 9px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line, #dde3e8);
  border-radius: 6px;
  background: #f8fafb;
}

.engineering-task-row,
.engineering-layout-row {
  grid-template-columns: repeat(3, minmax(110px, 1fr)) repeat(4, minmax(90px, .75fr)) 36px;
}

.engineering-edit-row label {
  display: grid;
  min-width: 0;
  gap: 5px;
  color: var(--muted, #687481);
  font-size: 12px;
}

.engineering-edit-row .icon-btn {
  width: 36px;
  height: 36px;
}

.engineering-code-field {
  display: grid;
  gap: 7px;
}

.engineering-code-field textarea {
  font-family: Consolas, "Courier New", monospace;
  line-height: 1.55;
}

@media (max-width: 1100px) {
  .engineering-input-grid,
  .engineering-edit-row,
  .engineering-task-row,
  .engineering-layout-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .engineering-edit-row .icon-btn {
    justify-self: end;
  }
}

@media (max-width: 680px) {
  .engineering-input-grid,
  .engineering-edit-row,
  .engineering-task-row,
  .engineering-layout-row {
    grid-template-columns: 1fr;
  }

  .engineering-row-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .engineering-row-heading .btn,
  .engineering-edit-row .icon-btn {
    width: 100%;
  }
}
