/* 写作页沿用主站的纸面、字体和低饱和蓝绿色。 */

:root {
  --ed-accent: #497a7a;
  --ed-accent-hover: #3f6a6a;
  --ed-fill: rgba(0, 0, 0, 0.045);
  --ed-fill-strong: rgba(0, 0, 0, 0.08);
  --ed-line: rgba(0, 0, 0, 0.1);
  --ed-ring: rgba(73, 122, 122, 0.25);
}

html[data-theme="night"] {
  --ed-accent: #8fc2b7;
  --ed-accent-hover: #a3d0c6;
  --ed-fill: rgba(255, 255, 255, 0.08);
  --ed-fill-strong: rgba(255, 255, 255, 0.14);
  --ed-line: rgba(255, 255, 255, 0.12);
  --ed-ring: rgba(143, 194, 183, 0.34);
}

.writer {
  max-width: 820px;
  margin: 0 auto;
  padding: 48px 0 88px;
  min-height: 70vh;
}

/* 按钮基础 */
.writer button {
  font: inherit;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  line-height: 1.25;
  transition: background-color 0.18s ease, color 0.18s ease, transform 0.06s ease;
}

.writer button:active {
  transform: scale(0.97);
}

.writer button:focus-visible,
.dialog button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px var(--ed-ring);
}

.writer button:disabled {
  opacity: 0.45;
  cursor: wait;
}

/* 输入框：去掉原生蓝色焦点/选择/控件颜色，统一 teal */
.writer input,
.writer textarea {
  outline: none;
  accent-color: var(--ed-accent);
  caret-color: var(--ed-accent);
  -webkit-tap-highlight-color: transparent;
}
.writer input::selection,
.writer textarea::selection {
  background: rgba(73, 122, 122, 0.22);
}
html[data-theme="night"] .writer input::selection,
html[data-theme="night"] .writer textarea::selection {
  background: #34534f;
}
.writer-title:focus {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--ed-ring);
  border-radius: 4px;
}
.writer-body:focus {
  outline: none;
  box-shadow: none;
}

/* 登录入口 */
.writer-gate {
  padding: 96px 0;
  text-align: center;
}

.writer-gate .eyebrow {
  color: var(--muted);
  margin-bottom: 14px;
}

.writer-gate h1 {
  font-family: var(--titleFont, "Songti SC", "Noto Serif CJK SC", serif);
  font-size: 40px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin: 0 0 12px;
}

.writer-gate > p:not(.eyebrow) {
  color: var(--muted);
  margin: 0 0 28px;
}

.writer .text-button {
  display: inline-block;
  font-weight: 500;
  font-size: 15px;
  color: var(--ed-accent);
  border-bottom: 1px solid var(--ed-accent);
  border-radius: 0;
  padding: 8px 0;
}

.writer .text-button:hover {
  color: var(--ed-accent-hover);
}

.writer-status {
  font-size: 13px;
  color: var(--muted);
  min-height: 22px;
  margin: 0 0 22px;
}

/* 顶部工具条 */
.writer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 16px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--ed-line);
}

.writer-links {
  display: flex;
  align-items: center;
  gap: 4px;
}

.writer-links button {
  color: var(--ed-accent);
  font-weight: 500;
  border-radius: 6px;
}

.writer-links button:hover {
  background: var(--ed-fill);
}

.admin-mode {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.05em;
  margin-right: 4px;
}

.paper {
  padding-top: 8px;
}

/* 标题 */
.writer-title {
  width: 100%;
  padding: 12px 0 20px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--titleFont, "Songti SC", "Noto Serif CJK SC", serif);
  font-size: 34px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.02em;
}

.writer-title::placeholder,
.writer-body::placeholder {
  color: var(--muted);
  opacity: 0.55;
}

/* 元信息 */
.metadata-panel {
  margin: 0 0 12px;
}

.metadata-panel > summary {
  width: fit-content;
  color: var(--ed-accent);
  font-size: 13px;
  cursor: pointer;
  padding: 8px 0;
}

.metadata-panel > summary span {
  color: var(--muted);
  margin-left: 12px;
  font-size: 12px;
}

.metadata-panel[open] > summary {
  margin-bottom: 12px;
}

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

.metadata label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}

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

.metadata input,
.metadata textarea {
  font: inherit;
  color: var(--ink);
  background: var(--ed-fill);
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  width: 100%;
  transition: background-color 0.18s ease, box-shadow 0.18s ease;
}

.metadata input {
  min-height: 42px;
}

.metadata textarea {
  resize: vertical;
  min-height: 84px;
}

.metadata input:focus,
.metadata textarea:focus {
  background: var(--paper);
  box-shadow: 0 0 0 4px var(--ed-ring);
}

/* 工具栏 */
.toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 0;
  margin: 0 0 8px;
  border-bottom: 1px solid var(--ed-line);
}

.toolbar button {
  padding: 8px 12px;
  min-height: 34px;
  color: var(--muted);
  font-size: 14px;
  border-radius: 7px;
}

.toolbar button:hover {
  color: var(--ink);
  background: var(--ed-fill);
}

.toolbar button[aria-pressed="true"] {
  color: var(--ed-accent);
  background: var(--ed-fill);
}

.toolbar .spacer {
  flex: 1;
  min-width: 8px;
}

/* 正文 */
.writer-body {
  width: 100%;
  min-height: min(54vh, 560px);
  box-sizing: border-box;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font: var(--bodySize, 17px)/1.8 var(--bodyFont);
  padding: 18px 0 28px;
  resize: vertical;
  scrollbar-color: var(--ed-line) transparent;
}

/* 底部 */
.writer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 20px;
  border-top: 1px solid var(--ed-line);
}

#count {
  color: var(--muted);
  font-size: 13px;
}

.writer-bottom .writer-links {
  gap: 8px;
}

.writer-bottom button {
  min-height: 40px;
  padding: 9px 18px;
  font-weight: 500;
}

.writer-bottom #draft {
  color: var(--ink);
  background: var(--ed-fill);
}

.writer-bottom #draft:hover {
  background: var(--ed-fill-strong);
}

.writer .publish {
  font-weight: 600;
  color: var(--paper);
  background: var(--ed-accent);
}

.writer .publish:hover {
  background: var(--ed-accent-hover);
}

.writer-bottom #delete {
  color: #b3453f;
  font-weight: 500;
}
.writer-bottom #delete:hover {
  background: rgba(179, 69, 63, 0.08);
  color: #b3453f;
}
html[data-theme="night"] .writer-bottom #delete {
  color: #e08a84;
}
html[data-theme="night"] .writer-bottom #delete:hover {
  background: rgba(224, 138, 132, 0.12);
  color: #e08a84;
}

/* 对话框 */
dialog {
  border: 0;
  border-radius: 20px;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  max-width: 520px;
  width: min(90vw, 520px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.2);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.32);
}

.dialog button {
  font: inherit;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  border-radius: 8px;
  transition: background-color 0.18s ease, color 0.18s ease;
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 24px 10px;
}

.dialog-head h2 {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.dialog-head button {
  padding: 6px 10px;
  font-size: 14px;
  color: var(--ed-accent);
}

.dialog-head button:hover {
  background: var(--ed-fill);
}

#post-list {
  display: grid;
  gap: 8px;
  padding: 4px 20px 20px;
}

#post-list button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 11px 14px;
  border-radius: 10px;
  background: var(--ed-fill);
  color: var(--ink);
}

#post-list button:hover {
  background: var(--ed-fill-strong);
}

/* 图片按钮 */
#image {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

#image svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

#image.dragging {
  color: var(--ed-accent);
  background: var(--ed-fill);
}

.image-panel {
  display: grid;
  gap: 16px;
  padding: 4px 20px 20px;
}

.image-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 32px 20px;
  border: 1.5px dashed var(--ed-line);
  border-radius: 14px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.18s ease, background-color 0.18s ease;
}

.image-drop:hover,
.image-drop.dragging {
  border-color: var(--ed-accent);
  background: var(--ed-fill);
}

.image-drop svg {
  width: 26px;
  height: 26px;
  color: var(--muted);
}

.image-drop.dragging svg {
  color: var(--ed-accent);
}

.image-drop p {
  margin: 0;
  font-weight: 600;
  color: var(--ink);
}

.image-drop-cta {
  color: var(--ed-accent);
  font-size: 13px;
  font-weight: 500;
}

.image-drop-sub {
  color: var(--muted);
  font-size: 12px;
}

.image-divider {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.image-url-row {
  display: flex;
  gap: 8px;
}

.image-url-row input {
  flex: 1;
  min-width: 0;
  font: inherit;
  color: var(--ink);
  background: var(--ed-fill);
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  min-height: 42px;
}

.image-url-row input:focus {
  background: var(--paper);
  box-shadow: 0 0 0 4px var(--ed-ring);
}

.image-url-row button {
  font: inherit;
  font-weight: 500;
  color: var(--paper);
  background: var(--ed-accent);
  border: 0;
  border-radius: 10px;
  padding: 9px 18px;
  min-height: 42px;
  cursor: pointer;
  transition: background-color 0.18s ease, transform 0.06s ease;
}

.image-url-row button:hover {
  background: var(--ed-accent-hover);
}

.image-url-row button:active {
  transform: scale(0.97);
}

.image-hint {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  min-height: 18px;
}

.writer .sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 640px) {
  .metadata {
    grid-template-columns: 1fr;
  }

  .writer {
    padding: 24px 0 56px;
  }

  .writer-gate {
    padding: 64px 0;
  }

  .writer-gate h1 {
    font-size: 32px;
  }

  .writer-title {
    font-size: 27px;
  }

  .toolbar {
    flex-wrap: wrap;
  }

  .writer-bar {
    gap: 8px;
  }

  .writer button {
    padding-left: 10px;
    padding-right: 10px;
  }

  .writer-bottom {
    align-items: flex-start;
    gap: 8px;
  }

  .writer-bottom .writer-links {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 4px;
  }

  .writer-bottom button {
    padding: 9px 12px;
  }
}

.image-sizing { display: grid; gap: 12px; padding-bottom: 20px; border-bottom: 1px solid var(--ed-line); }
.image-sizing label { font-size: 13px; color: var(--muted); }
.image-sizing select { width: 100%; min-width: 0; padding: 10px; background: var(--ed-fill); color: var(--ink); border: 1px solid var(--ed-line); border-radius: 8px; font: inherit; }
.image-size-row { display: flex; align-items: center; gap: 12px; }
.image-size-row input { flex: 1; min-width: 0; accent-color: var(--ed-accent); }
.image-size-row output { font-size: 13px; min-width: 42px; color: var(--muted); }
.image-sizing button { justify-self: start; padding: 9px 14px; border: 1px solid var(--ed-line); background: transparent; border-radius: 8px; color: var(--ed-accent); cursor: pointer; }
.image-sizing button:disabled { opacity: .4; cursor: default; }
.image-sizing p { font-size: 12px; line-height: 1.7; color: var(--muted); margin: 0; }
dialog { max-height: 85dvh; overflow-y: auto; }
