/* The Settings page. Colours, buttons, cells, menus, header and footer come from app.css; this file only adds
   what is new here and the few places where this page differs. */
:root { --hover-alt: #eaf0f9; --checked: #edf2fb; --f-blue: #2f57a0; --f-green: #1e7a46; --f-purple: #7a4fb5;
  --f-grey: #9aa3b2; --f-all: #5d6676; --f-pinned: #b8911f; }
@media (prefers-color-scheme: dark) {
  :root { --hover-alt: #222935; --checked: #1f2738; --f-blue: #8db3f2; --f-green: #6bcb8f; --f-purple: #c9a3f2;
    --f-grey: #4e5765; --f-all: #9ba4b0; --f-pinned: #f1d58a; }
}
.settings { font-size: 14px; line-height: 1.4; min-height: 100vh; display: flex; flex-direction: column; }
.settings button { cursor: pointer; }
.settings svg { flex: none; }
.sprite { position: absolute; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.settings .bar-inner { width: 100%; justify-content: flex-start; }
.topbar-link { color: #fff; text-decoration: none; min-height: 44px; display: inline-flex; align-items: center; gap: 6px; }
.topbar-link:hover { color: #fff; }
.settings .bar :focus-visible { outline-color: #fff; }
.page-status { margin: 48px auto; padding: 0 16px; color: var(--muted); }
.page-status:empty { display: none; }

/* page layout */
.settings .layout { display: flex; flex-wrap: wrap; gap: 32px; align-items: flex-start; width: 100%; margin: 0 auto;
  padding-top: 32px; padding-bottom: 32px; flex: 1; align-content: flex-start; }
.content { flex: 999 1 760px; min-width: 0; }
.settings-section { display: flex; flex-direction: column; gap: 16px; }

/* settings menu (collapsible) */
.settings-nav { flex: 1 1 180px; max-width: 220px; display: flex; flex-direction: column; gap: 16px; }
.settings-nav-head { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.settings-nav-head h1 { margin: 0; font-size: 26px; font-weight: 600; flex: 1; }
.nav-toggle { width: 40px; height: 40px; border: 1px solid var(--grid-strong); border-radius: var(--radius-sm);
  background: transparent; display: flex; align-items: center; justify-content: center; color: var(--ink-soft); }
.nav-toggle:hover { background: var(--hover-alt); }
.nav-list { display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 12px;
  border-radius: var(--radius-sm); text-decoration: none; font-weight: 500; color: var(--ink-soft); }
.nav-item:hover { background: var(--hover-alt); color: var(--tab-active); }
.nav-item[aria-current="page"] { background: var(--bar); color: var(--tab-active); }
.nav-label { flex: 1; }
.nav-count { font-size: 12px; color: var(--muted); }
.settings-nav.is-collapsed { flex: none; width: 44px; }
.settings-nav.is-collapsed h1, .settings-nav.is-collapsed .nav-label, .settings-nav.is-collapsed .nav-count { display: none; }
.settings-nav.is-collapsed .nav-item { padding: 0; justify-content: center; }
.nav-toggle .arrow-closed, .settings-nav.is-collapsed .nav-toggle .arrow-open { display: none; }
.settings-nav.is-collapsed .nav-toggle .arrow-closed { display: inline; }

/* section head */
.section-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.section-head h2 { margin: 0; font-size: 22px; font-weight: 600; outline: none; }
.section-head p { margin: 4px 0 0; color: var(--muted); }
.section-title { min-width: 260px; }
.search { flex: 0 1 260px; display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px;
  border: 1px solid var(--grid-strong); border-radius: var(--radius-sm); background: var(--card-alt); }
.search svg { color: var(--muted); }
.search:focus-within { outline: 2px solid var(--link); outline-offset: -1px; }
.search input { border: 0; background: transparent; width: 100%; outline: none; }
#page-error { margin: 0; }

.work { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.card { background: var(--paper); border: 1px solid var(--grid); border-radius: var(--radius); }

/* folders */
.folders { flex: 1 1 180px; max-width: 200px; padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.folder-list { display: grid; gap: 2px; }
.folder-row { position: relative; }
.folder { width: 100%; display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 10px; border: 0;
  border-radius: var(--radius-sm); background: transparent; color: var(--ink-soft); text-align: left; }
.folder:hover { background: var(--hover-alt); }
.folder[aria-pressed="true"] { background: var(--bar); color: var(--tab-active); font-weight: 600; }
.folder.is-drop-target { outline: 2px dashed var(--link); outline-offset: -2px; }
.settings .swatch { width: 10px; height: 10px; border-radius: 3px; background: var(--f-grey); }
.settings .swatch.sm { width: 7px; height: 7px; border-radius: 2px; }
.settings .swatch.f-blue { background: var(--f-blue); } .settings .swatch.f-green { background: var(--f-green); }
.settings .swatch.f-purple { background: var(--f-purple); } .settings .swatch.f-grey { background: var(--f-grey); }
.settings .swatch.f-all { background: var(--f-all); } .settings .swatch.f-pinned { background: var(--f-pinned); }
.folder-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.folder-count { font-size: 12px; font-weight: 400; color: var(--muted); }
.folder-more { position: absolute; right: 4px; top: 4px; opacity: 0; }
.folder-row:hover .folder-more, .folder-row:focus-within .folder-more, .folder-more[aria-expanded="true"] { opacity: 1; }
.folder-row.has-menu:hover .folder-count, .folder-row.has-menu:focus-within .folder-count { visibility: hidden; }
@media (hover: none) { .folder-more { opacity: 1; } .folder-row.has-menu .folder { padding-right: 40px; }
  .folder-row.has-menu .folder-count { visibility: visible !important; } }
.folder-input { height: 40px; }
.new-folder { margin-top: 6px; min-height: 38px; border: 1px dashed var(--grid-strong); border-radius: var(--radius-sm);
  background: transparent; color: var(--muted); }
.new-folder:hover { color: var(--ink); border-color: var(--muted); }
.folders .hint { margin: 6px 8px 4px; font-size: 12px; color: var(--muted); line-height: 1.5; }

/* table */
.table-card { flex: 999 1 360px; min-width: 0; overflow: hidden; }
.bulk { display: flex; align-items: center; gap: 8px; padding: 8px 12px 8px 16px; background: var(--bar); flex-wrap: wrap; }
.bulk-count { font-weight: 600; flex: 1; }
.btn-ghost, .btn-danger { min-height: 32px; padding: 0 10px; border: 1px solid var(--grid-strong); border-radius: 6px; background: transparent; }
.btn-danger { border-color: var(--bad-line); color: var(--bad); }
.btn-ghost:hover { background: var(--hover-alt); }
.btn-danger:hover { background: var(--bad-bg); }
.settings .icon-btn { width: 32px; height: 32px; border-radius: 6px; color: var(--ink-soft); }
.settings .panel-head .icon-btn { width: 36px; height: 36px; }
.t-head, .t-row { display: grid; grid-template-columns: 36px minmax(0, 1fr) 88px; gap: 8px; align-items: center; padding: 2px 16px 2px 12px; }
.t-head { padding-top: 10px; padding-bottom: 10px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--divider); }
.t-right { text-align: right; }
.t-row { border-bottom: 1px solid var(--divider); }
.t-row:hover { background: var(--hover); }
.t-row.is-checked { background: var(--checked); }
.t-row[aria-selected="true"] { background: var(--hover-alt); box-shadow: inset 3px 0 0 var(--gold); }
.t-row.is-dragging { opacity: .5; }
.t-check { width: 18px; height: 18px; margin: 0 0 0 4px; accent-color: var(--primary); }
.t-open { min-width: 0; display: flex; align-items: center; gap: 8px; border: 0; background: none; text-align: left; padding: 6px 0; min-height: 44px; }
.t-text { min-width: 0; display: flex; flex-direction: column; }
.t-name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-meta { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; min-width: 0; }
.pin { color: var(--gold); }
.t-used { color: var(--muted); font-size: 13px; text-align: right; }
.empty { margin: 0; padding: 24px 16px; color: var(--muted); }

/* detail panel */
.settings .panel { flex: 1 1 320px; max-width: 360px; margin: 0; padding: 0; border-radius: var(--radius); font-size: inherit;
  border-color: var(--input-line); display: flex; flex-direction: column; }
.settings .panel a { font-weight: inherit; }
.panel-head { padding: 16px 12px 16px 18px; border-bottom: 1px solid var(--divider); display: flex; gap: 12px; align-items: center; }
.panel-icon { width: 40px; height: 40px; border-radius: 10px; background: var(--input); color: var(--gold); display: flex;
  align-items: center; justify-content: center; flex: none; }
.panel-title { flex: 1; min-width: 0; }
.panel-name { font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel-block { padding: 16px 18px; border-bottom: 1px solid var(--divider); display: flex; flex-direction: column; gap: 14px; }
.panel-block:last-child { border-bottom: 0; }
.versions-block { gap: 4px; }
.settings .panel .btn-primary { min-height: 42px; display: flex; align-items: center; justify-content: center; border: 0;
  border-radius: var(--radius-sm); background: var(--primary); color: #fff; text-decoration: none; font-weight: 600; }
.settings .panel .btn-primary:hover { background: var(--primary-hover); }
.label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.settings .cell { padding: 0 10px; }
.panel .cell { height: 38px; font-size: 14px; }
.panel textarea.cell { height: auto; padding: 8px 10px; resize: vertical; }
.cell:focus { outline: 2px solid var(--link); outline-offset: -1px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 32px; cursor: pointer; }
.check input { width: 18px; height: 18px; flex: none; accent-color: var(--primary); }
.save-note { font-size: 12px; min-height: 18px; color: var(--muted); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.save-note.ok { color: var(--ok); } .save-note.bad { color: var(--bad); }
.versions-head { display: flex; align-items: center; gap: 8px; }
.versions-head span:first-child { flex: 1; font-size: 12px; color: var(--muted); }
.pill-pro { font-size: 11px; font-weight: 700; letter-spacing: .06em; color: var(--gold); border: 1px solid var(--input-line);
  padding: 1px 7px; border-radius: 999px; }
.versions { list-style: none; margin: 0 !important; padding: 0 !important; max-height: 280px !important; overflow: auto; }
.version { display: flex; align-items: center; gap: 8px; min-height: 38px; border-bottom: 1px solid var(--divider); font-size: 13px; }
.version span:first-child { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.version .current { font-size: 12px; color: var(--ok); display: inline; }
.upsell { margin: 4px 0 0 !important; font-size: 13px; color: var(--muted); }
.settings .upsell a { color: var(--link); }
.btn-sm { min-height: 30px; padding: 0 10px; border: 1px solid var(--grid-strong); border-radius: 6px; background: transparent; font-size: 12px; }
.btn-sm:hover { background: var(--hover-alt); }
.settings .actions { flex-direction: row; flex-wrap: wrap; align-items: stretch; gap: 8px; }
.actions .btn-outline, .actions .btn-danger { min-height: 36px; padding: 0 12px; border-radius: 6px; font-size: 13px; }
.actions .btn-outline { font-weight: 400; }

@media (max-width: 720px) {
  .settings .layout { padding-left: 16px; padding-right: 16px; gap: 20px; }
  .settings-nav, .folders, .settings .panel { max-width: none; flex-basis: 100%; }
  .settings-nav.is-collapsed { width: auto; flex: 1 1 100%; }
  .settings-nav.is-collapsed .nav-list { flex-direction: row; flex-wrap: wrap; }
  .settings-nav.is-collapsed .nav-item { width: 44px; }
  .content, .table-card { flex-basis: 100%; }
  .search { flex: 1 1 100%; }
  .settings .actions { width: auto; justify-content: flex-start; }
}
