* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

[hidden] {
  display: none !important;
}

/* ------------------------------------------------------------------ *
 * Tokens (shared design language with bg-maker)
 * ------------------------------------------------------------------ */
:root {
  --bg: #000000;
  --surface: #0d0f11;
  --surface-2: #14171a;
  --surface-3: #1c2126;
  --line: #23282d;
  --text: #f2f5f7;
  --text-dim: #7c878f;
  --accent: #7c5cff;
  --accent-hover: #8f74ff;
  --radius: 10px;
  --panel-w: 366px;
  --line-height: 20px;
  --mono:
    ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono",
    monospace;
  --sans:
    "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    sans-serif;
  color-scheme: dark;
}

html,
body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit;
  color: inherit;
}

/* ------------------------------------------------------------------ *
 * Shell
 * ------------------------------------------------------------------ */
.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--panel-w);
  height: 100dvh;
  overflow: hidden;
}

/* ------------------------------------------------------------------ *
 * Header
 * ------------------------------------------------------------------ */
.app-header {
  position: absolute;
  top: 0;
  left: 0;
  padding: 20px 24px;
  z-index: 20;
  pointer-events: none;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  pointer-events: auto;
}

/* ------------------------------------------------------------------ *
 * Footer
 * ------------------------------------------------------------------ */
.app-footer {
  /* Fixed, not absolute: the stage scrolls, and an absolute footer would
     anchor to the content box and scroll away from the bottom edge.
     The settings panel is a right column, so the left edge stays clear. */
  position: fixed;
  bottom: 0;
  left: 0;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 24px;
  font-size: 13px;
  color: var(--text-dim);
  z-index: 20;
}

.app-footer__links {
  display: flex;
  gap: 14px;
}

.app-footer a {
  color: var(--text-dim);
  text-decoration: none;
  transition: color 0.15s ease;
}

.app-footer a:hover {
  color: var(--text);
}

.app-footer a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 3px;
}

/* ------------------------------------------------------------------ *
 * Stage
 * ------------------------------------------------------------------ */
.stage {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 72px 40px;
  min-width: 0;
  background: var(--bg);
  overflow-y: auto;
}

.frame-row {
  display: flex;
  align-items: center;
  max-width: 100%;
}

/* ---------- Frame + window ---------- */

.frame {
  position: relative;
  background: var(--frame-bg, transparent);
  max-width: calc(100vw - var(--panel-w) - 120px);
  transition: padding 0.15s ease;
}

.watermark {
  position: absolute;
  display: inline-flex;
  align-items: center;
  color: var(--watermark-color, rgba(255, 255, 255, 0.55));
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1;
  opacity: 0.72;
  pointer-events: none;
  user-select: none;
  white-space: nowrap;
  max-width: calc(100% - 24px);
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Corner placement. Offsets are inside the frame padding so the watermark
   stays within the exported image at every position. */
.watermark--bottom-right {
  right: 12px;
  bottom: 8px;
}
.watermark--bottom-left {
  left: 12px;
  bottom: 8px;
}
.watermark--top-right {
  right: 12px;
  top: 8px;
}
.watermark--top-left {
  left: 12px;
  top: 8px;
}

.frame.resizing {
  transition: none;
}

.window {
  border-radius: var(--window-radius, 11px);
  background: var(--window-bg);
  border: 1px solid var(--window-border);
  box-shadow: 0 calc(20px * var(--shadow-scale, 1))
    calc(68px * var(--shadow-scale, 1)) rgba(0, 0, 0, 0.55);
  min-width: 320px;
  overflow: hidden;
}

.window.no-shadow {
  box-shadow: none;
}

.window-header {
  display: grid;
  grid-template-columns: 60px 1fr 60px;
  align-items: center;
  padding: 14px 16px 0;
}

.traffic-lights {
  display: flex;
  gap: 8px;
}

/* Keep the 60px grid column so the title stays centred. */
.window.no-dots .traffic-lights {
  visibility: hidden;
}

.tl {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}
.tl-red {
  background: #ff5f57;
}
.tl-yellow {
  background: #febc2e;
}
.tl-green {
  background: #28c840;
}

.window-title {
  background: transparent;
  border: none;
  outline: none;
  text-align: center;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  color: var(--title-color);
  min-width: 0;
}
.window-title::placeholder {
  color: var(--title-color);
  opacity: 0.7;
}

/* ---------- Editor ---------- */

.window.no-header .window-header {
  display: none;
}

.editor {
  display: flex;
  padding: 16px 16px 20px;
}

.window.no-header .editor {
  padding-top: 20px;
}

.gutter {
  flex: none;
  width: 40px;
  padding-right: 16px;
  text-align: right;
  font-family: var(--mono);
  font-size: 13px;
  line-height: var(--line-height, 20px);
  color: var(--gutter-color);
  user-select: none;
}

.editor.no-gutter .gutter {
  display: none;
}
.editor.no-gutter {
  padding-left: 24px;
}

.code-area {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
}

.highlight,
.code-input {
  font-family: var(--mono);
  font-size: 13px;
  line-height: var(--line-height, 20px);
  tab-size: 4;
  white-space: pre;
  word-wrap: normal;
}

.highlight {
  margin: 0;
  min-height: var(--line-height, 20px);
  overflow: hidden;
}

.highlight code.hljs {
  display: block;
  padding: 0;
  background: transparent;
  color: var(--sx-fg);
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  overflow: visible;
}

.code-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  outline: none;
  resize: none;
  overflow: hidden;
  background: transparent;
  color: transparent;
  caret-color: var(--sx-fg);
}

.code-input::selection {
  background: var(--selection-bg);
}

/* ---------- Syntax token mapping ---------- */

.hljs-comment,
.hljs-quote {
  color: var(--sx-comment);
  font-style: italic;
}
.hljs-keyword,
.hljs-selector-tag,
.hljs-literal,
.hljs-name,
.hljs-tag {
  color: var(--sx-keyword);
}
.hljs-string,
.hljs-regexp,
.hljs-addition,
.hljs-selector-attr,
.hljs-selector-pseudo {
  color: var(--sx-string);
}
.hljs-number,
.hljs-symbol,
.hljs-bullet,
.hljs-link {
  color: var(--sx-number);
}
.hljs-title,
.hljs-title.function_,
.hljs-section {
  color: var(--sx-title);
}
.hljs-title.class_,
.hljs-type,
.hljs-built_in,
.hljs-class {
  color: var(--sx-type);
}
.hljs-attr,
.hljs-attribute,
.hljs-property,
.hljs-variable,
.hljs-template-variable,
.hljs-selector-class,
.hljs-selector-id {
  color: var(--sx-attr);
}
.hljs-meta,
.hljs-doctag,
.hljs-deletion {
  color: var(--sx-meta);
}
.hljs-params {
  color: var(--sx-fg);
}
.hljs-emphasis {
  font-style: italic;
}
.hljs-strong {
  font-weight: 700;
}

/* ---------- Resize handles ---------- */

.resize-handle {
  flex: none;
  width: 28px;
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  cursor: ew-resize;
  touch-action: none;
}

.resize-handle .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #d7d7de;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.08);
  opacity: 0.55;
  transition:
    opacity 0.15s ease,
    transform 0.15s ease;
}

.resize-handle:hover .dot,
.resize-handle.active .dot {
  opacity: 1;
  transform: scale(1.2);
}

/* ---------- Auto width hint ---------- */

.auto-width-hint {
  margin-top: 18px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-family: var(--sans);
  font-size: 12.5px;
  cursor: pointer;
  transition: color 0.15s ease;
}

.auto-width-hint:hover {
  color: var(--text);
}
.auto-width-hint.measuring {
  pointer-events: none;
}

/* ------------------------------------------------------------------ *
 * Panel
 * ------------------------------------------------------------------ */
.panel {
  background: var(--surface);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.panel__scroll {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.section {
  border-bottom: 1px solid var(--line);
}

.section__head {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 18px 22px;
  background: none;
  border: 0;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text);
}
.section__head:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.chev {
  transition: transform 150ms ease;
  color: var(--text-dim);
}
.section__head[aria-expanded="false"] .chev {
  transform: rotate(180deg);
}

.section__body {
  padding: 0 22px 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ------------------------------------------------------------------ *
 * Fields
 * ------------------------------------------------------------------ */
.field {
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.field--inline {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

.field__label {
  font-size: 14px;
  color: var(--text-dim);
}
.field__label--inline {
  color: var(--text);
}

/* Theme picker ----------------------------------------------------- */
.picker {
  position: relative;
}

.picker__trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
  border: 0;
  border-radius: var(--radius);
  background: var(--surface-2);
  cursor: pointer;
  text-align: left;
  font-size: 15px;
  font-weight: 600;
  transition: background 120ms ease;
}
.picker__trigger:hover {
  background: var(--surface-3);
}
.picker__trigger:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 0;
}

.picker__current {
  display: flex;
  align-items: center;
  gap: 10px;
}

.theme-swatch {
  width: 22px;
  height: 22px;
  flex: none;
  border-radius: 50%;
  background: var(--swatch, #888);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22);
}

.picker__caret {
  display: grid;
  place-items: center;
  color: var(--text-dim);
}
.picker__caret .chev {
  transform: rotate(180deg);
}
.picker__trigger[aria-expanded="true"] .picker__caret .chev {
  transform: rotate(0deg);
}

.picker__list {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.65);
}

.theme-popover {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 10px;
}

.theme-popover button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 10px 6px 8px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--text-dim);
  font-size: 11.5px;
  cursor: pointer;
  transition:
    background 120ms ease,
    color 120ms ease;
}
.theme-popover button:hover {
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
}
.theme-popover button.is-active {
  border-color: var(--accent);
  color: var(--text);
}
.theme-popover button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.theme-popover .swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22);
}

/* Segmented ------------------------------------------------------- */
.segmented {
  display: flex;
  gap: 2px;
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 4px;
}

.segmented__btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 38px;
  padding: 8px 4px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition:
    background 120ms ease,
    color 120ms ease;
}
.segmented__btn:hover {
  color: var(--text);
}
.segmented__btn.is-active {
  background: var(--surface-3);
  color: var(--text);
}
.segmented__btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.segmented__label {
  font-size: 13px;
  font-weight: 500;
}

/* Switch ---------------------------------------------------------- */
.switch {
  --switch-w: 46px;
  --switch-h: 26px;
  --switch-pad: 3px;
  position: relative;
  display: inline-block;
  flex: none;
  cursor: pointer;
}

/* Inline variant for controls that sit beside another widget. */
.switch--sm {
  --switch-w: 34px;
  --switch-h: 19px;
  --switch-pad: 2px;
}

.switch input {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.switch__track {
  display: block;
  width: var(--switch-w);
  height: var(--switch-h);
  border-radius: 999px;
  background: var(--surface-3);
  transition: background 140ms ease;
}

.switch__thumb {
  position: absolute;
  top: var(--switch-pad);
  left: var(--switch-pad);
  width: calc(var(--switch-h) - 2 * var(--switch-pad));
  height: calc(var(--switch-h) - 2 * var(--switch-pad));
  border-radius: 50%;
  background: #fff;
  transition: transform 140ms ease;
}

.switch input:checked + .switch__track {
  background: var(--accent);
}
.switch input:checked + .switch__track .switch__thumb {
  transform: translateX(calc(var(--switch-w) - var(--switch-h)));
}
.switch input:focus-visible + .switch__track {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* Slider ----------------------------------------------------------- */
.field__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.field__value {
  font-size: 13px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 20px;
  background: none;
  cursor: pointer;
}

.slider::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  background: var(--surface-3);
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  margin-top: -6px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: transform 140ms ease;
}

.slider::-moz-range-track {
  height: 4px;
  border-radius: 999px;
  background: var(--surface-3);
}

.slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: none;
  border-radius: 50%;
  background: #fff;
  transition: transform 140ms ease;
}

.slider:active::-webkit-slider-thumb {
  transform: scale(1.12);
}
.slider:active::-moz-range-thumb {
  transform: scale(1.12);
}
.slider:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 4px;
}

.field.is-disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* Language select -------------------------------------------------- */
.select-wrap {
  position: relative;
}

.select-wrap select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 42px;
  padding: 0 36px 0 14px;
  background: var(--surface-2);
  border: 0;
  border-radius: 8px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  cursor: pointer;
  transition: background 120ms ease;
}

.select-wrap select:hover {
  background: var(--surface-3);
}
.select-wrap select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 0;
}
.select-wrap select option {
  background: var(--surface-3);
  color: var(--text);
}

.select-wrap .chevron {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%) rotate(180deg);
  color: var(--text-dim);
  pointer-events: none;
}

/* ------------------------------------------------------------------ *
 * Export
 * ------------------------------------------------------------------ */
.panel__download {
  border-top: 1px solid var(--line);
  padding: 16px 22px 20px;
  background: var(--surface);
}

/* Label row doubles as the home for Reset — it rides in the space the label
   already leaves empty, so the action costs no extra panel height. */
.panel__download-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel__download-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.panel__reset {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: none;
  color: var(--text-dim);
  font: inherit;
  font-size: 11px;
  line-height: 1.4;
  cursor: pointer;
}

.panel__reset:hover {
  color: var(--text);
  border-color: var(--text-dim);
}

.panel__reset svg {
  flex: none;
}

/* Reusable tooltip. Same surface, border and radius as the popovers and the
   toast, so floating chrome reads as one family. Opens above the host —
   every current user sits in the pinned footer, where there is no room below. */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after,
[data-tooltip]::before {
  position: absolute;
  bottom: calc(100% + 8px);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.14s ease,
    transform 0.14s ease;
  z-index: 40;
}

/* Centring is done with translate, not a negative margin: percentage margins
   resolve against the host's width, but translate resolves against the
   bubble's own. --tt-x lets the alignment variants swap that offset out. */
[data-tooltip]::after {
  content: attr(data-tooltip);
  --tt-x: -50%;
  left: 50%;
  transform: translate(var(--tt-x), 3px);
  padding: 6px 10px;
  width: max-content;
  max-width: 220px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  color: var(--text);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: 0;
  text-transform: none;
  text-align: center;
}

/* The arrow is a rotated square, so only two of its borders should show. */
[data-tooltip]::before {
  content: "";
  --tt-x: -50%;
  left: 50%;
  transform: translate(var(--tt-x), 3px) rotate(45deg);
  width: 8px;
  height: 8px;
  bottom: calc(100% + 4px);
  background: var(--surface-3);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

[data-tooltip]:hover::after,
[data-tooltip]:focus-visible::after {
  opacity: 1;
  transform: translate(var(--tt-x), 0);
}

[data-tooltip]:hover::before,
[data-tooltip]:focus-visible::before {
  opacity: 1;
  transform: translate(var(--tt-x), 0) rotate(45deg);
}

/* Right-anchored variant: a centred bubble would spill past the panel edge. */
[data-tooltip-align="right"]::after {
  --tt-x: 0;
  left: auto;
  right: 0;
  text-align: left;
}

[data-tooltip-align="right"]::before {
  --tt-x: 0;
  left: auto;
  right: 18px;
}

@media (prefers-reduced-motion: reduce) {
  [data-tooltip]::after,
  [data-tooltip]::before {
    transition: none;
  }
}

.panel__download-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* Hosts the tooltip for a button that can be disabled: the bubble sits on
   this wrapper instead of the button itself so a disabled button's opacity
   doesn't wash out the tooltip along with it. */
.tooltip-host {
  display: block;
}

.tooltip-host > .btn {
  width: 100%;
}

.btn {
  padding: 13px 16px;
  border: 0;
  border-radius: 8px;
  background: var(--surface-3);
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  transition:
    background 120ms ease,
    opacity 120ms ease;
}
.btn:hover:not(:disabled) {
  background: #2a3138;
}
.btn--primary {
  background: var(--accent);
}
.btn--primary:hover:not(:disabled) {
  background: var(--accent-hover);
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* ------------------------------------------------------------------ *
 * Toast + width badge
 * ------------------------------------------------------------------ */
.toast {
  position: fixed;
  top: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-3);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 999px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  z-index: 60;
  animation: toast-in 0.18s ease;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, -6px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

.width-badge {
  position: fixed;
  padding: 5px 10px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12px;
  font-family: var(--mono);
  color: var(--text);
  pointer-events: none;
  z-index: 50;
}

/* ------------------------------------------------------------------ *
 * Narrow screens — stack the two columns.
 * ------------------------------------------------------------------ */
@media (max-width: 1100px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(320px, 1fr) auto;
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }
  .stage {
    padding: 84px 20px 40px;
    overflow-y: visible;
  }
  .frame {
    max-width: calc(100vw - 120px);
  }
  .panel {
    border-left: 0;
    border-top: 1px solid var(--line);
  }
  .panel__scroll {
    overflow-y: visible;
  }
  /* The page scrolls at this width, so a fixed footer would hover over the
     settings panel. Let it flow at the end of the stage instead. */
  .app-footer {
    position: static;
    justify-content: center;
    padding-top: 28px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition-duration: 0.01ms !important;
  }
}

/* ------------------------------------------------------------------ *
 * Watermark customisation (paid feature)
 * ------------------------------------------------------------------ */
.watermark-custom {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 4px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

/* Dim the gated fields, but not the lock note — opacity on the whole block
   would take the call to action down with it, and that is the way out. */
.watermark-custom.is-locked > *:not(.watermark-lock) {
  opacity: 0.55;
}

.watermark-lock {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-dim);
}

.watermark-lock__icon {
  font-size: 12px;
  display: inline-block;
  animation: watermark-lock-pulse 1.6s ease-in-out infinite;
}

@keyframes watermark-lock-pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.2);
    opacity: 0.6;
  }
}

.watermark-lock__text {
  flex: 1;
}

.watermark-lock__cta {
  flex: none;
  padding: 4px 10px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.watermark-lock__cta:hover {
  filter: brightness(1.08);
}

.watermark-lock__cta:disabled {
  opacity: 0.6;
  cursor: default;
}

.text-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
}

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

.text-input:disabled,
.watermark-custom.is-locked input,
.watermark-custom.is-locked select {
  cursor: not-allowed;
}

.watermark-color {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.watermark-color__auto {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-dim);
}

.watermark-color input[type="color"] {
  width: 30px;
  height: 24px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  cursor: pointer;
}

/* ------------------------------------------------------------------ *
 * Account
 * ------------------------------------------------------------------ */
.account {
  position: fixed;
  top: 16px;
  /* Keep clear of the settings panel, which is a fixed-width right column. */
  right: calc(var(--panel-w) + 24px);
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 30;
  pointer-events: auto;
}

.account__status {
  font-size: 12px;
  color: var(--text-dim);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account.is-unlocked .account__status {
  color: var(--text);
}

.account__btn {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

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

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

.account__btn--accent {
  border-color: transparent;
  background: var(--accent);
}

.account__btn--accent:hover {
  background: var(--accent-hover);
}

.account__btn--ghost {
  background: transparent;
  color: var(--text-dim);
}

.account__btn[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ------------------------------------------------------------------ *
 * Sign-in modal
 * ------------------------------------------------------------------ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.66);
  backdrop-filter: blur(3px);
}

.modal__dialog {
  position: relative;
  width: min(360px, 100%);
  padding: 28px 24px 24px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  text-align: center;
  animation: modal-in 140ms ease-out;
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.985);
  }
}

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

.modal__close {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
}

.modal__close:hover {
  background: var(--surface-2);
  color: var(--text);
}

.modal__title {
  font-family: var(--sans);
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
}

.modal__subtitle {
  margin-top: 6px;
  font-family: var(--sans);
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-dim);
}

.modal__providers {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 20px;
}

.modal__empty {
  margin-top: 18px;
  font-family: var(--sans);
  font-size: 12.5px;
  color: var(--text-dim);
}

.modal__spinner {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}

.spinner--lg {
  width: 28px;
  height: 28px;
  border-width: 3px;
}

.modal__watermark-note {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-family: var(--sans);
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-dim);
}

.modal__watermark-cta {
  padding: 2px 9px;
  margin: 0 2px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
}

.modal__watermark-cta:hover {
  filter: brightness(1.08);
}

.provider-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
}

.provider-btn:hover {
  background: var(--surface-3);
  border-color: #2e353c;
}

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

body.is-modal-open {
  overflow: hidden;
}

/* Pending state — the /sign-in/social round-trip plus the redirect is slow
   enough to read as a dead click without this. */
.provider-btn__pending {
  display: none;
  align-items: center;
  gap: 9px;
  color: var(--text-dim);
}

.provider-btn.is-pending > svg,
.provider-btn.is-pending .provider-btn__label {
  display: none;
}

.provider-btn.is-pending .provider-btn__pending {
  display: inline-flex;
}

/* Only the untaken options grey out; the one being used stays legible. */
.provider-btn:disabled {
  cursor: default;
}

.provider-btn:disabled:not(.is-pending) {
  opacity: 0.45;
}

.provider-btn:disabled:hover {
  background: var(--surface-2);
  border-color: var(--line);
}

.spinner {
  width: 13px;
  height: 13px;
  border: 2px solid var(--line);
  border-top-color: var(--text-dim);
  border-radius: 50%;
  animation: spin 620ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation-duration: 1.8s;
  }
}

/* ------------------------------------------------------------------ *
 * Legal pages (terms, privacy)
 * ------------------------------------------------------------------ */
.legal-page {
  max-width: 760px;
  margin: 0 auto;
  padding: 40px 24px 80px;
  line-height: 1.65;
}

.legal-header {
  margin-bottom: 32px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.legal-page h1 {
  font-size: 30px;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.legal-page h2 {
  font-size: 18px;
  margin-top: 34px;
  margin-bottom: 12px;
}

.legal-page h3 {
  font-size: 15px;
  margin-top: 20px;
  margin-bottom: 10px;
}

.legal-page p {
  margin-bottom: 14px;
  color: var(--text-dim);
}

.legal-page .updated {
  font-size: 13px;
  margin-bottom: 8px;
}

.legal-page ul {
  margin: 0 0 14px 20px;
  color: var(--text-dim);
}

.legal-page li {
  margin-bottom: 8px;
}

.legal-page a {
  color: var(--accent);
  text-decoration: none;
}

.legal-page a:hover {
  text-decoration: underline;
}

.legal-page strong {
  color: var(--text);
}

.legal-back {
  margin-top: 44px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

/* ------------------------------------------------------------------ *
 * Pricing
 * ------------------------------------------------------------------ */
.pricing-page {
  max-width: 900px;
}

.pricing-intro {
  text-align: center;
  max-width: 560px;
  margin: 0 auto 40px;
}

.pricing-intro h1 {
  font-size: 30px;
  letter-spacing: -0.02em;
  margin-bottom: 10px;
}

.pricing-intro p {
  color: var(--text-dim);
  line-height: 1.6;
}

.pricing-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  align-items: stretch;
}

@media (max-width: 680px) {
  .pricing-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.plan-box {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 24px;
}

.plan-box--featured {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.plan-box__badge {
  position: absolute;
  top: -11px;
  left: 24px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
}

.plan-box__head {
  padding-bottom: 20px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.plan-box__name {
  font-size: 20px;
  margin-bottom: 4px;
}

.plan-box__tagline {
  color: var(--text-dim);
  font-size: 14px;
  margin-bottom: 16px;
}

.plan-box__price {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.plan-box__amount {
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.plan-box__period {
  color: var(--text-dim);
  font-size: 14px;
}

.plan-box__features {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  margin-bottom: 24px;
}

.plan-box__features li {
  position: relative;
  padding-left: 26px;
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.5;
}

.plan-box__features li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 3px;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E")
    center / 11px no-repeat;
}

.plan-box__features strong {
  color: var(--text);
}

.plan-box__cta {
  display: block;
  width: 100%;
  text-align: center;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition:
    background 0.15s ease,
    border-color 0.15s ease;
}

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

.plan-box__cta--primary {
  background: var(--accent);
  color: #fff;
}

.plan-box__cta--primary:hover {
  background: var(--accent-hover);
}

.plan-box__cta--primary:disabled {
  opacity: 0.7;
  cursor: default;
}

.plan-box__cta--ghost {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--line);
}

.plan-box__cta--ghost:hover {
  background: var(--surface-3);
}

.plan-box__note {
  margin: 12px 0 0;
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.5;
}
