:root {
  color-scheme: light;
  --bg: #f3f5f7;
  --panel: #ffffff;
  --panel-soft: #f8fafb;
  --ink: #17202a;
  --muted: #68737d;
  --line: #e1e6ea;
  --line-strong: #cbd3d9;
  --accent: #0d796f;
  --accent-dark: #075c55;
  --accent-soft: #e8f5f2;
  --amber: #b76f0a;
  --amber-soft: #fff4df;
  --red: #bb3e45;
  --red-soft: #fdebed;
  --blue: #3769b1;
  --blue-soft: #eaf1fb;
  --shadow: 0 12px 34px rgba(25, 37, 48, 0.07);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 85% 5%, rgba(13, 121, 111, 0.08), transparent 24rem),
    var(--bg);
  font-family:
    Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

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

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 10;
  display: flex;
  width: 244px;
  flex-direction: column;
  padding: 24px 18px;
  color: #ecf6f4;
  background:
    linear-gradient(165deg, rgba(255, 255, 255, 0.05), transparent 32%),
    #102d2a;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px 26px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 13px;
  color: #102d2a;
  background: #9de1d7;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.brand strong,
.brand span {
  display: block;
}

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

.brand span {
  margin-top: 3px;
  color: #9db5b1;
  font-size: 11px;
}

.nav-list {
  display: grid;
  gap: 7px;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 12px 13px;
  border: 0;
  border-radius: 10px;
  color: #bcd0cd;
  background: transparent;
  text-align: left;
}

.nav-item small {
  color: #668681;
  font-size: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.nav-item:hover,
.nav-item.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.09);
}

.nav-item.active {
  box-shadow: inset 3px 0 #79d0c4;
}

.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding: 14px 8px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
  color: #9db5b1;
  font-size: 11px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #8fa19f;
  box-shadow: 0 0 0 4px rgba(143, 161, 159, 0.1);
}

.status-dot.ok {
  background: #65d0a2;
  box-shadow: 0 0 0 4px rgba(101, 208, 162, 0.12);
}

.status-dot.error {
  background: #f07178;
}

.main {
  min-height: 100vh;
  margin-left: 244px;
  padding: 34px clamp(24px, 4vw, 58px) 60px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}

.eyebrow,
.panel-kicker {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(25px, 3vw, 34px);
  letter-spacing: -0.035em;
}

h2 {
  margin-bottom: 0;
  font-size: 18px;
  letter-spacing: -0.015em;
}

h3 {
  margin-bottom: 7px;
  font-size: 15px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.last-refresh {
  color: var(--muted);
  font-size: 12px;
}

.button,
.text-button,
.icon-button,
.toggle-button {
  border: 0;
}

.button {
  min-height: 38px;
  padding: 8px 15px;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 700;
}

.button.primary {
  color: #fff;
  background: var(--accent);
}

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

.button.secondary {
  border: 1px solid var(--line);
  color: var(--ink);
  background: #fff;
}

.button.danger {
  border: 1px solid #efc5c8;
  color: var(--red);
  background: var(--red-soft);
}

.button.danger:hover {
  border-color: #e6a8ad;
  background: #f9dfe2;
}

.compact-form {
  margin-bottom: 16px;
}

.secret-output {
  display: block;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-soft);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.totp-qr {
  width: 240px;
  max-width: 100%;
  margin: 0 auto 12px;
  border-radius: 12px;
}

.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
}

.role-editor summary {
  cursor: pointer;
}

.permission-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 8px 12px;
  margin: 14px 0;
}

.role-summary {
  align-items: flex-start;
}

.role-summary-copy {
  min-width: 0;
  flex: 1;
}

.role-permission-summary {
  display: -webkit-box;
  margin-top: 7px;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.role-picker {
  min-width: 0;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.role-picker legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

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

.role-option,
.permission-option {
  display: flex !important;
  align-items: flex-start;
  grid-template-columns: none !important;
  gap: 10px !important;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--ink) !important;
  background: #fff;
  cursor: pointer;
}

.role-option.selected,
.permission-option.selected {
  border-color: #8fc7bd;
  background: var(--accent-soft);
}

.role-option.disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.management-form .role-option input,
.management-form .permission-option input {
  width: auto;
  min-height: auto;
  margin-top: 3px;
}

.role-option span {
  display: grid;
  gap: 3px;
}

.role-option small {
  color: var(--muted);
  font-size: 10px;
}

.permission-groups {
  display: grid;
  gap: 12px;
  max-height: 440px;
  overflow: auto;
}

.permission-group {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-soft);
}

.permission-group h3 {
  margin: 0 0 9px;
  font-size: 12px;
}

.permission-option-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.permission-option {
  font-size: 11px;
  line-height: 1.45;
}

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

.text-button {
  padding: 4px;
  color: var(--accent);
  background: transparent;
  font-size: 12px;
}

.view {
  display: none;
}

.view.active {
  display: block;
  animation: fade-in 180ms ease-out;
}

@keyframes fade-in {
  from {
    transform: translateY(3px);
    opacity: 0.5;
  }
}

.hidden {
  display: none !important;
}

.notice {
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 1px solid #f0c9cd;
  border-radius: 10px;
  color: #8c2d34;
  background: var(--red-soft);
  font-size: 13px;
}

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

.metric {
  min-height: 130px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metric-label {
  color: var(--muted);
  font-size: 12px;
}

.metric-value {
  display: block;
  margin: 16px 0 5px;
  font-size: 30px;
  font-weight: 750;
  letter-spacing: -0.04em;
}

.metric-note {
  color: var(--muted);
  font-size: 11px;
}

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

.panel {
  overflow: hidden;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel.span-2 {
  grid-column: span 2;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
}

.panel-description {
  max-width: 720px;
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.stack-list {
  min-height: 80px;
}

.stack-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
}

.stack-item:last-child {
  border-bottom: 0;
}

.stack-title {
  overflow: hidden;
  margin-bottom: 4px;
  font-size: 13px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stack-meta {
  color: var(--muted);
  font-size: 11px;
}

.loading-block,
.empty-state {
  padding: 32px 22px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  color: #4d5a63;
  background: #eef1f3;
  font-size: 10px;
  font-weight: 750;
  white-space: nowrap;
}

.badge.requirement {
  color: var(--amber);
  background: var(--amber-soft);
}

.badge.planned_development,
.badge.passed,
.badge.captured {
  color: var(--accent);
  background: var(--accent-soft);
}

.badge.bugfix,
.badge.failed {
  color: var(--red);
  background: var(--red-soft);
}

.badge.active,
.badge.in_progress,
.badge.unchanged {
  color: var(--blue);
  background: var(--blue-soft);
}

.badge.binary,
.badge.too_large,
.badge.pending {
  color: var(--amber);
  background: var(--amber-soft);
}

.badge.legacy {
  color: #5f6971;
  background: #eceff1;
}

.conversation-heading {
  align-items: center;
}

.view-toggle {
  display: flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel-soft);
}

.toggle-button {
  padding: 7px 10px;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-size: 11px;
}

.toggle-button.active {
  color: var(--ink);
  background: #fff;
  box-shadow: 0 2px 8px rgba(18, 32, 42, 0.08);
}

.filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 1fr));
  gap: 14px;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-soft);
}

label > span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

input,
select {
  width: 100%;
  height: 38px;
  padding: 7px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  outline: none;
  color: var(--ink);
  background: #fff;
  font-size: 12px;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 121, 111, 0.1);
}

.filter-checks {
  display: flex;
  grid-column: span 2;
  align-items: center;
  gap: 18px;
  padding-top: 5px;
}

.filter-checks label {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
}

.filter-checks input {
  width: 15px;
  height: 15px;
}

.filter-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.document-filters {
  grid-template-columns: repeat(2, minmax(150px, 0.8fr)) minmax(150px, 0.7fr) minmax(220px, 1.4fr) auto;
}

.code-change-filters {
  grid-template-columns: repeat(3, minmax(160px, 1fr));
}

.document-filters .filter-actions {
  align-self: end;
}

.timeline-summary {
  padding: 14px 22px 0;
  color: var(--muted);
  font-size: 11px;
}

.conversation-timeline {
  position: relative;
  padding: 20px 22px;
}

.conversation-timeline::before {
  position: absolute;
  top: 24px;
  bottom: 24px;
  left: 35px;
  width: 1px;
  background: var(--line);
  content: "";
}

.turn-card {
  position: relative;
  margin: 0 0 18px 28px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.turn-card::before {
  position: absolute;
  top: 21px;
  left: -22px;
  width: 9px;
  height: 9px;
  border: 3px solid var(--bg);
  border-radius: 50%;
  background: var(--accent);
  content: "";
}

.turn-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 15px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfc;
}

.turn-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.turn-time {
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
}

.message {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  border-bottom: 1px solid var(--line);
}

.message:last-of-type {
  border-bottom: 0;
}

.message-role {
  padding: 16px 14px;
  color: var(--muted);
  background: var(--panel-soft);
  font-size: 11px;
  font-weight: 800;
}

.message.user .message-role {
  color: var(--accent);
}

.message-content {
  min-width: 0;
  padding: 16px;
  font-size: 13px;
  line-height: 1.75;
}

.message-content .text-block {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message-content pre {
  overflow: auto;
  margin: 12px 0;
  padding: 13px;
  border-radius: 8px;
  color: #e7f2f0;
  background: #18312f;
  font: 12px/1.6 Consolas, "Cascadia Code", monospace;
}

.missing-message {
  color: var(--muted);
  font-style: italic;
}

.turn-audit {
  display: flex;
  flex-wrap: wrap;
  gap: 13px;
  padding: 11px 15px;
  color: var(--muted);
  background: #fbfcfc;
  font-size: 10px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 0 22px 22px;
  color: var(--muted);
  font-size: 11px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  background: var(--panel-soft);
  font-size: 9px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover {
  background: #f8fbfa;
}

.table-title {
  max-width: 360px;
}

.table-title strong,
.table-title span {
  display: block;
}

.table-title span {
  overflow: hidden;
  margin-top: 3px;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 22px;
  border-bottom: 1px solid var(--line);
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.detail-section {
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
}

.detail-section:last-child {
  border-bottom: 0;
}

.record-list {
  display: grid;
  gap: 9px;
}

.record {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel-soft);
  font-size: 11px;
}

.record-content {
  margin-top: 8px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.document-preview {
  flex: 1;
  overflow: auto;
  min-height: 260px;
  padding: 26px;
  color: #263138;
  font-size: 13px;
  line-height: 1.78;
}

.document-preview .text-block {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.document-preview pre {
  overflow: auto;
  margin: 15px 0;
  padding: 15px;
  border-radius: 9px;
  color: #e7f2f0;
  background: #18312f;
  font: 12px/1.65 Consolas, "Cascadia Code", monospace;
}

.document-filename {
  max-width: 390px;
}

.code-file-path {
  max-width: 410px;
  font-family: Consolas, "Cascadia Code", monospace;
  overflow-wrap: anywhere;
}

.document-filename strong,
.document-filename span {
  display: block;
}

.document-filename span {
  overflow: hidden;
  margin-top: 4px;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.session-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--panel-soft);
}

.session-card code {
  display: block;
  overflow: hidden;
  margin-bottom: 9px;
  color: var(--accent-dark);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  color: var(--muted);
  font-size: 10px;
}

.session-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 13px;
}

.session-card .session-actions .button {
  margin-top: 0;
}

.definition-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px 18px;
  margin: 0;
  padding: 20px 22px;
  font-size: 12px;
}

.definition-list dt {
  color: var(--muted);
}

.definition-list dd {
  margin: 0;
  font-weight: 650;
  text-align: right;
}

.check-list {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 22px 42px;
  color: var(--muted);
  font-size: 12px;
}

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

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

.management-form label,
#context-form > label,
#memory-version-form > label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
}

.management-form input,
.management-form select,
.management-form textarea,
#context-form input,
#context-form select,
#memory-version-form input,
#memory-version-form textarea {
  width: 100%;
  min-height: 38px;
  padding: 9px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  font-weight: 400;
}

.management-form textarea,
#memory-version-form textarea {
  min-height: 92px;
  resize: vertical;
  line-height: 1.55;
}

.full-field {
  grid-column: 1 / -1;
}

.check-control {
  display: flex !important;
  align-items: center;
  grid-template-columns: auto 1fr;
}

.check-control input {
  width: auto;
  min-height: auto;
}

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

.workspace-list {
  display: grid;
  gap: 12px;
  padding: 18px 22px 22px;
}

.workspace-card {
  display: grid;
  grid-template-columns: minmax(180px, 0.7fr) minmax(260px, 1.3fr) auto;
  gap: 16px;
  align-items: start;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-soft);
}

.workspace-card h3,
.workspace-card p {
  margin-bottom: 4px;
}

.workspace-paths {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font: 11px/1.5 Consolas, "Cascadia Code", monospace;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 220px;
}

.row-actions .button {
  min-height: 32px;
  padding: 6px 10px;
  white-space: nowrap;
}

.path-cell {
  max-width: 320px;
  font-family: Consolas, "Cascadia Code", monospace;
  overflow-wrap: anywhere;
}

.context-dialog {
  width: min(860px, calc(100vw - 32px));
  max-width: none;
  max-height: 92vh;
  overflow: auto;
}

.settings-dialog {
  width: min(980px, calc(100vw - 32px));
}

.settings-dialog > .management-form {
  padding-top: 0;
}

.settings-dialog > .management-form > .dialog-header {
  margin: 0 -22px;
}

.settings-dialog h3 {
  margin: 0;
  padding-top: 4px;
}

.settings-section {
  display: grid;
  gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}

.settings-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.settings-editor {
  background: var(--panel-soft);
}

.qiniu-settings-panel {
  max-width: 980px;
}

.qiniu-header-status {
  display: grid;
  justify-items: end;
  gap: 7px;
}

.settings-source {
  color: var(--muted);
  font-size: 11px;
}

.qiniu-security-note,
.settings-result {
  margin: 18px 22px 0;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--muted);
  background: var(--panel-soft);
  font-size: 12px;
  line-height: 1.6;
}

.qiniu-security-note.success,
.settings-result.success {
  border-color: #b8ddd6;
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.qiniu-security-note.warning {
  border-color: #ead3a2;
  color: #7e520c;
  background: var(--amber-soft);
}

.qiniu-security-note.error,
.settings-result.error {
  border-color: #f0c9cd;
  color: #8c2d34;
  background: var(--red-soft);
}

.qiniu-settings-form {
  padding-top: 18px;
}

.credential-status {
  display: inline-flex;
  width: fit-content;
  margin: 0;
  padding: 2px 7px;
  border-radius: 999px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-size: 10px;
}

.qiniu-private-control {
  align-self: end;
  min-height: 38px;
  padding: 9px 0;
}

.qiniu-private-control span {
  margin: 0;
  color: var(--ink);
  font-size: 12px;
  letter-spacing: 0;
}

.qiniu-settings-form .settings-result {
  margin: 0;
}

.pending-upload-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-soft);
}

.pending-upload-card span,
.pending-upload-card strong,
.pending-upload-card small {
  display: block;
}

.pending-upload-card span {
  color: var(--muted);
  font-size: 11px;
}

.pending-upload-card strong {
  margin: 5px 0 3px;
  font-size: 20px;
}

.pending-upload-card small {
  color: var(--muted);
  font-size: 10px;
}

.qiniu-form-actions {
  gap: 10px;
}

.upload-confirm-dialog {
  width: min(620px, calc(100vw - 32px));
}

.account-create-dialog {
  width: min(760px, calc(100vw - 32px));
}

.role-editor-dialog,
.user-role-dialog {
  width: min(820px, calc(100vw - 32px));
}

.account-create-dialog .management-form,
.role-editor-dialog .management-form,
.user-role-dialog .management-form {
  padding: 0 22px 22px;
}

.account-create-dialog .dialog-header,
.role-editor-dialog .dialog-header,
.user-role-dialog .dialog-header {
  margin: 0 -22px;
}

.project-assignment-dialog,
.project-authorized-users-dialog {
  width: min(820px, calc(100vw - 32px));
}

.project-assignment-dialog .management-form,
.project-authorized-users-dialog .management-form {
  padding: 0 22px 22px;
}

.project-assignment-dialog .dialog-header,
.project-authorized-users-dialog .dialog-header {
  margin: 0 -22px;
}

.project-assignment-summary,
#project-authorized-users-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 9px;
  color: var(--muted);
  background: var(--panel-soft);
  font-size: 11px;
}

.project-assignment-summary strong,
#project-authorized-users-summary strong {
  color: var(--ink);
}

.project-assignment-picker {
  min-width: 0;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.project-assignment-picker legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.project-assignment-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  max-height: 340px;
  overflow: auto;
}

.project-assignment-option {
  display: flex !important;
  align-items: flex-start;
  grid-template-columns: none !important;
  gap: 10px !important;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--ink) !important;
  background: #fff;
  cursor: pointer;
}

.project-assignment-option.selected {
  border-color: #8fc7bd;
  background: var(--accent-soft);
}

.management-form .project-assignment-option input {
  width: auto;
  min-height: auto;
  margin-top: 3px;
}

.project-assignment-option span,
.project-assignment-option small {
  display: block;
}

.project-assignment-option small {
  margin-top: 3px;
  color: var(--muted);
  font: 10px/1.4 Consolas, "Cascadia Code", monospace;
}

#project-assignment-error {
  margin: 0;
}

#project-assignment-error strong {
  display: block;
}

#project-assignment-error ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

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

.authorized-user-item {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(240px, 1fr);
  gap: 14px;
  align-items: center;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel-soft);
}

.authorized-user-item > div {
  display: grid;
  gap: 4px;
}

.authorized-user-item > div:last-child {
  justify-items: end;
  color: var(--muted);
  font-size: 11px;
}

.authorized-user-item span,
.authorized-user-item small {
  color: var(--muted);
  font-size: 11px;
}

.project-scope-summary {
  min-width: 160px;
  line-height: 1.55;
}

.project-scope-empty {
  color: var(--muted);
  white-space: nowrap;
}

.upload-confirm-dialog .management-form {
  padding: 0 22px 22px;
}

.upload-confirm-dialog .dialog-header {
  margin: 0 -22px;
}

#context-form,
#memory-version-form {
  display: grid;
  gap: 15px;
  padding: 22px;
}

.memory-picker {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
}

.context-summary {
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--muted);
  background: var(--panel-soft);
  font-size: 11px;
  line-height: 1.6;
}

.context-summary strong {
  color: var(--ink);
}

#context-cross-project-warning {
  padding: 10px 12px;
  border: 1px solid #eacb8b;
  border-radius: 8px;
  color: #7e520c;
  background: var(--amber-soft);
}

#project-binding-confirm-control {
  padding: 10px 12px;
  border: 1px solid #eacb8b;
  border-radius: 8px;
  color: #7e520c;
  background: var(--amber-soft);
}

.memory-picker legend {
  padding: 0 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.check-list.compact {
  padding: 3px;
}

.check-list.compact label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.context-preview {
  max-height: 360px;
  overflow: auto;
  border-radius: 9px;
  background: #14201f;
}

.context-preview pre {
  margin: 0;
  padding: 16px;
  color: #d8e3e1;
  white-space: pre-wrap;
  word-break: break-word;
  font: 11px/1.6 Consolas, "Cascadia Code", monospace;
}

dialog {
  width: min(480px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 30px 90px rgba(11, 28, 31, 0.25);
}

dialog::backdrop {
  background: rgba(8, 25, 27, 0.48);
  backdrop-filter: blur(3px);
}

.document-dialog {
  width: min(960px, calc(100vw - 36px));
  max-width: none;
  max-height: 88vh;
  overflow: hidden;
}

.document-dialog-shell {
  display: flex;
  max-height: 88vh;
  flex-direction: column;
}

.document-dialog .detail-header {
  flex: 0 0 auto;
  background: #fff;
}

.document-dialog .document-preview {
  background: #fff;
}

.code-change-dialog {
  width: min(1120px, calc(100vw - 30px));
  max-width: none;
  max-height: 92vh;
  overflow: hidden;
}

.code-change-dialog-shell {
  display: flex;
  max-height: 92vh;
  flex-direction: column;
}

.code-change-tabs {
  display: flex;
  flex: 0 0 auto;
  gap: 4px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-soft);
}

.code-tab {
  padding: 8px 13px;
  border: 0;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  font-size: 11px;
  font-weight: 700;
}

.code-tab.active {
  color: #fff;
  background: var(--accent);
}

.code-change-content {
  flex: 1;
  overflow: auto;
  min-height: 340px;
  background: #14201f;
}

.code-change-content pre {
  min-width: max-content;
  margin: 0;
  padding: 18px 0;
  color: #d8e3e1;
  font: 12px/1.62 Consolas, "Cascadia Code", monospace;
}

.diff-line {
  display: block;
  min-height: 19px;
  padding: 0 20px;
  white-space: pre;
}

.diff-line.add {
  color: #b8efd2;
  background: rgba(39, 150, 94, 0.2);
}

.diff-line.delete {
  color: #ffc2c6;
  background: rgba(190, 59, 70, 0.2);
}

.diff-line.hunk {
  color: #add4ff;
  background: rgba(55, 105, 177, 0.18);
}

.diff-line.header {
  color: #e8c77a;
  font-weight: 700;
}

.code-empty {
  padding: 60px 24px;
  color: #9eb0ad;
  text-align: center;
}

#action-form {
  display: grid;
  gap: 16px;
  padding: 22px;
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.icon-button {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  color: var(--muted);
  background: var(--panel-soft);
  font-size: 20px;
}

#dialog-fields {
  display: grid;
  gap: 13px;
}

.dialog-help {
  margin: -7px 0 0;
  color: var(--muted);
  font-size: 10px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

@media (max-width: 1100px) {
  .metric-grid,
  .dashboard-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .panel.span-2 {
    grid-column: span 2;
  }

  .filters {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }

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

  .context-grid .span-2 {
    grid-column: span 1;
  }
}

@media (max-width: 760px) {
  .sidebar {
    position: static;
    width: auto;
    min-height: auto;
  }

  .brand {
    padding-bottom: 16px;
  }

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

  .nav-item small,
  .sidebar-footer {
    display: none;
  }

  .main {
    margin-left: 0;
    padding: 24px 16px 50px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .qiniu-header-status {
    justify-items: start;
  }

  .pending-upload-card {
    align-items: stretch;
    flex-direction: column;
  }

  .management-form {
    grid-template-columns: 1fr;
  }

  .project-assignment-options,
  .role-option-list,
  .permission-option-list,
  .authorized-user-item {
    grid-template-columns: 1fr;
  }

  .project-assignment-summary,
  #project-authorized-users-summary {
    align-items: flex-start;
    flex-direction: column;
  }

  .authorized-user-item > div:last-child {
    justify-items: start;
  }

  .full-field {
    grid-column: span 1;
  }

  .workspace-card {
    grid-template-columns: 1fr;
  }

  .metric-grid,
  .dashboard-grid,
  .session-grid,
  .filters,
  .document-filters {
    grid-template-columns: 1fr;
  }

  .code-change-filters {
    grid-template-columns: 1fr;
  }

  .panel.span-2,
  .filter-checks {
    grid-column: span 1;
  }

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

  .message-role {
    padding: 9px 14px;
  }
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 15%, rgba(63, 123, 255, 0.18), transparent 34%),
    rgba(8, 13, 24, 0.94);
  backdrop-filter: blur(12px);
}

.auth-gate.hidden {
  display: none;
}

.auth-card {
  width: min(460px, 100%);
  padding: 30px;
  border: 1px solid rgba(145, 171, 220, 0.24);
  border-radius: 22px;
  background: var(--panel);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
}

.auth-brand {
  padding: 0 0 24px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--line);
}

.auth-form {
  display: grid;
  gap: 16px;
}

.auth-form h1 {
  margin: 4px 0 8px;
  font-size: 25px;
}

.auth-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
}

.auth-error {
  padding: 11px 13px;
  border: 1px solid rgba(235, 91, 91, 0.34);
  border-radius: 10px;
  color: #ffb2b2;
  background: rgba(235, 91, 91, 0.1);
  font-size: 12px;
  line-height: 1.55;
}

.account-chip {
  max-width: 260px;
  overflow: hidden;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
}
