/* Mirrors MacScreenshotStudioView and ScreenshotStudioChrome.swift (StudioTheme,
   StudioButtonStyle, ScreenshotStudioPalette, ScreenshotStudioInspector).
   Sizes are the native points, 1 pt = 1 px. */
:root {
  color-scheme: dark;
  --window: #161619;
  --stage: #0c0c0e;
  --surface: #222226;
  --hairline: rgba(255, 255, 255, 0.08);
  --secondary: rgba(255, 255, 255, 0.56);
  --tertiary: rgba(255, 255, 255, 0.38);
  --accent: #0a84ff;
  --notice: 28px;
  --ease: cubic-bezier(0.2, 0, 0, 1);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--window);
  color: #fff;
  font:
    12px -apple-system,
    BlinkMacSystemFont,
    "SF Pro Text",
    system-ui,
    sans-serif;
  -webkit-font-smoothing: antialiased;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
button,
a {
  touch-action: manipulation;
}
button {
  cursor: pointer;
  border: 0;
  background: transparent;
  padding: 0;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
[role="slider"]:focus-visible {
  outline: 2px solid #72a9ff;
  outline-offset: 2px;
}
[hidden] {
  display: none !important;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.pn-icon {
  width: 1em;
  height: 1em;
}
.sample-notice {
  position: sticky;
  left: 0;
  height: var(--notice);
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: #101012;
  color: #a4a4aa;
  font-size: 10px;
  white-space: nowrap;
  border-bottom: 1px solid var(--hairline);
}
.sample-notice span {
  color: #aaaab3;
}

/* ---------- Window ---------- */
.studio-app {
  position: relative;
  min-width: 1040px;
  height: clamp(560px, calc(100vh - var(--notice)), 820px);
  display: flex;
  flex-direction: column;
  background: var(--window);
}
.studio-app.compact {
  height: auto;
}
.studio-app.drop-target {
  box-shadow: inset 0 0 0 2px var(--accent);
}

/* StudioButtonStyle: .circle / .pill / .primary / .icon */
.circle,
.pill,
.tool-button,
.more {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  transition:
    background-color 0.12s ease-out,
    color 0.12s ease-out,
    opacity 0.12s ease-out,
    transform 0.08s ease-out;
}
.circle:active,
.pill:active,
.tool-button:active {
  transform: scale(0.96);
}
.circle {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.075);
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
}
.circle .pn-icon {
  stroke-width: 3;
}
.circle:hover {
  background: rgba(255, 255, 255, 0.13);
  color: rgba(255, 255, 255, 0.95);
}
.pill {
  gap: 8px;
  height: 32px;
  padding: 0 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.075);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
}
.pill .pn-icon {
  font-size: 14px;
}
.pill:hover {
  background: rgba(255, 255, 255, 0.13);
}
.pill.primary {
  background: rgba(255, 255, 255, 0.92);
  color: #0f0f0f;
}
.pill.primary:hover {
  background: #fff;
}
.pill.primary .pn-icon {
  stroke-width: 2.4;
}
.pill-row {
  display: flex;
  gap: 8px;
}

/* ---------- Header ---------- */
.studio-header {
  position: relative;
  flex: none;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
}
.title {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex: 1;
  min-width: 0;
  padding-left: 6px;
}
.title strong {
  font-size: 13px;
  font-weight: 600;
}
.title small {
  font-size: 10.5px;
  color: var(--secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.more {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: rgba(255, 255, 255, 0.8);
  font-size: 15px;
}
.more .pn-icon {
  stroke-width: 2.6;
}
.more:hover,
.more[aria-expanded="true"] {
  background: rgba(255, 255, 255, 0.075);
}
#image-menu {
  position: absolute;
  right: 150px;
  top: 46px;
  z-index: 6;
  min-width: 232px;
  padding: 5px;
  background: rgba(42, 42, 46, 0.97);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6);
}
.studio-app.no-image #image-menu {
  right: 14px;
}
#image-menu button {
  display: block;
  width: 100%;
  text-align: left;
  padding: 5px 10px;
  border-radius: 5px;
  font-size: 13px;
}
#image-menu button:hover,
#image-menu button:focus-visible {
  background: var(--accent);
  color: #fff;
  outline: none;
}
#image-menu button.danger {
  color: #ff6b62;
}
#image-menu button.danger:hover,
#image-menu button.danger:focus-visible {
  color: #fff;
}
#image-menu hr {
  border: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  margin: 4px 6px;
}

/* ---------- Expanded: stage + inspector ---------- */
.expanded-editor {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 256px;
}
.stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  margin: 0 0 10px 10px;
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  overflow: hidden;
  background-color: var(--stage);
  /* StudioDotGrid: 1.6 pt dots every 18 pt, starting at 9 pt. */
  background-image: radial-gradient(circle at 0.8px 0.8px, rgba(255, 255, 255, 0.055) 0.8px, transparent 1.1px);
  background-size: 18px 18px;
  background-position: 9px 9px;
  box-shadow: inset 0 0 0 1px var(--hairline);
}

/* ScreenshotStudioPalette */
.palette {
  align-self: center;
  flex: none;
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border-radius: 13px;
  background: var(--surface);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.09),
    0 6px 24px rgba(0, 0, 0, 0.45);
  position: relative;
  z-index: 2;
}
.tools {
  display: flex;
  gap: 4px;
}
.tool-button {
  height: 30px;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.7);
}
.tool-button:not(:disabled):hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}
.tool-button:disabled {
  opacity: 0.3;
  cursor: default;
}
.tools .tool-button {
  width: 32px;
  font-size: 16px;
}
.tools .tool-button[aria-checked="true"] {
  background: rgba(255, 255, 255, 0.17);
  color: #fff;
}
.tools .pn-icon[data-icon="case-sensitive"] {
  font-size: 19px;
}
.step-glyph {
  display: grid;
  place-items: center;
  width: 15px;
  height: 15px;
  border: 1.4px solid currentColor;
  border-radius: 50%;
  font-size: 9px;
  font-weight: 600;
  line-height: 1;
}
.divider {
  flex: none;
  width: 1px;
  height: 18px;
  margin: 0 4px;
  background: rgba(255, 255, 255, 0.1);
}
.inks {
  display: flex;
  gap: 1px;
}
.inks button {
  position: relative;
  width: 26px;
  height: 30px;
  display: grid;
  place-items: center;
}
.inks button::after {
  content: "";
  position: absolute;
  left: 2px;
  top: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1.5px transparent;
}
.inks button[aria-checked="true"]::after {
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.95);
}
.inks span {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
  transition: transform 0.12s ease-out;
}
.inks button[data-ink="black"] span {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}
.inks button:not([aria-checked="true"]):hover span {
  transform: scale(1.15);
}
.history {
  width: 30px;
  font-size: 15px;
}
.hide-private {
  gap: 6px;
  padding: 0 10px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.hide-private .pn-icon {
  font-size: 14px;
  stroke-width: 2.2;
}

/* Canvas */
.canvas-space {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 20px 32px;
  overflow: hidden;
}
.canvas-frame {
  position: relative;
  border-radius: 4px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.55);
}
#composition {
  display: block;
  border-radius: 4px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: crosshair;
}
#composition[data-tool="select"] {
  cursor: default;
}
#composition[data-tool="text"] {
  cursor: text;
}
#composition:focus-visible {
  outline: 2px solid #72a9ff;
  outline-offset: 4px;
}
#text-input {
  position: absolute;
  min-width: 60px;
  padding: 0 4px;
  border: 0;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.28);
  outline: none;
}

/* Empty state */
.empty-state {
  position: relative;
  flex: 1;
  min-height: 0;
  margin: 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  border-radius: 18px;
}
.studio-app.drop-target .empty-state {
  background: rgba(255, 255, 255, 0.04);
}
.empty-state .dash {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}
.empty-state .dash rect {
  fill: none;
  stroke: rgba(255, 255, 255, 0.14);
  stroke-width: 1.5;
  stroke-dasharray: 6 5;
}
.studio-app.drop-target .empty-state .dash rect {
  stroke: rgba(255, 255, 255, 0.5);
}
.empty-icon {
  width: 60px;
  height: 60px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.75);
  font-size: 28px;
}
.empty-copy {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.empty-copy strong {
  font-size: 16px;
  font-weight: 600;
}
.empty-copy span {
  font-size: 12px;
  color: var(--secondary);
}
.empty-state .pill-row {
  margin-top: 4px;
}

/* Status bar */
.status-bar {
  flex: none;
  height: 44px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}
#hint-text {
  color: var(--secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.hint-keys {
  display: flex;
  gap: 8px;
}
.hint-keys > span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--tertiary);
}
kbd {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.07);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.7);
  font:
    600 10px ui-rounded,
    -apple-system,
    system-ui,
    sans-serif;
}
.spacer {
  flex: 1;
  min-width: 8px;
}
.export-size {
  color: var(--tertiary);
  font-variant-numeric: tabular-nums;
}
.drag-out {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 26px;
  padding: 0 10px;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.075);
  box-shadow: inset 0 0 0 1px var(--hairline);
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  cursor: grab;
}
.drag-out .pn-icon {
  font-size: 13px;
}

/* ---------- Inspector ---------- */
.inspector {
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: none;
  padding: 6px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.inspector::-webkit-scrollbar {
  display: none;
}
.inspector section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.section-head {
  height: 18px;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--secondary);
}
.format-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}
.format-grid button {
  height: 50px;
  flex-direction: column;
  gap: 5px;
  font-size: 10px;
  font-weight: 600;
}
.format-grid button[aria-pressed="true"] {
  background: rgba(255, 255, 255, 0.17);
  color: #fff;
}
.format-glyph {
  width: 24px;
  height: 18px;
  display: grid;
  place-items: center;
}
.format-glyph i {
  display: grid;
  place-items: center;
  border: 1.4px solid currentColor;
  border-radius: 2.5px;
}
.format-glyph i.auto {
  width: 22px;
  height: 15px;
  border-style: dashed;
}
.format-glyph i.auto .pn-icon {
  font-size: 8px;
  fill: currentColor;
  stroke-width: 1.5;
}
.background-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
}
.background-grid button {
  position: relative;
  padding: 3px;
  border-radius: 13px;
  aspect-ratio: 1;
}
/* A 2 pt ring centred on the padded edge, like the native stroke overlay. */
.background-grid button:hover {
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.25),
    inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}
.background-grid button[aria-pressed="true"] {
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.95),
    inset 0 0 0 1px rgba(255, 255, 255, 0.95);
}
.background-grid canvas {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 10px;
}
.background-grid button::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 10px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
  pointer-events: none;
}
.background-grid .pn-icon {
  position: absolute;
  left: 50%;
  top: 50%;
  translate: -50% -50%;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.75);
  stroke-width: 2.4;
}

/* StudioScrubSlider */
.scrubs {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.scrub {
  --f: 0;
  position: relative;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.05);
  box-shadow: inset 0 0 0 1px var(--hairline);
  font-size: 11.5px;
  font-weight: 500;
  cursor: ew-resize;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.scrub-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: calc(var(--f) * 100%);
  background: rgba(255, 255, 255, 0.1);
  transition: background-color 0.12s ease-out;
}
.scrub-mark {
  position: absolute;
  top: 8px;
  left: clamp(0px, calc(var(--f) * 100% - 1px), calc(100% - 2px));
  width: 2px;
  height: 14px;
  background: rgba(255, 255, 255, 0.55);
  transition: background-color 0.12s ease-out;
}
.scrub:hover .scrub-fill {
  background: rgba(255, 255, 255, 0.13);
}
.scrub.dragging .scrub-fill {
  background: rgba(255, 255, 255, 0.16);
}
.scrub:hover .scrub-mark,
.scrub.dragging .scrub-mark,
.scrub:focus-visible .scrub-mark {
  background: rgba(255, 255, 255, 0.9);
}
.scrub-title,
.scrub-value {
  position: relative;
  pointer-events: none;
}
.scrub-title {
  color: rgba(255, 255, 255, 0.82);
}
.scrub-value {
  color: var(--secondary);
  font-variant-numeric: tabular-nums;
}

/* Headline: mini switch in the section header */
.switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  width: 36px;
  height: 16px;
  margin: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.09);
  cursor: pointer;
  transition: background-color 0.2s var(--ease);
}
.switch::before {
  content: "";
  position: absolute;
  left: 1.5px;
  top: 1.5px;
  width: 21px;
  height: 13px;
  border-radius: 7px;
  background: #e2e2e4;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s var(--ease);
}
.switch:checked {
  background: var(--accent);
}
.switch:checked::before {
  background: #fff;
  transform: translateX(12px);
}
#headline {
  display: block;
  width: 100%;
  min-height: 52px;
  max-height: 84px;
  padding: 8px 10px;
  resize: none;
  border: 0;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: inset 0 0 0 1px var(--hairline);
  font-size: 12px;
  line-height: 1.3;
  field-sizing: content;
}
#headline:focus-visible {
  outline-offset: 0;
}
.headline-hint {
  margin: 0;
  font-size: 11px;
  color: var(--tertiary);
}

/* ---------- Compact ---------- */
.compact-editor {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px 16px;
}
.compact-thumb {
  position: relative;
  flex: none;
  width: 170px;
  height: 96px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  overflow: hidden;
  background: var(--stage);
  color: var(--tertiary);
  font-size: 22px;
}
.compact-thumb canvas {
  display: block;
  width: 100%;
  height: 100%;
}
.compact-thumb::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 12px;
  box-shadow: inset 0 0 0 1px var(--hairline);
  pointer-events: none;
}
.compact-copy {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.compact-copy h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

/* Toast */
.toast {
  position: absolute;
  left: 50%;
  bottom: 56px;
  z-index: 5;
  margin: 0;
  transform: translateX(-50%);
  pointer-events: none;
}
#toast {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 16px;
  border-radius: 20px;
  background: var(--surface);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.1),
    0 6px 24px rgba(0, 0, 0, 0.4);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  animation: toast-in 0.15s ease-out;
}
#toast .pn-icon {
  font-size: 14px;
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* ---------- Closed + dialogs ---------- */
#closed-state {
  padding: 30px;
  text-align: center;
  min-height: 560px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 15px;
}
#saved-image {
  max-width: min(560px, 90%);
  max-height: 340px;
  width: auto;
  height: auto;
  border-radius: 10px;
}
#closed-state p {
  margin: 0;
  font-size: 12px;
  color: var(--secondary);
  max-width: 420px;
  line-height: 1.6;
}
dialog {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  background: var(--window);
  color: #fff;
  padding: 20px;
  width: min(560px, calc(100vw - 30px));
  overscroll-behavior: contain;
}
dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
}
dialog header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
dialog h3 {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
}
dialog header p {
  margin: 3px 0 0;
  font-size: 11.5px;
  color: var(--secondary);
}
dialog form {
  margin: 0;
}
.source-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.source-grid button {
  padding: 7px;
  border-radius: 8px;
  text-align: left;
  transition: background-color 0.12s ease-out;
}
.source-grid button:hover {
  background: rgba(255, 255, 255, 0.08);
}
.source-grid img,
.source-grid canvas {
  display: block;
  width: 100%;
  height: 104px;
  object-fit: contain;
  border-radius: 8px;
  background: var(--stage);
}
.source-grid span {
  display: block;
  margin: 7px 2px 0;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#confirm-remove {
  width: min(400px, calc(100vw - 30px));
}
#confirm-remove p {
  font-size: 11.5px;
  color: var(--secondary);
  line-height: 1.6;
}
#confirm-remove > div {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}
#confirm-remove button {
  height: 28px;
  padding: 0 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.1);
  font-size: 12px;
  font-weight: 500;
}
#confirm-delete {
  color: #ff6b62;
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}

/* Narrow frames (homepage on tablets and phones): the inspector moves below
   the stage as four columns; the palette keeps its native size, so the
   editor scrolls sideways under 800 px. */
@media (max-width: 1039px) {
  .studio-app {
    min-width: 800px;
  }
  .expanded-editor {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(300px, 1fr) auto;
  }
  .stage {
    margin: 0 10px;
  }
  .inspector {
    overflow: visible;
    display: grid;
    grid-template-columns: 1.05fr 1fr 1fr 0.9fr;
    gap: 20px;
    padding: 12px 18px 16px;
  }
  .background-grid {
    gap: 6px;
  }
  .format-grid button {
    height: 44px;
  }
  .sample-notice span {
    display: none;
  }
}
