:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --line: #dde5f0;
  --text: #162033;
  --muted: #657189;
  --accent: #1d67d3;
  --danger: #c23737;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: radial-gradient(circle at 10% 0%, #edf4ff, #f7f9fc 45%, #eef2f8 100%);
  color: var(--text);
  font-family: "IBM Plex Sans", "PingFang SC", "Noto Sans SC", sans-serif;
}

.topbar {
  border-bottom: 1px solid var(--line);
  background: linear-gradient(120deg, #ffffff, #f3f7ff);
  padding: 14px 18px;
}

.topbar-main {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}

.topbar-sub {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 14px;
}

.topbar h1 {
  margin: 0;
  font-size: 1.25rem;
}

.topbar p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap;
}

.topbar-ad {
  flex: 0 0 auto;
  display: block;
  grid-column: 3;
  justify-self: center;
  width: 380px;
  max-width: 56vw;
}

.topbar-ad img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 8px 18px rgba(19, 40, 80, 0.12);
}

.admin-entry {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid rgba(29, 103, 211, 0.18);
  background: rgba(29, 103, 211, 0.08);
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
  white-space: nowrap;
}

.layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 16px;
  padding: 16px;
  min-height: calc(100vh - 84px);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  overflow: auto;
}

.panel section {
  margin-bottom: 18px;
}

.editor-shell.is-locked #editorControls {
  opacity: 0.4;
  pointer-events: none;
  user-select: none;
}

h2 {
  margin: 0 0 8px;
  font-size: 1rem;
}

label,
.hint,
li,
.workspace-meta {
  font-size: 0.86rem;
}

label {
  display: block;
  margin: 10px 0 5px;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="datetime-local"],
select,
textarea,
input[type="file"],
button {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  background: #fff;
  color: var(--text);
}

textarea {
  min-height: 108px;
  resize: vertical;
  font: inherit;
}

button {
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease;
  font-weight: 600;
}

button:hover {
  background: #f0f5ff;
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  background: #f6f8fc;
  border-color: #d6deea;
  color: #8a96ab;
  cursor: not-allowed;
}

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

.primary:hover {
  background: #155cc4;
}

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

.tool-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.hidden-input {
  display: none;
}

.undo-btn {
  margin-top: 8px;
}

.tool-btn.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(29, 103, 211, 0.14);
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.stack-form {
  display: grid;
  gap: 10px;
}

.checkline {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.checkline-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.checkline-row .checkline {
  margin-top: 0;
}

.checkline input[type="checkbox"] {
  width: auto;
  margin: 0;
}

.auth-card,
.admin-card {
  border: 1px solid rgba(29, 103, 211, 0.12);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(239, 245, 255, 0.9));
  box-shadow: 0 14px 32px rgba(17, 29, 52, 0.08);
  padding: 14px;
}

.session-banner,
.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.session-text {
  margin: 8px 0 0;
  color: var(--muted);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.status-pill.success {
  background: rgba(29, 124, 58, 0.12);
  color: #1d7c3a;
}

.status-pill.warn {
  background: rgba(173, 107, 0, 0.12);
  color: #ad6b00;
}

.status-pill.danger {
  background: rgba(194, 55, 55, 0.12);
  color: #c23737;
}

.hidden {
  display: none !important;
}

ul {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--muted);
}

.workspace-wrap {
  min-width: 0;
}

.lock-notice {
  display: none;
  margin-bottom: 12px;
  border: 1px solid rgba(194, 55, 55, 0.14);
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(255, 246, 246, 0.96), rgba(255, 236, 230, 0.96));
  padding: 14px 16px;
  box-shadow: 0 14px 28px rgba(146, 32, 32, 0.08);
}

.lock-notice h2 {
  margin-bottom: 6px;
}

.lock-notice p {
  margin: 0;
  color: #7a3f3f;
}

.editor-shell.is-locked .lock-notice {
  display: block;
}

.workspace-meta {
  color: var(--muted);
  margin-bottom: 8px;
}

.workspace-meta.dpi-ok {
  color: #1d7c3a;
  font-weight: 600;
}

.workspace-meta.dpi-warn {
  color: #ad6b00;
  font-weight: 600;
}

.workspace-meta.dpi-bad {
  color: #c23737;
  font-weight: 600;
}

.workspace {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(45deg, #ffffff 25%, #f2f6fc 25%, #f2f6fc 50%, #ffffff 50%, #ffffff 75%, #f2f6fc 75%, #f2f6fc);
  background-size: 18px 18px;
  padding: 10px;
  height: calc(100vh - 146px);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
}

.editor-shell.is-locked .workspace {
  pointer-events: none;
  filter: grayscale(0.12) saturate(0.9);
}

.workspace-copyright {
  margin: 10px 0 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: #000;
  font-size: 1rem;
  font-family: "SimHei", "Heiti SC", "Microsoft YaHei", sans-serif;
  font-weight: 700;
  line-height: 1.5;
  text-align: center;
}

#editorCanvas {
  display: block;
  max-width: 100%;
  border-radius: 8px;
  box-shadow: 0 18px 40px rgba(17, 29, 52, 0.16);
  background: #fff;
}

.empty-state {
  position: absolute;
  color: var(--muted);
  font-weight: 600;
  pointer-events: none;
}

.inline-text-editor {
  position: absolute;
  min-width: 140px;
  max-width: 360px;
  width: 220px;
  z-index: 10;
  border: 2px solid #1d67d3;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 12px 24px rgba(19, 40, 80, 0.18);
  padding: 6px 8px;
  outline: none;
}

.admin-layout {
  display: grid;
  gap: 16px;
  padding: 16px;
  min-height: calc(100vh - 84px);
}

.admin-shell.admin-locked .protected-admin {
  opacity: 0.45;
  pointer-events: none;
  user-select: none;
}

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

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

th,
td {
  padding: 10px 8px;
  border-bottom: 1px solid rgba(221, 229, 240, 0.9);
  font-size: 0.86rem;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-weight: 700;
}

.table-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.text-btn {
  width: auto;
  padding: 6px 10px;
}

.flash {
  margin: 10px 0 0;
  min-height: 20px;
  color: var(--muted);
  white-space: pre-wrap;
}

.flash.error {
  color: var(--danger);
}

.flash.success {
  color: #1d7c3a;
}

.mono {
  font-family: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
}

@media (max-width: 1100px) {
  .topbar-main {
    align-items: flex-start;
    gap: 10px;
  }

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

  .topbar p {
    white-space: normal;
  }

  .topbar-ad {
    margin-left: 0;
    width: 100%;
    max-width: 560px;
  }

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

  .workspace {
    height: 62vh;
  }
}

@media (max-width: 720px) {
  .row,
  .grid-2,
  .checkline-row {
    grid-template-columns: 1fr;
  }

  .session-banner,
  .section-heading {
    flex-direction: column;
  }

  .topbar-ad {
    max-width: 100%;
  }
}
