/* Shared tokens, navigation, and base typography come from the website. */
.demo-page {
  height: 100dvh;
  min-height: 480px;
  display: flex;
  flex-direction: column;
}
.demo-header {
  width: 100%;
  flex: none;
  position: relative;
  z-index: 30;
}
.demo-main,
.demo-footer {
  margin-inline: clamp(12px, 2vw, 32px);
}
.demo-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.demo-controls {
  flex: none;
  display: grid;
  grid-template-columns: auto minmax(240px, 420px) minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px 16px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}
.demo-title {
  max-width: 280px;
}
.demo-title h1 {
  font-size: 17px;
  line-height: 1.4;
  margin: 0;
}
.demo-title p {
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-secondary);
  margin: 2px 0 0;
}
.demo-picker {
  position: relative;
  min-width: 0;
}
.demo-controls :is(button, select, summary) {
  font: inherit;
  font-size: 14px;
  line-height: 20px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg-color);
  color: var(--text-primary);
  min-height: 46px;
  padding: 12px 18px;
  cursor: pointer;
  transition:
    border-color 150ms,
    background-color 150ms;
}
.demo-picker select {
  appearance: none;
  width: 100%;
  min-width: 0;
  padding-right: 44px;
  text-overflow: ellipsis;
}
.demo-select-chevron {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  pointer-events: none;
  color: var(--text-secondary);
}
.demo-controls :is(button, select, summary):hover {
  border-color: var(--accent);
}
.demo-controls :is(button, summary):hover {
  background: var(--surface-hover);
}
.demo-controls :is(button, select, summary):focus-visible {
  outline-width: 2px;
  outline-offset: 3px;
  border-radius: 9px;
}
.demo-controls button:disabled {
  opacity: 0.55;
  cursor: wait;
}
.demo-actions {
  grid-column: 4;
  display: flex;
  gap: 10px;
}
.demo-actions button {
  white-space: nowrap;
}
.demo-add-icon {
  display: none;
  width: 20px;
  height: 20px;
}
.demo-controls #reset-demo {
  background: var(--accent-soft);
}
.demo-about {
  grid-column: 5;
  position: relative;
}
.demo-about summary {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 46px;
  padding: 0;
  list-style: none;
  background: transparent;
  color: var(--text-secondary);
}
.demo-about summary::-webkit-details-marker {
  display: none;
}
.demo-about summary svg {
  width: 21px;
  height: 21px;
}
.demo-about[open] summary {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: var(--accent);
}
.demo-guide {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  z-index: 10;
  width: min(640px, calc(100vw - 64px));
  max-height: min(520px, calc(100dvh - 220px));
  overflow: auto;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-color);
  color: var(--text-secondary);
  box-shadow: 0 8px 28px var(--shadow);
  font-size: 14px;
  line-height: 1.6;
}
.demo-guide h2 {
  color: var(--text-primary);
  font-size: 18px;
  margin: 0 0 4px;
}
.demo-guide h3 {
  color: var(--text-primary);
  font-size: 15px;
  margin-top: 16px;
}
.demo-guide-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}
.demo-guide-actions button {
  flex: 1;
  white-space: nowrap;
}
.demo-guide p + p {
  margin-top: 10px;
}
.demo-start-counts {
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  color: var(--text-primary);
}
.demo-hint,
.demo-reset-note {
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.demo-scale-note[hidden] {
  display: none;
}
.demo-frame-wrap {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 272px;
  background: var(--bg-color);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow:
    0 2px 6px var(--shadow),
    0 10px 28px -8px var(--shadow-lg);
  overflow: hidden;
}
.demo-browser-bar {
  flex: none;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  min-height: 32px;
  padding: 4px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-secondary);
}
.demo-window-dots {
  display: flex;
  gap: 6px;
}
.demo-window-dots i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ed827c;
}
.demo-window-dots i:nth-child(2) {
  background: #e4b858;
}
.demo-window-dots i:nth-child(3) {
  background: #77ba83;
}
.demo-browser-title {
  font-weight: 600;
}
.demo-browser-badge {
  justify-self: end;
}
#exit-expanded {
  justify-self: end;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-color);
  color: var(--text-primary);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
#exit-expanded[hidden] {
  display: none;
}
#exit-expanded:hover {
  border-color: var(--accent);
  background: var(--surface-hover);
}
#exit-expanded:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.demo-viewport {
  position: relative;
  flex: 1;
  min-height: 240px;
}
#demo-frame {
  /* Keep the embedded System theme tied to the OS, not the website theme. */
  color-scheme: light dark;
  display: block;
  position: absolute;
  inset: 0;
  border: 0;
  height: 100%;
  width: 100%;
  background: var(--bg-color);
}
.demo-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: var(--bg-color);
  padding: 20px;
  margin: 0;
  color: var(--text-secondary);
}
.demo-loading[hidden] {
  display: none;
}
.demo-footer {
  flex: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding-block: 6px 8px;
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-secondary);
}
.demo-counts {
  flex: none;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
#demo-activity {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  text-align: right;
  margin: 0;
}
.demo-footer .system-appearance {
  flex: none;
  min-height: 28px;
  padding-inline: 4px;
  font-size: 12px;
}
.demo-site.demo-expanded {
  overflow: hidden;
}
.demo-page[data-expanded='true'] {
  position: fixed;
  inset: 0;
  z-index: 100;
  height: var(--demo-viewport-height, 100dvh);
  min-height: 0;
  padding: max(8px, env(safe-area-inset-top))
    max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom))
    max(8px, env(safe-area-inset-left));
  background: var(--bg-color);
}
.demo-page[data-expanded='true'] .demo-header,
.demo-page[data-expanded='true'] .demo-controls,
.demo-page[data-expanded='true'] .system-appearance {
  display: none;
}
.demo-page[data-expanded='true'] .demo-main {
  flex: 1;
  min-height: 0;
  margin: 0;
}
.demo-page[data-expanded='true'] .demo-frame-wrap {
  flex: 1;
  height: auto;
  min-height: 0;
}
.demo-page[data-expanded='true'] .demo-viewport {
  min-height: 0;
}
.demo-page[data-expanded='true'] .demo-browser-badge {
  display: none;
}
.demo-page[data-expanded='true'] .demo-footer {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: 0;
  overflow: hidden;
  clip-path: inset(50%);
}
@media (pointer: coarse) {
  .demo-footer .system-appearance {
    min-height: var(--tap-target-size);
  }
}
@media (max-width: 1000px) {
  .demo-controls {
    grid-template-columns: minmax(0, 1fr) auto;
  }
  .demo-title {
    max-width: none;
    grid-column: 1;
    grid-row: 1;
  }
  .demo-about {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
  }
  .demo-picker {
    grid-column: 1;
    grid-row: 2;
  }
  .demo-actions {
    grid-column: 2;
    grid-row: 2;
  }
}
@media (max-width: 600px) {
  .demo-page {
    height: auto;
    min-height: 100dvh;
  }
  .demo-header {
    padding-inline: 12px;
  }
  .demo-main {
    flex: none;
    gap: 10px;
  }
  .demo-controls {
    grid-template-columns: minmax(0, 1fr) 44px 44px;
    gap: 8px;
    padding: 8px;
  }
  .demo-title,
  .demo-add-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
  }
  .demo-picker {
    grid-column: 1;
    grid-row: 1;
  }
  .demo-picker select {
    padding-left: 12px;
    padding-right: 36px;
  }
  .demo-select-chevron {
    right: 12px;
  }
  .demo-actions {
    grid-column: 2;
    grid-row: 1;
  }
  .demo-actions #add-tab {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    padding: 0;
  }
  .demo-add-icon {
    display: block;
  }
  .demo-about {
    grid-column: 3;
    grid-row: 1;
  }
  .demo-about summary {
    width: 44px;
  }
  .demo-guide {
    width: calc(100vw - 42px);
    max-height: min(520px, calc(100dvh - 160px));
    padding: 16px;
  }
  .demo-frame-wrap {
    flex: none;
    height: max(
      272px,
      calc(
        var(--demo-viewport-height, 100dvh) - var(--demo-shell-height, 150px)
      )
    );
  }
  .demo-browser-bar {
    grid-template-columns: 1fr auto;
    gap: 8px;
    min-height: 26px;
    padding: 2px 10px;
  }
  .demo-browser-title {
    display: none;
  }
  .demo-footer {
    flex-wrap: wrap;
    gap: 4px 8px;
    padding-block: 12px max(12px, env(safe-area-inset-bottom));
  }
  .demo-counts {
    flex-shrink: 1;
  }
  #demo-activity {
    order: 1;
    flex-basis: 100%;
    text-align: left;
  }
}

