:root {
  color-scheme: light;
  --ink: #111318;
  --muted: #687083;
  --line: #dfe3e8;
  --panel: #ffffff;
  --canvas: #eef2f7;
  --deep-blue: #0a1f5c;
  --smart-blue: #1677ff;
  --soft-blue: #e6f1ff;
  --success: #16a34a;
  --warning: #ef4444;
  --nav-height: 64px;
  font-family: Inter, "Noto Sans CJK SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
}

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

button {
  cursor: pointer;
}

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

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(22, 119, 255, 0.22);
  outline-offset: 1px;
}

.login-page {
  min-height: 100svh;
  background: #f5f8fc;
}

.login-shell {
  display: flex;
  align-items: stretch;
  justify-content: center;
  flex-direction: column;
  width: min(calc(100% - 40px), 380px);
  min-height: 100svh;
  margin-inline: auto;
  padding-block: 64px;
  text-align: center;
}

.login-brand img {
  display: block;
  width: 52px;
  height: 52px;
  margin-inline: auto;
}

.login-product {
  margin: 18px 0 8px;
  color: var(--deep-blue);
  font-size: 13px;
  font-weight: 700;
}

.login-shell h1 {
  margin: 0;
  color: var(--deep-blue);
  font-size: 32px;
  line-height: 1.2;
}

.login-lead {
  margin: 14px auto 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.login-form {
  display: grid;
  margin-top: 34px;
  gap: 8px;
  text-align: left;
}

.login-form label {
  margin-top: 7px;
  color: var(--deep-blue);
  font-size: 13px;
  font-weight: 650;
}

.login-form input {
  width: 100%;
  min-height: 50px;
  padding: 0 14px;
  border: 1px solid #cbd1da;
  border-radius: 7px;
  background: #ffffff;
  font-size: 16px;
}

.login-form input:focus {
  border-color: var(--smart-blue);
}

.login-error {
  min-height: 22px;
  margin: 6px 0 0;
  color: var(--warning);
  font-size: 12px;
  line-height: 1.6;
}

.login-submit {
  min-height: 50px;
  margin-top: 2px;
  border: 1px solid var(--smart-blue);
  border-radius: 7px;
  background: var(--smart-blue);
  color: #ffffff;
  font-size: 15px;
  font-weight: 700;
}

.login-submit:hover {
  border-color: #0868e3;
  background: #0868e3;
}

.login-boundary {
  margin: 30px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(260px, 1fr);
  align-items: center;
  min-height: var(--nav-height);
  padding: 8px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.97);
}

.brand-block,
.draft-status,
.topbar-actions,
.panel-toolbar,
.preview-toolbar,
.viewport-controls,
.canvas-mode,
.format-toolbar,
.editor-actions,
.editor-stats {
  display: flex;
  align-items: center;
}

.brand-block {
  gap: 10px;
}

.brand-mark {
  display: block;
  width: 30px;
  height: 30px;
  object-fit: contain;
}

.brand-block div {
  display: grid;
  gap: 2px;
}

.brand-block strong {
  font-size: 14px;
}

.brand-block span:last-child {
  color: var(--muted);
  font-size: 11px;
}

.draft-status {
  gap: 8px;
  padding: 7px 12px;
  border: 1px solid #b7d4ff;
  border-radius: 6px;
  background: #f5f9ff;
  color: var(--deep-blue);
  font-size: 12px;
  font-weight: 650;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--smart-blue);
}

.topbar-actions {
  justify-content: flex-end;
  gap: 12px;
}

.logout-form {
  margin: 0;
}

.topbar-actions > span {
  max-width: 220px;
  overflow: hidden;
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace {
  display: grid;
  grid-template-columns: 286px minmax(420px, 1fr) 380px;
  min-height: calc(100vh - var(--nav-height));
}

.sidebar,
.preview-panel,
.editor-panel {
  min-width: 0;
  background: var(--panel);
}

.sidebar {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
}

.sidebar-head,
.sidebar-section,
.sidebar-foot,
.panel-toolbar,
.preview-address,
.editor-body,
.empty-editor,
.review-note {
  padding: 16px;
}

.sidebar-head {
  border-bottom: 1px solid var(--line);
}

.sidebar-head label,
.section-label,
.panel-kicker {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0;
  text-transform: uppercase;
}

.sidebar-head input {
  width: 100%;
  height: 40px;
  padding: 0 11px;
  border: 1px solid #cbd1da;
  border-radius: 5px;
  background: white;
  font-size: 13px;
}

.sidebar-section {
  border-bottom: 1px solid var(--line);
}

.sidebar-section--scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.page-list,
.section-list,
.field-list {
  display: grid;
  gap: 3px;
}

.page-list button,
.section-list button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 34px;
  padding: 7px 9px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #3c4350;
  font-size: 12px;
  text-align: left;
}

.page-list button:hover,
.section-list button:hover,
.field-item:hover {
  background: #f4f6f8;
}

.page-list button.is-active,
.section-list button.is-active {
  background: var(--soft-blue);
  color: var(--deep-blue);
  font-weight: 700;
}

.page-list small,
.section-list small {
  color: var(--muted);
  font-size: 10px;
}

.field-heading {
  margin-top: 18px;
}

.field-item {
  display: grid;
  width: 100%;
  padding: 10px 9px;
  overflow: hidden;
  border: 0;
  border-left: 3px solid transparent;
  border-radius: 0 4px 4px 0;
  background: transparent;
  gap: 3px;
  text-align: left;
}

.field-item.is-active {
  border-left-color: var(--smart-blue);
  background: #edf5ff;
}

.field-item-meta,
.field-item-preview {
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.field-item strong {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.field-list-empty {
  margin: 8px 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.sidebar-foot {
  display: grid;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
  gap: 4px;
}

.preview-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--canvas);
}

.panel-toolbar {
  justify-content: space-between;
  min-height: 64px;
  border-bottom: 1px solid var(--line);
  background: white;
  gap: 12px;
}

.panel-toolbar > div:first-child {
  display: grid;
}

.panel-toolbar .panel-kicker {
  margin-bottom: 2px;
}

.panel-toolbar strong {
  font-size: 14px;
}

.preview-toolbar {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) auto auto auto;
}

.preview-toolbar small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 500;
}

.canvas-mode,
.viewport-controls {
  overflow: hidden;
  border: 1px solid #cbd1da;
  border-radius: 5px;
}

.canvas-mode button,
.viewport-controls button {
  min-height: 32px;
  padding: 0 10px;
  border: 0;
  border-right: 1px solid #cbd1da;
  background: white;
  font-size: 11px;
}

.canvas-mode button:last-child,
.viewport-controls button:last-child {
  border-right: 0;
}

.canvas-mode button.is-active,
.viewport-controls button.is-active {
  background: var(--deep-blue);
  color: white;
}

.canvas-mode button.is-active {
  background: var(--smart-blue);
}

.quiet-button,
.primary-button,
.publish-button,
.format-toolbar button {
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid #cbd1da;
  border-radius: 5px;
  background: white;
  font-size: 11px;
  font-weight: 650;
}

.quiet-link {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding-inline: 10px;
  border-radius: 5px;
  color: var(--deep-blue);
  font-size: 11px;
  font-weight: 650;
  text-decoration: none;
}

.quiet-link:hover {
  background: #f4f6f8;
}

.quiet-button:hover,
.format-toolbar button:hover {
  border-color: #9ca7b8;
  background: #f7f8fa;
}

.primary-button {
  border-color: var(--smart-blue);
  background: var(--smart-blue);
  color: white;
}

.primary-button:hover {
  background: #0868e3;
}

.publish-button {
  border-color: var(--success);
  background: var(--success);
  color: #fff;
}

.publish-button:hover {
  border-color: #12813d;
  background: #12813d;
}

.publish-button[data-state="publishing"] {
  border-color: var(--smart-blue);
  background: var(--smart-blue);
}

.preview-address {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-block: 8px;
  border-bottom: 1px solid var(--line);
  background: #f9fafb;
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 10px;
}

#canvas-state {
  color: var(--deep-blue);
  font-family: Inter, "Noto Sans CJK SC", "PingFang SC", sans-serif;
  font-weight: 700;
}

#canvas-state[data-tone="warning"] {
  color: #a15c00;
}

#canvas-state[data-tone="success"] {
  color: var(--success);
}

.preview-scroll {
  flex: 1;
  min-height: 620px;
  padding: 20px;
  overflow: auto;
}

.preview-scroll iframe {
  display: block;
  height: calc(100vh - 166px);
  min-height: 620px;
  margin-inline: auto;
  border: 1px solid #c8ced8;
  background: white;
  box-shadow: 0 8px 24px rgba(10, 31, 92, 0.1);
}

.editor-panel {
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--line);
}

.dirty-state {
  padding: 4px 7px;
  border-radius: 4px;
  background: #f0f2f5;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.dirty-state.is-dirty {
  background: #fff1f0;
  color: #b42318;
}

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

.empty-editor strong {
  color: var(--ink);
  font-size: 16px;
}

.empty-editor p {
  margin: 8px 0 0;
  font-size: 13px;
  line-height: 1.7;
}

.editor-body {
  flex: 1;
  overflow-y: auto;
}

.field-meta {
  display: grid;
  margin-bottom: 14px;
  gap: 5px;
}

.field-meta label {
  font-size: 14px;
  font-weight: 750;
}

.field-meta code {
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 10px;
}

.format-toolbar {
  flex-wrap: wrap;
  margin-bottom: 10px;
  gap: 6px;
}

.format-toolbar button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.frame-editor {
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid #b7d4ff;
  border-radius: 6px;
  background: #f7fbff;
}

.frame-editor-heading,
.frame-controls,
.review-note {
  display: flex;
  align-items: center;
}

.frame-editor-heading {
  justify-content: space-between;
  gap: 12px;
}

.frame-editor-heading > div {
  display: grid;
  gap: 2px;
}

.frame-editor-heading strong {
  color: var(--deep-blue);
  font-size: 12px;
}

.frame-editor-heading small,
.frame-editor > p {
  color: var(--muted);
  font-size: 10px;
}

.frame-controls {
  margin-top: 10px;
  gap: 10px;
}

.frame-controls label {
  display: grid;
  grid-template-columns: auto minmax(68px, 1fr) auto;
  align-items: center;
  min-width: 0;
  gap: 6px;
  color: var(--deep-blue);
  font-size: 11px;
  font-weight: 650;
}

.frame-controls input {
  width: 88px;
  height: 34px;
  padding-inline: 8px;
  border: 1px solid #bfc6d1;
  border-radius: 5px;
  background: #fff;
  font-variant-numeric: tabular-nums;
}

.frame-controls small {
  color: var(--muted);
  font-size: 9px;
}

.frame-editor > p {
  margin: 9px 0 0;
  line-height: 1.55;
}

.swatch {
  width: 9px;
  height: 9px;
  border-radius: 2px;
  background: currentColor;
}

.swatch--smart {
  color: var(--smart-blue);
}

.swatch--deep {
  color: var(--deep-blue);
}

.swatch--success {
  color: var(--success);
}

.swatch--warning {
  color: var(--warning);
}

#field-editor {
  width: 100%;
  min-height: 360px;
  padding: 14px;
  resize: vertical;
  border: 1px solid #bfc6d1;
  border-radius: 5px;
  background: #fff;
  font-family: "Noto Sans CJK SC", "PingFang SC", sans-serif;
  font-size: 15px;
  line-height: 1.75;
}

.editor-stats {
  justify-content: space-between;
  margin-top: 6px;
  color: var(--muted);
  font-size: 10px;
}

.editor-help {
  margin: 12px 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.65;
}

.editor-actions {
  justify-content: space-between;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  gap: 10px;
}

.save-message {
  min-height: 42px;
  padding-top: 10px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.save-message[data-tone="success"] {
  color: var(--success);
}

.save-message[data-tone="warning"] {
  color: #a15c00;
}

.save-message[data-tone="error"] {
  color: var(--warning);
}

.review-note {
  justify-content: space-between;
  border-top: 1px solid var(--line);
  background: #f8fafc;
  gap: 12px;
}

.review-note > div {
  min-width: 0;
}

.review-note strong {
  color: var(--deep-blue);
  font-size: 12px;
}

.review-note p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.55;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 250px minmax(380px, 1fr) 340px;
  }

  .draft-status {
    max-width: 330px;
  }

  .topbar-actions > span {
    display: none;
  }

  .preview-toolbar {
    grid-template-columns: minmax(120px, 1fr) auto auto;
  }

  .preview-toolbar > .quiet-button {
    display: none;
  }
}

@media (max-width: 920px) {
  .topbar {
    grid-template-columns: 1fr auto;
  }

  .draft-status {
    grid-column: 1 / -1;
    grid-row: 2;
    max-width: none;
    margin-top: 6px;
  }

  .workspace {
    grid-template-columns: minmax(220px, 0.7fr) minmax(340px, 1.3fr);
    grid-template-areas:
      "sidebar editor"
      "preview preview";
  }

  .sidebar {
    grid-area: sidebar;
  }

  .editor-panel {
    grid-area: editor;
  }

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

  .sidebar-section--scroll {
    max-height: 480px;
  }

  .preview-panel {
    grid-area: preview;
    min-height: 760px;
  }

  .preview-scroll iframe {
    height: 640px;
  }

  .editor-panel {
    min-height: 720px;
  }
}

@media (max-width: 600px) {
  :root {
    --nav-height: 58px;
  }

  .topbar {
    padding: 8px 12px;
  }

  .login-shell {
    width: min(calc(100% - 40px), 360px);
    padding-block: 44px;
  }

  .login-brand img {
    width: 44px;
    height: 44px;
  }

  .login-shell h1 {
    font-size: 28px;
  }

  .workspace {
    grid-template-columns: 1fr;
    grid-template-areas:
      "sidebar"
      "editor"
      "preview";
  }

  .topbar-actions .quiet-button {
    padding-inline: 8px;
  }

  .topbar-actions {
    gap: 4px;
  }

  .topbar-actions .quiet-link,
  .topbar-actions #reload-content {
    display: none;
  }

  .publish-button {
    min-height: 42px;
  }

  .draft-status {
    align-items: flex-start;
    font-size: 11px;
  }

  .sidebar-head,
  .sidebar-section,
  .sidebar-foot,
  .panel-toolbar,
  .preview-address,
  .editor-body,
  .empty-editor,
  .review-note {
    padding-inline: 12px;
  }

  .preview-toolbar {
    grid-template-columns: 1fr auto;
  }

  .canvas-mode,
  .viewport-controls {
    grid-column: 1 / -1;
    display: grid;
  }

  .canvas-mode {
    grid-row: 2;
    grid-template-columns: repeat(2, 1fr);
  }

  .viewport-controls {
    grid-row: 3;
    grid-template-columns: repeat(3, 1fr);
  }

  .preview-scroll {
    padding: 10px 0;
  }

  .preview-scroll iframe {
    margin-left: 0;
  }

  .editor-actions {
    align-items: stretch;
    flex-direction: column-reverse;
  }

  .editor-actions button {
    width: 100%;
    min-height: 42px;
  }

  .frame-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .frame-controls label {
    grid-template-columns: 1fr 88px auto;
  }

  .review-note {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
