html[data-layout="compact"] .layout { gap: 6px; padding-inline: 14px; }
html[data-layout="compact"] .grid { grid-template-columns: repeat(auto-fill, minmax(var(--bookmark-compact-min, 170px), 1fr)); gap: var(--bookmark-compact-gap, 8px); }
html[data-layout="compact"] .section { margin-bottom: 20px; }
html[data-layout="compact"] .section + .section { margin-top: 20px; }
html[data-layout="compact"] .section h2 { min-height: 30px; margin-bottom: 9px; font-size: 16px; }
html[data-layout="compact"] .card { min-height: 70px; gap: 9px; padding: 10px; }
html[data-layout="compact"] .ico { width: 34px; height: 34px; flex-basis: 34px; }
html[data-layout="compact"] .ico img { width: 21px; height: 21px; }
html[data-layout="compact"] .card h3 { margin-bottom: 2px; font-size: 13px; }
html[data-layout="compact"] .meta { margin-top: 4px; }

html[data-layout="list"] .grid { grid-template-columns: repeat(var(--bookmark-list-columns, 2), minmax(0, 1fr)); gap: var(--bookmark-compact-gap, 8px); }
html[data-layout="list"] .section { margin-bottom: 20px; }
html[data-layout="list"] .section + .section { margin-top: 20px; }
html[data-layout="list"] .card { min-height: 64px; align-items: center; gap: 10px; padding: 10px 12px; }
html[data-layout="list"] .ico { width: 36px; height: 36px; flex-basis: 36px; }
html[data-layout="list"] .ico img { width: 22px; height: 22px; }
html[data-layout="list"] .card h3,
html[data-layout="list"] .card p { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
html[data-layout="list"] .card h3 { display: block; margin-bottom: 2px; }
html[data-layout="list"] .meta { margin-top: 4px; }

html[data-layout="icons"] .grid { grid-template-columns: repeat(auto-fill, minmax(var(--bookmark-icon-min, 96px), 1fr)); gap: var(--bookmark-compact-gap, 8px); }
html[data-layout="icons"] .section { margin-bottom: 20px; }
html[data-layout="icons"] .section + .section { margin-top: 20px; }
html[data-layout="icons"] .section h2 { min-height: 30px; margin-bottom: 9px; font-size: 16px; }
html[data-layout="icons"] .card {
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-height: 98px;
  padding: 12px 8px 10px;
  text-align: center;
}
html[data-layout="icons"] .card > div:not(.ico) {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}
html[data-layout="icons"] .card h3 { margin: 0; font-size: 12px; }
html[data-layout="icons"] .card p,
html[data-layout="icons"] .card .meta,
html[data-layout="icons"] .card-peek { display: none; }
.choice[data-value="icons"] .layout-swatch { grid-template-columns: repeat(3, 1fr); gap: 3px; }
.choice[data-value="icons"] .layout-swatch i { border-radius: 50%; }

/* Grouped board: each category has its own page size, so large groups cannot hide others. */
html[data-layout="board"] .nav-cols { flex-direction: column; align-self: start; max-height: calc(100vh - 24px); overflow-y: auto; }
html[data-layout="board"] .nav-cols > .nav-col { flex-shrink: 0; width: 100%; max-height: none; }
.board-columns {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
  gap: 14px;
  align-items: start;
  padding-inline: 8px;
}
.board-column.nav-col {
  width: auto;
  min-width: 0;
  max-height: none;
  overflow: visible;
  padding: 14px;
  border-top: 2px solid hsl(var(--h), 55%, 60%);
}
.board-heading { margin: 0; font: inherit; }
.board-heading button {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 2px 0;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  font: inherit;
  cursor: pointer;
}
.board-heading span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.board-heading b { padding: 2px 8px; border: 1px solid var(--stroke); border-radius: 999px; color: var(--muted); font-size: 12px; font-weight: 400; }
/* Top-level columns have no path line, so the heading itself spaces the cards. */
.board-heading + .grid { margin-top: 12px; }
.board-path { margin: 6px 0 14px 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 11px; }
.board-column .grid { grid-template-columns: minmax(0, 1fr); gap: 8px; }
.board-column .card { min-height: 76px; padding: 11px; gap: 10px; }
.board-column .card > div:not(.ico) { min-width: 0; flex: 1; }
.board-column .card p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-column .ico { width: 36px; height: 36px; flex-basis: 36px; }
.board-column .meta { margin-top: 5px; }
.board-column .tag { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-more { width: 100%; margin-top: 10px; padding: 10px 4px; border: 1px dashed var(--stroke); border-radius: 8px; background: transparent; color: var(--text); font: inherit; font-size: 12px; cursor: pointer; }
.board-more span { color: var(--muted); }
.board-more:hover { background: var(--glass); }

/* A bounded sidebar replaces the expanding multi-column navigation only in tree mode. */
.tree-nav.nav-col { width: max-content; min-width: 0; max-width: 240px; }
.tree-caption { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; width: 100%; padding: 5px 8px 12px; border: 0; background: none; color: var(--text); font: inherit; font-size: 13px; text-align: left; cursor: default; }
.tree-caption span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 11px; }
.tree-caption-toggle { display: none; }
.tree-nav ul { list-style: none; padding: 0; margin: 0; }
.tree-row { display: flex; align-items: center; min-width: 0; padding-left: calc(var(--tree-depth) * 12px); }
.tree-all { margin-bottom: 6px; padding-bottom: 6px; border-bottom: 1px solid var(--stroke); }
.tree-toggle, .tree-spacer { width: 24px; height: 30px; flex: 0 0 24px; }
.tree-toggle { display: grid; place-items: center; padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; }
.tree-toggle svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.5; }
.tree-toggle[aria-expanded="true"] svg { transform: rotate(90deg); }
.tree-toggle:hover { color: var(--text); background: var(--glass); }
.tree-label.folder { width: auto; flex: 0 1 auto; min-width: 0; padding: 8px 6px; gap: 7px; }
.tree-label.folder::after { display: none; }
.tree-label.folder b { flex: 0 1 auto; width: auto; min-width: 0; text-align: left; text-align-last: auto; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; font-size: 13px; }
.tree-label.folder span { min-width: 24px; flex-shrink: 0; text-align: center; font-size: 11px; }
.tree-folder-icon { width: 17px; height: 17px; flex: 0 0 17px; color: hsl(var(--h), 55%, 58%); fill: currentColor; fill-opacity: .15; stroke: currentColor; stroke-width: 1.5; stroke-linejoin: round; }
.board-heading button:focus-visible, .board-more:focus-visible, .tree-toggle:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
@media (max-width: 900px) {
  html[data-layout="tree"] .nav-cols { display: block; min-width: 0; }
  .tree-nav.nav-col { max-width: min(240px, 100%); max-height: 260px; }
  html[data-layout="board"] .nav-cols { flex-direction: row; max-height: 260px; }
  html[data-layout="board"] .nav-cols > .nav-col { display: flex; flex-wrap: wrap; gap: 4px; width: 100%; max-height: 180px; }
  html[data-layout="board"] .nav-cols .folder { width: auto; }
}
@media (max-width: 600px) {
  .board-columns { grid-template-columns: minmax(0, 1fr); padding-inline: 0; }
}

/* Horizontal navigation keeps the content width independent of folder depth. */
html:is([data-layout="tabs"], [data-layout="start"], [data-layout="accordion"]) .layout { grid-template-columns: minmax(0, 1fr); gap: 24px; }
html:is([data-layout="tabs"], [data-layout="start"], [data-layout="accordion"]) .nav-cols { position: static; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.horizontal-tabs.nav-col { display: flex; width: 100%; min-width: 0; max-height: none; gap: 6px; overflow-x: auto; padding: 8px; }
.horizontal-tabs .folder, .horizontal-children .folder, .layout-breadcrumbs .folder { width: auto; flex: 0 0 auto; }
.horizontal-tabs .folder b, .horizontal-children .folder b, .layout-breadcrumbs .folder b { width: auto; flex: 0 1 auto; max-width: 18em; text-align: left; text-align-last: auto; }
.horizontal-tabs .folder::after, .horizontal-children .folder::after, .layout-breadcrumbs .folder::after { display: none; }
.horizontal-tabs .folder.on { border-bottom: 2px solid hsl(var(--h), 65%, 60%); }
.horizontal-children { display: flex; gap: 6px; flex-wrap: wrap; }
.horizontal-children .folder { border: 1px solid var(--stroke); font-size: 13px; }
.layout-breadcrumbs { display: flex; align-items: center; flex-wrap: wrap; color: var(--muted); font-size: 12px; gap: 3px; }
.layout-breadcrumbs .folder { padding: 6px 8px; }
.layout-breadcrumbs .folder.on { background: none; box-shadow: none; color: var(--text); }
.horizontal-tabs .folder:focus-visible, .horizontal-children .folder:focus-visible, .layout-breadcrumbs .folder:focus-visible { outline: 2px solid var(--text); outline-offset: -2px; }

/* A centered clock and search form the start page's main landmark. */
html[data-layout="start"] header { --start-clock-size: clamp(52px, 8vw, 96px); --start-clock-space: clamp(12px, 4vh, 48px); position: relative; grid-template-columns: minmax(0, 1fr); gap: 24px; padding: 24px 24px 32px; }
html[data-layout="start"] .tools { position: absolute; right: 24px; top: calc(24px + var(--start-clock-space) + var(--start-clock-size) * .575); transform: translateY(-50%); justify-content: flex-end; }
html[data-layout="start"] .hello { grid-row: 1; justify-self: center; width: 100%; height: auto; flex-wrap: wrap; justify-content: center; gap: 12px 24px; margin-top: var(--start-clock-space); }
html[data-layout="start"] .hello .time { flex-basis: 100%; height: auto; min-width: 0; text-align: center; font-size: var(--start-clock-size); line-height: 1.15; }
html[data-layout="start"] .calendar-dates, html[data-layout="start"] .weather-row { padding-left: 0; border-left: 0; }
html[data-layout="start"] .search { grid-row: 2; grid-column: 1; max-width: 640px; }
html[data-layout="start"] .layout { max-width: 1040px; margin: 0 auto; }
html[data-layout="start"] .horizontal-tabs { width: auto; max-width: 100%; align-self: center; }
html[data-layout="start"] .layout-breadcrumbs, html[data-layout="start"] .horizontal-children { align-self: center; justify-content: center; }
/* Tiles keep a bounded width and center under the clock instead of hugging the left edge. */
html[data-layout="start"] .grid { grid-template-columns: repeat(auto-fit, minmax(var(--bookmark-start-min, 112px), calc(var(--bookmark-start-min, 112px) * 1.3))); justify-content: center; gap: var(--bookmark-grid-gap, 12px); }
html[data-layout="start"] .section { margin-inline: 0; }
html[data-layout="start"] .section h2 { justify-content: center; min-height: 28px; font-size: 14px; margin-bottom: 12px; }
html[data-layout="start"] .card { flex-direction: column; align-items: center; text-align: center; min-height: 112px; padding: 16px 10px; gap: 12px; }
html[data-layout="start"] .card > div:not(.ico) { width: 100%; }
html[data-layout="start"] .card h3 { margin: 0; font-size: 13px; }
html[data-layout="start"] .card p, html[data-layout="start"] .card .meta, html[data-layout="start"] .card-peek { display: none; }
@media (max-width: 1100px) {
  html[data-layout="start"] .tools { position: static; transform: none; grid-row: 1; }
  html[data-layout="start"] .hello { grid-row: 2; }
  html[data-layout="start"] .search { grid-row: 3; }
}
@media (max-width: 600px) {
  html:is([data-layout="tabs"], [data-layout="start"], [data-layout="accordion"]) .layout { padding-inline: 12px; gap: 16px; }
  html[data-layout="start"] header { padding: 16px 12px 24px; gap: 18px; }
  html[data-layout="start"] .tools { justify-content: center; }
  html[data-layout="start"] .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  html[data-layout="start"] .card { min-height: 104px; padding: 12px 6px; }
  .horizontal-tabs .folder b, .horizontal-children .folder b, .layout-breadcrumbs .folder b { max-width: 12em; }
}


/* Category panels collapse independently while retaining each group's page size. */
.accordion-group.nav-col { width: 100%; min-width: 0; max-height: none; overflow: visible; padding: 0; margin-bottom: 12px; }
.accordion-group h2 { margin: 0; font: inherit; }
.accordion-toggle { display: flex; align-items: center; gap: 12px; width: 100%; padding: 16px; border: 0; border-radius: var(--radius); background: transparent; color: var(--text); text-align: left; font: inherit; cursor: pointer; }
.accordion-toggle:hover { background: var(--glass); }
.accordion-toggle:focus-visible { outline: 2px solid var(--text); outline-offset: -3px; }
.accordion-arrow { flex: 0 0 16px; text-align: center; font-size: 24px; line-height: 1; color: hsl(var(--h), 65%, 60%); }
.accordion-toggle[aria-expanded="true"] .accordion-arrow { transform: rotate(90deg); }
.accordion-name { flex: 1; min-width: 0; overflow-wrap: anywhere; font-weight: 600; }
.accordion-count { flex-shrink: 0; color: var(--muted); font-size: 12px; }
.accordion-body { padding: 0 16px 16px; }
.accordion-body[hidden] { display: none; }

/* The additional layouts use a full-width category bar, leaving room for their own structure. */
html:is([data-layout="waterfall"], [data-layout="shelves"], [data-layout="index"], [data-layout="table"], [data-layout="tiles"], [data-layout="split"], [data-layout="text"]) .layout { grid-template-columns: minmax(0, 1fr); gap: 20px; }
html:is([data-layout="waterfall"], [data-layout="shelves"], [data-layout="index"], [data-layout="table"], [data-layout="tiles"], [data-layout="split"], [data-layout="text"]) .nav-cols { position: static; flex-direction: column; min-width: 0; gap: 10px; }

/* Category panels flow down each column instead of sharing the board's row height. */
html[data-layout="waterfall"] .board-columns { display: block; columns: 280px; column-gap: 16px; }
html[data-layout="waterfall"] .board-column { display: inline-block; width: 100%; margin-bottom: 16px; break-inside: avoid; }

.collection-group { min-width: 0; margin: 0 8px 24px; padding-bottom: 20px; border-bottom: 1px solid var(--stroke); }
.collection-heading { margin: 0 0 12px; font-size: 15px; }
.collection-heading button { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; max-width: 100%; padding: 4px 0; border: 0; color: var(--text); background: none; font: inherit; font-weight: 650; text-align: left; overflow-wrap: anywhere; cursor: pointer; }
.collection-heading small { color: var(--muted); font-size: 12px; font-weight: 400; }
.collection-heading button:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
html[data-layout="shelves"] #main .grid { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: minmax(160px, var(--bookmark-card-min, 210px)); align-items: stretch; overflow-x: auto; padding: 8px 4px 14px; scroll-snap-type: x proximity; scrollbar-width: thin; scrollbar-color: var(--muted) transparent; }
html[data-layout="shelves"] #main .grid::-webkit-scrollbar { display: block; height: 6px; }
html[data-layout="shelves"] #main .grid::-webkit-scrollbar-thumb { background: var(--muted); border-radius: 6px; }
html[data-layout="shelves"] #main .bookmark-item { scroll-snap-align: start; }
html[data-layout="shelves"] .collection-group > .board-more { width: auto; min-width: 180px; padding-inline: 16px; }

/* Index and text views retain the same links and pin controls, with no card ornament. */
html:is([data-layout="index"], [data-layout="text"]) #main .card,
html[data-layout="table"] #main .card { min-height: 40px; padding: 10px 30px 10px 8px; align-items: center; border: 0; border-radius: 6px; background: none; box-shadow: none; clip-path: none; transform: none; }
html:is([data-layout="index"], [data-layout="text"], [data-layout="table"]) #main .card:hover { background: var(--glass); }
html:is([data-layout="index"], [data-layout="text"], [data-layout="table"]) #main .card::before,
html:is([data-layout="index"], [data-layout="text"], [data-layout="table"]) #main .card::after,
html:is([data-layout="index"], [data-layout="text"], [data-layout="table"]) #main :is(.card-glow, .card .meta, .card p) { display: none; }
html:is([data-layout="index"], [data-layout="text"], [data-layout="table"]) #main .card h3 { margin: 0; padding-right: 0; font-size: var(--bookmark-card-title, 14px); }
html:is([data-layout="index"], [data-layout="text"], [data-layout="table"]) #main .bookmark-pin { top: 50%; right: 2px; transform: translateY(-50%); }
html[data-layout="index"] .collection-group { display: grid; grid-template-columns: minmax(100px, 160px) minmax(0, 1fr); gap: 10px 20px; align-items: start; padding-block: 14px; margin-bottom: 0; }
html[data-layout="index"] .collection-heading { margin: 4px 0 0; border-left: 3px solid var(--stroke); padding-left: 12px; }
html[data-layout="index"] #main .grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--bookmark-compact-min, 170px)), 1fr)); gap: 4px 16px; }
html[data-layout="index"] #main .ico { width: 20px; height: 20px; flex-basis: 20px; font-size: 12px; }
html[data-layout="index"] #main .ico img { width: 16px; height: 16px; }
html[data-layout="index"] .collection-group > .board-more { grid-column: 2; width: auto; justify-self: start; padding: 6px 12px; }
html[data-layout="text"] .collection-groups { columns: 250px; column-gap: 32px; padding-inline: 8px; }
html[data-layout="text"] .collection-group { display: inline-block; width: 100%; break-inside: avoid; margin-inline: 0; }
html[data-layout="text"] #main .grid { grid-template-columns: minmax(0, 1fr); gap: 0; }
html[data-layout="text"] #main .ico { display: none; }
html[data-layout="text"] #main .card { padding-left: 0; }
html[data-layout="text"] .collection-group > .board-more { text-align: left; border: 0; padding-left: 0; margin-top: 4px; color: var(--muted); }

.bookmark-table-wrap { margin-inline: 8px; overflow-x: auto; scrollbar-width: thin; }
.bookmark-table { width: 100%; min-width: 520px; table-layout: fixed; border-collapse: collapse; font-size: 13px; }
.bookmark-table caption { text-align: left; padding: 0 0 12px; color: var(--muted); font-size: 12px; }
.bookmark-table th { padding: 12px 10px; color: var(--muted); background: var(--glass); text-align: left; font-weight: 600; border-bottom: 1px solid var(--stroke); }
.bookmark-table th:first-child { width: 42%; }
.bookmark-table th:nth-child(2) { width: 26%; }
.bookmark-table td { padding: 4px 10px; border-bottom: 1px solid var(--stroke); overflow-wrap: anywhere; color: var(--muted); }
.bookmark-table td:first-child { color: var(--text); padding-left: 0; }
.bookmark-table tr:hover td { background: var(--glass); }
html[data-layout="table"] #main .ico { width: 26px; height: 26px; flex-basis: 26px; }
html[data-layout="table"] #main .ico img { width: 20px; height: 20px; }

/* All tiles share the same dimensions and follow the density setting. */
html[data-layout="tiles"] #main .grid,
html[data-layout="tiles"] #pinnedGrid { grid-template-columns: repeat(auto-fill, minmax(min(100%, calc(var(--bookmark-start-min, 112px) * 1.2)), 1fr)); grid-auto-rows: minmax(calc(var(--bookmark-card-height, 88px) + 16px), auto); gap: var(--bookmark-grid-gap, 12px); }
html[data-layout="tiles"] :is(#main, #pinnedGrid) .card { height: 100%; min-height: 0; flex-direction: column; justify-content: center; align-items: center; text-align: center; gap: calc(var(--bookmark-card-gap, 12px) / 2); }
html[data-layout="tiles"] :is(#main, #pinnedGrid) .card > div:not(.ico) { flex: 0 1 auto; width: 100%; }
html[data-layout="tiles"] :is(#main, #pinnedGrid) .card h3 { margin: 0; padding-inline: 4px; }
html[data-layout="tiles"] :is(#main, #pinnedGrid) :is(.card p, .card .meta) { display: none; }

@media (min-width: 901px) {
  html[data-layout="split"] .bookmark-content:has(.pinned-shelf:not([hidden])) { display: grid; grid-template-columns: minmax(230px, 300px) minmax(0, 1fr); grid-template-rows: auto auto 1fr; gap: 0 24px; align-items: start; }
  html[data-layout="split"] .pinned-shelf:not([hidden]) { grid-column: 1; grid-row: 1 / 4; position: sticky; top: 12px; max-height: calc(100vh - 24px); overflow-y: auto; margin: 0; padding: 0 18px 16px 0; border-bottom: 0; border-right: 1px solid var(--stroke); }
  html[data-layout="split"] .shelf-heading { align-items: flex-start; flex-direction: column; gap: 8px; }
  html[data-layout="split"] .shelf-heading > span { font-size: 11px; color: var(--muted); }
  html[data-layout="split"] #pinnedGrid { grid-template-columns: minmax(0, 1fr); }
  html[data-layout="split"] .library-toolbar, html[data-layout="split"] .library-status, html[data-layout="split"] #main { grid-column: 2; }
}
@media (max-width: 600px) {
  html[data-layout="index"] .collection-group { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  html[data-layout="index"] .collection-group > .board-more { grid-column: 1; }
  html[data-layout="tiles"] #main .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
