/* Base typography and shared controls */
:root {
  font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
  color: #263349;
  font-size: 14px;
  --blue: #2b59e8;
  --line: #e2e7ee;
  --muted: #8791a0;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: #f5f7fa;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
button,
input,
select,
textarea {
  font: inherit;
}
button {
  cursor: pointer;
  background: #fff;
  color: inherit;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 10px;
}
button:hover {
  background: #f1f5ff;
  border-color: #c5d3f5;
}
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 2px solid #799afa;
  outline-offset: 2px;
}
input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: inherit;
  padding: 8px 10px;
  min-width: 0;
}
textarea {
  width: 100%;
  resize: vertical;
  line-height: 1.6;
}
h1,
h2 {
  margin: 0;
}
h1 {
  font-size: 21px;
  letter-spacing: -0.4px;
}
h1 span {
  font-size: 14px;
  font-weight: 400;
  color: var(--muted);
  margin-left: 10px;
  letter-spacing: 0;
}
h2 {
  font-size: 16px;
  font-weight: 600;
}
/* Header and formatting toolbar */
.header {
  height: 70px;
  background: white;
  border-bottom: 1px solid var(--line);
  padding: 0 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  gap: 12px;
}
.header > div {
  display: flex;
  align-items: center;
  gap: 16px;
}
#save-state {
  font-size: 12px;
  color: var(--muted);
}
#save-state.error {
  color: #bd4242;
}
.primary {
  background: var(--blue);
  color: white;
  border-color: var(--blue);
  padding: 8px 14px;
}
.primary:hover {
  background: #244dcd;
  color: white;
  border-color: #244dcd;
}
.toolbar {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 10px 22px;
  flex-wrap: wrap;
  flex-shrink: 0;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.toolbar button {
  border-color: transparent;
  padding: 5px 9px;
  min-width: 29px;
}
#editing-label {
  font-size: 12px;
  color: var(--muted);
  min-width: 125px;
  max-width: 170px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.divider {
  height: 19px;
  width: 1px;
  background: var(--line);
  margin: 0 4px;
}
.color-select {
  padding: 5px 7px;
  max-width: 110px;
  cursor: pointer;
  border-color: transparent;
  background: #fff;
}
.color-select:hover {
  background: #f1f5ff;
  border-color: #c5d3f5;
}
#selection-count {
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
}
/* Workspace panels and competitor source */
.workspace {
  display: grid;
  grid-template-columns: 1.05fr 0.85fr 1.1fr;
  gap: 14px;
  margin: 16px 22px 18px;
  flex: 1;
  min-height: 0;
  position: relative;
}
.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 9px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.panel-heading {
  height: 58px;
  min-height: 58px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.panel-heading button {
  padding: 6px 9px;
}
.source-picker {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 12px 16px 4px;
  flex-shrink: 0;
}
.source-buttons {
  display: flex;
  flex: 1;
  min-width: 0;
  flex-wrap: wrap;
  gap: 6px;
}
.source-button {
  padding: 6px 9px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: var(--source-bg);
  color: var(--source-color);
  border-color: var(--source-border);
  opacity: 0.8;
}
.source-button.active {
  color: var(--source-color);
  background: var(--source-bg);
  border-color: var(--source-color);
  opacity: 1;
  box-shadow: inset 0 -2px var(--source-color);
}
.quiet {
  border-color: transparent;
  background: transparent;
  color: #929aa7;
  padding: 3px 7px;
  font-size: 18px;
}
.quiet:hover {
  color: #a44949;
  background: #fff2f2;
}
.source-name {
  border-color: transparent;
  margin: 4px 16px;
  padding: 5px 0;
  width: calc(100% - 32px);
  color: #68768c;
  font-size: 14px;
}
.source-name:focus {
  outline: 0;
  border-bottom: 1px solid #8eaff7;
  border-radius: 0;
}
.scroll {
  overflow: auto;
  flex: 1;
  min-height: 0;
  padding: 16px;
  scrollbar-width: thin;
  scrollbar-color: #d1d9e5 transparent;
}
.source-scroll {
  padding-top: 7px;
}
/* Shared rich-text editing */
.editor {
  font-family: Arial, 'Microsoft YaHei', sans-serif;
  font-size: 16px;
  line-height: 1.7;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  min-height: 45px;
  outline: 0;
}
.editor p,
.editor div {
  margin: 0 0 0.65em;
}
.editor p:last-child,
.editor div:last-child {
  margin-bottom: 0;
}
.editor ul,
.editor ol {
  margin: 7px 0;
  padding-left: 24px;
}
.editor h1,
.editor h2 {
  font-size: 21px;
  margin: 8px 0;
}
.editor h3 {
  font-size: 18px;
  margin: 8px 0;
}
.editor blockquote {
  border-left: 3px solid var(--line);
  padding-left: 12px;
  margin: 10px 0;
  color: #6e7d94;
}
.editor:empty::before {
  content: attr(data-placeholder);
  color: #a4adba;
  pointer-events: none;
}
.editor:focus {
  box-shadow: -3px 0 #c6d7ff;
}
.source-editor {
  min-height: 260px;
}
.source-count {
  padding: 9px 16px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  flex-shrink: 0;
}
/* Material fields */
.material-field {
  margin-bottom: 17px;
}
.material-name {
  flex: 1;
  width: 70px;
  min-width: 40px;
  padding: 3px 0;
  border-color: transparent;
  border-radius: 0;
  font-size: 14px;
  font-weight: 500;
}
.material-name:focus {
  outline: 0;
  border-bottom-color: #8eaff7;
}
.material-field .field-top {
  gap: 5px;
}
.material-field .field-top button {
  white-space: nowrap;
}
.empty {
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  padding: 30px 8px;
  line-height: 1.8;
}
/* Keyword bar */
.keyword-bar {
  flex-shrink: 0;
  background: #fff;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  padding: 8px 22px;
}
.keyword-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.keyword-row > label {
  color: #68768c;
  white-space: nowrap;
}
.keyword-content {
  flex: 1;
  min-width: 0;
}
#keyword-list {
  line-height: 1.7;
  overflow-wrap: anywhere;
}
#keyword-input {
  width: 100%;
  padding: 3px 7px;
  font-size: 13px;
  display: block;
  min-height: 54px;
  max-height: 160px;
  line-height: 1.6;
  resize: vertical;
}
#keyword-input[hidden],
#keyword-list[hidden] {
  display: none;
}
#keyword-summary {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
#keyword-edit-toggle {
  font-size: 12px;
  padding: 3px 7px;
}
.keyword {
  display: inline;
  font-family: Arial, 'Microsoft YaHei', sans-serif;
  font-size: 13px;
  line-height: inherit;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #af7729;
  text-align: left;
  cursor: default;
}
.keyword.used {
  color: #42815d;
  cursor: pointer;
}
.keyword:hover {
  background: transparent;
  border: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.keyword b {
  font-weight: 400;
  font-size: 11px;
  margin-left: 4px;
  opacity: 0.7;
}
.keyword-comma {
  color: var(--muted);
}
/* Draft fields and notifications */
.draft-field {
  margin-bottom: 17px;
}
.field-top {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 7px;
}
.field-top label {
  font-size: 14px;
  font-weight: 500;
}
.field-count {
  font-size: 12px;
  color: var(--muted);
  margin-left: auto;
  white-space: nowrap;
}
.field-top button {
  font-size: 12px;
  padding: 3px 5px;
  border-color: transparent;
  color: #8a95a6;
}
.field-top button:hover {
  color: var(--blue);
  background: #eff4ff;
}
.draft-editor {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 11px;
  min-height: 78px;
  line-height: 1.7;
}
.draft-editor:focus {
  border-color: #c3d4ff;
  box-shadow: none;
}
.draft-editor[data-kind='title'] {
  min-height: 88px;
}
.draft-editor[data-kind='description'] {
  min-height: 200px;
}
.add-feature {
  width: 100%;
  border: 1px dashed #d8e1ef;
  color: #7c8eaa;
  background: #fcfdff;
  margin: 0 0 20px;
  padding: 9px;
}
.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  border-radius: 7px;
  box-shadow: 0 5px 25px #192e4930;
  background: #283950;
  color: #fff;
  padding: 11px 16px;
  z-index: 10;
  max-width: 90vw;
  font-size: 13px;
  line-height: 1.6;
}
.toast button {
  color: #c8d7ff;
  background: transparent;
  border: 0;
  text-decoration: underline;
  margin-left: 12px;
  padding: 0;
}
.toast[hidden] {
  display: none;
}
@media (max-width: 1000px) {
  .header,
  .toolbar,
  .keyword-bar {
    padding-left: 14px;
    padding-right: 14px;
  }
  .workspace {
    margin: 14px;
    gap: 10px;
  }
  .panel-heading {
    padding: 0 12px;
  }
  .scroll {
    padding: 12px;
  }
  .field-top button {
    font-size: 12px;
  }
}
/* Resizable column handles */
.layout-separator {
  position: absolute;
  top: 0;
  bottom: 0;
  transform: translateX(-50%);
  cursor: col-resize;
  touch-action: none;
  user-select: none;
  z-index: 2;
}
.layout-separator::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 2px;
  height: 40px;
  transform: translate(-50%, -50%);
  background: #d1d9e5;
  border-radius: 2px;
}
.layout-separator:hover::before,
.layout-separator:focus-visible::before,
.layout-dragging .layout-separator::before {
  background: var(--blue);
}
.layout-separator:focus-visible {
  outline: 2px solid #799afa;
  outline-offset: -2px;
}
.layout-separator[hidden] {
  display: none;
}
.workspace.layout-dragging {
  cursor: col-resize;
  user-select: none;
}
.source-editor:focus {
  box-shadow: none;
}
.source-button:hover {
  color: var(--source-color);
  border-color: var(--source-color);
  background: var(--source-bg);
  opacity: 1;
}
.source-editor::highlight(excerpt-source) {
  background: var(--source-bg);
}
@media (max-width: 900px) {
  body {
    height: auto;
    overflow: auto;
  }
  .header {
    height: auto;
    min-height: 65px;
    flex-wrap: wrap;
    padding: 12px 14px;
  }
  .header > div {
    gap: 10px;
  }
  h1 span {
    display: none;
  }
  .workspace {
    display: flex;
    flex-direction: column;
    margin: 12px;
  }
  .panel {
    height: 550px;
    flex-shrink: 0;
  }
  .toolbar {
    padding: 10px 12px;
  }
  #editing-label {
    min-width: 90px;
    font-size: 11px;
  }
  .source-count {
    padding: 8px 12px;
  }
  .keyword-bar {
    padding: 8px 12px;
  }
  .keyword-row {
    gap: 8px;
  }
  .layout-separator {
    display: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
  }
}
/* Per-line source marks and navigation */
.material-body {
  position: relative;
}
.material-editor {
  padding-left: 29px;
  padding-right: 36px;
}
.material-references {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.material-reference {
  position: absolute;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 7px 0 11px;
}
.reference-marks,
.reference-jumps {
  display: flex;
  align-items: center;
  gap: 3px;
}
.reference-mark {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--source-color);
  flex-shrink: 0;
}
.reference-jump {
  width: 21px;
  height: 21px;
  padding: 0;
  line-height: 21px;
  font-size: 15px;
  background: transparent;
  border: 0;
  border-radius: 3px;
  color: #9aa3af;
  pointer-events: auto;
}
.reference-jump:hover {
  color: var(--source-color);
  background: var(--source-bg);
  border: 0;
}
.reference-jump:focus-visible {
  outline-color: var(--source-color);
}
.draft-editor p,
.draft-editor div {
  margin: 0;
  line-height: inherit;
}
.draft-editor p:empty,
.draft-editor div:empty {
  min-height: 1.7em;
}
/* Read-only HTML preview */
/* Material sorting */
.material-field .field-top .material-drag {
  cursor: grab;
  touch-action: none;
  font-size: 19px;
  line-height: 22px;
  padding: 0 3px;
  flex-shrink: 0;
  color: #98a3b4;
}
.material-drag:active {
  cursor: grabbing;
}
.material-dragging {
  opacity: 0.45;
}
.material-field.drop-before {
  box-shadow: 0 -3px var(--blue);
}
.material-field.drop-after {
  box-shadow: 0 3px var(--blue);
}

.dialog {
  width: min(600px, calc(100vw - 32px));
  max-height: 90vh;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
}
.dialog::backdrop {
  background: rgb(16 32 55 / 35%);
}
.dialog-heading,
.dialog-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.dialog-heading {
  justify-content: space-between;
}
.dialog-heading h2 {
  margin: 0;
  font-size: 18px;
}
.dialog p {
  line-height: 1.65;
}
.dialog-actions {
  margin-top: 16px;
  flex-wrap: wrap;
}
.dialog-actions[hidden] {
  display: none;
}
.dialog input,
.dialog select {
  width: 100%;
  padding: 10px;
  margin-top: 8px;
}
.dialog details {
  margin-top: 20px;
}
.dialog .muted {
  color: var(--muted);
  font-size: 12px;
}
.html-dialog {
  width: min(880px, calc(100vw - 32px));
}
#html-code {
  width: 100%;
  height: 55vh;
  padding: 14px;
  resize: vertical;
  font:
    14px/1.7 Consolas,
    monospace;
}
#cloud-open {
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
