@font-face {
  font-family: Matter;
  src: url('assets/matter.woff2') format('woff2');
  font-display: swap;
}
@font-face {
  font-family: Teodor;
  src: url('assets/teodor.woff2') format('woff2');
  font-display: swap;
}
:root {
  --ink: #131313;
  --secondary: #656565;
  --stage: #f7f7f7;
  --header-height: 40px;
  --paper-ratio: .72664;
  font-family: Matter, Arial, sans-serif;
  color: var(--ink);
  background: #fff;
}
* { box-sizing: border-box; }
html { scroll-padding-top: var(--header-height); }
body { margin: 0; padding-top: var(--header-height); -webkit-tap-highlight-color: transparent; }
body :not(textarea):not(input) { -webkit-user-select: none; user-select: none; }
textarea, input { -webkit-user-select: text; user-select: text; }
button, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:focus, :focus-visible { outline: none; box-shadow: none; }

.masthead {
  position: fixed;
  z-index: 10;
  inset: 0 0 auto;
  height: var(--header-height);
  padding-inline: 18px 16px;
  border-bottom: 1px solid var(--ink);
  background: #fff;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
}
.brand { display: inline-flex; width: 200px; align-items: center; min-height: 32px; color: inherit; text-decoration: none; }
.brand-logo { display: block; width: 100%; height: auto; }
.instagram { color: inherit; font-size: 12px; text-decoration: none; }
.instagram:hover { text-decoration: underline; text-underline-offset: 3px; }
.cigala { position: absolute; right: 16px; bottom: -15px; width: 55px; height: 55px; padding: 0; border: 0; background: transparent; transform: scaleX(-1); transition: transform .18s ease; }
.cigala img { display: block; width: 100%; height: 100%; object-fit: contain; }
.cigala:hover { transform: translateY(-2px) scaleX(-1) rotate(-8deg); }
@media (prefers-reduced-motion: reduce) { .cigala { transition: none; } }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 988fr) minmax(0, 524fr);
  min-height: calc(100dvh - var(--header-height));
}
.preview { min-width: 0; background: var(--stage); }
.stage {
  position: sticky;
  top: var(--header-height);
  height: calc(100dvh - var(--header-height));
  display: grid;
  place-items: center;
  padding: 32px 30px;
}
.sheet {
  position: relative;
  width: min(82%, 700px, calc((100dvh - var(--header-height) - 64px) * var(--paper-ratio)));
  aspect-ratio: var(--paper-ratio);
  background: #fff;
}
#poster, #poster > svg { display: block; width: 100%; height: 100%; }
.loading { margin: 0; padding: 16px; font-size: 12px; }
#preview-toggle { position: absolute; inset: 0; border: 0; background: transparent; cursor: zoom-in; }
#poster-dialog {
  --zoom-padding: 32px;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  border: 0;
  padding: 0;
  overflow: auto;
  overscroll-behavior: contain;
  color: #fff;
  background: transparent;
}
#poster-dialog::backdrop { background: rgb(0 0 0 / .33); backdrop-filter: blur(8.4px); }
.zoom-canvas { display: grid; place-items: center; }
#poster-dialog .sheet {
  flex: none;
  --crop-gap: 9px;
  --crop-length: 20px;
}
#poster-dialog[data-zoom-direction="in"] #preview-toggle { cursor: zoom-in; }
#poster-dialog[data-zoom-direction="out"] #preview-toggle { cursor: zoom-out; }
#poster-dialog[data-panning="true"] #preview-toggle { cursor: grabbing; }
body:has(#poster-dialog[open]) { overflow: hidden; }
@media (max-width: 760px) {
  #poster-dialog { --zoom-padding: 24px; }
  #poster-dialog .sheet { --crop-gap: 4px; --crop-length: 9px; }
}

.crop { position: absolute; z-index: 1; width: 0; height: 0; pointer-events: none; }
.crop::before, .crop::after { content: ''; position: absolute; background: currentColor; }
.crop::before { width: .5px; height: var(--crop-length, 14px); }
.crop::after { width: var(--crop-length, 14px); height: .5px; }
.crop-tl { top: 0; left: 0; }
.crop-tr { top: 0; right: 0; }
.crop-bl { bottom: 0; left: 0; }
.crop-br { bottom: 0; right: 0; }
.crop-tl::before, .crop-tr::before { bottom: var(--crop-gap, 6px); }
.crop-bl::before, .crop-br::before { top: var(--crop-gap, 6px); }
.crop-tl::before, .crop-bl::before { left: 0; }
.crop-tr::before, .crop-br::before { right: 0; }
.crop-tl::after, .crop-bl::after { right: var(--crop-gap, 6px); }
.crop-tr::after, .crop-br::after { left: var(--crop-gap, 6px); }
.crop-tl::after, .crop-tr::after { top: 0; }
.crop-bl::after, .crop-br::after { bottom: 0; }

.editor {
  min-width: 0;
  container-type: inline-size;
}
.editor-controls {
  position: sticky;
  top: var(--header-height);
  height: calc(100dvh - var(--header-height));
  background: #fff;
}
.editor-body {
  --small-type: clamp(9px, 1.88cqw, 13px);
  --corner: clamp(4px, 1.124cqw, 7px);
  padding: clamp(24px, 6cqw, 40px) 6.98cqw 0;
  position: relative;
}
.text-frame { position: relative; }
textarea {
  display: block;
  width: 100%;
  height: 22.18cqw;
  min-height: 64px;
  padding: clamp(8px, 2.65cqw, 17px);
  border: 0;
  border-radius: 0;
  resize: none;
  background: rgb(217 217 217 / .2);
  font: 2.5cqw/1.25 Teodor, Georgia, serif;
}
textarea:focus { outline: none; box-shadow: none; }
textarea::selection { background: transparent; color: inherit; }
textarea::placeholder { color: #999; opacity: 1; }
#word-count, .small-label {
  display: block;
  margin: 0;
  font-size: var(--small-type);
  letter-spacing: .1em;
  text-align: center;
  line-height: 1.1;
}
#word-count { margin-top: 1.9cqw; }
.small-label { color: var(--secondary); text-transform: uppercase; }
.controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 6.8cqw;
  margin-top: 11.68cqw;
}
.corner-squares {
  background:
    linear-gradient(var(--ink) 0 0) left top,
    linear-gradient(var(--ink) 0 0) right top,
    linear-gradient(var(--ink) 0 0) left bottom,
    linear-gradient(var(--ink) 0 0) right bottom;
  background-size: var(--corner) var(--corner);
  background-repeat: no-repeat;
}
.dial-frame {
  aspect-ratio: 208.15 / 193.7;
  display: grid;
  place-items: center;
}
.dial {
  width: 77.3%;
  aspect-ratio: 1;
  border-radius: 50%;
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.dial:active { cursor: grabbing; }
.dial svg { display: block; width: 100%; height: 100%; pointer-events: none; }
.dial-face { fill: var(--ink); }
#dial-indicator { fill: #fff; }
.fragment-control .small-label { margin-top: 1px; }
.actions { display: flex; flex-direction: column; justify-content: space-between; padding-bottom: calc(var(--small-type) * 1.1 + 1px); }
.shuffle-frame, .formats { padding: 1.875cqw; }
.export .small-label { margin-bottom: 1px; }
.formats { display: grid; grid-template-columns: 1fr 1fr; gap: 1.18cqw; }
.action {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  height: 6.29cqw;
  min-height: 27px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: var(--ink);
  color: #fff;
  font-size: var(--small-type);
  text-transform: uppercase;
}
.action::after { content: ''; position: absolute; inset: min(0px, (100% - 44px) / 2) 0; }
.action:hover:not(:disabled) { background: #373737; }
.action:disabled { opacity: .5; }
#status { position: absolute; right: 6.98cqw; bottom: -2.1em; margin: 0; color: var(--secondary); font-size: 11px; }
#status:empty { display: none; }

.studio-credit {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  text-align: center;
  font: inherit;
  letter-spacing: 0;
  cursor: pointer;
}
.studio-credit:hover { text-decoration: underline; text-underline-offset: 3px; }

@media (min-width: 761px) and (max-height: 760px) {
  .editor-body { padding-top: 24px; }
  textarea { height: 18cqw; }
  .controls { margin-top: 5cqw; }
}

@media (max-width: 760px) {
  :root {
    --header-height: 32px;
    --mobile-stage-height: min(60dvh, max(180px, calc(100dvh - var(--header-height) - 260px)));
  }
  .masthead { padding-inline: 3.125vw 2vw; }
  .brand { width: min(32vw, 200px); min-height: 24px; }
  .instagram { font-size: 10px; }
  .cigala { width: 44px; height: 44px; bottom: -12px; }
  .workspace { display: block; }
  .editor-controls { height: auto; min-height: 0; }
  .stage { position: static; height: var(--mobile-stage-height); padding: 12px 0; }
  .sheet { width: min(88%, calc((var(--mobile-stage-height) - 24px) * var(--paper-ratio))); --crop-length: 8px; --crop-gap: 3px; }
  .stage .crop { display: none; }
  .editor-body { padding: 20px 7cqw 0; --small-type: clamp(8px, 1.875cqw, 13px); }
  textarea { height: 64px; min-height: 64px; padding: 6px 10px; font-size: 16px; line-height: 1.1; }
  textarea::placeholder { white-space: normal; }
  .text-frame { --crop-gap: 3px; --crop-length: clamp(8px, 2.7cqw, 14px); }
  #word-count { margin-top: 1.875cqw; }
  .controls { column-gap: 6.625cqw; margin-top: 14px; }
  .dial-frame { height: clamp(112px, 35vw, 152px); aspect-ratio: auto; }
  .dial { width: min(77.3%, 120px); }
  .shuffle-frame, .formats { padding: 1.875cqw; }
  .formats { gap: 1.31cqw; }
}

@media (max-width: 760px) and (max-height: 700px) {
  .editor-body { padding-top: 20px; }
  textarea { height: 64px; }
  .controls { margin-top: 12px; }
  .dial { width: min(77.3%, 100px); }
}

.studio-credit--desktop { display: none; }
@media (min-width: 761px) {
  .studio-credit--desktop {
    display: block;
    padding: 29cqw 4cqw 12cqw;
    font: 2.5cqw/1.3 Teodor, Georgia, serif;
  }
  .studio-credit--desktop span { display: block; white-space: nowrap; }
}
@media (min-width: 761px) and (max-height: 760px) {
  .studio-credit--desktop { padding-top: 2cqw; padding-bottom: 5cqw; }
}

/* Solo las líneas de texto reciben el puntero; el espacio de composición no es un enlace. */
.studio-credit { pointer-events: none; cursor: default; }
.studio-credit span { pointer-events: auto; cursor: pointer; }
.studio-credit--desktop span { width: fit-content; margin-inline: auto; }
