/* Bento Shelf — layout and shelf chrome.
   Rules from docs/SPEC.md §10: uniform gap and radius, outlines never borders,
   no drop shadows, everything honours prefers-reduced-motion via --motion. */

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Author `display` rules (notably the dock buttons) otherwise beat the UA
   stylesheet's `[hidden] { display: none }`. Every hidden control must really
   be gone, not merely marked hidden. */
[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  height: 100vh;
  background: var(--surface);
  color: var(--fg);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

h1 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* ------------------------------------------------------------------- top bar */

/* No lines: the chrome floats over the wallpaper. */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
}

/* The logo is an SVG asset; the same file feeds the PWA icons. */
.brand__mark {
  width: 18px;
  height: 18px;
  display: block;
  border-radius: 5px;
}

.topbar__ops {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status {
  margin-right: 6px;
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--fg-muted);
}

.status[data-state="ok"] {
  color: var(--accent);
}

.status[data-state="error"] {
  color: var(--danger);
}

.chip {
  height: 28px;
  padding: 0 11px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  outline: 1px solid var(--guide-square);
  outline-offset: -1px;
  color: var(--fg-muted);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: background var(--motion), color var(--motion);
}

.chip:hover:not(:disabled) {
  background: var(--surface-raised);
  color: var(--fg);
}

.chip:disabled {
  opacity: 0.35;
  cursor: default;
}

.chip.is-on {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--fg);
  outline-color: var(--accent);
}

/* --------------------------------------------------------------------- stage */

/* The bento canvas is its own layer, full viewport, under the floating docks. */
.stage {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  padding: 0;
}

/* The only horizontal scroller in the app. */
.viewport {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  /* When the shelf is wider than the screen, `safe` keeps its left edge
     reachable instead of clipping both sides to centre it. */
  justify-items: safe center;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0;
  scrollbar-width: thin;
}

.shelf-frame {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--gap);
  width: max-content;
  min-width: 100%;
  padding-inline: 32px;
}

.viewport[data-orientation="vertical"] {
  /* `safe` keeps a zoomed shelf reachable from the left instead of clipping. */
  place-items: start safe center;
  overflow-x: auto;
  overflow-y: auto;
  padding: 0;
}

.shelf {
  position: relative;
  flex: 0 0 auto;
  border-radius: var(--radius);
}

/* A vertical space stacks its 4×4 squares downwards, one screen each. */
.shelf-frame[data-orientation="vertical"] {
  flex-direction: column;
  width: auto;
  min-width: 0;
  justify-content: flex-start;
  align-items: center;
  margin-inline: auto;
  /* Starts at the top and leaves room for whichever docks are present. */
  padding: var(--dock-top, 16px) 0 var(--dock-bottom, 24px);
}

/* The shelf-end add buttons are just a plus: no circle, no chrome. */
.add-end {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--fg-muted);
  font: inherit;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.45;
  transition: opacity var(--motion), color var(--motion);
}

.add-end:hover,
.add-end:focus-visible {
  opacity: 1;
  color: var(--fg);
}

/* -------------------------------------------------------------------- blocks */

.block {
  position: absolute;
  border-radius: var(--radius);
  background: var(--surface-raised);
  outline: var(--dash);
  outline-offset: -1px;
  cursor: grab;
  touch-action: none;
  transition:
    left var(--motion) ease-out,
    top var(--motion) ease-out,
    width var(--motion) ease-out,
    height var(--motion) ease-out,
    background var(--motion);
}

.block:hover {
  background: color-mix(in srgb, var(--surface-raised) 94%, white 6%);
}

.block:focus-visible {
  outline: 2px solid var(--accent);
}

.block.is-selected {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  z-index: 2;
}

.block.is-dragging {
  cursor: grabbing;
  transition: none;
  z-index: 3;
}

.block.is-returning {
  transition: transform 180ms cubic-bezier(0.2, 0.8, 0.3, 1);
}

/* FLIP: a shifted block starts at its old position and glides home. */
.block.is-flipping {
  transition: transform 180ms cubic-bezier(0.2, 0.8, 0.3, 1);
}

.block.is-resizing {
  outline-color: var(--accent);
}



/* Empty space: a dashed box you can fill with a copy of its neighbour. */
.gap {
  position: absolute;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  outline: 1px dashed color-mix(in srgb, var(--fg) 20%, transparent);
  outline-offset: -1px;
  color: var(--fg-muted);
  font: inherit;
  cursor: pointer;
  transition:
    background var(--motion),
    outline-color var(--motion),
    color var(--motion);
}

.gap:hover,
.gap:focus-visible {
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  outline-color: var(--accent);
  color: var(--fg);
}

.gap__plus {
  font-size: 17px;
  line-height: 1;
  opacity: 0.65;
}

/* Handles only exist on the selected block (rendered conditionally). */
.handle {
  position: absolute;
  z-index: 5;
}

.handle--e {
  top: 0;
  right: -3px;
  width: 10px;
  height: 100%;
  cursor: ew-resize;
}

.handle--s {
  left: 0;
  bottom: -3px;
  width: 100%;
  height: 10px;
  cursor: ns-resize;
}

.handle--se {
  right: -5px;
  bottom: -5px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  cursor: nwse-resize;
}

/* -------------------------------------------------------------------- ghosts */

.ghost {
  position: absolute;
  z-index: 6;
  border-radius: var(--radius);
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  pointer-events: none;
}

.ghost[data-valid="false"] {
  outline-color: var(--danger);
  background: color-mix(in srgb, var(--danger) 14%, transparent);
}

/* -------------------------------------------------------------- empty shelf */

.ghost-square {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 4px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  outline: var(--dash);
  outline-offset: -1px;
  color: var(--fg-muted);
  font: inherit;
  cursor: pointer;
  transition: background var(--motion), color var(--motion);
}

.ghost-square:hover,
.ghost-square:focus-visible {
  background: var(--surface-raised);
  color: var(--fg);
}

.ghost-square__plus {
  font-size: 22px;
  line-height: 1;
}

.ghost-square__hint {
  font-size: 11px;
  letter-spacing: 0.02em;
}

/* -------------------------------------------------------------------- picker */

.layer {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
}

.backdrop {
  position: absolute;
  inset: 0;
  pointer-events: auto;
}

.picker {
  position: absolute;
  width: 336px;
  padding: 12px;
  display: grid;
  gap: 10px;
  border-radius: var(--radius);
  background: var(--surface-raised);
  outline: 1px solid var(--guide-square);
  outline-offset: -1px;
  pointer-events: auto;
}

.picker--gap {
  width: 336px;
}

.picker--gap .picker__grid {
  max-height: 430px;
  gap: 5px;
}

.picker--gap .picker__item {
  grid-template-rows: auto auto auto;
  align-content: start;
  padding: 8px 4px 6px;
  gap: 3px;
}

.picker__group {
  grid-column: 1 / -1;
  margin: 7px 0 1px;
  padding-left: 2px;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-muted);
  opacity: 0.75;
}

.picker__group:first-child {
  margin-top: 0;
}

.picker__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
}

.picker__fit {
  color: var(--fg-muted);
  font-size: 11px;
}

.picker__search {
  height: 30px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--surface);
  outline: 1px solid var(--guide);
  outline-offset: -1px;
  color: var(--fg);
  font: inherit;
  font-size: 12px;
}

.picker__search:focus {
  outline: 1px solid var(--accent);
}

.picker__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  max-height: 306px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.picker__item {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 10px 6px 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  outline: 1px solid transparent;
  outline-offset: -1px;
  color: var(--fg-muted);
  font: inherit;
  cursor: pointer;
  transition: background var(--motion), color var(--motion), outline-color var(--motion);
}

.picker__item:hover,
.picker__item.is-active {
  background: var(--surface);
  outline-color: var(--guide-square);
  color: var(--fg);
}

.picker__item.is-active {
  outline-color: var(--accent);
}

.picker__name {
  font-size: 11px;
  line-height: 1.2;
  text-align: center;
}

.picker__slots {
  font-size: 10px;
  opacity: 0.6;
}

.picker__empty {
  grid-column: 1 / -1;
  margin: 8px 0;
  font-size: 11px;
  color: var(--fg-muted);
  text-align: center;
}

.picker__foot {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--fg-muted);
  font-size: 10px;
}

.picker__foot kbd {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--surface);
  outline: 1px solid var(--guide);
  outline-offset: -1px;
  font-family: inherit;
  font-size: 10px;
}

/* ------------------------------------------------------------------- thumbs */

.thumb {
  position: relative;
  display: block;
  border-radius: 6px;
  background: color-mix(in srgb, var(--fg) 4%, transparent);
}

.thumb__cell {
  position: absolute;
  border-radius: 3px;
  background: color-mix(in srgb, var(--fg) 18%, transparent);
}

.picker__item.is-active .thumb__cell,
.picker__item:hover .thumb__cell {
  background: color-mix(in srgb, var(--accent) 55%, transparent);
}

/* --------------------------------------------------------------------- menu */

.menu {
  position: absolute;
  min-width: 168px;
  padding: 5px;
  display: grid;
  gap: 2px;
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  outline: 1px solid var(--guide-square);
  outline-offset: -1px;
  pointer-events: auto;
}

.menu__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  height: 30px;
  padding: 0 9px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}

.menu__item span {
  color: var(--fg-muted);
  font-size: 10px;
}

.menu__item:hover,
.menu__item:focus-visible {
  background: var(--surface);
  outline: none;
}

.menu__item--danger {
  color: var(--danger);
}

/* ------------------------------------------------------------------- toasts */

.toasts {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  display: grid;
  gap: 6px;
  justify-items: center;
  pointer-events: none;
  z-index: 60;
}

.toast {
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--surface-raised);
  outline: 1px solid var(--guide-square);
  outline-offset: -1px;
  color: var(--fg);
  font-size: 12px;
  animation: toast-in 160ms ease-out;
}

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

@media (prefers-reduced-motion: reduce) {
  .toast {
    animation: none;
  }
}


/* --------------------------------------------------------------------- docks */

.dock {
  position: fixed;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 999px;
  background: var(--surface-raised);
  outline: 1px solid var(--guide);
  outline-offset: -1px;
  max-width: min(92vw, 720px);
  overflow-x: auto;
  scrollbar-width: none;
}

.dock::-webkit-scrollbar {
  display: none;
}

.dock--spaces {
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
}

/* A vertical space keeps the shelf column away from the docks by turning them
   into side rails: spaces on the left, space and account controls on the right.
   Narrow screens keep the phone toolbar below instead. */
@media (min-width: 721px) {
  body[data-orientation="vertical"] .dock--spaces {
    top: 50%;
    bottom: auto;
    left: 14px;
    right: auto;
    transform: translateY(-50%);
    flex-direction: column;
    max-width: none;
    max-height: calc(100vh - 48px);
    overflow-x: hidden;
    overflow-y: auto;
    border-radius: 28px;
  }

  /* The account dock stacks its icons at the top right. Reversing keeps the
     avatar in the corner, exactly where it sits in the horizontal dock. */
  body[data-orientation="vertical"] .dock--account {
    top: 14px;
    right: 16px;
    flex-direction: column-reverse;
  }

  /* One width for both rails: the signed-in avatar is 32px by default and would
     make the account dock two pixels wider than the space dock. */
  body[data-orientation="vertical"] .dock--account .avatar.is-signed-in {
    width: 30px;
    min-width: 30px;
  }

  /* The space dock hangs from the bottom right, name at the bottom, and its
     controls open upwards as a column instead of a wide row. */
  body[data-orientation="vertical"] .dock--space {
    top: auto;
    bottom: 14px;
    right: 16px;
    left: auto;
    transform: none;
    flex-direction: column-reverse;
  }

  body[data-orientation="vertical"] .dock--space .space-dock__controls {
    grid-template-columns: 1fr;
    grid-template-rows: 0fr;
    transition:
      grid-template-rows var(--dock-motion) var(--dock-ease),
      opacity calc(var(--dock-motion) * 0.62) ease,
      visibility 0s linear var(--dock-motion);
  }

  body[data-orientation="vertical"] .dock--space:hover .space-dock__controls,
  body[data-orientation="vertical"] .dock--space:has(:focus-visible) .space-dock__controls,
  body[data-orientation="vertical"] .dock--space.is-open .space-dock__controls,
  body[data-orientation="vertical"] .dock--space.is-editing .space-dock__controls {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
  }

  /* No space name on the vertical rail: it widens the dock over the shelf.
     The ellipsis stays as the expand affordance and the pill keeps a 40px
     footprint. */
  body[data-orientation="vertical"] .dock--space .space-dock__name {
    width: 30px;
    min-width: 30px;
    padding: 0;
    justify-content: center;
  }

  body[data-orientation="vertical"] .dock--space #space-name {
    display: none;
  }

  body[data-orientation="vertical"] .dock--space .space-dock__hint,
  body[data-orientation="vertical"] .dock--space:hover .space-dock__hint,
  body[data-orientation="vertical"] .dock--space:has(:focus-visible) .space-dock__hint,
  body[data-orientation="vertical"] .dock--space.is-open .space-dock__hint,
  body[data-orientation="vertical"] .dock--space.is-editing .space-dock__hint {
    max-width: none;
    opacity: 1;
  }

  body[data-orientation="vertical"] .dock--space .space-dock__controls-inner {
    flex-direction: column;
    min-height: 0;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    scrollbar-width: none;
    transform: none;
  }

  body[data-orientation="vertical"] .dock--space .space-dock__controls-inner::-webkit-scrollbar {
    display: none;
  }

  body[data-orientation="vertical"]:not([data-surface="display"]) .shelf-frame {
    padding: 16px 72px;
  }
}

/* Two top docks, split by ownership: the space's controls in the centre and
   the account/app settings on the right. */
.dock--space {
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
}

.dock--account {
  top: 14px;
  right: 16px;
}

.space-dock__name {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  padding: 0 8px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--fg);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--motion);
}

.space-dock__name:hover {
  background: var(--surface);
}

.space-dock__name > span:first-child {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  /* Tie the space name to its icon in the bottom dock, mixed with the text
     colour so the tint stays readable in both themes. */
  color: color-mix(in srgb, var(--space-color, var(--fg)) 74%, var(--fg) 26%);
}

.space-dock__hint {
  display: inline-block;
  max-width: 14px;
  overflow: hidden;
  color: var(--fg-muted);
  font-size: 13px;
  line-height: 1;
  opacity: 1;
  transition:
    max-width var(--dock-motion) var(--dock-ease),
    opacity var(--motion) ease;
}

/* Collapsed by default in view mode; hover, focus, a tap (`.is-open`) or edit
   mode reveals the controls. The shelf never moves: the dock overlays it.
   A 0fr → 1fr grid track animates to the controls' real width, so the easing
   is fully used instead of finishing early at an arbitrary max-width. */
.space-dock__controls {
  display: grid;
  grid-template-columns: 0fr;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    grid-template-columns var(--dock-motion) var(--dock-ease),
    opacity calc(var(--dock-motion) * 0.62) ease,
    visibility 0s linear var(--dock-motion);
}

.space-dock__controls-inner {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
  transform: translateX(-4px);
  transition: transform var(--dock-motion) var(--dock-ease);
}

.dock--space:hover .space-dock__controls,
.dock--space:has(:focus-visible) .space-dock__controls,
.dock--space.is-open .space-dock__controls,
.dock--space.is-editing .space-dock__controls {
  grid-template-columns: 1fr;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition:
    grid-template-columns var(--dock-motion) var(--dock-ease),
    opacity calc(var(--dock-motion) * 0.7) ease 30ms,
    visibility 0s;
}

.dock--space:hover .space-dock__controls-inner,
.dock--space:has(:focus-visible) .space-dock__controls-inner,
.dock--space.is-open .space-dock__controls-inner,
.dock--space.is-editing .space-dock__controls-inner {
  transform: none;
}

/* The ellipsis is only an affordance for the collapsed pill. Once the controls
   are showing (hover, focus, tap or edit) it fades and collapses away. */
.dock--space:hover .space-dock__hint,
.dock--space:has(:focus-visible) .space-dock__hint,
.dock--space.is-open .space-dock__hint,
.dock--space.is-editing .space-dock__hint {
  max-width: 0;
  opacity: 0;
}

/* Edit is for editing: sharing, exporting and the details dialog are view
   actions. Leave edit to reach them. */
.dock--space.is-editing #share-space,
.dock--space.is-editing #export-space,
.dock--space.is-editing #space-details {
  display: none;
}

.dock__action--badge {
  position: relative;
}

.dock__badge {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--surface);
  font-size: 9px;
  line-height: 15px;
  text-align: center;
}

.dialog--notifications {
  width: min(92vw, 440px);
}

.notice-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 4px;
  max-height: min(56vh, 420px);
  overflow-y: auto;
}

.notice-prefs {
  padding: 6px 10px;
  border-radius: 10px;
  background: var(--surface);
  font-size: 11px;
  color: var(--fg-muted);
}

.notice-prefs summary {
  cursor: pointer;
}

.notice-prefs__grid {
  display: grid;
  gap: 4px;
  padding-top: 6px;
}

.notice-prefs label {
  display: flex;
  align-items: center;
  gap: 6px;
}

.notice-push {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--guide);
}

.notice-push span {
  display: grid;
  gap: 2px;
}

.notice-push__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.notice-push strong {
  font-size: 11px;
  color: var(--fg);
}

.notice-push small {
  font-size: 10px;
  color: var(--fg-muted);
}

.notice {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
}

.notice.is-unread {
  outline: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: -1px;
}

.notice strong {
  display: block;
  font-size: 12px;
}

.notice p {
  margin: 1px 0 0;
  color: var(--fg-muted);
  font-size: 11px;
}

.notice small {
  color: var(--fg-muted);
  font-size: 10px;
  white-space: nowrap;
}

.dock__action {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: transparent;
  color: var(--fg-muted);
  cursor: pointer;
  transition: background var(--motion), color var(--motion), opacity var(--motion);
}

.dock__action:hover:not(:disabled) {
  background: var(--surface);
  color: var(--fg);
}

.dock__action:disabled {
  opacity: 0.3;
  cursor: default;
}

.dock__action[aria-pressed="true"] {
  color: var(--fg);
  background: color-mix(in srgb, var(--accent) 20%, transparent);
}

#mode-toggle {
  position: relative;
}

#mode-toggle [data-icon] {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  opacity: 0;
  transform: scale(0.7) rotate(-12deg);
  transition:
    opacity var(--motion) ease,
    transform var(--dock-motion) var(--dock-ease);
}

#mode-toggle [data-icon="edit"] {
  opacity: 1;
  transform: none;
}

#mode-toggle[aria-pressed="true"] [data-icon="edit"] {
  opacity: 0;
  transform: scale(0.7) rotate(12deg);
}

#mode-toggle[aria-pressed="true"] [data-icon="done"] {
  opacity: 1;
  transform: none;
}

.dock__space,
.dock__add {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--motion), outline-color var(--motion), opacity var(--motion);
}

.dock__space {
  color: #10131a;
  background: color-mix(in srgb, var(--space-color) 82%, white 18%);
  outline: 2px solid transparent;
  outline-offset: 1px;
}

.dock__space:hover {
  transform: translateY(-2px);
}

.dock__space.is-current {
  outline-color: var(--space-color);
  outline-offset: 2px;
}

.dock__add {
  background: transparent;
  color: var(--fg-muted);
  outline: var(--dash);
  outline-offset: -1px;
}

.dock__add:hover {
  color: var(--fg);
  background: var(--surface);
}

/* ------------------------------------------------------------------- avatar */

.avatar {
  width: 30px;
  min-width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--surface-raised);
  outline: 1px solid var(--guide-square);
  outline-offset: -1px;
  color: var(--fg);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: background var(--motion);
}

.avatar:hover {
  background: var(--surface);
}

.avatar.is-signed-in {
  width: 32px;
  min-width: 32px;
  padding: 0;
  font-weight: 600;
  background: color-mix(in srgb, var(--accent) 24%, var(--surface-raised));
  outline-color: color-mix(in srgb, var(--accent) 60%, transparent);
}

/* --------------------------------------------------------------- dialogs */

.dialog {
  width: min(92vw, 380px);
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: var(--surface-raised);
  color: var(--fg);
  outline: 1px solid var(--guide-square);
  outline-offset: -1px;
}

.dialog::backdrop {
  background: rgba(6, 8, 12, 0.62);
  backdrop-filter: blur(2px);
}

/* Overlay close: the card has no footer Close button. */
.dialog__close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--surface);
  color: var(--fg-muted);
  font: inherit;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.dialog__close:hover {
  background: var(--surface-raised);
  color: var(--fg);
}

.dialog__form {
  display: grid;
  gap: 12px;
  padding: 18px;
  max-height: min(90vh, 720px);
  overflow: auto;
}

.dialog__form h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.dialog__note,
.dialog__name {
  margin: 0;
  font-size: 12px;
  color: var(--fg-muted);
  line-height: 1.45;
}

.dialog__name {
  font-size: 14px;
  color: var(--fg);
}

.dialog__error {
  margin: 0;
  min-height: 14px;
  font-size: 12px;
  color: var(--danger);
}

.dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.field {
  display: grid;
  gap: 5px;
  font-size: 11px;
  color: var(--fg-muted);
}

.field--row {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.field input {
  height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--surface);
  outline: 1px solid var(--guide);
  outline-offset: -1px;
  color: var(--fg);
  font: inherit;
  font-size: 13px;
}

.field input[type="color"] {
  width: 44px;
  padding: 2px;
  cursor: pointer;
}

.field input:focus {
  outline: 1px solid var(--accent);
}

.link-button {
  justify-self: start;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--fg-muted);
  font: inherit;
  font-size: 12px;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.link-button:hover {
  color: var(--fg);
}

.chip--primary {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  color: var(--fg);
  outline-color: var(--accent);
}

.chip--danger {
  color: var(--danger);
  outline-color: color-mix(in srgb, var(--danger) 40%, transparent);
}

/* One full-width account action, big enough to be the only button in the
   account state. The dialog closes by clicking outside or Escape. */
.chip--block {
  flex: 1 1 100%;
  width: 100%;
  height: 44px;
  font-size: 13px;
}

/* ------------------------------------------------------------------ view mode */

.shelf[data-mode="view"] .block {
  outline: none;
  background: transparent;
  cursor: default;
}

/* In view mode an empty box disappears, but a filled one keeps its surface:
   the widget's size is part of the layout and should stay readable. */
.shelf[data-mode="view"] .block.is-filled {
  background: var(--surface-raised);
}

/* The shelf is an interface, not a document: no text selection in either mode,
   so a double-click on a plus or a label never highlights half the board.
   Links and buttons stay clickable; real inputs stay selectable. */
.shelf-frame {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.shelf-frame :is(input, textarea, select, [contenteditable="true"]) {
  user-select: text;
  -webkit-user-select: text;
}

/* View mode is not an editor: no grab cursor and no hover lift. */
.shelf[data-mode="view"] .block.is-filled:hover {
  background: var(--surface-raised);
}

.shelf[data-mode="view"] .widget-host,
.shelf[data-mode="view"] .block.is-filled:active .widget-host {
  cursor: default;
}

.shelf[data-mode="view"] .block:hover {
  background: transparent;
}

/* --------------------------------------------------------------- wallpapers */

:root {
  --wallpaper-none: none;
  --wallpaper-aurora: linear-gradient(135deg, #1b2a4a 0%, #3b1d5a 48%, #0d1b2a 100%);
  --wallpaper-dusk: linear-gradient(160deg, #3a1c2c 0%, #16121e 58%, #0b0d12 100%);
  --wallpaper-forest: linear-gradient(150deg, #10251c 0%, #0d1b16 55%, #070d0b 100%);
  --wallpaper-ember: linear-gradient(140deg, #3a1a12 0%, #1d0f0c 55%, #0b0806 100%);
  --wallpaper-sea: linear-gradient(150deg, #0f2a33 0%, #0a1820 60%, #060b10 100%);
  --wallpaper-mono: linear-gradient(160deg, #23262c 0%, #121418 60%, #0a0b0d 100%);
}

body[data-wallpaper]:not([data-wallpaper="none"])::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: var(--wallpaper) center / cover no-repeat;
}

body[data-wallpaper]:not([data-wallpaper="none"])::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: var(--wallpaper-veil);
}

/* Content sits above the wallpaper. Never touch `position` here: `.topbar`,
   `.stage` and `.layer` are fixed layers and a later `position: relative` would
   silently destroy them (this happened twice). */
.topbar,
.stage {
  z-index: 1;
}

/* ------------------------------------------------------------- space dialog */

.wallpaper {
  display: grid;
  gap: 6px;
}

.wallpaper__label {
  font-size: 11px;
  color: var(--fg-muted);
}

.swatches {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.swatch {
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background-color: var(--surface);
  background-image: var(--swatch, none);
  outline: 1px solid var(--guide);
  outline-offset: 1px;
  cursor: pointer;
  transition: outline-color var(--motion), transform var(--motion);
}

.swatch:hover {
  transform: translateY(-1px);
}

.swatch.is-active {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.upload {
  display: grid;
  gap: 4px;
  font-size: 11px;
  color: var(--fg-muted);
  cursor: pointer;
}

.upload input {
  font-size: 11px;
  color: var(--fg-muted);
}

/* ------------------------------------------------------------- widget slots */

.block.is-filled {
  --w-accent: var(--accent);
  border-radius: var(--widget-radius);
  outline: 1px solid color-mix(in srgb, var(--fg) 6%, transparent);
  outline-offset: -1px;
  background:
    radial-gradient(120% 90% at 0% 0%,
      color-mix(in srgb, var(--w-accent) 16%, transparent),
      transparent 62%),
    var(--surface-raised);
  cursor: default;
}

.block.is-filled:hover {
  outline-color: color-mix(in srgb, var(--fg) 11%, transparent);
}

html[data-theme="light"] .block.is-filled {
  background:
    radial-gradient(120% 90% at 0% 0%,
      color-mix(in srgb, var(--w-accent) 22%, transparent),
      transparent 64%),
    var(--surface-raised);
}

/* One accent per widget type, used only as a tonal wash (Material color role). */
.block.is-filled[data-kind="weather"] { --w-accent: #6aa4ff; }
.block.is-filled[data-kind="sun"] { --w-accent: #f5b34a; }
.block.is-filled[data-kind="air"] { --w-accent: #46cbb4; }
.block.is-filled[data-kind="markets"] { --w-accent: #5ecb8b; }
.block.is-filled[data-kind="crypto"] { --w-accent: #f2964a; }
.block.is-filled[data-kind="holidays"] { --w-accent: #b18cff; }
.block.is-filled[data-kind="feed"] { --w-accent: #7c9cff; }
.block.is-filled[data-kind="countdown"] { --w-accent: #ff8fa3; }
.block.is-filled[data-kind="dice"] { --w-accent: #ffcf7c; }
.block.is-filled[data-kind="units"] { --w-accent: #8ee0b0; }
.block.is-filled[data-kind="note"] { --w-accent: #ffcf7c; }
.block.is-filled[data-kind="links"] { --w-accent: #9ad1ff; }
.block.is-filled[data-kind="stat"] { --w-accent: #7c9cff; }
.block.is-filled[data-kind="progress"] { --w-accent: #8ee0b0; }
.block.is-filled[data-kind="image"] { --w-accent: #9aa3b2; }
.block.is-filled[data-kind="qr"] { --w-accent: #c7ccd6; }
.block.is-filled[data-kind="gree"] { --w-accent: #6fd3d0; }

/* Space-level choice from Edit space: auto, neutral, or one colour for all. */
html[data-widget-tint="none"] .block.is-filled {
  background: var(--surface-raised);
}

html[data-widget-tint="custom"] .block.is-filled[data-kind] {
  --w-accent: var(--space-widget-tint, var(--accent));
}

.block.is-drag-source {
  opacity: 0.35;
}

.block.is-drop-ok {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.block.is-drop-no {
  outline: 2px solid var(--danger);
  outline-offset: -1px;
  opacity: 0.5;
}

/* Adding a widget to a container is a plus, not a circled button. */
.block__plus {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 48px;
  height: 48px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--fg-muted);
  font: inherit;
  font-size: 30px;
  font-weight: 300;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity var(--motion), color var(--motion);
}

.block:hover .block__plus,
.block.is-selected .block__plus {
  opacity: 1;
  color: var(--fg);
}

.block__plus:hover {
  color: var(--accent);
}

.widget-host {
  position: absolute;
  inset: 0;
  padding: var(--widget-pad);
  display: grid;
  overflow: hidden;
  border-radius: inherit;
  cursor: grab;
  touch-action: none;
}

.block.is-filled:active .widget-host {
  cursor: grabbing;
}

.widget-ghost {
  position: fixed;
  z-index: 80;
  transform: translate(-50%, -50%);
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--surface-raised);
  outline: 1px solid var(--accent);
  outline-offset: -1px;
  color: var(--fg);
  font-size: 12px;
  pointer-events: none;
}

/* ---------------------------------------------------------------- widgets */

.wg {
  position: relative;
  display: grid;
  align-content: center;
  gap: 0.4615em;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  color: var(--fg);
  font-size: 1em;
  line-height: 1.25;
}

.wg small {
  font-size: 0.55em;
  color: var(--fg-muted);
}

.wg-stat__value--muted {
  color: var(--fg-muted);
  font-size: 0.72em;
}

/* clock */
.wg-clock {
  align-content: center;
  gap: 0;
}

.wg-clock__time {
  font-size: clamp(1.5385em, 34cqmin, 3.2308em);
  font-weight: 600;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

.wg-clock__date {
  font-size: 0.8462em;
  color: var(--fg-muted);
}

.wg-clock[data-size="1x1"] .wg-clock__date {
  display: none;
}

.wg-clock[data-size="1x1"] .wg-clock__time {
  font-size: 1.3846em;
}

.wg-clock[data-size="4x2"] .wg-clock__time {
  font-size: 4.3077em;
}

/* stat */
.wg-stat {
  align-content: center;
}

.wg-stat__label {
  font-size: 0.7692em;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-muted);
}

.wg-stat__value {
  font-size: clamp(1.3846em, 26cqmin, 2.6154em);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.wg-stat[data-size="1x1"] .wg-stat__label {
  display: none;
}

.wg-stat[data-size="1x1"] .wg-stat__value {
  font-size: 1.5385em;
}

/* note */
.wg-note {
  align-content: start;
}

.wg-note__text {
  margin: 0;
  font-size: 0.9231em;
  line-height: 1.45;
  color: var(--fg);
  opacity: 0.9;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 6;
  -webkit-box-orient: vertical;
}

.wg-note[data-size="1x1"] .wg-note__text {
  -webkit-line-clamp: 2;
  font-size: 0.7692em;
}

/* links */
.wg-links {
  align-content: start;
}

.wg-links__list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.3846em;
}

.wg-links__list a {
  color: var(--fg);
  font-size: 0.9231em;
  text-decoration: none;
  opacity: 0.85;
}

.wg-links__list a:hover {
  color: var(--accent);
  opacity: 1;
}

.wg-links[data-size="4x2"] .wg-links__list {
  grid-template-columns: 1fr 1fr;
}

/* image / photo frame */
.wg-image,
.wg-frame {
  align-content: stretch;
}

.wg-image__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: calc(var(--widget-radius) - 0.6154em);
}

.wg-image__empty {
  align-self: center;
  justify-self: center;
  font-size: 0.8462em;
  color: var(--fg-muted);
}

.wg-frame {
  position: relative;
  display: block;
}

.wg-frame__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: calc(var(--widget-radius) - 0.6154em);
  opacity: 0;
  transition: opacity 700ms ease;
}

.wg-frame__img.is-active {
  opacity: 1;
}

.wg-frame__empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 0.8462em;
  color: var(--fg-muted);
}

/* progress */
.wg-progress {
  align-content: center;
  gap: 0.4615em;
}

.wg-progress__label {
  font-size: 0.7692em;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-muted);
}

.wg-progress__value {
  font-size: 1.5385em;
  font-weight: 600;
}

.wg-progress__track {
  display: block;
  height: 0.3846em;
  border-radius: 999px;
  background: color-mix(in srgb, var(--fg) 12%, transparent);
  overflow: hidden;
}

.wg-progress__bar {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--accent);
}

/* countdown */
.wg-count {
  align-content: center;
}

.wg-count__label {
  font-size: 0.7692em;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
}

.wg-count__value {
  font-size: clamp(1.3846em, 26cqmin, 2.3077em);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.wg-count__hint {
  font-size: 0.7692em;
  color: var(--fg-muted);
}

.wg-count[data-size="1x1"] .wg-count__hint {
  display: none;
}

/* clock */
.wg-clock__label {
  font-size: 0.7692em;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
}

.wg-clock__zone {
  display: flex;
  align-items: baseline;
  gap: 0.4615em;
  font-size: 0.8462em;
  color: var(--fg-muted);
}

.wg-clock__zone-label {
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.wg-clock__zone-time {
  font-variant-numeric: tabular-nums;
  color: var(--fg);
  opacity: 0.8;
}

.wg-clock[data-size="1x1"] .wg-clock__label,
.wg-clock[data-size="1x1"] .wg-clock__date {
  display: none;
}

/* weather */
.wg-weather {
  align-content: center;
}

.wg-weather__label {
  font-size: 0.7692em;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
}

.wg-weather__value {
  font-size: clamp(1.5385em, 28cqmin, 2.6154em);
  font-weight: 600;
}

.wg-weather__summary {
  font-size: 0.8462em;
  color: var(--fg-muted);
}

.wg-weather[data-size="1x1"] .wg-weather__label,
.wg-weather[data-size="1x1"] .wg-weather__range,
.wg-weather[data-size="1x1"] .wg-weather__feels {
  display: none;
}

.wg-weather__range {
  font-size: 0.8462em;
  color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
}

.wg-weather__days {
  margin: 0.3077em 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.1538em;
}

.wg-weather__day {
  display: flex;
  justify-content: space-between;
  gap: 0.6154em;
  font-size: 0.7692em;
  color: var(--fg-muted);
}

.wg-weather__day-range {
  font-variant-numeric: tabular-nums;
}

.wg-weather__feels {
  font-size: 0.7692em;
  color: var(--fg-muted);
}

.wg-weather[data-size="2x1"] .wg-weather__days,
.wg-weather[data-size="2x1"] .wg-weather__feels {
  display: none;
}

/* A 2x2 cannot hold two forecast days plus the feels line without clipping. */
.wg-weather[data-size="2x2"] .wg-weather__feels,
.wg-weather[data-size="2x2"] .wg-weather__day:nth-child(2) {
  display: none;
}

.wg-weather[data-size="2x2"] { gap: 0.3077em; }

/* feed */
.wg-feed {
  align-content: start;
  gap: 0.4615em;
}

.wg-feed__label {
  font-size: 0.7692em;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wg-feed__hint {
  margin: 0;
  font-size: 0.8462em;
  color: var(--fg-muted);
}

.wg-feed__list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.3077em;
  min-height: 0;
  overflow: hidden;
}

.wg-feed__item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6154em;
  min-width: 0;
}

.wg-feed__title {
  color: var(--fg);
  font-size: 0.8462em;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0.9;
}

.wg-feed__title:hover {
  color: var(--accent);
  opacity: 1;
}

.wg-feed__time {
  flex: none;
  font-size: 0.7692em;
  color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
}

.wg-feed[data-size="4x2"] .wg-feed__list {
  grid-template-columns: 1fr 1fr;
  column-gap: 1.0769em;
}

/* markets */
.wg-markets {
  align-content: start;
  gap: 0.4615em;
}

.wg-markets__label {
  font-size: 0.7692em;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
}

.wg-markets__hint {
  margin: 0;
  font-size: 0.8462em;
  color: var(--fg-muted);
}

.wg-markets__list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.2308em;
}

.wg-markets__row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: baseline;
  gap: 0.6154em;
  font-size: 0.8462em;
}

.wg-markets__symbol {
  font-weight: 600;
  letter-spacing: 0.04em;
}

.wg-markets__price {
  text-align: right;
  font-variant-numeric: tabular-nums;
  opacity: 0.9;
}

.wg-markets__change {
  min-width: 3.5385em;
  text-align: right;
  font-size: 0.7692em;
  font-variant-numeric: tabular-nums;
  color: var(--fg-muted);
}

.wg-markets__change.is-up {
  color: #3ba55d;
}

.wg-markets__change.is-down {
  color: #e05a4f;
}

.wg-markets__more {
  font-size: 0.7692em;
  color: var(--fg-muted);
}

/* widget picker */
.widget-glyph {
  display: grid;
  place-items: center;
  width: 2.6154em;
  height: 2.6154em;
  border-radius: 0.7692em;
  background: color-mix(in srgb, var(--fg) 8%, transparent);
  font-size: 1.1538em;
  color: var(--fg-muted);
}

.picker--widgets .picker__grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* Container queries need a container; the host is the box. */
.widget-host {
  container-type: size;
  container-name: box;
}

.wg-mount {
  display: grid;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}


/* ------------------------------------------------------------- API tokens */

.dialog--tokens {
  width: min(94vw, 540px);
}

.token-create {
  display: grid;
  gap: 8px;
  padding: 10px;
  border-radius: 12px;
  background: var(--surface);
}

.token-create .field {
  margin: 0;
}

.token-create .chip {
  justify-self: start;
}

.token-secret {
  display: grid;
  gap: 6px;
  padding: 10px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
}

.token-secret__row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.token-secret code {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 11px;
}

.token-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
  max-height: min(40vh, 300px);
  overflow-y: auto;
}

.token {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--surface);
}

.token span {
  display: grid;
  min-width: 0;
}

.token strong {
  font-size: 12px;
}

.token small {
  color: var(--fg-muted);
  font-size: 10px;
  overflow-wrap: anywhere;
}

.consent {
  display: grid;
  gap: 0.7692em;
  padding: 1.0769em;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface-raised));
  outline: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: -1px;
}

.consent h3 {
  margin: 0;
}


.people__permissions {
  color: var(--accent);
  opacity: 0.9;
}

/* ------------------------------------------------------------ settings fields */

.segmented {
  display: flex;
  gap: 4px;
  padding: 3px;
  border-radius: 999px;
  background: var(--surface);
  outline: 1px solid var(--guide);
  outline-offset: -1px;
}

.segmented button {
  flex: 1;
  height: 26px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--fg-muted);
  font: inherit;
  font-size: 11px;
  cursor: pointer;
  transition: background var(--motion), color var(--motion);
}

.segmented button:hover {
  color: var(--fg);
}

.segmented button.is-active {
  background: var(--surface-raised);
  color: var(--fg);
  outline: 1px solid var(--guide-square);
  outline-offset: -1px;
}

.segmented--zoom {
  display: grid;
  grid-template-columns: 42px minmax(64px, 1fr) 42px;
  align-items: center;
}

.segmented--zoom button {
  height: 30px;
  padding: 0;
  font-size: 15px;
}

.segmented--zoom output {
  text-align: center;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--fg);
}

.zoom-preview {
  display: grid;
  place-items: center;
  height: 92px;
  margin-top: 8px;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--surface);
  outline: 1px solid var(--guide);
  outline-offset: -1px;
}

.zoom-preview__stage {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 4px;
  width: 220px;
  height: 72px;
  transform-origin: center;
  transition: transform var(--motion) ease;
}

.zoom-preview__block {
  border-radius: 4px;
  background: color-mix(in srgb, var(--accent) 32%, transparent);
  outline: 1px solid color-mix(in srgb, var(--accent) 44%, transparent);
  outline-offset: -1px;
}

.field select {
  height: 32px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--surface);
  outline: 1px solid var(--guide);
  outline-offset: -1px;
  color: var(--fg);
  font: inherit;
  font-size: 12px;
}

/* ------------------------------------------------------------------ shared view */

body[data-view="shared"] .topbar,
body[data-view="shared"] .dock--spaces,
body[data-view="shared"] #account-dock {
  display: none;
}

/* A shared view keeps the space name for context, nothing else. */
body[data-view="shared"] .space-dock__controls,
body[data-view="shared"] .space-dock__hint {
  display: none;
}

body[data-view="shared"] .space-dock__name {
  cursor: default;
  pointer-events: none;
}

.lock[hidden] {
  display: none;
}

.lock {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(6px);
}

.lock__card {
  display: grid;
  gap: 10px;
  width: min(88vw, 300px);
  padding: 22px;
  border-radius: var(--radius);
  background: var(--surface-raised);
  outline: 1px solid var(--guide-square);
  outline-offset: -1px;
  text-align: center;
}

.lock__eyebrow {
  margin: 0;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-muted);
}

.lock__card h2 {
  margin: 0;
  font-size: 18px;
}

.lock__hint {
  margin: 0;
  font-size: 12px;
  color: var(--fg-muted);
}

.lock__card input {
  height: 38px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--surface);
  outline: 1px solid var(--guide);
  outline-offset: -1px;
  color: var(--fg);
  font: inherit;
  font-size: 18px;
  letter-spacing: 0.2em;
  text-align: center;
}

.lock__card input:focus {
  outline-color: var(--accent);
}

/* --------------------------------------------------------------- people dialog */

.dialog--wide {
  width: min(94vw, 520px);
}

.dialog--wide .dialog__form {
  max-height: 84vh;
  overflow-y: auto;
}

.people__section {
  display: grid;
  gap: 8px;
}

.people__section h3 {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--fg-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.people__list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
}

.people__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  outline: 1px solid var(--guide);
  outline-offset: -1px;
}

.people__item span {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.people__item small {
  font-size: 10px;
  color: var(--fg-muted);
}

.connector__health {
  font-size: 10px;
}

.connector__health.is-ok {
  color: var(--accent);
}

.connector__health.is-bad {
  color: var(--danger);
}

.people__actions {
  display: flex;
  gap: 6px;
  flex: 0 0 auto;
}

.people__row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.people__row input,
.people__row select,
.people__link {
  height: 30px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--surface);
  outline: 1px solid var(--guide);
  outline-offset: -1px;
  color: var(--fg);
  font: inherit;
  font-size: 11px;
  min-width: 0;
  flex: 1 1 120px;
}

.people__link {
  flex-basis: 100%;
  font-size: 10px;
  color: var(--fg-muted);
}

.people__empty {
  font-size: 11px;
  color: var(--fg-muted);
}

.people__error {
  min-height: 14px;
  margin: 0;
  font-size: 11px;
  color: var(--danger);
}

.bridge-setup {
  display: grid;
  gap: 8px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--guide);
}

.bridge-pairing,
.bridge-files {
  display: grid;
  gap: 6px;
}

.bridge-code {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.bridge-code code {
  font-size: 15px;
  letter-spacing: 2px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  outline: 1px solid var(--guide);
}

.bridge-steps {
  margin: 0;
  padding-left: 18px;
  font-size: 11px;
  color: var(--fg-muted);
  display: grid;
  gap: 2px;
}

.bridge-file {
  display: grid;
  gap: 3px;
  font-size: 10px;
  color: var(--fg-muted);
}

.bridge-file textarea {
  width: 100%;
  padding: 6px 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--surface);
  outline: 1px solid var(--guide);
  color: var(--fg);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  line-height: 1.5;
  resize: vertical;
}

.people__item--block {
  display: grid;
  gap: 8px;
}

.people__list--nested {
  padding-left: 4px;
  border-left: 1px solid var(--guide);
}


/* A quiet way out of a shared view (also shown on the owner's own preview). */
.view-exit {
  position: fixed;
  top: 14px;
  right: 16px;
  z-index: 60;
  height: 28px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-raised) 80%, transparent);
  outline: 1px solid var(--guide-square);
  outline-offset: -1px;
  color: var(--fg-muted);
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}

.view-exit:hover {
  color: var(--fg);
}


/* ------------------------------------------------------------ 4×4 squares */

.square {
  position: absolute;
  border-radius: var(--radius);
  /* The 4x4 block's boundary sits just outside the square, in the gutter, so
     filled cards cannot hide it. */
  outline: 1px dashed color-mix(in srgb, var(--fg) 32%, transparent);
  outline-offset: 4px;
  background: color-mix(in srgb, var(--fg) 2%, transparent);
  pointer-events: none;
}

.square__move {
  position: absolute;
  bottom: -34px;
  left: 50%;
  transform: translateX(-50%);
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface);
  outline: 1px solid var(--guide);
  outline-offset: -1px;
  color: var(--fg-muted);
  cursor: grab;
  pointer-events: auto;
  opacity: 0.55;
  transition: opacity var(--motion), color var(--motion), outline-color var(--motion);
}

/* Vertical spaces put the handle on the left edge instead of underneath. */
.shelf[data-orientation="vertical"] .square__move {
  bottom: auto;
  left: -24px;
  top: 50%;
  transform: translateY(-50%);
}

.square:hover .square__move,
.square__move:focus-visible,
.square__move.is-dragging {
  opacity: 1;
  color: var(--fg);
  outline-color: var(--guide-square);
}

.square__move.is-dragging {
  cursor: grabbing;
}

.square.is-drop-target {
  outline: 2px solid var(--accent);
}

.square.is-drag-source {
  outline-style: dashed;
  outline-color: var(--accent);
  opacity: 0.5;
}

/* Sandboxed module widgets run in an opaque-origin iframe. */
.wg-frame {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: transparent;
  color-scheme: dark light;
}

/* ---------------------------------------------------------------- display surface */

/* A paired panel: read-only, no top chrome, spaces and actions become side
   rails. These rules come after the shared-view rules on purpose: a display is
   also a view, and `body[data-view="shared"]` hides the docks. */
body[data-surface="display"] {
  cursor: none;
}

body[data-surface="display"] .topbar,
body[data-surface="display"] #view-exit,
body[data-surface="display"] #account-dock {
  display: none;
}

/* The space dock becomes the right rail and keeps one control: fullscreen.
   Everything editable, the name and the rest of the actions are gone. */
body[data-surface="display"] #space-dock {
  display: flex;
  right: 16px;
}

body[data-surface="display"] #space-dock.is-empty-display {
  display: none;
}

body[data-surface="display"] .space-dock__name {
  display: none;
}

body[data-surface="display"] #space-dock .space-dock__controls {
  grid-template-columns: 1fr;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

body[data-surface="display"] #space-dock .space-dock__controls-inner {
  flex-direction: column;
  transform: none;
}

body[data-surface="display"] #space-dock .space-dock__controls-inner > :not(#display-fullscreen) {
  display: none;
}

body[data-surface="display"] #display-fullscreen {
  display: grid;
}

body[data-surface="display"] .dock {
  display: flex;
  top: 50%;
  bottom: auto;
  left: auto;
  right: auto;
  transform: translateY(-50%);
  flex-direction: column;
  max-width: none;
  max-height: calc(100vh - 48px);
  overflow-x: hidden;
  overflow-y: auto;
  border-radius: 28px;
}

body[data-surface="display"] .dock--spaces {
  left: 16px;
}

body[data-surface="display"] .dock--space {
  right: 16px;
}

/* A display is paired to one space: there is nothing to add or switch to. */
body[data-surface="display"] .dock__add {
  display: none;
}

/* Leave room for both rails, whatever the dock preferences say. */
body[data-surface="display"] .shelf-frame {
  padding: 24px 96px;
}

/* ------------------------------------------------------------------ phone */

/* The unit is viewport-derived (§ metrics.js), so a phone already gets smaller
   squares and a stacked space. Touch targets get a floor of 44 px. */
@media (max-width: 720px) {
  .topbar {
    padding: 12px 14px;
    gap: 10px;
  }

  .status {
    display: none;
  }

  /* Keep the top row: brand, space pill, account. Expanding takes over that
     row as a full-width toolbar instead of covering the controls underneath. */
  .dock--space {
    top: 10px;
  }

  .dock--space.is-open,
  .dock--space.is-editing {
    top: 10px;
    left: 10px;
    right: 10px;
    transform: none;
    justify-content: space-between;
    gap: 4px;
    padding: 4px;
  }

  body.space-dock-open .topbar,
  body.space-dock-open #account-dock {
    opacity: 0;
    pointer-events: none;
  }

  .dock--space .space-dock__controls-inner {
    gap: 4px;
  }

  .space-dock__name > span:first-child {
    max-width: 120px;
  }

  .dock--space.is-editing .dock__action {
    width: 36px;
    height: 36px;
  }

  .dock--space.is-editing #display-fullscreen {
    display: none;
  }

  /* Fullscreen is a panel/desktop control; dropping it here lets the share,
     export and zoom row fit a phone. Export/share stay one tap away in view. */
  body:not([data-surface="display"]) .dock--space #display-fullscreen {
    display: none;
  }


  .dock {
    max-width: calc(100vw - 24px);
    padding: 6px;
  }

  .dock__space,
  .dock__add {
    width: 44px;
    height: 44px;
  }

  .dock__action {
    width: 40px;
    height: 40px;
  }

  .chip {
    min-height: 40px;
  }
}

/* A phone scrolls through a space with a finger: in view mode the blocks must
   not swallow the gesture. Editing still owns touch for drag and resize. */
.shelf[data-mode="view"] .block,
.shelf[data-mode="view"] .widget-host {
  touch-action: pan-y;
}

.shelf[data-mode="view"][data-orientation="horizontal"] .block,
.shelf[data-mode="view"][data-orientation="horizontal"] .widget-host {
  touch-action: pan-x;
}

/* The export popup's secondary note. */
.dialog__note--quiet {
  color: var(--fg-muted);
  font-size: 11px;
}

/* --------------------------------------------------------------- Gree AC */

.wg-ac {
  grid-template-rows: auto 1fr auto;
  align-content: stretch;
  gap: 0.4615em;
}

.wg-ac__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6154em;
}

.wg-ac__label {
  font-size: 0.7692em;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-muted);
}

.wg-ac__state {
  font-size: 0.9231em;
  font-weight: 600;
  color: var(--fg-muted);
}

.wg-ac__state.is-on {
  color: var(--accent);
}

.wg-ac__temps {
  display: flex;
  align-items: baseline;
  gap: 0.6154em;
  min-height: 0;
}

.wg-ac__temp {
  font-size: 1.7em;
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.wg-ac__now,
.wg-ac__hint {
  font-size: 0.8462em;
  color: var(--fg-muted);
}

.wg-ac__toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.7692em;
  height: 2.3077em;
  padding: 0 0.9231em 0 0.3846em;
  border: 0;
  border-radius: 999px;
  background: var(--surface);
  outline: 1px solid var(--guide-square);
  outline-offset: -1px;
  color: var(--fg-muted);
  font: inherit;
  font-size: 0.8462em;
  cursor: pointer;
}

.wg-ac__toggle[aria-pressed="true"] {
  color: var(--fg);
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  outline-color: var(--accent);
}

.wg-ac__toggle:disabled {
  opacity: 0.45;
  cursor: default;
}

.wg-ac__knob {
  width: 1.6923em;
  height: 1.6923em;
  border-radius: 999px;
  background: var(--fg-muted);
  transition: transform var(--motion), background var(--motion);
}

.wg-ac__toggle[aria-pressed="true"] .wg-ac__knob {
  background: var(--accent);
}

.wg-ac__setup-button {
  justify-self: start;
  height: 2.1538em;
  padding: 0 0.9231em;
  border: 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  outline: 1px solid var(--accent);
  outline-offset: -1px;
  color: var(--fg);
  font: inherit;
  font-size: 0.8462em;
  cursor: pointer;
}

.wg-ac__select {
  width: 100%;
  height: 2.3077em;
  border: 0;
  border-radius: 8px;
  background: var(--surface);
  color: var(--fg);
  font: inherit;
  font-size: 0.9231em;
  padding: 0 0.6154em;
}

.wg-ac__error {
  align-self: center;
  font-size: 0.9231em;
  color: var(--danger);
}

/* --------------------------------------------------------------- HTTP card */

.wg-http {
  grid-template-rows: auto 1fr;
  align-content: start;
  gap: 0.4615em;
}

.wg-http__top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6154em;
}

.wg-http__title {
  font-size: 0.7692em;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wg-http__meta {
  font-size: 0.6923em;
  color: var(--fg-muted);
}

.wg-http__rows {
  display: grid;
  gap: 0.1538em;
  margin: 0;
  padding: 0;
  list-style: none;
  min-height: 0;
  overflow: hidden;
}

.wg-http__rows li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6154em;
  font-size: 0.8462em;
  color: var(--fg-muted);
}

.wg-http__rows strong {
  color: var(--fg);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wg-http[data-size="1x1"] .wg-http__rows li:nth-child(n + 2) {
  display: none;
}

.wg-http[data-size="2x1"] .wg-http__rows li:nth-child(n + 3) {
  display: none;
}

.wg-http__hint,
.wg-http__error {
  font-size: 0.8462em;
  color: var(--fg-muted);
}

.wg-http__error {
  color: var(--danger);
}

.wg-http__select {
  width: 100%;
  height: 2.3077em;
  border: 0;
  border-radius: 8px;
  background: var(--surface);
  color: var(--fg);
  font: inherit;
  font-size: 0.9231em;
  padding: 0 0.6154em;
}

.wg-http__setup {
  justify-self: start;
  height: 2.1538em;
  padding: 0 0.9231em;
  border: 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  outline: 1px solid var(--accent);
  outline-offset: -1px;
  color: var(--fg);
  font: inherit;
  font-size: 0.8462em;
  cursor: pointer;
}

/* -------------------------------------------------------- Home Assistant */

.wg-ha {
  grid-template-rows: auto 1fr auto;
  align-content: stretch;
  gap: 0.4615em;
}

.wg-ha__top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6154em;
}

.wg-ha__label {
  font-size: 0.7692em;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wg-ha__meta {
  font-size: 0.6923em;
  color: var(--fg-muted);
}

.wg-ha__value {
  font-size: 1.7em;
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wg-ha__value small {
  font-size: 0.5em;
  color: var(--fg-muted);
}

.wg-ha__reading {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.1538em;
  min-width: 0;
}

.wg-ha__details {
  font-size: 0.7692em;
  color: var(--fg-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wg-ha__hint,
.wg-ha__error {
  font-size: 0.8462em;
  color: var(--fg-muted);
}

.wg-ha__error {
  color: var(--danger);
}

.wg-ha__select {
  width: 100%;
  height: 2.3077em;
  border: 0;
  border-radius: 8px;
  background: var(--surface);
  color: var(--fg);
  font: inherit;
  font-size: 0.9231em;
  padding: 0 0.6154em;
}

.wg-ha__setup {
  justify-self: start;
  height: 2.1538em;
  padding: 0 0.9231em;
  border: 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  outline: 1px solid var(--accent);
  outline-offset: -1px;
  color: var(--fg);
  font: inherit;
  font-size: 0.8462em;
  cursor: pointer;
}

.wg-ha__toggle {
  justify-self: start;
  height: 2.1538em;
  padding: 0 0.9231em;
  border: 0;
  border-radius: 999px;
  background: var(--surface);
  outline: 1px solid var(--guide-square);
  outline-offset: -1px;
  color: var(--fg);
  font: inherit;
  font-size: 0.8462em;
  cursor: pointer;
}

.wg-ha__toggle[aria-pressed="true"] {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  outline-color: var(--accent);
}

.wg-ha__toggle:disabled {
  opacity: 0.45;
  cursor: default;
}

/* declarative actions */
.wg-action__row {
  display: flex;
  align-items: center;
  gap: 0.6154em;
  min-width: 0;
}

.wg-action {
  justify-self: start;
  height: 2.1538em;
  padding: 0 0.9231em;
  border: 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  outline: 1px solid var(--accent);
  outline-offset: -1px;
  color: var(--fg);
  font: inherit;
  font-size: 0.8462em;
  cursor: pointer;
}

.wg-action:disabled {
  opacity: 0.5;
  cursor: default;
}

.wg-action__select {
  width: 100%;
  height: 2.3077em;
  border: 0;
  border-radius: 8px;
  background: var(--surface);
  color: var(--fg);
  font: inherit;
  font-size: 0.9231em;
  padding: 0 0.6154em;
}

.wg-action__note {
  font-size: 0.7692em;
  color: var(--fg-muted);
}

/* qr */
.wg-qr {
  align-content: center;
  justify-items: center;
  gap: 0.4615em;
}

.wg-qr__frame {
  display: grid;
  place-items: center;
  width: min(100%, 68cqmin);
  aspect-ratio: 1;
  padding: 0.3077em;
  border-radius: 8px;
  background: #fff;
}

.wg-qr__svg {
  width: 100%;
  height: 100%;
  display: block;
}

.wg-qr__label {
  max-width: 100%;
  font-size: 0.7692em;
  color: var(--fg-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wg-qr[data-size="1x1"] .wg-qr__label {
  display: none;
}

.wg-qr__hint {
  margin: 0;
  font-size: 0.8462em;
  color: var(--fg-muted);
  text-align: center;
}

/* sun & moon */
.wg-sun {
  align-content: center;
  gap: 0.2308em;
}

.wg-sun__label {
  font-size: 0.7692em;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
}

.wg-sun__moon {
  font-size: clamp(1.3846em, 26cqmin, 2.3077em);
  line-height: 1;
}

.wg-sun__phase {
  font-size: 0.8462em;
  color: var(--fg);
  opacity: 0.9;
}

.wg-sun__row {
  display: flex;
  gap: 0.9231em;
  font-size: 0.8462em;
  color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
}

.wg-sun__hint {
  margin: 0;
  font-size: 0.7692em;
  color: var(--fg-muted);
}

.wg-sun[data-size="1x1"] .wg-sun__label,
.wg-sun[data-size="1x1"] .wg-sun__phase,
.wg-sun[data-size="1x1"] .wg-sun__row,
.wg-sun[data-size="1x1"] .wg-sun__hint {
  display: none;
}

.wg-sun[data-size="2x1"] .wg-sun__label,
.wg-sun[data-size="2x1"] .wg-sun__phase {
  display: none;
}

/* unit converter */
.wg-units {
  align-content: center;
  gap: 0.1538em;
}

.wg-units__label {
  font-size: 0.8462em;
  color: var(--fg-muted);
}

.wg-units__value {
  font-size: clamp(1.3846em, 26cqmin, 2.3077em);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.wg-units__value small {
  margin-left: 0.3077em;
  font-size: 0.5em;
  font-weight: 500;
  color: var(--fg-muted);
}

.wg-units__hint {
  font-size: 0.7692em;
  color: var(--fg-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wg-units[data-size="1x1"] .wg-units__hint {
  display: none;
}

/* dice & picker */
.wg-dice {
  align-content: center;
  justify-items: start;
  gap: 0.4615em;
  cursor: pointer;
}

.wg-dice__label {
  font-size: 0.7692em;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
}

.wg-dice__row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4615em;
}

.wg-dice__face {
  display: grid;
  place-items: center;
  min-width: 2.3077em;
  height: 2.3077em;
  padding: 0 0.4615em;
  border-radius: 8px;
  background: color-mix(in srgb, var(--fg) 8%, transparent);
  font-size: 1.2308em;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.wg-dice__total {
  font-size: 0.8462em;
  color: var(--fg-muted);
}

.wg-dice__choice {
  font-size: clamp(1.2308em, 22cqmin, 1.8462em);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.wg-dice__hint {
  font-size: 0.7692em;
  color: var(--fg-muted);
}

.wg-dice[data-size="1x1"] .wg-dice__hint,
.wg-dice[data-size="1x1"] .wg-dice__label {
  display: none;
}

/* holidays */
.wg-holidays {
  align-content: start;
  gap: 0.4615em;
}

.wg-holidays__label {
  font-size: 0.7692em;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
}

.wg-holidays__hint {
  margin: 0;
  font-size: 0.8462em;
  color: var(--fg-muted);
}

.wg-holidays__list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.3846em;
  overflow: hidden;
}

.wg-holidays__item {
  display: grid;
  grid-template-columns: 4.7692em 1fr auto;
  align-items: baseline;
  gap: 0.6154em;
  min-width: 0;
}

.wg-holidays__date,
.wg-holidays__when {
  font-size: 0.7692em;
  color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.wg-holidays__name {
  font-size: 0.8462em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* transit */
.wg-transit {
  align-content: start;
  gap: 0.4615em;
}

.wg-transit__label {
  font-size: 0.7692em;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wg-transit__hint {
  margin: 0;
  font-size: 0.8462em;
  color: var(--fg-muted);
}

.wg-transit__list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.3077em;
  overflow: hidden;
}

.wg-transit__item {
  display: grid;
  grid-template-columns: 3.3846em 1fr auto;
  align-items: baseline;
  gap: 0.5385em;
  min-width: 0;
}

.wg-transit__line {
  font-size: 0.7692em;
  font-weight: 650;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wg-transit__dest {
  font-size: 0.8462em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wg-transit__when {
  font-size: 0.7692em;
  color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* crypto */
.wg-crypto {
  align-content: start;
  gap: 0.2308em;
}

.wg-crypto__label {
  font-size: 0.7692em;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
}

.wg-crypto__price {
  font-size: clamp(1.2308em, 22cqmin, 1.8462em);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.wg-crypto__change {
  font-size: 0.7692em;
  font-variant-numeric: tabular-nums;
}

.wg-crypto__change.is-up,
.wg-crypto__chart.is-up {
  color: #3ba55d;
}

.wg-crypto__change.is-down,
.wg-crypto__chart.is-down {
  color: #e05a4f;
}

.wg-crypto__chart {
  width: 100%;
  height: auto;
  min-height: 2.6154em;
  margin-top: auto;
  overflow: visible;
}

.wg-crypto__line {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  vector-effect: non-scaling-stroke;
  stroke-linejoin: round;
}

.wg-crypto__area {
  fill: currentColor;
  opacity: 0.12;
  stroke: none;
}

.wg-crypto[data-size="2x1"] .wg-crypto__chart,
.wg-crypto[data-size="4x1"] .wg-crypto__chart {
  min-height: 1.8462em;
}

.wg-crypto__hint {
  margin: 0;
  font-size: 0.8462em;
  color: var(--fg-muted);
}

/* air quality */
.wg-air {
  align-content: center;
  gap: 0.1538em;
}

.wg-air__label {
  font-size: 0.7692em;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-muted);
}

.wg-air__value {
  font-size: clamp(1.5385em, 28cqmin, 2.6154em);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.wg-air__value--good { color: #3ba55d; }
.wg-air__value--fair { color: #8bbf4a; }
.wg-air__value--moderate { color: #d9a521; }
.wg-air__value--poor { color: #e07a3f; }
.wg-air__value--very-poor { color: #e05a4f; }
.wg-air__value--extreme { color: #b1499c; }

.wg-air__band {
  font-size: 0.8462em;
  color: var(--fg);
  opacity: 0.9;
}

.wg-air__detail {
  font-size: 0.7692em;
  color: var(--fg-muted);
  font-variant-numeric: tabular-nums;
}

.wg-air[data-size="1x1"] .wg-air__label,
.wg-air[data-size="1x1"] .wg-air__detail {
  display: none;
}

/* last-known-state badge; set by web/src/lib/offline.js */
.wg[data-stale]::after {
  content: attr(data-stale);
  position: absolute;
  bottom: 5px;
  left: 7px;
  z-index: 3;
  padding: 0.0769em 0.4615em;
  border-radius: 999px;
  font-size: 0.6923em;
  letter-spacing: 0.03em;
  color: var(--fg-muted);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  pointer-events: none;
  white-space: nowrap;
}

.block.is-stale {
  outline: 1px dashed color-mix(in srgb, var(--fg) 22%, transparent);
  outline-offset: -1px;
}

/* Edit-mode actions live in one overflow menu, so a container shows a single
   handle instead of a row of buttons. Revealed on hover/selection; always
   visible on touch, so a tablet never needs a right-click. */
.block__menu {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 4;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  color: var(--fg-muted);
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  outline: 1px solid color-mix(in srgb, var(--fg) 10%, transparent);
  outline-offset: -1px;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease, color 120ms ease, background 120ms ease;
}

.block:hover .block__menu,
.block.is-selected .block__menu,
.block__menu:focus-visible {
  opacity: 1;
  pointer-events: auto;
}

.block__menu:hover,
.block__menu:focus-visible {
  color: var(--fg);
  background: var(--surface-raised);
}

@media (hover: none) {
  .block__menu {
    opacity: 1;
    pointer-events: auto;
  }
}

/* widget settings dialog fields */
.config-fields {
  display: grid;
  gap: 12px;
  max-height: min(60vh, 440px);
  overflow: auto;
  padding-right: 2px;
}

.field textarea,
.field select {
  min-height: 32px;
  padding: 7px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--surface);
  outline: 1px solid var(--guide);
  outline-offset: -1px;
  color: var(--fg);
  font: inherit;
  font-size: 13px;
}

.field textarea {
  resize: vertical;
  min-height: 64px;
  line-height: 1.4;
}

.field input[type="checkbox"] {
  width: 18px;
  height: 18px;
  padding: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

/* Widget padding follows the box, not just the viewport. */
.block[data-size="1x1"] .widget-host { padding: 0.9231em; }
.block[data-size="2x1"] .widget-host { padding: 1.0769em 1.2308em; }
.block[data-size="2x2"] .widget-host { padding: 1.3846em; }

/* Android hierarchy: eyebrow, dominant value, supporting line. */
.wg :is(.wg-weather__label, .wg-clock__label, .wg-count__label, .wg-progress__label,
        .wg-markets__label, .wg-feed__label, .wg-holidays__label, .wg-crypto__label,
        .wg-air__label, .wg-sun__label, .wg-dice__label, .wg-units__label,
        .wg-transit__label) {
  font-size: 0.8462em;
  font-weight: 500;
  letter-spacing: 0.07em;
}

.wg :is(.wg-weather__value, .wg-count__value, .wg-units__value, .wg-air__value) {
  font-size: clamp(1.8462em, 32cqmin, 2.9231em);
  font-weight: 650;
  line-height: 1.02;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.wg-crypto__price {
  font-size: clamp(1.6923em, 27cqmin, 2.3077em);
  font-weight: 650;
  letter-spacing: -0.02em;
}

.wg-ac__temp {
  font-size: clamp(1.8462em, 30cqmin, 2.7692em);
  font-weight: 650;
  letter-spacing: -0.02em;
}

/* Tonal chips, not outlines: the Material way to show a delta or a band. */
.wg-markets__change {
  padding: 0.0769em 0.4615em;
  border-radius: 999px;
  line-height: 1.5;
  background: color-mix(in srgb, currentColor 12%, transparent);
}

.wg-air__band {
  justify-self: start;
  padding: 0.1538em 0.6154em;
  border-radius: 999px;
  background: color-mix(in srgb, var(--w-accent) 16%, transparent);
}

.wg-feed__list { gap: 6px; }
.wg-dice__face { border-radius: 12px; }
.wg-qr__frame { border-radius: 14px; }

/* chip--small is used in dense dialogs */
.chip--small {
  padding: 3px 8px;
  font-size: 11px;
}

/* ------------------------------------------------------------- automations */

.auto-section {
  display: grid;
  gap: 8px;
}

.auto-section__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.auto-section__head h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
}

.auto-profiles,
.auto-rules {
  display: grid;
  gap: 6px;
  overflow-x: auto;
}

.auto-profile {
  display: grid;
  grid-template-columns: minmax(110px, 1fr) 76px 58px 58px 58px 26px;
  gap: 6px;
  align-items: center;
  min-width: 460px;
}

.auto-profile--head span {
  font-size: 9px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-muted);
}

.auto-profile input,
.auto-profile select,
.auto-bracket input,
.auto-bracket select,
.auto-editor input,
.auto-editor select {
  height: 30px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--surface-raised);
  outline: 1px solid var(--guide);
  outline-offset: -1px;
  color: var(--fg);
  font: inherit;
  font-size: 12px;
  min-width: 0;
}

.auto-rule {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.auto-rule__main {
  display: grid;
  gap: 1px;
  flex: 1;
  min-width: 0;
}

.auto-rule__main strong {
  font-size: 12px;
}

.auto-rule__main span {
  font-size: 10px;
  color: var(--fg-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auto-rule__toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: var(--fg-muted);
}

.auto-rule__toggle input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.auto-editor {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--surface);
  outline: 1px solid var(--guide);
  outline-offset: -1px;
}

.auto-editor h3 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
}

.auto-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.auto-brackets {
  display: grid;
  gap: 6px;
}

.auto-bracket {
  display: grid;
  grid-template-columns: auto 96px 1fr 26px;
  align-items: center;
  gap: 6px;
}

.auto-bracket > span {
  font-size: 10px;
  color: var(--fg-muted);
  white-space: nowrap;
}

@media (max-width: 560px) {
  .auto-grid {
    grid-template-columns: 1fr;
  }

  .auto-rule {
    flex-wrap: wrap;
  }
}

/* ------------------------------------------------------------ marketplace popup */

.picker__foot {
  justify-content: space-between;
}

.mkt-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: var(--surface);
  outline: 1px solid var(--guide);
  outline-offset: -1px;
}

.mkt-tab {
  flex: 1;
  padding: 6px 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--fg-muted);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.mkt-tab.is-active {
  background: var(--surface-raised);
  color: var(--fg);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

.mkt-search input {
  width: 100%;
  height: 40px;
  padding: 0 14px;
  border: 0;
  border-radius: 12px;
  background: var(--surface);
  outline: 1px solid var(--guide);
  outline-offset: -1px;
  color: var(--fg);
  font: inherit;
  font-size: 13px;
}

.mkt-search input:focus {
  outline-color: var(--accent);
}

/* Source chips, AltStore-style: one row, the active source inverted. */
.mkt-source-chips,
.mkt-tag-chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.mkt-source-chips::-webkit-scrollbar,
.mkt-tag-chips::-webkit-scrollbar {
  display: none;
}

.mkt-tag-chips .mkt-chip {
  height: 27px;
  padding: 0 10px;
  font-size: 10.5px;
}

.mkt-chip {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 11px;
  border: 0;
  border-radius: 999px;
  background: var(--surface);
  outline: 1px solid var(--guide);
  outline-offset: -1px;
  color: var(--fg-muted);
  font: inherit;
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
}

.mkt-chip span {
  font-size: 9px;
  opacity: 0.6;
}

.mkt-chip:hover {
  color: var(--fg);
}

.mkt-chip.is-active {
  background: var(--fg);
  color: var(--surface);
  outline-color: transparent;
}

.mkt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  align-content: start;
  gap: 10px;
  max-height: none;
  overflow-y: auto;
  scrollbar-width: thin;
}

/* A source section is a full-width heading inside the two-column card grid. */
.mkt-section {
  grid-column: 1 / -1;
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 8px 0 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.mkt-section:first-child {
  margin-top: 0;
}

.mkt-section span {
  font-size: 10px;
  font-weight: 500;
  color: var(--fg-muted);
}

.mkt-empty {
  grid-column: 1 / -1;
}

.mkt-card {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 72px;
  padding: 10px;
  border-radius: 16px;
  background:
    linear-gradient(135deg,
      color-mix(in srgb, hsl(var(--mkt-hue, 220) 70% 60%) 15%, var(--surface-raised)),
      var(--surface-raised) 72%);
  outline: 1px solid color-mix(in srgb, hsl(var(--mkt-hue, 220) 55% 55%) 20%, var(--guide));
  outline-offset: -1px;
  cursor: pointer;
  transition: transform var(--motion) ease, outline-color var(--motion) ease;
}

.mkt-card:hover {
  transform: translateY(-1px);
  outline-color: color-mix(in srgb, hsl(var(--mkt-hue, 220) 60% 55%) 38%, var(--guide));
}

.mkt-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.mkt-card__icon--image {
  object-fit: cover;
  background: var(--surface-2);
}

.mkt-card__icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 13px;
  background: linear-gradient(145deg,
    hsl(var(--mkt-hue, 220) 74% 64%),
    hsl(calc(var(--mkt-hue, 220) + 28) 68% 46%));
  color: #fff;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.mkt-card__body {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.mkt-card__body strong {
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mkt-card__body small {
  font-size: 10.5px;
  color: var(--fg-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mkt-tier {
  display: inline-grid;
  place-items: center;
  width: 13px;
  height: 13px;
  margin-left: 4px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--surface);
  font-size: 9px;
  font-weight: 700;
  vertical-align: text-top;
}

.mkt-tier--official {
  background: #d6a51f;
}

.mkt-card__action {
  justify-self: end;
  height: 28px;
  padding: 0 12px;
  font-size: 11px;
}

.mkt-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.mkt-tags .tag {
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface);
  outline: 1px solid var(--guide);
  outline-offset: -1px;
  color: var(--fg-muted);
  font-size: 10px;
}

.mkt-tags .tag--tier {
  background: color-mix(in srgb, var(--fg) 8%, transparent);
  color: var(--fg-muted);
  outline-color: transparent;
  text-transform: capitalize;
}

.mkt-tags .tag--accent,
.mkt-tags .tag--category {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
  outline-color: transparent;
}

.mkt-installed__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 0;
  margin-bottom: 4px;
}

.mkt-installed__head span {
  color: var(--fg-muted);
  font-size: 11px;
}

.mkt-installed {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  align-content: start;
  gap: 6px;
}

.mkt-installed__item {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 14px;
  background:
    linear-gradient(135deg,
      color-mix(in srgb, hsl(var(--mkt-hue, 220) 70% 60%) 10%, var(--surface)),
      var(--surface) 72%);
  outline: 1px solid color-mix(in srgb, hsl(var(--mkt-hue, 220) 55% 55%) 16%, var(--guide));
  outline-offset: -1px;
}

.mkt-installed__icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  font-size: 18px;
}

.mkt-installed__main {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.mkt-installed__main strong { font-size: 12px; }
.mkt-installed__main small {
  font-size: 10px;
  color: var(--fg-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mkt-sources {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  align-content: start;
  gap: 6px;
}

.mkt-source {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 16px;
  background:
    linear-gradient(135deg,
      color-mix(in srgb, hsl(var(--mkt-hue, 220) 70% 60%) 11%, var(--surface)),
      var(--surface) 72%);
  outline: 1px solid color-mix(in srgb, hsl(var(--mkt-hue, 220) 55% 55%) 16%, var(--guide));
  outline-offset: -1px;
}

.mkt-source__main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.mkt-source__icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  font-size: 18px;
}

.mkt-source__text {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.mkt-source__text strong { font-size: 12px; }
.mkt-source__text small {
  font-size: 10px;
  color: var(--fg-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mkt-source .tag--kind {
  background: color-mix(in srgb, var(--fg) 7%, transparent);
  color: var(--fg-muted);
}

.mkt-source .tag {
  padding: 2px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
  font-size: 10px;
  white-space: nowrap;
}

/* Store page overlay: tinted hero, description, permissions, one action. */
.mkt-detail {
  width: min(100%, 520px);
  border-radius: var(--radius);
  background: var(--surface-raised);
  overflow: hidden;
}

.mkt-detail__hero {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px;
  background: linear-gradient(135deg,
    color-mix(in srgb, hsl(var(--mkt-hue, 220) 70% 60%) 26%, transparent),
    transparent 72%);
}

.mkt-detail__icon {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  font-size: 21px;
}

.mkt-detail__icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}

.mkt-detail__hero h3 {
  margin: 0;
  font-size: 20px;
  letter-spacing: -0.02em;
}

.mkt-detail__body {
  display: grid;
  gap: 14px;
  padding: 2px 20px 20px;
}

.mkt-versions {
  display: grid;
  gap: 5px;
}

.mkt-versions h4 {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--fg-muted);
}

.mkt-version-row {
  display: grid;
  grid-template-columns: 54px 70px minmax(0, 1fr);
  gap: 8px;
  align-items: baseline;
  padding: 5px 8px;
  border-radius: 8px;
  background: var(--surface);
  font-size: 11px;
}

.mkt-version-row strong { font-size: 11px; }
.mkt-version-row small { color: var(--fg-muted); font-size: 10px; }
.mkt-version-row span {
  color: var(--fg-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mkt-detail__description {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
}

.mkt-setup {
  display: grid;
  gap: 10px;
  padding: 4px 0;
}

/* Marketplace sizing: roomy on desktop, full-width on a phone. */
.dialog--marketplace {
  width: min(90vw, 800px);
}

.dialog--marketplace .dialog__form {
  height: 90vh;
  max-height: 90vh;
  /* Explicit tracks: a fixed-height grid otherwise stretches every auto row,
     inflating the tabs and the cards. */
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
}

.dialog--marketplace [data-mkt-panel]:not([hidden]) {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  overflow: hidden;
}

.dialog--marketplace [data-mkt-panel]:not([hidden]) .mkt-grid,
.dialog--marketplace [data-mkt-panel]:not([hidden]) .mkt-installed {
  flex: 1;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
}

/* Sources keep the list compact; the add form sits right below it. */
.dialog--marketplace [data-mkt-panel]:not([hidden]) .mkt-sources {
  flex: 0 0 auto;
  max-height: 46vh;
  overflow-y: auto;
}

/* Overlays over the marketplace: the remove warning and the store page. */
.mkt-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  padding: 24px;
  border-radius: inherit;
  background: rgba(6, 8, 12, 0.55);
  backdrop-filter: blur(2px);
}

.mkt-overlay[hidden] {
  display: none;
}

.mkt-confirm {
  position: relative;
  display: grid;
  gap: 10px;
  width: min(100%, 430px);
  padding: 18px;
  border-radius: var(--radius);
  background: var(--surface-raised);
}

.mkt-confirm h3 {
  margin: 0;
}

.mkt-publisher-link {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: inherit;
  cursor: pointer;
}

.mkt-publisher-link:hover {
  text-decoration: underline;
}

.mkt-publisher__head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mkt-publisher__head h3 {
  margin: 0;
}

.mkt-publisher__icon {
  width: 52px;
  height: 52px;
  border-radius: 15px;
  font-size: 18px;
}

.mkt-publisher__bio {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
}

.mkt-publisher__site {
  color: var(--accent);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mkt-publisher__widgets {
  display: grid;
  gap: 4px;
  max-height: 220px;
  overflow-y: auto;
}

.mkt-publisher__widget {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  border: 0;
  border-radius: 10px;
  background: var(--surface);
  color: var(--fg);
  font: inherit;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}

.mkt-publisher__widget small {
  color: var(--fg-muted);
  font-size: 10px;
}

.mkt-feedback__history {
  display: grid;
  gap: 6px;
  max-height: 180px;
  overflow-y: auto;
}

.mkt-feedback__thread {
  display: grid;
  gap: 3px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--surface);
  font-size: 11px;
}

.mkt-feedback__thread small {
  color: var(--fg-muted);
  font-size: 10px;
}

.mkt-feedback__reply {
  padding-left: 8px;
  border-left: 2px solid var(--guide);
  color: var(--fg-muted);
}

.mkt-feedback textarea {
  width: 100%;
  padding: 10px;
  border: 0;
  border-radius: 10px;
  background: var(--surface);
  outline: 1px solid var(--guide);
  outline-offset: -1px;
  color: var(--fg);
  font: inherit;
  font-size: 12px;
  resize: vertical;
}

.mkt-report {
  width: min(92vw, 430px);
}

.mkt-report__label {
  display: grid;
  gap: 4px;
  font-size: 11px;
  color: var(--fg-muted);
}

.mkt-report select {
  height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--surface);
  outline: 1px solid var(--guide);
  outline-offset: -1px;
  color: var(--fg);
  font: inherit;
  font-size: 12px;
}

.mkt-report textarea {
  width: 100%;
  padding: 10px;
  border: 0;
  border-radius: 10px;
  background: var(--surface);
  outline: 1px solid var(--guide);
  outline-offset: -1px;
  color: var(--fg);
  font: inherit;
  font-size: 12px;
  resize: vertical;
}

.mkt-confirm__actions {
  justify-content: flex-end;
}

.mkt-source-add {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mkt-source-kind {
  flex: 1 1 100%;
}

.mkt-source-kind button {
  flex: 1;
}

.mkt-source-add input {
  flex: 1 1 180px;
  height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--surface);
  outline: 1px solid var(--guide);
  outline-offset: -1px;
  color: var(--fg);
  font: inherit;
  font-size: 12px;
}

.mkt-tabs .mkt-tab { flex: 1; }

/* Accessible labels that should not render. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}


/* A placement whose widget type is no longer installed. */
.wg-missing {
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 0.4615em;
  height: 100%;
  color: var(--fg-muted);
}

.wg-missing strong {
  color: var(--fg);
  font-size: 1em;
}

.wg-missing span {
  font-size: 0.8462em;
  line-height: 1.4;
}

.wg-missing .chip {
  margin-top: 0.3077em;
}
