/* ─── 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; }
