/* ─── Settings Modal ─── */

.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,.65);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease;
}
.modal-overlay.open {
  opacity: 1; pointer-events: auto;
}

.modal-box {
  background: #181c24; color: #e8e8e8;
  border: 1px solid #333; border-radius: 12px;
  width: min(92vw, 520px);
  max-height: 85vh; overflow-y: auto;
  padding: 1.5rem;
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
}
.modal-box h3 {
  margin: 0 0 1rem; font-size: 1.2rem; font-weight: 700;
}

.modal-row {
  margin-bottom: .75rem;
}
.modal-row label {
  display: block; font-size: .85rem; color: #aaa; margin-bottom: .25rem;
}
.modal-row input[type="text"],
.modal-row input[type="password"],
.modal-row input[type="date"],
.modal-row select,
.modal-row textarea {
  width: 100%; padding: .55rem .7rem;
  background: #0e1117; color: #e8e8e8;
  border: 1px solid #333; border-radius: 8px;
  font-size: .95rem; outline: none;
  font-family: inherit;
}
.modal-row input:focus,
.modal-row select:focus,
.modal-row textarea:focus {
  border-color: #58a6ff;
}

.modal-actions {
  display: flex; gap: .5rem; margin-top: 1rem; flex-wrap: wrap;
}
.modal-actions button {
  padding: .5rem 1.1rem;
  border: none; border-radius: 8px;
  font-size: .9rem; cursor: pointer;
  font-weight: 600;
}
.btn-primary   { background: #238636; color: #fff; }
.btn-secondary { background: #30363d; color: #c9d1d9; }
.btn-danger    { background: #da3633; color: #fff; }
.btn-primary:hover   { background: #2ea043; }
.btn-secondary:hover { background: #3c444d; }
.btn-danger:hover    { background: #f85149; }

.settings-status, .editor-status {
  margin-top: .75rem; font-size: .85rem; color: #8b949e;
  min-height: 1.4em;
}
.settings-status.success, .editor-status.success { color: #3fb950; }
.settings-status.error, .editor-status.error { color: #f85149; }

.settings-hint {
  font-size: .8rem; color: #6e7681; margin-top: .25rem; line-height: 1.4;
}
.settings-hint a { color: #58a6ff; text-decoration: none; }
.settings-hint a:hover { text-decoration: underline; }

.settings-view[hidden] { display: none !important; }
.settings-view.is-active { display: block; }

.settings-section-title {
  margin-top: 1rem;
  font-size: .9rem;
  font-weight: 700;
  color: #c9d1d9;
}

.settings-subheader {
  display: flex;
  align-items: center;
  margin-bottom: .4rem;
}
.settings-back-btn {
  font-size: .82rem;
  padding: .35rem .72rem;
}

.profile-preview {
  margin-top: .35rem;
  padding: .7rem .8rem;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 10px;
  background: rgba(255,255,255,.02);
}
.profile-preview-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: .35rem;
  font-size: .86rem;
}
.profile-preview-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .6rem;
}
.profile-preview-label {
  color: #8b949e;
}
.profile-preview-value {
  color: #e8e8e8;
  text-align: right;
}
.profile-preview-colors {
  display: flex;
  flex-wrap: wrap;
  gap: .45rem;
  margin-top: .65rem;
}
.profile-preview-chip {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .2rem .5rem;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.02);
  font-size: .76rem;
  color: #c9d1d9;
}
.profile-preview-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.settings-advanced {
  margin-top: .6rem;
  border: 1px solid #30363d;
  border-radius: 8px;
  padding: .35rem .6rem .2rem;
  background: rgba(255,255,255,.02);
}
.settings-advanced summary {
  cursor: pointer;
  font-size: .85rem;
  color: #9aa4b2;
  user-select: none;
  margin-bottom: .4rem;
}

/* ─── Editor Modal ─── */

.editor-box {
  width: min(96vw, 860px);
}
.editor-box h3 {
  display: flex; align-items: center; gap: .5rem;
}
.editor-city-badge {
  font-size: .85rem; padding: .15rem .5rem;
  background: #0d419d; color: #79c0ff; border-radius: 6px;
}

.editor-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: .5rem;
}
@media (max-width: 520px) {
  .editor-grid { grid-template-columns: 1fr; }
}

/* ─── 移动端编辑器适配 ─── */

@media (max-width: 768px) {
  .modal-box {
    width: calc(100vw - 16px);
    max-height: 92vh;
    padding: 1rem;
    border-radius: 10px;
  }
  .editor-box {
    width: calc(100vw - 16px);
  }
  .editor-grid {
    grid-template-columns: 1fr 1fr;
    gap: .4rem;
  }
  .editor-toolbar {
    flex-wrap: wrap;
    gap: .3rem;
  }
  #vditorContainer {
    min-height: 200px;
  }
  /* Vditor toolbar simplified on mobile */
  .vditor-toolbar { flex-wrap: wrap; }
}

.editor-textarea {
  min-height: 240px; resize: vertical;
  font-family: 'Menlo', 'Consolas', 'Monaco', monospace;
  font-size: .88rem; line-height: 1.6;
  tab-size: 4;
}

.editor-preview {
  display: none;
  background: #0e1117; border: 1px solid #333; border-radius: 8px;
  padding: .75rem 1rem; min-height: 240px;
  font-size: .9rem; line-height: 1.6;
  overflow-y: auto;
}
.editor-preview h1, .editor-preview h2, .editor-preview h3, .editor-preview h4 {
  margin: .4em 0;
}
.editor-preview img { max-width: 100%; border-radius: 6px; }

/* Visual editor image-row layout (shared with md-viewer semantics) */
.vditor .img-row, .vditor-reset .img-row {
  display: flex;
  gap: 0.75rem;
  margin: 1rem auto;
  flex-wrap: wrap;
  justify-content: center;
  align-items: stretch;
  --row-width: 100%;
  width: var(--row-width);
}
.vditor .img-row.large, .vditor-reset .img-row.large { --row-width: 100%; }
.vditor .img-row.middle, .vditor-reset .img-row.middle { --row-width: 75%; }
.vditor .img-row.small, .vditor-reset .img-row.small { --row-width: 50%; }
.vditor .img-row.tiny, .vditor-reset .img-row.tiny { --row-width: 30%; }
.vditor .img-row .img-wrap, .vditor-reset .img-row .img-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-direction: column;
  flex: 0 0 calc((100% - (var(--cols,1) - 1) * 0.75rem) / var(--cols,1));
}
.vditor .img-row .img-wrap img, .vditor-reset .img-row .img-wrap img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
}

.editor-toolbar {
  display: flex; gap: .5rem; align-items: center; margin-bottom: .5rem; flex-wrap: wrap;
}
.editor-toolbar .pill {
  font-size: .82rem; padding: .3rem .7rem;
}

.upload-label {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .3rem .7rem;
  background: #30363d; color: #c9d1d9;
  border-radius: 8px; cursor: pointer;
  font-size: .82rem; font-weight: 600;
}
.upload-label:hover { background: #3c444d; }
.upload-label input { display: none; }

/* ─── Drawer add-record button ─── */

.detail-add-btn {
  display: flex; align-items: center; justify-content: center; gap: .4rem;
  width: 100%; padding: .65rem;
  background: #161b22; border: 1px dashed #30363d;
  color: #58a6ff; border-radius: 8px;
  cursor: pointer; font-size: .9rem; font-weight: 600;
  transition: background .15s, border-color .15s;
}
.detail-add-btn:hover {
  background: #1c2333; border-color: #58a6ff;
}

/* ─── Drawer status changer → filter bar ─── */

.detail-status-bar {
  display: flex; gap: .4rem; padding: .5rem .75rem;
  border-bottom: 1px solid #222; flex-wrap: wrap; align-items: center;
}
.detail-status-bar span {
  font-size: .82rem; color: #8b949e; margin-right: .25rem;
}
.status-btn {
  padding: .3rem .6rem; border: 1px solid #333;
  border-radius: 6px; background: transparent;
  color: #c9d1d9; cursor: pointer; font-size: .8rem;
  transition: all .15s;
}
.status-btn:hover { border-color: #58a6ff; color: #58a6ff; }
.status-btn.active { font-weight: 700; }
.status-btn.active[data-status="xiaoang"]  { background: #87CEFA33; border-color: #87CEFA; color: #87CEFA; }
.status-btn.active[data-status="xiaoyu"]   { background: #F0808033; border-color: #F08080; color: #F08080; }
.status-btn.active[data-status="together"] { background: #80008033; border-color: #800080; color: #EE82EE; }
.status-btn.active[data-status="all"]      { background: #58a6ff33; border-color: #58a6ff; color: #58a6ff; }

/* ─── Vditor dark overrides ─── */

#vditorContainer {
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: .75rem;
}
.vditor { border-color: #333; }
.vditor--dark .vditor-toolbar { border-bottom-color: #333; }

/* ─── Edit/Delete buttons in drawer ─── */

.fp-edit-btn, .fp-del-btn {
  padding: .2rem .45rem;
  font-size: .75rem;
  background: #30363d;
  min-width: auto;
  height: 28px;
}
.fp-edit-btn:hover { background: #58a6ff33; }
.fp-del-btn { background: #30363d; }
.fp-del-btn:hover { background: #f8514933; }

/* ─── Sync status indicator in header ─── */

.sync-dot {
  display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; margin-left: .35rem; vertical-align: middle;
}
.sync-dot.connected    { background: #3fb950; }
.sync-dot.disconnected { background: #6e7681; }

/* ─── Immersive record workspace ─── */

#editorModal {
  background:
    radial-gradient(circle at 12% 0%, rgba(46, 183, 164, .16), transparent 31rem),
    radial-gradient(circle at 90% 100%, rgba(86, 134, 215, .15), transparent 34rem),
    rgba(7, 12, 18, .82);
  backdrop-filter: blur(12px);
}

.editor-box {
  width: min(1660px, 100vw);
  height: 100dvh;
  max-height: 100dvh;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: #111923;
  box-shadow: none;
  display: flex;
  flex-direction: column;
}

.editor-topbar {
  min-height: 68px;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid rgba(156, 184, 205, .14);
  background: rgba(18, 29, 40, .94);
  flex: 0 0 auto;
}

.editor-document-mark {
  min-width: 150px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #e6f0f6;
  font-size: .94rem;
  font-weight: 750;
  letter-spacing: .02em;
  white-space: nowrap;
}

.editor-mark-icon {
  width: 26px;
  height: 26px;
  display: inline-grid;
  place-items: center;
  color: #b8fff0;
  border: 1px solid rgba(135, 242, 220, .34);
  border-radius: 8px;
  background: rgba(37, 159, 142, .16);
}

.editor-city-badge {
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: .18rem .5rem;
  border: 1px solid rgba(132, 222, 207, .27);
  border-radius: 999px;
  color: #9ce9da;
  background: rgba(37, 159, 142, .12);
  font-size: .75rem;
  font-weight: 600;
}

.editor-meta-row {
  display: flex;
  min-width: 0;
  flex: 1 1 auto;
  align-items: center;
  gap: 8px;
}

.editor-field {
  min-width: 0;
  height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  border: 1px solid rgba(157, 188, 208, .16);
  border-radius: 8px;
  background: rgba(6, 13, 20, .38);
  color: #8fa4b4;
  font-size: .73rem;
  white-space: nowrap;
}

.editor-field input,
.editor-field select {
  width: auto;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #e7f1f6;
  font: inherit;
  font-size: .86rem;
  outline: 0;
}

.editor-field input[type="date"] { color-scheme: dark; }
.editor-date-field { flex: 0 0 auto; }
.editor-visitor-field { flex: 0 0 auto; }
.editor-visitor-field select { cursor: pointer; }
.editor-title-field { flex: 1 1 260px; }
.editor-title-field input { width: 100%; }
.editor-title-field:focus-within,
.editor-field:focus-within { border-color: rgba(109, 228, 207, .62); box-shadow: 0 0 0 3px rgba(81, 214, 191, .09); }

.editor-top-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.editor-top-actions button { margin: 0; border-radius: 8px; font-size: .82rem; font-weight: 700; }
.editor-quiet-action { padding: .45rem .58rem; border: 0; color: #8499a8; background: transparent; cursor: pointer; }
.editor-quiet-action:hover { color: #f0b8b8; background: rgba(205, 75, 75, .1); }
.editor-save-btn { padding: .55rem .82rem !important; background: #198d7a; }
.editor-save-btn:hover { background: #22a78f; }
.editor-cancel-btn { padding: .55rem .72rem !important; background: #2b3a48; }
.editor-cancel-btn:hover { background: #405261; }

.editor-workspace {
  min-height: 0;
  flex: 1 1 auto;
  display: flex;
  overflow: hidden;
}

.editor-outline-panel {
  width: 244px;
  flex: 0 0 244px;
  overflow-y: auto;
  padding: 20px 12px 24px;
  border-right: 1px solid rgba(156, 184, 205, .13);
  background:
    linear-gradient(rgba(19, 31, 42, .72), rgba(15, 24, 33, .72)),
    repeating-linear-gradient(0deg, transparent 0, transparent 27px, rgba(146, 180, 198, .035) 28px);
}

.editor-outline-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 9px 10px;
  color: #b6c6d1;
  font-size: .72rem;
  font-weight: 750;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.editor-outline-count {
  min-width: 20px;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(121, 166, 190, .14);
  color: #92adbd;
  text-align: center;
  font-size: .66rem;
}

.editor-outline { display: grid; gap: 2px; }
.editor-outline-empty { margin: 7px 9px; color: #627989; font-size: .79rem; line-height: 1.7; }
.editor-outline-item {
  width: 100%;
  overflow: hidden;
  padding: 7px 9px;
  border: 0;
  border-left: 2px solid transparent;
  border-radius: 0 6px 6px 0;
  background: transparent;
  color: #9fb1bf;
  cursor: pointer;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  font: inherit;
  font-size: .82rem;
  line-height: 1.35;
}
.editor-outline-item[data-level="2"] { padding-left: 21px; color: #7f96a5; font-size: .78rem; }
.editor-outline-item:hover, .editor-outline-item.is-active { border-left-color: #62d5bf; background: rgba(73, 185, 164, .1); color: #d7faf2; }

.editor-canvas {
  min-width: 0;
  min-height: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  padding: 12px clamp(12px, 2.4vw, 42px) 14px;
  background: #101820;
}

.editor-canvas-hint {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 30px;
  padding: 0 2px 9px;
  color: #708897;
  font-size: .77rem;
}

.editor-canvas-hint .upload-label {
  padding: .3rem .63rem;
  border: 1px solid rgba(133, 214, 199, .24);
  border-radius: 7px;
  background: rgba(34, 133, 119, .14);
  color: #a7ecdf;
  font-size: .76rem;
}
.editor-canvas-hint .upload-label:hover { background: rgba(42, 162, 143, .25); }

#vditorContainer {
  min-height: 0;
  flex: 1 1 auto;
  margin: 0;
  border: 1px solid rgba(160, 191, 209, .15);
  border-radius: 10px;
  overflow: hidden;
  background: #17222d;
  box-shadow: 0 18px 40px rgba(0, 0, 0, .12);
}
#vditorContainer > .vditor { height: 100% !important; border: 0; }
#vditorContainer .vditor-toolbar { padding: 5px 8px; border-bottom-color: rgba(160, 191, 209, .13); background: #1b2935; }
#vditorContainer .vditor-toolbar button:hover { background: rgba(97, 217, 196, .12); }
#vditorContainer .vditor-wysiwyg { background: #17222d; }
#vditorContainer .vditor-wysiwyg pre.vditor-reset { max-width: 980px; margin: 0 auto; padding: 34px clamp(18px, 5vw, 82px) 260px; color: #d7e4eb; font-size: 16px; line-height: 1.86; }
#vditorContainer .vditor-wysiwyg h1, #vditorContainer .vditor-wysiwyg h2 { color: #f0f7f8; }
#vditorContainer .vditor-wysiwyg img { max-width: min(100%, 900px); border-radius: 9px; box-shadow: 0 9px 25px rgba(0, 0, 0, .2); }

#editorUploadProgressHost { flex: 0 0 auto; margin-top: 8px; }
.editor-status { flex: 0 0 auto; min-height: 1.2em; margin: 7px 2px 0; color: #8297a5; }

@media (max-width: 1100px) {
  .editor-document-mark { min-width: auto; }
  .editor-document-mark > #editorTitlebarLabel { display: none; }
  .editor-outline-panel { width: 204px; flex-basis: 204px; }
}

@media (max-width: 820px) {
  .editor-topbar { min-height: auto; flex-wrap: wrap; gap: 8px; padding: 9px 12px; }
  .editor-document-mark { order: 0; }
  .editor-top-actions { order: 1; margin-left: auto; }
  .editor-meta-row { order: 2; flex: 1 0 100%; }
  .editor-outline-panel { display: none; }
  .editor-canvas { padding: 10px; }
  .editor-canvas-hint span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

@media (max-width: 560px) {
  .editor-box { height: 100dvh; width: 100vw; }
  .editor-topbar { align-items: center; }
  .editor-meta-row { display: grid; grid-template-columns: 1fr 1fr; }
  .editor-title-field { grid-column: 1 / -1; }
  .editor-field { width: 100%; }
  .editor-quiet-action { display: none; }
  .editor-canvas-hint span { display: none; }
  #vditorContainer .vditor-wysiwyg pre.vditor-reset { padding: 24px 18px 220px; font-size: 15px; }
}
