/* persistent scrollable block list in the right menu zone; clicking a block
   jumps the main grid to it (see BlockSidebar in js/blocksidebar.js). .block-list's
   own flex:1 + overflow-y:auto (base rule) does the actual scrolling, same
   as inside .block-pop-box -- this just needs to be its flex column parent. */
.block-sidebar {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.block-sidebar .block-list {
  grid-template-columns: 1fr;
  padding: 8px;
  gap: 2px;
  flex: 1;
}

.block-sidebar-tabs {
  flex: none;
  display: flex;
  gap: 6px;
  padding: 6px;
}

/* Neumorphic toggle instead of an underline: inactive tabs sit raised (like
   any other button), the active one reads as pressed/recessed in. */
.block-sidebar-tab {
  flex: 1;
  padding: 6px;
  border: none;
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: .8rem;
  box-shadow: 2px 2px 4px var(--neu-dark), -2px -2px 4px var(--neu-light);
  transition: box-shadow .12s, color .12s;
}

.block-sidebar-tab.active {
  color: var(--text);
  font-weight: 600;
  box-shadow: inset 2px 2px 4px var(--neu-dark), inset -2px -2px 4px var(--neu-light);
}

.block-sidebar-empty {
  padding: 24px 16px;
  color: var(--muted);
  font-size: .82rem;
  text-align: center;
  line-height: 1.7;
}

/* plane-jump shortcuts reused in the sidebar's "全て" tab: unlike in the
   modal header (a flex row, where it shares space with the close button),
   here it's a block-column child and must not grow to fill the list's space */
.block-sidebar .plane-jump {
  flex: none;
  padding: 8px;
}

/* drag-to-reorder feedback in the favorites tab */
.block-item.dragging {
  opacity: .4;
}

.block-item.drag-over {
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
}

/* color-mode toggle embedded in the legend (right column), so it appears
   everywhere the legend does (the shared bar above the tabs, and the block
   picker popup) */
.colormode-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  padding-left: 10px;
}

.colormode-label {
  color: var(--muted);
  font-size: .78rem;
  margin-right: 2px;
  white-space: nowrap;
}

.legend-items {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* only the block picker modal keeps the legend horizontal (wraps across
   multiple items per row) -- it has the width to spare, unlike the narrow
   left menu zone bar where the vertical list lives normally. */
.block-pop-box .legend-items {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 12px 24px;
}

/* fixed width per item so wrapped rows line up into neat columns instead of
   each item's width following its (Japanese vs. English) label length.
   Widened from 128px now that ja/en sit on one row instead of stacked. */
.block-pop-box .legend-item {
  width: 148px;
  flex: none;
}

/* Only the block picker's legend is clickable (filters the list below to
   that group) -- the left menu's legend is a separate Legend instance with
   no click handler wired up. */
.block-pop-box .legend-item:not(.legend-none) {
  cursor: pointer;
  border-radius: 6px;
  padding: 2px 4px;
  margin: -2px -4px;
}

.block-pop-box .legend-item:not(.legend-none):hover {
  background: color-mix(in srgb, var(--text) 12%, transparent);
}

.block-pop-box .legend-item.legend-active {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  outline: 1px solid var(--accent);
}

.block-pop-box .legend-label {
  min-width: 0;
  flex: 1;
}

.block-pop-box .legend-ja {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.block-pop-box .legend-en {
  flex: none;
  white-space: nowrap;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: .72rem;
  color: var(--muted);
}

.legend-none {
  font-style: italic;
}

/* legend items: English shown small to the right of the Japanese, on the
   same line -- saves vertical space over the old stacked layout, which
   mattered more once items got wider gaps (see block-legend/attr-legend
   above). */
.legend-label {
  display: flex;
  flex-direction: row;
  align-items: baseline;
  gap: 4px;
  min-width: 0;
  line-height: 1.2;
}

.legend-label .legend-ja {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: .72rem;
}

.legend-label .legend-en {
  flex: none;
  font-size: .62rem;
}

/* other (non-legend) uses of .legend-en stay inline, e.g. the character
   detail modal's "文字の種類"/"追加時期" rows */
.legend-en {
  font-size: .64rem;
  opacity: .75;
}

.swatch {
  display: inline-block;
  flex: none;
  width: .6rem;
  height: .6rem;
  border-radius: 3px;
  background: var(--grp-color, var(--muted));
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .25);
}

.swatch[data-group="letter"] {
  --grp-color: var(--grp-letter);
}

.swatch[data-group="mark"] {
  --grp-color: var(--grp-mark);
}

.swatch[data-group="number"] {
  --grp-color: var(--grp-number);
}

.swatch[data-group="punct"] {
  --grp-color: var(--grp-punct);
}

.swatch[data-group="symbol"] {
  --grp-color: var(--grp-symbol);
}

.swatch[data-group="emoji"] {
  --grp-color: var(--grp-emoji);
}

.swatch[data-group="separator"] {
  --grp-color: var(--grp-separator);
}

.swatch[data-group="control"] {
  --grp-color: var(--grp-control);
}

.swatch[data-group="format"] {
  --grp-color: var(--grp-format);
}

.swatch[data-group="surrogate"] {
  --grp-color: var(--grp-surrogate);
}

.swatch[data-group="private"] {
  --grp-color: var(--grp-private);
}

.swatch[data-group="unassigned"] {
  --grp-color: var(--grp-unassigned);
}

.swatch[data-group="e1"] {
  --grp-color: var(--era-e1);
}

.swatch[data-group="e2"] {
  --grp-color: var(--era-e2);
}

.swatch[data-group="e3"] {
  --grp-color: var(--era-e3);
}

.swatch[data-group="e4"] {
  --grp-color: var(--era-e4);
}

.swatch[data-group="e5"] {
  --grp-color: var(--era-e5);
}

.swatch[data-group="e6"] {
  --grp-color: var(--era-e6);
}

.swatch[data-group="e7"] {
  --grp-color: var(--era-e7);
}

.swatch[data-group="e8"] {
  --grp-color: var(--era-e8);
}

.swatch[data-group="e9"] {
  --grp-color: var(--era-e9);
}

.swatch[data-group="e10"] {
  --grp-color: var(--era-e10);
}

.swatch[data-group="e11"] {
  --grp-color: var(--era-e11);
}

.swatch[data-group="e12"] {
  --grp-color: var(--era-e12);
}

.swatch[data-group="e13"] {
  --grp-color: var(--era-e13);
}

.swatch[data-group="e14"] {
  --grp-color: var(--era-e14);
}

.swatch[data-group="e15"] {
  --grp-color: var(--era-e15);
}

.swatch[data-group="e16"] {
  --grp-color: var(--era-e16);
}

.swatch[data-group="e17"] {
  --grp-color: var(--era-e17);
}

/* 2D palette: many blocks per row instead of one long vertical list. */
.block-list {
  list-style: none;
  margin: 0;
  padding: 0 8px 8px;
  overflow-y: auto;
  flex: 1;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  align-content: start;
}

.plane-header {
  grid-column: 1 / -1;
  padding: 12px 4px 4px;
  margin-top: 4px;
  border-top: 1px solid var(--border);
  font-size: .74rem;
  font-weight: 700;
  color: var(--muted);
}

.plane-header:first-child {
  margin-top: 0;
  border-top: none;
}

.plane-header[hidden] {
  display: none;
}

/* row layout: name on the left, sample glyphs on the right -- saves
   vertical space over stacking them, which matters since this list (both
   the modal's and the sidebar's) can get long */
.block-item {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 7px;
  cursor: pointer;
  border: 1px solid transparent;
  min-width: 0;
  background: color-mix(in srgb, var(--grp-color, transparent) 10%, transparent);
}

.block-item-head {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  flex: 1 1 auto;
}

.block-item-samples {
  display: flex;
  flex: none;
  gap: 6px;
  margin-left: auto;
  font-family: var(--font-glyph);
}

/* star shown only for blocks favorited via right-click (see openBlockFavMenu
   in js/blockheader.js); invisible otherwise so it doesn't clutter every row */
.block-item-fav {
  flex: none;
  margin-left: auto;
  opacity: 0;
  color: var(--fav);
  font-size: .8rem;
}

.block-item.is-fav .block-item-fav {
  opacity: 1;
}

.sample-glyph {
  font-size: 1.1rem;
  line-height: 1;
  color: var(--text);
  opacity: .85;
}

.block-item:hover {
  border-color: var(--border);
  background: color-mix(in srgb, var(--grp-color, transparent) 20%, var(--panel-2));
}

.block-item.active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 16%, transparent);
}

.block-item[hidden] {
  display: none;
}

.block-item[data-group="letter"] {
  --grp-color: var(--grp-letter);
}

.block-item[data-group="mark"] {
  --grp-color: var(--grp-mark);
}

.block-item[data-group="number"] {
  --grp-color: var(--grp-number);
}

.block-item[data-group="punct"] {
  --grp-color: var(--grp-punct);
}

.block-item[data-group="symbol"] {
  --grp-color: var(--grp-symbol);
}

.block-item[data-group="emoji"] {
  --grp-color: var(--grp-emoji);
}

.block-item[data-group="separator"] {
  --grp-color: var(--grp-separator);
}

.block-item[data-group="control"] {
  --grp-color: var(--grp-control);
}

.block-item[data-group="format"] {
  --grp-color: var(--grp-format);
}

.block-item[data-group="surrogate"] {
  --grp-color: var(--grp-surrogate);
}

.block-item[data-group="private"] {
  --grp-color: var(--grp-private);
}

.block-item[data-group="unassigned"] {
  --grp-color: var(--grp-unassigned);
}

.block-item[data-group="e1"] {
  --grp-color: var(--era-e1);
}

.block-item[data-group="e2"] {
  --grp-color: var(--era-e2);
}

.block-item[data-group="e3"] {
  --grp-color: var(--era-e3);
}

.block-item[data-group="e4"] {
  --grp-color: var(--era-e4);
}

.block-item[data-group="e5"] {
  --grp-color: var(--era-e5);
}

.block-item[data-group="e6"] {
  --grp-color: var(--era-e6);
}

.block-item[data-group="e7"] {
  --grp-color: var(--era-e7);
}

.block-item[data-group="e8"] {
  --grp-color: var(--era-e8);
}

.block-item[data-group="e9"] {
  --grp-color: var(--era-e9);
}

.block-item[data-group="e10"] {
  --grp-color: var(--era-e10);
}

.block-item[data-group="e11"] {
  --grp-color: var(--era-e11);
}

.block-item[data-group="e12"] {
  --grp-color: var(--era-e12);
}

.block-item[data-group="e13"] {
  --grp-color: var(--era-e13);
}

.block-item[data-group="e14"] {
  --grp-color: var(--era-e14);
}

.block-item[data-group="e15"] {
  --grp-color: var(--era-e15);
}

.block-item[data-group="e16"] {
  --grp-color: var(--era-e16);
}

.block-item[data-group="e17"] {
  --grp-color: var(--era-e17);
}

.block-item-name {
  min-width: 0;
  line-height: 1.25;
}

.block-item .name-ja {
  display: block;
  font-size: .82rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.block-item .name-en {
  display: block;
  font-size: .66rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.block-item-range {
  display: block;
  font-size: .6rem;
  color: var(--muted);
  opacity: .75;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

