/* css/settings.css — Settings tab and settings-driven interface states */

.fs-hidden-by-settings { display: none !important; }

/* ── Shell ── */
.fs-root {
  --fs-ui: system-ui, -apple-system, 'Segoe UI', sans-serif;
  --fs-radius: 14px;
  --fs-ease: cubic-bezier(.2, .7, .2, 1);
  font-family: var(--fs-ui);
  color: var(--ink);
}

.fs-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 8px 4px 96px;
  position: relative;
}

.fs-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  padding: 28px 32px;
  border-radius: 18px;
  background:
    radial-gradient(120% 140% at 0% 0%, rgba(168, 52, 31, .10) 0%, transparent 55%),
    linear-gradient(135deg, #fffdf8 0%, var(--card) 100%);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
}

.fs-eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 6px;
}

.fs-title {
  font-family: var(--font-display);
  font-size: 34px;
  line-height: 1.05;
  font-weight: 400;
  letter-spacing: -.01em;
}

.fs-subtitle {
  margin-top: 8px;
  max-width: 520px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--muted);
}

.fs-header-tools {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}

/* ── Scope switcher ── */
.fs-scope {
  display: inline-flex;
  padding: 4px;
  gap: 2px;
  border-radius: 999px;
  background: rgba(26, 22, 17, .06);
  border: 1px solid var(--line);
}

.fs-scope-btn {
  padding: 8px 16px;
  border-radius: 999px;
  font: 600 13px/1 var(--fs-ui);
  color: var(--ink-soft);
  transition: background .15s var(--fs-ease), color .15s, box-shadow .15s;
}

.fs-scope-btn:hover { color: var(--ink); }

.fs-scope-btn.is-active {
  background: #fff;
  color: var(--accent);
  box-shadow: 0 1px 2px rgba(26, 22, 17, .08), 0 4px 12px -4px rgba(26, 22, 17, .18);
}

/* ── Search ── */
.fs-root .fs-search {
  flex: none;
  flex-direction: row;
  font-family: var(--fs-ui);
  letter-spacing: normal;
  text-transform: none;
  color: var(--ink);
}

.fs-search {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 280px;
  max-width: 100%;
  padding: 0 14px;
  height: 40px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid var(--line);
  transition: border-color .15s, box-shadow .15s;
}

.fs-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(168, 52, 31, .14);
}

.fs-search svg { width: 16px; height: 16px; color: var(--muted); flex-shrink: 0; }

.fs-root .fs-search-input {
  flex: 1;
  width: auto;
  padding: 0;
  border: 0;
  outline: 0;
  box-shadow: none;
  background: transparent;
  font: 14px var(--fs-ui);
  color: var(--ink);
  min-width: 0;
}

/* ── Context line ── */
.fs-context {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 14px 6px 0;
  font-size: 13px;
  color: var(--ink-soft);
}

.fs-context-meta { color: var(--muted); font-size: 12px; }

.fs-readonly {
  margin: 12px 0 0;
  padding: 12px 16px;
  border-radius: 10px;
  background: #fff7e6;
  border: 1px solid #f0d9a8;
  color: #7a5600;
  font-size: 13px;
}

/* ── Body layout ── */
.fs-body {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  gap: 24px;
  margin-top: 20px;
  align-items: start;
}

.fs-nav {
  position: sticky;
  top: 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px;
  border-radius: var(--fs-radius);
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

.fs-nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border-radius: 9px;
  font: 500 13.5px var(--fs-ui);
  color: var(--ink-soft);
  text-align: left;
  transition: background .15s, color .15s;
}

.fs-nav-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 3px;
  background: var(--accent);
  transform: scaleY(0);
  transition: transform .15s var(--fs-ease);
}

.fs-nav-item:hover { background: rgba(26, 22, 17, .045); color: var(--ink); }

.fs-nav-item.is-active {
  background: rgba(168, 52, 31, .08);
  color: var(--accent);
  font-weight: 650;
}

.fs-nav-item.is-active::before { transform: scaleY(1); }

.fs-nav-item .fs-icon { width: 17px; height: 17px; flex-shrink: 0; }
.fs-nav-label { flex: 1; min-width: 0; }

.fs-nav-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(168, 52, 31, .18);
}

.fs-nav-count {
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(26, 22, 17, .08);
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  color: var(--ink-soft);
}

/* ── Section content ── */
.fs-content { animation: fs-fade .18s var(--fs-ease); }

@keyframes fs-fade {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.fs-section-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin: 4px 0 18px;
}

.fs-section-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(168, 52, 31, .14), rgba(168, 52, 31, .04));
  color: var(--accent);
  flex-shrink: 0;
}

.fs-section-icon .fs-icon { width: 20px; height: 20px; }

.fs-section-title {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 400;
  line-height: 1.15;
}

.fs-section-desc { margin-top: 4px; font-size: 13.5px; color: var(--muted); }

.fs-card {
  margin-bottom: 16px;
  border-radius: var(--fs-radius);
  background: #fffdf8;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.fs-card-title {
  padding: 14px 20px 12px;
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(235, 229, 211, .35), transparent);
}

.fs-card--danger { border-color: rgba(139, 42, 26, .35); }
.fs-card--danger .fs-card-title { color: var(--bad); background: rgba(139, 42, 26, .05); }

.fs-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px 20px;
  transition: background .15s;
}

.fs-row + .fs-row { border-top: 1px solid rgba(217, 210, 193, .6); }
.fs-row:hover { background: rgba(245, 241, 232, .6); }
.fs-row.is-dependent-off { opacity: .5; }

.fs-row-text { min-width: 0; flex: 1; }

.fs-row-label {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

.fs-row-desc { margin-top: 3px; font-size: 12.5px; line-height: 1.45; color: var(--muted); }

.fs-row-warn {
  margin-top: 6px;
  padding: 6px 10px;
  border-radius: 7px;
  background: rgba(184, 134, 11, .1);
  color: #7a5600;
  font-size: 12px;
}

.fs-row-control {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.fs-row-reset {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  color: var(--muted);
  transition: background .15s, color .15s;
}

.fs-row-reset:hover { background: rgba(26, 22, 17, .06); color: var(--accent); }
.fs-row-reset svg { width: 14px; height: 14px; }

/* ── Pills ── */
.fs-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .02em;
  line-height: 1.5;
}

.fs-pill--modified { background: rgba(2, 132, 199, .1); color: #0369a1; }
.fs-pill--override { background: rgba(168, 52, 31, .1); color: var(--accent); }
.fs-pill--inherit { background: rgba(26, 22, 17, .06); color: var(--muted); font-weight: 600; }
.fs-pill--unsaved { background: rgba(184, 134, 11, .14); color: #7a5600; }

/* ── Controls ── */
.fs-switch {
  position: relative;
  width: 44px;
  height: 26px;
  border-radius: 999px;
  background: #d6cfbf;
  box-shadow: inset 0 1px 2px rgba(26, 22, 17, .15);
  transition: background .15s var(--fs-ease);
  flex-shrink: 0;
}

.fs-switch-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(26, 22, 17, .3);
  transition: transform .15s var(--fs-ease);
}

.fs-switch.is-on { background: var(--accent); }
.fs-switch.is-on .fs-switch-knob { transform: translateX(18px); }
.fs-switch:focus-visible,
.fs-seg:focus-visible,
.fs-scope-btn:focus-visible,
.fs-nav-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.fs-switch:disabled,
.fs-seg:disabled,
.fs-select:disabled { cursor: not-allowed; opacity: .6; }

.fs-segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: 10px;
  background: rgba(26, 22, 17, .06);
}

.fs-seg {
  padding: 6px 12px;
  border-radius: 8px;
  font: 600 12.5px/1.2 var(--fs-ui);
  color: var(--ink-soft);
  white-space: nowrap;
  transition: background .15s, color .15s, box-shadow .15s;
}

.fs-seg.is-active {
  background: #fff;
  color: var(--accent);
  box-shadow: 0 1px 2px rgba(26, 22, 17, .1);
}

.fs-select-wrap { position: relative; }

.fs-select {
  appearance: none;
  min-width: 200px;
  height: 36px;
  padding: 0 34px 0 12px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b6358' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 12px center;
  font: 500 13.5px var(--fs-ui);
  cursor: pointer;
}

.fs-select:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(168, 52, 31, .14); }

.fs-root .fs-color {
  display: inline-flex;
  flex: none;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  padding: 4px 12px 4px 4px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  font: 600 12.5px var(--font-mono);
  letter-spacing: .02em;
  text-transform: none;
  color: var(--ink-soft);
  cursor: pointer;
}

.fs-color-swatch {
  position: relative;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  box-shadow: inset 0 0 0 1px rgba(26, 22, 17, .15);
  overflow: hidden;
}

.fs-color-swatch input {
  position: absolute;
  inset: -8px;
  width: calc(100% + 16px);
  height: calc(100% + 16px);
  opacity: 0;
  cursor: pointer;
}

body.fs-theme-dark .fs-root .fs-color { background: #1f222a; }

/* ── Content tab effects ── */
body.fs-hide-content-warnings #citation-warnings,
body.fs-hide-content-warnings #figure-warnings,
body.fs-hide-content-warnings #table-warnings,
body.fs-hide-content-warnings #equation-warnings { display: none !important; }
body.fs-editor-compact #art-body .ProseMirror { min-height: 220px; max-height: 45vh; }
body.fs-editor-tall #art-body .ProseMirror { min-height: 560px; max-height: 88vh; }
body.fs-editor-full #art-body .ProseMirror { min-height: 360px; max-height: none; }
body.fs-editor-font-14 #art-body .ProseMirror { font-size: 14px; }
body.fs-editor-font-18 #art-body .ProseMirror { font-size: 18px; }

.fs-root input.fs-text {
  width: 300px;
  max-width: 100%;
  height: 36px;
  margin: 0;
  padding: 0 12px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font: 500 13px var(--fs-ui);
  transition: border-color .15s, box-shadow .15s;
}

.fs-root input.fs-text::placeholder { color: var(--muted); opacity: .7; }
.fs-root input.fs-text:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(168, 52, 31, .14); }
.fs-root input.fs-text.is-invalid { border-color: #b3261e; box-shadow: 0 0 0 3px rgba(179, 38, 30, .12); }
.fs-root input.fs-text:disabled { cursor: not-allowed; opacity: .6; }
.fs-row-error { color: #b3261e; }
body.fs-theme-dark .fs-root input.fs-text { background: #1f222a; }

@media (max-width: 760px) {
  .fs-row--text { flex-direction: column; align-items: stretch; gap: 10px; }
  .fs-row--text .fs-row-control, .fs-root .fs-row--text input.fs-text { width: 100%; }
}

/* ── Buttons ── */
.fs-btn {
  height: 36px;
  padding: 0 16px;
  border-radius: 9px;
  font: 600 13px var(--fs-ui);
  transition: background .15s, border-color .15s, color .15s, transform .1s;
}

.fs-btn:active:not(:disabled) { transform: translateY(1px); }
.fs-btn:disabled { opacity: .55; cursor: not-allowed; }
.fs-btn--primary { background: var(--accent); color: #fff; box-shadow: 0 6px 16px -8px rgba(168, 52, 31, .8); }
.fs-btn--primary:hover:not(:disabled) { background: #922c19; }
.fs-btn--ghost { border: 1px solid var(--line-strong); color: var(--ink); background: #fff; }
.fs-btn--ghost:hover:not(:disabled) { border-color: var(--ink-soft); }
.fs-btn--danger { border: 1px solid rgba(139, 42, 26, .4); color: var(--bad); background: #fff; }
.fs-btn--danger:hover:not(:disabled) { background: var(--bad); color: #fff; }

.fs-link-btn {
  font: 600 13px var(--fs-ui);
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.fs-link-btn:hover { color: var(--accent); }
.fs-section-foot { padding: 4px 4px 12px; text-align: right; }

.fs-empty {
  padding: 32px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--fs-radius);
}

.fs-empty--large { padding: 56px 32px; }
.fs-empty--large .fs-icon { width: 34px; height: 34px; color: var(--accent); margin-bottom: 10px; }
.fs-empty h3 { font-family: var(--font-display); font-weight: 400; font-size: 22px; color: var(--ink); margin-bottom: 6px; }

/* ── Save bar ── */
.fs-savebar {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 500;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 10px 10px 18px;
  border-radius: 14px;
  background: #1a1611;
  color: #fff;
  box-shadow: 0 18px 40px -12px rgba(26, 22, 17, .55);
  transform: translate(-50%, 140%);
  opacity: 0;
  pointer-events: none;
  transition: transform .2s var(--fs-ease), opacity .2s;
}

.fs-savebar.is-visible { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }
.fs-savebar-dot { width: 8px; height: 8px; border-radius: 50%; background: #f5b04c; }
.fs-savebar-count { font-size: 13.5px; font-weight: 600; margin-right: 12px; white-space: nowrap; }
.fs-savebar-actions { display: flex; gap: 8px; }
.fs-savebar .fs-btn--ghost { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .25); }
.fs-savebar .fs-btn--ghost:hover { border-color: #fff; }
.fs-savebar .fs-btn--primary { box-shadow: none; }

/* ── Top-bar Save now ── */
.formatter-save-now {
  height: 32px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: #fff;
  font: 600 12.5px system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--ink);
  transition: background .15s, color .15s, border-color .15s;
}

.formatter-save-now.has-changes { background: var(--accent); border-color: var(--accent); color: #fff; }
.formatter-save-now:disabled { opacity: .6; cursor: progress; }

/* ── Responsive ── */
@media (max-width: 900px) {
  .fs-header { padding: 22px; }
  .fs-header-tools { align-items: stretch; width: 100%; }
  .fs-search { width: 100%; }
  .fs-body { grid-template-columns: 1fr; }
  .fs-nav {
    position: static;
    flex-direction: row;
    overflow-x: auto;
    padding: 6px;
  }
  .fs-nav-item { width: auto; white-space: nowrap; }
  .fs-nav-item::before { display: none; }
  .fs-row { flex-direction: column; align-items: flex-start; gap: 10px; }
  .fs-savebar { left: 12px; right: 12px; transform: translateY(140%); }
  .fs-savebar.is-visible { transform: none; }
}

/* ── Settings-driven interface states ── */
body.fs-hide-hints .card-hint { display: none; }

body.fs-reduce-motion *,
body.fs-reduce-motion *::before,
body.fs-reduce-motion *::after {
  transition: none !important;
  animation: none !important;
  scroll-behavior: auto !important;
}

body.fs-density-compact .card { padding: 14px 16px; }
body.fs-density-compact .card-title { font-size: 1.05rem; margin-bottom: 8px; }
body.fs-density-compact .workspace { gap: 12px; }
body.fs-density-compact .fs-row { padding: 10px 16px; }
body.fs-density-compact .fs-card-title { padding: 10px 16px; }
body.fs-density-compact input,
body.fs-density-compact select,
body.fs-density-compact textarea { font-size: 14px; }

body.fs-theme-dark {
  --paper: #121318;
  --paper-deep: #1a1c22;
  --ink: #ece7dc;
  --ink-soft: #cbc4b6;
  --rule: #3a3d46;
  --accent: #e0694f;
  --accent-soft: #eb8a73;
  --muted: #9a9486;
  --card: #1b1d24;
  --line: #2e313a;
  --line-strong: #454955;
  --shadow-sm: 0 1px 0 rgba(0, 0, 0, .3), 0 4px 12px -6px rgba(0, 0, 0, .5);
  --shadow-md: 0 1px 0 rgba(0, 0, 0, .3), 0 8px 24px -12px rgba(0, 0, 0, .6);
  background-image: none;
  color-scheme: dark;
}

body.fs-theme-dark input,
body.fs-theme-dark select,
body.fs-theme-dark textarea,
body.fs-theme-dark .rich-editor,
body.fs-theme-dark .ProseMirror {
  background-color: #15171d;
  color: var(--ink);
  border-color: var(--line);
}

body.fs-theme-dark .formatter-topbar,
body.fs-theme-dark .workflow-strip { background: #16181e; border-color: var(--line); color: var(--ink); }

body.fs-theme-dark .fs-header { background: radial-gradient(120% 140% at 0% 0%, rgba(224, 105, 79, .14) 0%, transparent 55%), var(--card); }
body.fs-theme-dark .fs-card,
body.fs-theme-dark .fs-search,
body.fs-theme-dark .fs-select,
body.fs-theme-dark .fs-btn--ghost,
body.fs-theme-dark .fs-btn--danger,
body.fs-theme-dark .formatter-save-now { background-color: #1f222a; }
body.fs-theme-dark .fs-scope-btn.is-active,
body.fs-theme-dark .fs-seg.is-active { background: #2a2d36; }
body.fs-theme-dark .fs-row:hover { background: rgba(255, 255, 255, .03); }
body.fs-theme-dark .fs-switch { background: #3a3d46; }
body.fs-theme-dark .fs-switch.is-on { background: var(--accent); }
body.fs-theme-dark .fs-root .fs-search-input { background: transparent; }

body.fs-theme-dark,
body.fs-theme-dark .formatter-main,
body.fs-theme-dark .workspace { background: var(--paper) !important; }
body.fs-theme-dark .card { background: var(--card); color: var(--ink); }
body.fs-theme-dark .card-title,
body.fs-theme-dark .fs-root h1,
body.fs-theme-dark .fs-root h2,
body.fs-theme-dark .fs-root h3 { color: var(--ink); }
body.fs-theme-dark .fs-readonly { background: #2a2414; border-color: #4a3f1f; color: #e8c877; }
body.fs-theme-dark .formatter-save-now.has-changes { background: var(--accent); }

/* Article preview stays on paper so the print layout is judged accurately. */
body.fs-theme-dark #article-preview { color-scheme: light; }
