/* ==========================================================================
   Converter page and workspace
   The drop area, the state machine panels and the result screen. This is the
   part of the interface that must never feel ambiguous.
   ========================================================================== */

/* ------------------------------------------------------------ page header */
.converter-hero {
  padding-block: var(--space-10) var(--space-6);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.converter-hero__crumbs {
  margin-bottom: var(--space-5);
}

.converter-hero__title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4);
}

.converter-hero__title {
  font-size: clamp(1.75rem, 3vw, 2.5rem);
}

.converter-hero__lede {
  margin-top: var(--space-4);
  max-width: 68ch;
  color: var(--text-muted);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
}

.converter-hero__meta {
  margin-top: var(--space-5);
}

/* --------------------------------------------------------------- layout */
.converter-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: var(--space-8);
  align-items: start;
  padding-block: var(--space-10);
}

.converter-main {
  display: grid;
  gap: var(--space-8);
  min-width: 0;
}

.converter-sidebar {
  display: grid;
  gap: var(--space-5);
  position: sticky;
  top: calc(var(--header-height) + var(--space-6));
}

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

  .converter-sidebar {
    position: static;
  }
}

/* ----------------------------------------------------------- workspace card */
.workspace {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.workspace__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border);
}

.workspace__title {
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  letter-spacing: -0.015em;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.workspace__body {
  padding: clamp(1rem, 3vw, 1.75rem);
}

.workspace__foot {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

/* --------------------------------------------------------------- dropzone */
.dropzone {
  position: relative;
  display: grid;
  place-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-8) var(--space-6);
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--accent);
  border-radius: var(--radius-sm);
  transition: border-color var(--duration-fast) var(--ease-out),
    background-color var(--duration-fast) var(--ease-out);
}

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

.dropzone:focus-within {
  box-shadow: var(--focus-ring);
}

.dropzone.is-dragging {
  border-color: var(--accent);
  border-style: solid;
  background: var(--pill);
}

.dropzone.is-invalid {
  border-color: var(--danger);
}

.dropzone.is-invalid.is-dragging {
  background: var(--danger-soft);
}

.dropzone__icon {
  display: grid;
  place-items: center;
  color: var(--accent);
}

.dropzone__icon svg {
  width: 24px;
  height: 24px;
  stroke-width: 1.4;
}

.dropzone__title {
  display: block;
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  letter-spacing: -0.015em;
  color: var(--text);
}

.dropzone__subtitle {
  display: block;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.dropzone__or {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: min(260px, 100%);
  color: var(--text-muted);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-wide);
}

.dropzone__or::before,
.dropzone__or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.dropzone__formats {
  font-size: var(--text-xs);
  color: var(--text-muted);
  max-width: 52ch;
}

.dropzone__formats code {
  background: transparent;
  border: 0;
  padding: 0;
  color: var(--text-2);
  font-size: var(--text-2xs);
}

.dropzone__privacy {
  margin-top: var(--space-1);
}

.dropzone__live {
  min-height: 1.25rem;
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* A tighter variant used inside the homepage quick-start card. */
.dropzone--compact {
  padding: var(--space-5) var(--space-4);
  gap: var(--space-2);
}

.dropzone--compact .dropzone__icon svg {
  width: 20px;
  height: 20px;
}

.dropzone--compact .dropzone__title {
  font-size: var(--text-sm);
  display: block;
}

.dropzone--compact .dropzone__subtitle {
  display: block;
  font-size: var(--text-xs);
}

/* The formats note is supporting detail: smaller, on its own line, and never
   wider than the card padding allows. */
.dropzone--compact .dropzone__formats {
  margin-top: var(--space-1);
  font-size: var(--text-2xs);
  line-height: 1.5;
  max-width: 34ch;
}

/* Homepage quick-start: tools matched from the dropped file name. */
.quick-matches {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}

/* Homepage card: a single column with an even rhythm between the field, the
   primary action and the drop area. */
[data-quick-start] .card__body {
  display: grid;
  gap: var(--space-4);
}

[data-quick-start] .card__body > * + * {
  margin-top: 0;
}

[data-quick-start] .converter-form {
  gap: var(--space-3);
}

.quick-matches__title {
  font-size: var(--text-sm);
  font-weight: var(--weight-normal);
  color: var(--text-muted);
  margin-bottom: var(--space-3);
}

.quick-matches__list {
  display: grid;
  gap: var(--space-2);
  list-style: none;
  padding: 0;
  margin: 0;
}

.quick-match {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: background-color var(--duration-fast) var(--ease-out);
}

.quick-match:hover {
  color: var(--text);
  background: var(--surface-hover);
  text-decoration: none;
}

.quick-match__icon {
  display: grid;
  place-items: center;
  color: var(--text-muted);
  flex-shrink: 0;
}

.quick-match__icon svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.5;
}

.quick-match__text {
  display: grid;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.quick-match__title {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quick-match__meta {
  font-size: var(--text-xs);
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.quick-match__arrow {
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ------------------------------------------------------------- file list */
.file-list {
  display: grid;
  gap: var(--space-3);
}

.file-item {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.file-item__icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--pill);
  border: 1px solid var(--border);
  color: var(--text-muted);
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  font-weight: var(--weight-normal);
}

.file-item__body {
  min-width: 0;
  flex: 1;
  display: grid;
  gap: 2px;
}

.file-item__name {
  font-weight: var(--weight-medium);
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-item__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.file-item__actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

/* ------------------------------------------------------- conversion form */
.converter-form {
  display: grid;
  gap: var(--space-5);
}

.converter-form__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--space-4);
}

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

.converter-form__flow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-muted);
  letter-spacing: 0;
}

.converter-form__flow svg {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}

/* Read-only statement of the output format for in-place tools. */
.output-note {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0.5rem 0.75rem;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-muted);
  font-size: var(--text-sm);
}

/* Checkbox controls for tool options (find and replace, line endings). */
.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3) var(--space-5);
}

.checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-muted);
  cursor: pointer;
}

.checkbox-row input {
  flex-shrink: 0;
}

.checkbox-row:hover {
  color: var(--text);
}

.output-note svg {
  width: 15px;
  height: 15px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.output-note code {
  background: transparent;
  border: 0;
  padding: 0;
  color: var(--text);
}

/* ---------------------------------------------------------- state panels */
.state-panel {
  display: grid;
  gap: var(--space-4);
  padding: clamp(1.25rem, 3vw, 2rem);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
}

.state-panel--center {
  justify-items: center;
  text-align: center;
}

.state-panel__icon {
  display: grid;
  place-items: center;
  color: var(--accent);
}

.state-panel__icon svg {
  width: 24px;
  height: 24px;
  stroke-width: 1.4;
}

.state-panel__title {
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  letter-spacing: -0.015em;
}

.state-panel__body {
  color: var(--text-muted);
  font-size: var(--text-sm);
  max-width: 56ch;
  line-height: var(--leading-normal);
}

.state-panel--success .state-panel__icon {
  color: var(--success);
}

.state-panel--error {
  border-color: var(--danger-border);
  background: var(--danger-soft);
}

.state-panel--error .state-panel__icon {
  color: var(--danger);
}

.state-panel--warning {
  border-color: var(--warning-border);
  background: var(--warning-soft);
}

.state-panel--warning .state-panel__icon {
  color: var(--warning);
}

/* Spinner sized for a state panel. */
.state-spinner {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--pill);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

/* ---------------------------------------------------------- result screen */
.result-card {
  display: grid;
  gap: var(--space-5);
}

.result-head {
  display: grid;
  justify-items: center;
  text-align: center;
  gap: var(--space-2);
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(130px, 100%), 1fr));
  gap: var(--space-4);
  padding: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.result-stat {
  display: grid;
  gap: 2px;
}

.result-stat__label {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.result-stat__value {
  font-weight: var(--weight-medium);
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------- state preview grid */
.state-gallery {
  display: grid;
  gap: var(--space-5);
}

.state-gallery__item {
  display: grid;
  gap: var(--space-2);
}

.state-gallery__label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  font-weight: var(--weight-normal);
  letter-spacing: var(--tracking-wide);
  color: var(--text-muted);
}

.state-gallery__label span {
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: var(--radius-full);
  background: var(--pill);
  color: var(--text-muted);
  font-size: 10px;
}

.state-gallery__frame {
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

/* ============================================== preview / visualiser */
.preview-pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: var(--space-4);
}

.preview-pair--single {
  grid-template-columns: minmax(0, 1fr);
}

.preview-pair__arrow {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  color: var(--text-muted);
}

.preview-pair__arrow svg {
  width: 16px;
  height: 16px;
}

@media (max-width: 720px) {
  .preview-pair {
    grid-template-columns: minmax(0, 1fr);
    justify-items: stretch;
  }

  .preview-pair__arrow {
    justify-self: center;
    transform: rotate(90deg);
  }
}

.preview {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  margin: 0;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
}

.preview__head,
.preview__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  min-width: 0;
}

.preview__head {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.preview__foot {
  border-top: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
}

.preview__label {
  font-weight: var(--weight-medium);
  color: var(--text);
}

.preview__kind {
  flex-shrink: 0;
}

.preview__name {
  font-weight: var(--weight-medium);
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.preview__meta {
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.preview__stage {
  display: grid;
  place-items: center;
  min-height: 220px;
  max-height: 380px;
  padding: var(--space-3);
  background: var(--pill);
  overflow: auto;
}

.preview__image {
  max-width: 100%;
  max-height: 340px;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.preview__frame {
  width: 100%;
  height: 340px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.preview__video {
  max-width: 100%;
  max-height: 340px;
  width: auto;
  height: auto;
  border-radius: var(--radius-sm);
  background: var(--text);
}

.preview__audio {
  width: 100%;
  max-width: 420px;
}

.preview__text {
  margin: 0;
  width: 100%;
  align-self: stretch;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 1.6;
  color: var(--text);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.preview__placeholder {
  display: grid;
  justify-items: center;
  gap: var(--space-2);
  color: var(--text-muted);
  font-size: var(--text-sm);
  text-align: center;
}

.preview__placeholder svg {
  width: 22px;
  height: 22px;
  color: var(--text-muted);
  stroke-width: 1.4;
}

.preview__placeholder p {
  margin: 0;
  max-width: 30ch;
}

/* Static illustration used by the design-reference gallery, where there is no
   real file behind the panel. */
.preview__sample {
  width: 100%;
  align-self: stretch;
  padding: var(--space-3);
  background: var(--surface);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  color: var(--text-2);
  line-height: var(--leading-relaxed);
}

.preview__sample p {
  margin: 0 0 var(--space-2);
}

.preview__sample p:last-child {
  margin-bottom: 0;
}

.preview__sample-title {
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  color: var(--text);
}

/* PDF and HTML previews need the full stage, not the padded checkerboard. */
.preview__stage:has(.preview__frame) {
  padding: 0;
  background: var(--pill);
}

/* ----------------------------------------------------------- sidebar bits */
.side-card {
  padding: var(--space-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.side-card__title {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-wide);
  color: var(--text-muted);
  margin-bottom: var(--space-4);
}

.side-list {
  display: grid;
  gap: var(--space-3);
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.side-list li {
  display: flex;
  gap: var(--space-3);
}

.side-list svg {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  margin-top: 3px;
  flex-shrink: 0;
  stroke-width: 1.5;
}

.side-list--check svg {
  color: var(--success);
}

.kv {
  display: grid;
  gap: var(--space-3);
  margin: 0;
}

.kv__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  font-size: var(--text-sm);
}

.kv__key {
  color: var(--text-muted);
}

.kv__value {
  color: var(--text);
  font-weight: var(--weight-medium);
  text-align: right;
  min-width: 0;
  overflow-wrap: anywhere;
}

/* -------------------------------------------------------- browser support */
.support-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr));
  gap: var(--space-3);
}

.support-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: var(--text-xs);
}

.support-item svg {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  stroke-width: 1.5;
}

.support-item__label {
  flex: 1;
  min-width: 0;
  color: var(--text-muted);
}

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

.support-item--ok svg {
  color: var(--success);
}

.support-item--warn svg {
  color: var(--warning);
}

.support-item--no svg {
  color: var(--danger);
}

.support-item--no {
  border-color: var(--danger-border);
  background: var(--danger-soft);
}

.note--danger {
  color: var(--danger-text);
}

/* ------------------------------------------------------------ crop editor */
/* A draggable crop frame like a phone photo editor: move it from the inside,
   resize it from any of the eight handles. The box-shadow dims everything
   outside the selection without an extra element. */
.crop-editor {
  display: grid;
  gap: var(--space-3);
  justify-items: center;
}

.crop-editor__frame {
  position: relative;
  display: inline-block;
  max-width: 100%;
  line-height: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--pill);
}

.crop-editor__image {
  display: block;
  max-width: 100%;
  height: auto;
  user-select: none;
  -webkit-user-drag: none;
}

.crop-editor__box {
  position: absolute;
  box-sizing: border-box;
  border: 1px solid var(--accent);
  box-shadow: 0 0 0 9999px color-mix(in srgb, var(--text) 55%, transparent);
  cursor: move;
  touch-action: none;
}

.crop-editor__handle {
  position: absolute;
  width: 14px;
  height: 14px;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 2px;
  touch-action: none;
}

.crop-editor__handle--nw { left: -9px; top: -9px; cursor: nwse-resize; }
.crop-editor__handle--n  { left: 50%; top: -9px; transform: translateX(-50%); cursor: ns-resize; }
.crop-editor__handle--ne { right: -9px; top: -9px; cursor: nesw-resize; }
.crop-editor__handle--e  { right: -9px; top: 50%; transform: translateY(-50%); cursor: ew-resize; }
.crop-editor__handle--se { right: -9px; bottom: -9px; cursor: nwse-resize; }
.crop-editor__handle--s  { left: 50%; bottom: -9px; transform: translateX(-50%); cursor: ns-resize; }
.crop-editor__handle--sw { left: -9px; bottom: -9px; cursor: nesw-resize; }
.crop-editor__handle--w  { left: -9px; top: 50%; transform: translateY(-50%); cursor: ew-resize; }

.crop-editor__hint {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--text-xs);
  text-align: center;
  line-height: 1.6;
}

/* ---------------------------------------------------------- rotate editor */
/* A preview with rotate controls: click the rotate icon (or a button) to turn
   the image a quarter turn. The image is CSS-rotated for the preview; the
   engine applies the real rotation on Convert. The frame is square so a
   quarter turn of an image that already fits can never clip. */
.rotate-editor {
  display: grid;
  gap: var(--space-3);
  justify-items: center;
}

.rotate-editor__frame {
  position: relative;
  display: grid;
  place-items: center;
  width: min(100%, 420px);
  aspect-ratio: 1 / 1;
  padding: var(--space-4);
  background: var(--pill);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.rotate-editor__image {
  grid-area: 1 / 1;
  display: block;
  max-width: 100%;
  max-height: 100%;
  transition: transform var(--duration-base) var(--ease-out);
  user-select: none;
  -webkit-user-drag: none;
}

/* The rotate icon that sits on the image itself: one click turns it 90°. */
.rotate-editor__spin {
  position: absolute;
  right: var(--space-3);
  bottom: var(--space-3);
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.125rem;
  transition: color var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out);
}

.rotate-editor__spin:hover,
.rotate-editor__spin:focus-visible {
  color: var(--accent);
  border-color: var(--accent);
}

.rotate-editor__controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  justify-content: center;
}

.rotate-editor__value {
  margin-left: var(--space-2);
  padding: 2px 10px;
  border-radius: var(--radius-full);
  background: var(--pill);
  border: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
  font-size: var(--text-xs);
  font-weight: var(--weight-normal);
  color: var(--text-muted);
}

/* ------------------------------------------------------ colour picker */
/* A live eyedropper: the image is shown, hovering reads the pixel under the
   pointer, and the readout shows its HEX and RGB values. The small ring marks
   exactly which pixel is being read. */
.color-picker-editor {
  display: grid;
  gap: var(--space-3);
  justify-items: center;
}

.color-picker-editor__frame {
  position: relative;
  display: inline-block;
  max-width: 100%;
  line-height: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: crosshair;
  touch-action: none;
}

/* A locked colour is frozen so it can be read and copied; say so clearly. */
.color-picker-editor__frame.is-locked {
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

.color-picker-editor__frame.is-locked .color-picker-editor__cursor {
  border-color: var(--accent);
}

.color-picker-editor__image {
  display: block;
  max-width: 100%;
  height: auto;
  user-select: none;
  -webkit-user-drag: none;
}

.color-picker-editor__cursor {
  position: absolute;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border: 1.5px solid var(--surface);
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--text);
  pointer-events: none;
}

.color-picker-editor__readout {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: var(--space-2) var(--space-3);
  padding: var(--space-2) var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.color-picker-editor__swatch {
  width: 24px;
  height: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--surface);
}

.color-picker-editor__value {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: var(--weight-normal);
  color: inherit;
  /* The values can be selected and copied even without the copy button. */
  user-select: text;
  cursor: text;
}

.color-picker-editor__coords {
  color: var(--text-muted);
  font-size: var(--text-xs);
}

/* ------------------------------------------------------------ link source */
/* A direct-URL loader beneath the dropzone. Kept visually secondary: dropping
   or browsing a file is the primary path, a link is the alternative. */
.link-source {
  margin-top: var(--space-3);
  padding: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.link-source__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.link-source__title {
  font-weight: var(--weight-medium);
  color: var(--text);
}

.link-source__row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.link-source__input {
  flex: 1 1 16rem;
  min-width: 0;
}

.link-source__progress {
  margin-top: var(--space-3);
}

.link-source__track {
  height: 4px;
  border-radius: var(--radius-full);
  background: var(--pill);
  overflow: hidden;
}

.link-source__bar {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--accent);
  transition: width var(--duration-fast) linear;
}

.link-source__status {
  margin: var(--space-2) 0 0;
  min-height: 1.25em;
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.link-source__status[data-tone="error"] {
  color: var(--danger-text);
}

.link-source__status[data-tone="success"] {
  color: var(--success-text);
}

.link-source__hint {
  margin: var(--space-2) 0 0;
  font-size: var(--text-xs);
  line-height: 1.6;
  color: var(--text-muted);
}

.link-source__hint strong {
  color: var(--text);
}

/* ------------------------------------------------------------- calculators */
/* Calculators are not converters: no dropzone, no download. A form on the left
   of the card, and the answer fields beneath it once Calculate is pressed. */
.calc-app {
  display: grid;
  gap: var(--space-6);
  padding: clamp(1.25rem, 3vw, 2rem);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.calc-form__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: var(--space-4);
}

.calc-form .field--primary {
  grid-column: 1 / -1;
}

.calc-form .field[hidden] {
  display: none;
}

.calc-form__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-4);
}

.calc-form__privacy {
  color: var(--text-muted);
  font-size: var(--text-xs);
}

.calc-result {
  padding-top: var(--space-5);
  border-top: 1px solid var(--border);
}

.calc-result__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.calc-result__title {
  margin: 0;
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
}

.calc-headline {
  display: grid;
  gap: var(--space-1);
  padding: var(--space-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.calc-headline__label {
  color: var(--text-muted);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-wide);
}

.calc-headline__value {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-tight);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.calc-output {
  display: grid;
  margin-top: var(--space-4);
  border-top: 1px solid var(--border);
}

.calc-output__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-1);
  border-bottom: 1px solid var(--border);
}

.calc-output__row[data-target="true"] .calc-output__value {
  color: var(--accent);
}

.calc-output__label {
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.calc-output__value {
  font-weight: var(--weight-medium);
  font-variant-numeric: tabular-nums;
  text-align: right;
  overflow-wrap: anywhere;
}

.calc-result__error {
  margin: 0 0 var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  border: 1px solid var(--danger-border);
  color: var(--danger-text);
  font-size: var(--text-sm);
}

.calc-result__note {
  margin: var(--space-3) 0 0;
  color: var(--text-muted);
  font-size: var(--text-xs);
}
