/* Shared control geometry: form fields are filled; navigation and menu actions
   use quiet surfaces. Selection behavior does not change a field's chrome. */
html:root {
  --radius-control: 6px;
  --radius-panel: 8px;
  --control-fill: var(--color-surface-raised);
}
html:root
  :is(
    .btn,
    .icon-btn,
    .rune-close,
    .ms-trigger,
    .field-input,
    .search-input,
    .scope-option,
    .sync-chip,
    .fab-action,
    .mobile-bottom-nav-item
  ) {
  border-radius: var(--radius-control);
}
/* The book frame has ID-scoped navigation rules; apply the same geometry there. */
html:root
  body
  #book-stage
  :is(.btn, .icon-btn, .rune-close, .ms-trigger, .scope-option, .sync-chip, .search-input),
html:root .mobile-bottom-nav .mobile-bottom-nav-item {
  border-radius: var(--radius-control);
}
html:root
  :is(
    .field,
    .grid-control-field,
    .collection-toolbar-popover,
    .bulk-edit-panel,
    .location-index-toolbar,
    .add-details
  )
  :is(
    input:not([type='checkbox']):not([type='radio']):not([type='range']):not([type='hidden']),
    select
  ),
html:root :is(.ms-trigger, .printing-filter-input, .location-combobox > input) {
  box-sizing: border-box;
  min-height: 36px;
  background-color: var(--control-fill);
  color: var(--color-text);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-control);
  padding: 7px 10px;
  box-shadow: none;
  font-family: var(--font-body);
  font-size: var(--font-size-base);
  line-height: 1.25;
}
html:root :is(.field, .grid-control-field, .collection-toolbar-popover, .bulk-edit-panel) select,
html:root .location-combobox > input {
  appearance: none;
  padding-right: 30px;
  background-image: var(--control-chevron);
  background-position: right 11px center;
  background-repeat: no-repeat;
  background-size: 10px 6px;
}
html:root {
  --control-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='m1 1 4 4 4-4' fill='none' stroke='%23746f60' stroke-width='1.4' stroke-linecap='round'/%3E%3C/svg%3E");
}
html:root .ms-trigger::after {
  border: 0;
  width: 10px;
  height: 6px;
  background: var(--control-chevron) center / contain no-repeat;
  transform: none;
}
html:root
  body
  :is(.ui-popover, .collection-toolbar-popover, .ui-modal-card, .deck-details-modal-card),
html:root[data-frame]
  body
  :is(.ui-popover, .collection-toolbar-popover, .ui-modal-card, .deck-details-modal-card) {
  border-radius: var(--radius-panel);
}
html:root body :is(#detailDrawer, .detail-drawer, .ui-drawer),
html:root[data-frame] body :is(#detailDrawer, .detail-drawer, .ui-drawer) {
  border-radius: 0;
}
html:root
  :is(.field, .collection-toolbar-popover, .bulk-edit-panel, .add-details)
  :is(input, select):focus-visible,
html:root .ms-trigger:focus-visible {
  outline: 2px solid var(--color-line-focus);
  outline-offset: 2px;
}
html:root :is(.language-toggle, .condition-toggle) {
  display: inline-flex;
  width: fit-content;
  align-items: stretch;
  overflow: hidden;
  border-radius: var(--radius-control);
  background: var(--control-fill);
}
html:root :is(.language-toggle, .condition-toggle) > label {
  display: flex;
  margin: 0;
  padding: 0;
}
html:root :is(.language-toggle, .condition-toggle) > label > span {
  display: grid;
  place-items: center;
  min-height: 34px;
  box-sizing: border-box;
  padding: 6px 8px;
}
html:root #addEditor :is(.language-row, .language-options, .language-select-wrap) {
  width: 100%;
}
html:root #addEditor .field > label {
  display: block;
  margin: 0 0 6px;
}
html:root .location-combobox {
  display: block;
  width: 100%;
}
html:root .location-combobox > input {
  width: 100%;
}
html:root #addTagsRow {
  border: 1px solid var(--color-line);
  border-radius: var(--radius-control);
  background: var(--control-fill);
  min-height: 36px;
  box-sizing: border-box;
  padding: 5px 10px;
  gap: 6px;
}
html:root #addTagsRow:focus-within {
  outline: 2px solid var(--color-line-focus);
  outline-offset: 2px;
}
html:root #addTagsRow .tag-input {
  background: transparent;
  min-height: 24px;
  outline: none;
  box-shadow: none;
  border-radius: 0;
}
.quantity-input {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-control);
  background: var(--control-fill);
  overflow: hidden;
  width: 132px;
}
html:root #addQty {
  border: 0;
  border-radius: 0;
  width: 52px;
  min-width: 0;
  padding: 6px 0;
  text-align: center;
  appearance: textfield;
}
.quantity-input input::-webkit-inner-spin-button,
.quantity-input input::-webkit-outer-spin-button {
  appearance: none;
  margin: 0;
}
.quantity-input > button {
  width: 38px;
  border: 0;
  background: transparent;
  color: var(--color-text);
  cursor: pointer;
  font: inherit;
}
.quantity-input > button:hover {
  background: var(--color-surface-hover);
}
.quantity-input:focus-within {
  outline: 2px solid var(--color-line-focus);
  outline-offset: 2px;
}
html:root .quantity-input > input:focus-visible {
  outline: none;
}
/* One drawer surface, with a single scrolling content area below its header. */
html:root body .app-right-layer .app-right.ui-drawer {
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
html:root body .app-right-layer .app-right-drawer-handle {
  position: static;
  flex: 0 0 auto;
  margin: 0;
  padding: 10px 16px;
  background: var(--color-bg);
}
html:root body .app-right-layer #addDetails {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  margin: 0;
  padding: 0 16px 16px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  scroll-padding-block: 12px 130px;
}
html:root #addDetails > .details-body {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}
html:root .add-tabs {
  margin-top: 0;
  padding-top: 0;
}
html:root #addEditor .add-actions {
  background: var(--color-bg);
}
/* Top-layer popovers remain attached in the DOM for focus and event ownership. */
html:root .sync-menu[popover] {
  margin: 0;
  max-width: calc(100vw - 16px);
  max-height: calc(100dvh - 16px);
  overflow: auto;
  border-radius: var(--radius-panel);
}
html:root .bulk-edit-panel[popover] {
  margin: 0;
  inset: auto;
  transform: none;
  width: min(640px, calc(100vw - 16px));
  max-height: calc(100dvh - 112px);
  border-radius: var(--radius-panel);
  padding: 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
html:root .bulk-edit-panel-header {
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
html:root .bulk-edit-panel-header > span {
  font-weight: 600;
}
html:root .bulk-edit-dismiss {
  margin: -6px -6px -6px 0;
}
html:root .bulk-action-group {
  border: 0;
  padding: 6px 0;
}
html:root .bulk-action-group-primary,
html:root .bulk-action-group-corrections {
  grid-column: 1 / -1;
}
/* A table is the home default. Gallery cards remain available as a view. */
html:root .location-index-header {
  flex-wrap: wrap;
  gap: 16px;
}
html:root .location-index-toolbar {
  flex-wrap: wrap;
  flex: 0 1 auto;
  max-width: none;
}
html:root .location-index-header > .location-index-identity {
  flex: 1 1 auto;
  width: auto;
}
@media (min-width: 901px) {
  html:root .location-index-toolbar {
    flex-shrink: 0;
  }
}
html:root .location-index-sort-field select {
  min-width: 100px;
  padding-right: 30px;
}
html:root .location-index-sort-field {
  margin: 0;
}
html:root .location-index-compact-toggle {
  flex-shrink: 0;
}
html:root .fab-cluster > details .fab-action {
  border-radius: var(--radius-control);
}
html:root .segmented .segment-btn:first-child {
  border-radius: var(--radius-control) 0 0 var(--radius-control);
}
html:root .segmented .segment-btn:last-child {
  border-radius: 0 var(--radius-control) var(--radius-control) 0;
}
html:root .location-index-toolbar input[type='search'] {
  width: min(220px, 100%);
}
html:root .locations-list.is-table {
  display: block;
}
html:root .is-table > .location-index-create-card {
  min-height: 36px;
  padding: 7px 12px;
  display: inline-flex;
  margin-bottom: 14px;
}
html:root .is-table .location-index-create-icon,
html:root .is-table .location-index-create-copy > span {
  display: none;
}
html:root .is-table .location-index-create-copy strong {
  font: inherit;
}
.location-table-scroll {
  overflow-x: auto;
}
.location-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--font-size-sm);
}
.location-table th {
  text-align: left;
  color: var(--color-text-muted);
  font-weight: 500;
  white-space: nowrap;
}
.location-table :is(th, td) {
  border-bottom: 1px solid var(--color-line);
  padding: 12px 10px;
}
.location-table th button {
  background: none;
  border: 0;
  color: inherit;
  padding: 0;
  font: inherit;
  cursor: pointer;
}
html:root .location-table .location-card {
  display: table-row;
  min-height: 0;
  padding: 0;
  background: transparent;
  box-shadow: none;
  border: 0;
}
html:root .location-table .location-card:hover,
html:root .location-table .location-card.is-drop-target {
  background: var(--color-surface-hover);
  outline: none;
}
.location-table-open {
  display: flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: 0;
  padding: 0;
  color: var(--color-text-strong);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.location-table-cover {
  width: 30px;
  height: 42px;
  object-fit: contain;
  border-radius: 3px;
}
.location-table .location-card-emoji {
  width: 22px;
  height: 22px;
}
.location-table .location-table-number {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.location-order-cell {
  width: 28px;
}
html:root .location-card-reorder {
  cursor: grab;
  opacity: 0.65;
  touch-action: none;
}
.location-card-reorder:active {
  cursor: grabbing;
}
.location-table-actions {
  width: 30px;
  position: relative;
}
html:root .location-table .location-card-menu-btn {
  opacity: 1;
}
html:root .location-table .location-card.editing .location-card-edit-row {
  display: grid;
  margin-top: 12px;
  min-width: 220px;
}
html:root .location-index-grid:not(.is-table) {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
}
html:root .deck-home-card:has(.deck-card-cover) {
  min-height: 188px;
  padding-left: 150px;
}
html:root .deck-home-card .deck-card-cover {
  position: absolute;
  inset: 0 auto 0 0;
  width: 134px;
  height: 100%;
  padding: 0;
  border: 0;
  border-radius: var(--radius-panel) 0 0 var(--radius-panel);
  overflow: hidden;
  background: var(--color-surface-sunken);
}
html:root .deck-home-card .deck-card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 0;
}
html:root .deck-home-card:has(.deck-card-cover) .location-card-head {
  grid-template-columns: minmax(0, 1fr) auto;
}
html:root .deck-home-card:has(.deck-card-cover) .location-card-stats {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
html:root .deck-home-card:has(.deck-card-cover) .location-card-stats > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.deck-card-ownership-status {
  margin: 4px 8px 8px;
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
}
@media (max-width: 600px) {
  html:root .bulk-edit-panel[popover] {
    grid-template-columns: minmax(0, 1fr);
  }
  html:root .location-index-toolbar {
    width: 100%;
    justify-content: flex-start;
  }
  html:root .location-index-toolbar input[type='search'] {
    flex: 1 1 100%;
    width: 100%;
  }
  .location-table :is(th, td) {
    padding: 10px 6px;
  }
}
/* Row menus retain their event ownership without being clipped by table overflow. */
.location-card-menu[popover] {
  position: fixed;
  inset: auto;
  margin: 0;
}
