@layer components {

  /* Right-hand panel docked to the window edge; the 3D view fills the space left of it
     (viewer.css), so the model centres in what's visible. Full screen on phones. */
  .panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: var(--panel-width);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding-top: env(safe-area-inset-top);
    background: var(--color-surface);
    border-left: 1px solid var(--color-edge);
  }

  /* Divider on the panel's left edge: drag to resize (panel_resize_controller). */
  .panel__resizer {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1;
    width: 6px;
    cursor: col-resize;
    touch-action: none;

    &:hover,
    &:focus-visible,
    &.is-dragging {
      background: color-mix(in oklch, var(--color-primary) 55%, transparent);
      outline: none;
    }
  }

  .panel__head {
    display: flex;
    align-items: start;
    gap: 8px;
    padding: 12px 14px 10px;
    border-bottom: 1px solid var(--color-line);
  }

  .panel__heading {
    flex: 1;
  }

  .panel__title {
    font-size: 15px;
    font-weight: 600;
  }

  /* A linked project's original, under the title. */
  .panel__linked {
    margin-top: 2px;
    font-size: 12px;
    color: var(--color-ink-muted);

    & a {
      color: inherit;
    }
  }

  .panel__summary {
    margin-top: 2px;
    color: var(--color-ink-muted);

    &.is-fault {
      color: var(--color-danger-ink);
    }
  }

  /* The sketch was saved elsewhere meanwhile (houses/_conflict): reload theirs or keep ours. */
  .conflict {
    display: grid;
    gap: 8px;
    margin-top: 8px;
    padding: 10px;
    font-size: 12px;
    background: var(--color-warning-surface);
    border: 1px solid var(--color-warning);
    border-radius: 6px;
  }

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

  /* Pages of a workspace's panel (houses/_heating_tabs): edge to edge under the head, the open one
     underlined. */
  .panel-tabs {
    display: flex;
    margin-bottom: 6px;
    border-bottom: 1px solid var(--color-line);
  }

  .panel-tabs__tab {
    flex: 1;
    padding: 8px 10px 7px;
    font-size: 13px;
    color: var(--color-ink-muted);
    background: transparent;
    border: 0;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    margin-bottom: -1px;

    &:hover {
      color: var(--color-ink);
    }

    &[aria-selected="true"] {
      color: var(--color-ink);
      border-bottom-color: var(--color-primary);
    }
  }

  .panel__list {
    flex: 1;
    overflow: auto;
    padding-bottom: 6px;
  }

  .panel__floor {
    padding: 10px 14px 4px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--color-ink-muted);
  }

  .panel-open,
  .panel__close {
    display: none;
  }

  @media (max-width: 760px) {
    .panel {
      display: none;
      inset: 0;

      z-index: 20;
      width: auto;
      padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
      background: var(--color-surface);
      border: 0;
      border-radius: 0;

      &.is-open {
        display: flex;
      }
    }

    /* Full screen here: nothing to resize. */
    .panel__resizer {
      display: none;
    }

    .panel-open,
    .panel__close {
      display: block;
      font-size: 13px;
    }

    .panel-open {
      padding: 6px 10px;
    }

    .panel__close {
      padding: 4px 10px;
    }
  }
}
