/* ---------- Settings page layout ---------- */
/* Colors, buttons, switches and form fields come from style.css */

/* One column, sized for the narrow Notion embed first */
.s-page { max-width: 600px; margin: 0 auto; padding: 0 16px; min-height: 100vh; display: flex; flex-direction: column; }
.s-main { flex: 1; padding-bottom: 24px; }

/* ---------- Header: ← Settings  ● Unsaved changes ---------- */
.s-header { display: flex; align-items: center; gap: 6px; padding: 16px 0 8px; }
.s-header h1 { font-size: 1.2rem; font-weight: 600; }
.back-link {
  width: 32px; height: 32px; margin-left: -6px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px; color: var(--text);
}
.back-link:hover { background: var(--surface); }
.save-status {
  margin-left: auto;
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.74rem; color: var(--muted);
}
.save-status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--scheduled); }
.save-status[hidden] { display: none; }

/* ---------- Tabs (underline style, like the widget) ---------- */
.s-tabs {
  display: flex; gap: 22px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto; scrollbar-width: none;
}
.s-tabs::-webkit-scrollbar { display: none; }
.s-tab {
  position: relative;
  background: none; border: 0;
  padding: 12px 0;
  font-size: 0.88rem; font-weight: 500;
  color: var(--muted);
  cursor: pointer; white-space: nowrap;
}
.s-tab:hover { color: var(--text); }
.s-tab.active { color: var(--text); }
.s-tab::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px;
  height: 2px; background: var(--accent);
  transform: scaleX(0); transition: transform 0.2s;
}
.s-tab.active::after { transform: scaleX(1); }

.s-panel { padding-top: 4px; animation: fadeUp 0.2s ease; }

/* ---------- Groups: small grey heading, then a white card ---------- */
.s-heading {
  font-size: 0.7rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted);
  margin: 22px 2px 8px;
}
.s-card {
  background: var(--field);
  border: 1px solid var(--border); border-radius: var(--r-card);
}
.s-card[hidden] { display: none; }
.s-card-pad { padding: 14px; }
.s-hint { font-size: 0.76rem; color: var(--muted); line-height: 1.45; margin: 8px 2px 0; }
.s-hint-top { margin: 16px 2px 12px; }
.s-row-hint { font-size: 0.76rem; color: var(--muted); line-height: 1.45; margin-top: 3px; }

/* A row inside a card: title on the left, the control on the right */
.s-row {
  display: flex; justify-content: space-between; align-items: center; gap: 14px;
  width: 100%; min-height: 50px;
  padding: 10px 14px;
  background: none; border: 0;
  font-size: 0.88rem; color: var(--text); text-align: left;
}
.s-row + .s-row { border-top: 1px solid var(--border); }
.s-row-title { font-size: 0.88rem; font-weight: 500; color: var(--text); }
.s-switch-row { cursor: pointer; }
.s-switch-row:hover { background: var(--surface); }
.s-card > .s-row:first-child { border-radius: var(--r-card) var(--r-card) 0 0; }
.s-card > .s-row:last-child { border-radius: 0 0 var(--r-card) var(--r-card); }
.s-select {
  flex-shrink: 0; min-width: 130px; height: 34px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: var(--r-control);
  background: var(--field); color: var(--text); font-size: 0.85rem; cursor: pointer;
}

/* Segmented choice (Light / Dark / Auto) */
.seg { display: inline-flex; gap: 2px; background: var(--surface); padding: 3px; border-radius: var(--r-control); flex-shrink: 0; }
.seg-btn {
  border: 0; background: transparent;
  padding: 6px 14px; border-radius: 7px;
  font-size: 0.82rem; color: var(--muted);
  cursor: pointer;
}
.seg-btn:hover { color: var(--text); }
.seg-btn.on { background: var(--field); color: var(--text); font-weight: 500; box-shadow: var(--shadow-sm); }

/* ---------- Profile (no cards: photo, then the fields one under another) ---------- */
.s-photo { display: flex; align-items: center; gap: 16px; margin: 18px 0 20px; }
.s-photo .img-preview { width: 64px; }
.s-photo .file-btn { display: inline-flex; gap: 6px; }
.s-photo .file-btn .icon { width: 15px; height: 15px; }
.s-plain .field { margin-bottom: 16px; }
.s-plain .field input, .s-plain .field textarea { font-size: 0.88rem; }
.s-card .field { margin-bottom: 14px; }
.s-card .field:last-child { margin-bottom: 0; }
.field-label .optional { color: var(--muted); font-weight: 400; margin-left: 5px; }
/* "Bio" on the left, "24 / 150" on the right */
.label-row { display: flex; justify-content: space-between; align-items: baseline; }
.label-count { font-size: 0.74rem; color: var(--muted); }
/* Field titles in dark text, 12px medium (like the edit pop-up) */
.s-page .field label.field-label { color: var(--text); font-size: 12px; font-weight: 500; margin-bottom: 6px; }
.s-card .field input, .s-card .field textarea { font-size: 0.88rem; }
.s-card .field-label .optional { color: var(--muted); font-weight: 400; margin-left: 5px; }

/* ---------- Pillar rows: circle · hex · name · count · trash ---------- */
.row-card {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; margin-bottom: 8px;
  border: 1px solid var(--border); border-radius: var(--r-card);
  background: var(--field);
}
.row-card input[type="text"] {
  flex: 1; min-width: 0; height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border); border-radius: var(--r-control);
  background: var(--field); color: var(--text); font-size: 0.88rem;
}
.color-input {
  width: 32px; height: 32px; padding: 0; flex-shrink: 0;
  border: 1px solid var(--border); border-radius: 50%;
  background: none; cursor: pointer; overflow: hidden;
}
.color-input::-webkit-color-swatch-wrapper { padding: 0; }
.color-input::-webkit-color-swatch { border: 0; border-radius: 50%; }
.color-input::-moz-color-swatch { border: 0; border-radius: 50%; }
.row-card input.hex-input {
  flex: 0 0 78px; width: 78px;
  padding: 0 6px; text-align: center;
  font-size: 0.76rem; font-variant-numeric: tabular-nums;
  text-transform: uppercase;
}
.row-card input.hex-input.invalid { border-color: var(--danger); }
.row-count { font-size: 0.76rem; color: var(--muted); white-space: nowrap; }
.row-card .icon-btn {
  width: 32px; height: 32px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: none; border: 0; color: var(--muted); border-radius: 8px; cursor: pointer;
}
.row-card .icon-btn:hover { color: var(--danger); background: var(--danger-soft); }
.add-row {
  width: 100%; padding: 12px;
  border: 1.5px dashed var(--border); border-radius: var(--r-card);
  background: none; color: var(--muted);
  font-size: 0.86rem; font-weight: 500; cursor: pointer;
}
.add-row:hover { background: var(--surface); color: var(--text); }
.empty-note { color: var(--muted); font-size: 0.85rem; padding: 6px 2px 14px; }

/* ---------- Connection ---------- */
.conn-head { display: flex; align-items: flex-start; gap: 10px; }
.conn-cloud { flex-shrink: 0; display: flex; color: var(--muted); padding-top: 1px; }
.conn-cloud.on { color: var(--saved); }
.conn-cloud .icon { width: 20px; height: 20px; }
.conn-title { font-size: 0.88rem; font-weight: 500; color: var(--text); }
.conn-explain { margin: 14px 0; }
.conn-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.conn-buttons .btn, #embedBtn { gap: 6px; }
.conn-buttons .btn .icon, #embedBtn .icon { width: 15px; height: 15px; }
.lock-note { display: flex; gap: 6px; align-items: flex-start; }
.lock-note .icon { width: 13px; height: 13px; flex-shrink: 0; margin-top: 2px; }
.conn-connect { width: 100%; height: 40px; }
#editConnSlot:not(:empty) { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); }
#editConnSlot .conn-explain { margin-top: 0; }
#connForm .field { margin-bottom: 12px; }
#connForm input { font-size: 0.88rem; }
#connForm[hidden], #connDone[hidden], #connNotCard[hidden] { display: none; }
.secret-box { position: relative; }
.secret-box input { padding-right: 42px; }
.eye-btn {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px; border: 0; background: none; border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); cursor: pointer;
}
.eye-btn:hover, .eye-btn[aria-pressed="true"] { color: var(--text); background: var(--surface); }
.btn[hidden] { display: none; }
#embedBtn { margin: 0 0 10px; }
#embedNote:not([hidden]) { margin-bottom: 8px; }
.embed-link {
  width: 100%; margin: 0 0 8px; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: var(--r-control);
  background: var(--surface); color: var(--text);
  font-size: 0.74rem;
}
.embed-link[hidden] { display: none; }

/* ---------- Bottom bar, pinned on every tab ---------- */
.save-bar {
  position: sticky; bottom: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 0 -16px; padding: 12px 16px;
  background: var(--bg);
  border-top: 1px solid var(--border);
}
.save-actions { display: flex; gap: 8px; }
.save-actions .btn { height: 36px; }
.preview-link {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--muted); font-size: 0.85rem;
  text-decoration: underline; text-underline-offset: 3px;
}
.preview-link:hover { color: var(--text); }
.preview-link .icon { width: 16px; height: 16px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }
.btn-primary:disabled:hover { opacity: 0.4; }

/* ---------- Preview pop-up (opens only when "Preview" is clicked) ---------- */
.preview-content { max-width: 440px; padding: 0 0 12px; display: flex; flex-direction: column; overflow: hidden; }
.preview-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 10px 10px 16px; border-bottom: 1px solid var(--border);
}
#previewFrame {
  display: block; width: 100%; height: min(640px, 72vh);
  border: 0; background: var(--bg);
}
.preview-note { padding: 8px 16px 0; }

/* ---------- Small screens ---------- */
@media (max-width: 480px) {
  .s-tabs { gap: 18px; }
  .row-card { gap: 8px; padding: 8px; }
  .seg-btn { padding: 6px 10px; }
  .s-select { min-width: 110px; }
}
@media (max-width: 380px) {
  .row-count { display: none; }          /* very narrow: hide "8 posts" to keep the name readable */
}
