:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-2: #f3f4f7;
  --ink: #1c2430;
  --muted: #6b7585;
  --line: #e4e8ee;
  --line-strong: #cfd6e0;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-ink: #ffffff;
  --warn: #b45309;
  --danger: #b42318;
  --ok: #047857;
  --shadow-sm: 0 1px 2px rgba(28, 36, 48, 0.06), 0 1px 3px rgba(28, 36, 48, 0.08);
  --shadow: 0 10px 30px rgba(28, 36, 48, 0.14);
  --mono: "SFMono-Regular", "Menlo", "Consolas", monospace;
  font-family: -apple-system, "PingFang SC", "Avenir Next", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  min-width: 980px;
  -webkit-font-smoothing: antialiased;
}

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

button {
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
  height: 32px;
  padding: 0 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;
}

button:hover {
  border-color: var(--accent);
  background: #fafbff;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  box-shadow: var(--shadow-sm);
}

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

button.danger {
  color: var(--danger);
  border-color: rgba(180, 35, 24, 0.3);
}

button.danger:hover {
  border-color: var(--danger);
  background: rgba(180, 35, 24, 0.05);
}

button.ghost {
  background: transparent;
  border-color: transparent;
}

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

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  padding: 8px 10px;
  outline: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 420px;
  align-items: stretch;
}

.auth-brand {
  padding: 68px 72px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-right: 1px solid var(--line);
}

.brand-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0;
  box-shadow: var(--shadow-sm);
}

.auth-brand h1 {
  margin: 36px 0 16px;
  font-size: 52px;
  line-height: 1;
  letter-spacing: 0;
}

.auth-brand p {
  margin: 0;
  max-width: 720px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.7;
}

.auth-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  max-width: 760px;
}

.fact {
  border-top: 2px solid var(--accent);
  padding-top: 14px;
}

.fact strong {
  display: block;
  font-size: 22px;
}

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

.auth-panel {
  padding: 48px 36px;
  background: rgba(255, 255, 255, 0.84);
  display: flex;
  align-items: center;
}

.auth-card {
  width: 100%;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 20px;
}

.auth-tabs button.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

.hint {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.muted {
  color: var(--muted);
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  box-shadow: 0 1px 2px rgba(28, 36, 48, 0.04);
  position: relative;
  z-index: 5;
}

.topbar-left,
.topbar-right,
.toolbar,
.row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.wordmark {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.wordmark::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 3px;
  background: var(--accent);
}

.pill {
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 12px;
  background: #fff;
}

.env-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.env-badge.env-test {
  color: #9a3412;
  background: #ffedd5;
  border: 1px solid #fdba74;
}

.env-badge.env-prod {
  color: #166534;
  background: #dcfce7;
  border: 1px solid #86efac;
}

.auth-brand .env-badge {
  margin-top: 12px;
}

.workspace {
  display: grid;
  grid-template-columns: var(--project-pane, 270px) 7px var(--file-pane, 360px) 7px minmax(420px, 1fr);
  min-height: 0;
}

.workspace.projects-collapsed {
  --project-pane: 42px !important;
}

.workspace.files-collapsed {
  --file-pane: 42px !important;
}

.permission-empty {
  height: 100%;
  display: grid;
  place-items: center;
  text-align: center;
  background: rgba(255, 255, 255, 0.72);
}

.sidebar,
.files-panel,
.editor-panel,
.admin-panel {
  min-height: 0;
  border-right: 1px solid var(--line);
  background: #fcfcfd;
}

.sidebar {
  padding: 16px;
  overflow: auto;
}

.collapsed-pane {
  min-height: 0;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
  display: grid;
  place-items: start center;
  padding-top: 12px;
}

.collapsed-pane button {
  width: 30px;
  height: auto;
  min-height: 86px;
  padding: 8px 4px;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  background: #fff;
}

.splitter {
  position: relative;
  cursor: col-resize;
  background: rgba(255, 255, 255, 0.64);
  border-right: 1px solid var(--line);
  border-left: 1px solid rgba(255, 255, 255, 0.55);
}

.splitter::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 3px;
  height: 42px;
  border-radius: 999px;
  background: var(--line-strong);
  transform: translate(-50%, -50%);
}

.splitter:hover,
body.resizing .splitter {
  background: rgba(79, 70, 229, 0.08);
}

body.resizing {
  cursor: col-resize;
  user-select: none;
}

body.resizing iframe {
  pointer-events: none;
}

.files-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
}

.editor-panel {
  border-right: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
}

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

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

.project-list {
  display: grid;
  gap: 8px;
}

.project-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  width: 100%;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}

.project-row.active {
  border-color: rgba(79, 70, 229, 0.35);
  background: #eef0fe;
}

.project-row:hover {
  background: rgba(79, 70, 229, 0.05);
}

.project-open {
  display: block;
  width: 100%;
  height: auto;
  padding: 11px 0 11px 12px;
  border: 0;
  background: transparent;
  text-align: left;
}

.project-open strong {
  display: block;
}

.project-open small {
  color: var(--muted);
}

.project-menu-button {
  width: 28px;
  height: 28px;
  align-self: center;
  justify-self: center;
  border: 0;
  border-radius: 6px;
  padding: 0;
  color: var(--muted);
  background: transparent;
}

.project-row:hover .project-menu-button,
.project-menu-button:hover {
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
}

.project-menu {
  position: absolute;
  top: 38px;
  right: 8px;
  z-index: 9;
  width: 190px;
  display: grid;
  gap: 2px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: var(--shadow);
}

.project-menu button {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
  border: 0;
  background: transparent;
  border-radius: 5px;
}

.project-menu button:hover {
  background: #eef0f4;
}

.pathbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
}

.pathbar code {
  font-family: var(--mono);
  color: var(--muted);
  background: #eef0f4;
  padding: 4px 6px;
  border-radius: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-list {
  overflow: auto;
}

.tree-list {
  padding: 4px 0;
}

.tree-node {
  min-width: 0;
}

.file-list.drag-over {
  box-shadow: inset 0 0 0 2px rgba(79, 70, 229, 0.15);
}

.file-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 30px 34px;
  border: 0;
  border-radius: 8px;
  margin: 1px 6px;
  background: transparent;
  transition: background-color 0.12s ease;
}

.tree-row {
  grid-template-columns: 26px minmax(0, 1fr) 30px 34px;
  padding-left: var(--tree-indent, 0);
}

.tree-row.has-source {
  grid-template-columns: 26px minmax(0, 1fr) 28px 30px 34px;
}

.tree-row.with-check {
  grid-template-columns: 22px 24px minmax(0, 1fr) 30px 34px;
}

.tree-row.with-check.has-source {
  grid-template-columns: 22px 24px minmax(0, 1fr) 28px 30px 34px;
}

.file-row[draggable="true"] {
  cursor: grab;
}

.file-row.dragging {
  opacity: 0.52;
}

.file-row.drag-over {
  background: rgba(79, 70, 229, 0.12);
  box-shadow: inset 0 0 0 2px rgba(79, 70, 229, 0.28);
}

.file-row.active {
  background: #eef0fe;
}

.file-row:hover {
  background: #f1f2f6;
}

.file-row.active:hover {
  background: #e7eafd;
}

.file-open {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
  height: auto;
  padding: 9px 0 9px 12px;
  border: 0;
  border-radius: 0;
  background: transparent;
  text-align: left;
}

.file-open .row-icon {
  flex: 0 0 24px;
  text-align: center;
}

.file-open .dir-caret,
.file-open .file-meta {
  margin-left: auto;
}

.file-main {
  min-width: 0;
  flex: 0 1 auto;
  display: grid;
  gap: 4px;
}

.tree-toggle {
  width: 24px;
  height: 30px;
  align-self: center;
  justify-self: end;
  padding: 0;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
}

.tree-toggle:hover:not(:disabled) {
  background: #eef0f4;
  color: var(--ink);
}

.tree-toggle:disabled {
  opacity: 0.35;
}

.select-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--line);
  background: #eef0fe;
  color: var(--ink);
  font-size: 13px;
}

.select-bar-actions {
  display: inline-flex;
  gap: 6px;
}

.select-bar button {
  height: 28px;
  padding: 0 10px;
}

.row-check {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-left: 6px;
}

.row-check input {
  width: 15px;
  height: 15px;
  cursor: pointer;
  accent-color: #4f46e5;
  opacity: 0.35;
  transition: opacity 0.12s ease;
}

.file-row:hover .row-check input,
.row-check input:checked,
.row-check input:focus-visible {
  opacity: 1;
}

.file-row.checked {
  background: #eef0fe;
}

.group-row {
  grid-template-columns: minmax(0, 1fr) 30px;
  margin: 1px 10px;
  padding-left: var(--tree-indent, 0);
}

.group-row.has-source {
  grid-template-columns: minmax(0, 1fr) 28px 30px;
}

.group-row.with-check {
  grid-template-columns: 22px minmax(0, 1fr) 30px;
}

.group-row.with-check.has-source {
  grid-template-columns: 22px minmax(0, 1fr) 28px 30px;
}

.row-icon {
  font-size: 13px;
}

.dir-icon {
  font-size: 14px;
}

.file-row[data-entry-type="dir"] .file-name {
  font-weight: 600;
}

.dir-caret {
  align-self: center;
  padding-right: 6px;
  color: var(--muted);
  font-size: 11px;
  flex: 0 0 auto;
}

.file-open {
  cursor: pointer;
}

.source-link-button {
  align-self: center;
  justify-self: center;
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: #2563eb;
  background: transparent;
  text-decoration: none;
  font-size: 13px;
  line-height: 1;
  opacity: 0.72;
}

.source-link-button:hover {
  background: #eef0f4;
  opacity: 1;
}

.ku-link {
  color: #2563eb;
  text-decoration: none;
}

.ku-link:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.local-md {
  align-self: center;
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  font-size: 13px;
  line-height: 1;
  opacity: 0.55;
}

.local-md:hover {
  background: #eef0f4;
  opacity: 1;
}

.tag-group-list {
  padding: 8px 0 16px;
}

.tag-group {
  padding: 4px 0 8px;
}

.tag-group + .tag-group {
  border-top: 1px solid var(--line);
  margin-top: 6px;
  padding-top: 10px;
}

.tag-group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  font-size: 13px;
}

.tag-group-head .tag-dot {
  width: 10px;
  height: 10px;
}

.tag-group-count {
  margin-left: auto;
  min-width: 22px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  background: var(--panel-2);
  border-radius: 999px;
  padding: 1px 7px;
}

.tag-group-empty {
  padding: 4px 16px 8px;
  color: var(--muted);
  font-size: 12px;
}

.tree-empty {
  min-height: 34px;
  padding-left: calc(var(--tree-indent, 0px) + 28px);
  display: flex;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-tag {
  max-width: 72px;
  height: 19px;
  display: inline-flex;
  align-items: center;
  padding: 0 7px;
  border-radius: 999px;
  background: #eef0f4;
  background: color-mix(in srgb, var(--tag-color, #4f46e5) 10%, #fff);
  color: var(--tag-color, #4f46e5);
  border: 1px solid #dfe4ea;
  border: 1px solid color-mix(in srgb, var(--tag-color, #4f46e5) 25%, #fff);
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-tag.more {
  color: var(--muted);
  background: #eef0f4;
  border-color: #dfe4ea;
}

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

.file-tag-button,
.file-menu-button {
  width: 28px;
  height: 28px;
  align-self: center;
  justify-self: center;
  border: 0;
  border-radius: 6px;
  padding: 0;
  color: var(--muted);
  background: transparent;
}

.file-tag-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.file-tag-button.has-tags {
  background: #f8fafc;
  border: 1px solid #dfe4ea;
}

.tag-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--tag-color, #4f46e5);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.9);
}

.tag-icon-empty {
  width: 14px;
  height: 10px;
  border: 1.5px solid #9aa4b2;
  border-left-width: 4px;
  border-radius: 3px;
}

.file-row:hover .file-tag-button,
.file-tag-button:hover,
.file-row:hover .file-menu-button,
.file-menu-button:hover {
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
}

.file-menu {
  position: absolute;
  top: 34px;
  right: 8px;
  z-index: 8;
  width: 176px;
  display: grid;
  gap: 2px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.file-menu button {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
  border: 0;
  background: transparent;
  border-radius: 5px;
}

.file-menu button:hover {
  background: #eef0f4;
}

.file-menu button.danger {
  color: var(--danger);
}

.tag-config-list,
.tag-check-list {
  display: grid;
  gap: 14px;
}

.tag-config-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px 64px;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
}

.tag-config-row input[type="color"] {
  width: 38px;
  min-width: 38px;
  height: 34px;
  padding: 2px;
}

.tag-add-button {
  width: 100%;
  margin-top: 14px;
  border-style: dashed;
  color: var(--muted);
}

.tag-add-button:hover {
  color: var(--accent);
}

.tag-check-list {
  gap: 4px;
}

.tag-check {
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 10px;
  border-radius: 8px;
  cursor: pointer;
}

.tag-check:hover {
  background: var(--panel-2);
}

.tag-check input {
  width: 16px;
  height: 16px;
  flex: none;
}

.tag-check-hint {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
}

.batch-hint {
  margin-top: 12px;
}

.modebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
}

.mode-tabs {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel-2);
  padding: 3px;
}

.mode-tabs button {
  height: 28px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 500;
}

.mode-tabs button.active {
  background: #fff;
  color: var(--ink);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.mode-status {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.editor-body {
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  overflow: hidden;
  padding: 14px;
}

.editor-textarea {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.6;
  overflow: auto;
  resize: none;
  border-radius: 8px;
}

.empty {
  height: 100%;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
}

.preview-shell {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.preview-tools-left,
.preview-tools-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

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

.preview-toolbar button,
.preview-toolbar select {
  width: auto;
  height: 30px;
  padding: 0 9px;
}

.preview-toolbar select {
  min-width: 78px;
}

.preview-scroll {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.preview-canvas {
  --preview-zoom: 1;
  --preview-inverse: 100%;
  position: relative;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.preview-markdown .preview-canvas {
  width: 100%;
  min-width: 0;
  overflow: hidden;
}

.preview-stage {
  position: relative;
  width: var(--preview-inverse);
  height: var(--preview-inverse);
  transform: scale(var(--preview-zoom));
  transform-origin: top left;
  background: #fff;
  box-shadow: 0 1px 0 rgba(31, 41, 51, 0.06);
}

.preview-frame {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  background: #fff;
  overflow: auto;
}

.version-list,
.admin-list {
  overflow: auto;
  display: grid;
  gap: 10px;
}

.version-item,
.user-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.version-item strong,
.user-item strong {
  display: block;
}

.admin-console {
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-columns: 214px minmax(0, 1fr);
  background: #f3f5f7;
}

.admin-nav {
  min-height: 0;
  overflow: auto;
  border-right: 1px solid var(--line);
  background: #fcfcfd;
  padding: 14px 10px;
}

.admin-nav-title {
  display: grid;
  gap: 4px;
  padding: 2px 8px 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 10px;
}

.admin-nav-title span {
  color: var(--muted);
  font-size: 12px;
}

.admin-nav button {
  width: 100%;
  height: auto;
  min-height: 54px;
  display: grid;
  gap: 4px;
  justify-items: start;
  padding: 9px 10px;
  margin-bottom: 5px;
  border: 1px solid transparent;
  background: transparent;
  text-align: left;
}

.admin-nav button small {
  color: var(--muted);
  font-size: 12px;
}

.admin-nav button.active {
  border-color: rgba(79, 70, 229, 0.3);
  background: #eef0fe;
}

.admin-content {
  min-width: 0;
  overflow: auto;
  padding: 20px 22px 28px;
}

.admin-page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 22px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.admin-page-head h1 {
  margin: 0 0 5px;
  font-size: 22px;
  line-height: 1.2;
  letter-spacing: 0;
}

.admin-page-head p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
  max-width: 760px;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(3, 86px);
  gap: 8px;
  flex: 0 0 auto;
}

.admin-stats div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.admin-stats strong {
  display: block;
  font-size: 21px;
  line-height: 1;
}

.admin-stats span {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
}

.admin-toolbar-panel {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto auto auto;
  gap: 10px;
  align-items: end;
  margin: 16px 0 2px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.search-field label,
.storage-root-card span,
.storage-path-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.switch-row {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  padding: 0 10px;
  white-space: nowrap;
}

.switch-row input {
  width: auto;
}

.admin-section-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-end;
  padding: 18px 0 10px;
}

.admin-section-head h2 {
  margin: 0 0 5px;
  font-size: 17px;
}

.admin-section-head p {
  margin: 0;
  max-width: 860px;
}

.table-count,
.pager span {
  color: var(--muted);
  font-size: 13px;
}

.pager {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.member-table,
.request-table,
.storage-projects {
  display: grid;
  gap: 8px;
}

.member-row,
.request-row,
.storage-project-row {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.member-row-compact {
  display: grid;
  grid-template-columns: minmax(170px, 1.05fr) 150px minmax(145px, 0.8fr) minmax(145px, 0.8fr) auto;
  gap: 12px;
  align-items: center;
  padding: 11px 12px;
}

.request-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 110px auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
}

.member-person,
.member-actions,
.permission-summary,
.invite-summary {
  min-width: 0;
}

.member-person strong {
  display: block;
  font-size: 14px;
  line-height: 1.25;
}

.member-person code,
.role-chip,
.storage-project-row code,
.storage-root-card code,
.storage-path-grid code,
.invite-meta code {
  display: inline-block;
  max-width: 100%;
  margin-top: 5px;
  font-family: var(--mono);
  color: var(--muted);
  background: #eef0f4;
  border-radius: 4px;
  padding: 3px 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: top;
}

.role-chip {
  margin-top: 0;
  margin-left: 6px;
  font-family: inherit;
  font-size: 12px;
  color: var(--ink);
}

.member-person p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.permission-summary,
.invite-summary {
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.member-actions,
.invite-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
  min-width: 0;
}

.permission-editor {
  display: grid;
  gap: 10px;
}

.permission-editor.compact {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 4px 0 14px;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 9px;
  font-size: 13px;
  color: var(--ink);
  background: var(--panel-2);
  white-space: nowrap;
}

.check input {
  width: auto;
}

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

.new-user-grid .wide {
  grid-column: 1 / -1;
}

.invite-modal-body {
  display: grid;
  gap: 10px;
}

.copy-textarea {
  min-height: 220px;
  width: 100%;
  resize: vertical;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.invite-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.storage-map {
  display: grid;
  grid-template-columns: minmax(260px, 0.7fr) minmax(0, 1.3fr);
  gap: 12px;
  margin-top: 16px;
}

.storage-root-card,
.storage-path-grid > div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 13px 14px;
}

.storage-root-card p {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

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

.storage-numbers,
.storage-project-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.storage-numbers span,
.storage-project-meta span {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  padding: 7px 9px;
  white-space: nowrap;
}

.storage-numbers strong {
  margin-right: 4px;
}

.storage-project-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 12px 14px;
}

.storage-project-row strong {
  display: inline-block;
  margin-right: 8px;
}

.storage-project-row p {
  margin: 7px 0 0;
  overflow-wrap: anywhere;
}

.compact-empty {
  min-height: 86px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  background: #eef0f4;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 700;
}

.sync-arch-hint {
  margin: 0 0 14px;
}

.admin-project-row {
  grid-template-columns: minmax(0, 1fr) auto auto;
}

.sync-source-table {
  display: grid;
  gap: 10px;
}

.sync-source-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 16px;
  align-items: center;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.sync-source-row.sync-disabled {
  opacity: 0.55;
}

.sync-source-main {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.sync-source-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.sync-source-url {
  font-size: 12px;
  color: var(--muted, #6b7280);
  overflow-wrap: anywhere;
  text-decoration: none;
}

.sync-source-url:hover {
  text-decoration: underline;
}

.sync-source-meta {
  display: grid;
  gap: 4px;
  justify-items: end;
  font-size: 12px;
  color: var(--muted, #6b7280);
  white-space: nowrap;
}

.sync-status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 1px 8px;
  font-weight: 700;
}

.sync-status.sync-ok {
  background: #e8f6ee;
  color: #15803d;
}

.sync-status.sync-error {
  background: #fdeaea;
  color: #b91c1c;
}

.sync-status.sync-none {
  background: #eef0f4;
  color: #4b5563;
}

.sync-tag-chip {
  font-size: 12px;
  background: #eef2ff;
  color: #4338ca;
}

.sync-chain-badge {
  font-size: 11px;
  line-height: 1;
  padding: 2px 7px;
  border-radius: 999px;
  background: #eef2ff;
  color: #4338ca;
  font-weight: 600;
}

.hint-inline {
  font-size: 12px;
  color: var(--muted, #6b7280);
}

.sync-run-list {
  display: grid;
  gap: 6px;
  max-height: 50vh;
  overflow: auto;
}

.sync-run-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12px;
}

.sync-run-time {
  color: var(--muted, #6b7280);
  white-space: nowrap;
}

.sync-run-runner {
  color: #4338ca;
  white-space: nowrap;
}

.sync-run-detail {
  color: var(--ink, #1f2937);
  min-width: 0;
  overflow-wrap: anywhere;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(28, 36, 48, 0.4);
  backdrop-filter: blur(2px);
  display: grid;
  place-items: center;
  z-index: 10;
}

.modal {
  width: min(720px, calc(100vw - 40px));
  max-height: calc(100vh - 40px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: #fff;
  border-radius: 14px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}

.modal.modal-sm {
  width: min(480px, calc(100vw - 40px));
}

.modal-head,
.modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.modal-foot {
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.modal-body {
  padding: 16px;
  overflow: auto;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  background: var(--ink);
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  font-size: 13px;
  z-index: 20;
}

.status-pending {
  color: var(--warn);
}

.status-approved {
  color: var(--ok);
}

.status-disabled,
.status-rejected {
  color: var(--danger);
}

@media (max-width: 900px) {
  body {
    min-width: 0;
  }

  .auth-shell,
  .workspace {
    display: block;
    height: auto;
  }

  .auth-brand {
    padding: 36px 24px;
  }

  .auth-panel {
    padding: 24px;
  }

  .app-shell {
    height: auto;
  }

  .sidebar,
  .files-panel,
  .editor-panel,
  .splitter {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .splitter {
    display: none;
  }

  .editor-body {
    height: 560px;
  }

  .preview-toolbar {
    align-items: flex-start;
    display: grid;
  }

  .preview-tools-left,
  .preview-tools-right {
    flex-wrap: wrap;
  }

  .modebar {
    align-items: flex-start;
    display: grid;
  }

  .mode-status {
    white-space: normal;
  }

  .admin-console,
  .admin-page-head,
  .admin-section-head,
  .storage-panel,
  .storage-project-row,
  .agent-invite,
  .agent-invite-main {
    display: block;
  }

  .admin-stats,
  .member-main {
    grid-template-columns: 1fr;
  }

  .admin-content {
    padding: 18px;
  }

  .admin-nav {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .member-role,
  .member-permissions,
  .member-actions,
  .agent-invite-actions,
  .storage-numbers,
  .storage-project-meta {
    margin-top: 12px;
  }
}
