:root {
  --ink: #1e2025;
  --muted: #6f736f;
  --faint: #9a9d98;
  --paper: #f7f5f0;
  --surface: #fffefb;
  --line: #dfddd5;
  --line-strong: #c9c6bd;
  --accent: #e7633d;
  --accent-dark: #c84725;
  --accent-soft: #fff0e9;
  --green: #328d6b;
  --shadow: 0 22px 60px rgba(49, 42, 34, 0.09);
  --serif: Iowan Old Style, Palatino Linotype, Book Antiqua, Georgia, serif;
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--paper); }

body {
  min-width: 20rem;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 88% 5%, rgba(231, 99, 61, 0.09), transparent 26rem),
    linear-gradient(rgba(30, 32, 37, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(30, 32, 37, 0.018) 1px, transparent 1px),
    var(--paper);
  background-size: auto, 32px 32px, 32px 32px, auto;
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.5;
}

button, input, select { font: inherit; }
button, .drop-zone { -webkit-tap-highlight-color: transparent; }
button { color: inherit; cursor: pointer; }
a { color: inherit; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.studio-shell { min-height: 100vh; }

.studio-header {
  display: flex;
  width: calc(100% - 2 * clamp(1rem, 3vw, 4rem));
  min-height: 5.5rem;
  margin: 0 auto;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  gap: 1.5rem;
}

.studio-brand { display: inline-flex; align-items: center; gap: .72rem; font-family: var(--serif); font-size: 1.22rem; font-weight: 700; text-decoration: none; }
.studio-brand__mark { display: grid; width: 2.35rem; height: 2.35rem; place-items: center; border-radius: .68rem; background: var(--accent); color: white; transform: rotate(-2deg); }
.studio-brand__mark svg { width: 1.35rem; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }
.studio-brand__by { color: var(--muted); font-family: var(--sans); font-size: .7rem; font-weight: 500; }

.privacy-note { display: flex; align-items: center; color: var(--muted); font-size: .74rem; gap: .48rem; }
.privacy-note__dot { width: .48rem; height: .48rem; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(50, 141, 107, .1); }

.studio-main { display: grid; width: calc(100% - 2 * clamp(1rem, 3vw, 4rem)); margin: 0 auto; padding: 3.25rem 0 4.5rem; gap: clamp(2.5rem, 7vw, 6.5rem); grid-template-columns: 15.5rem minmax(0, 1fr); }

.tool-rail { min-width: 0; position: sticky; top: 1rem; height: fit-content; }
.tool-rail__label, .eyebrow { margin: 0; color: var(--faint); font-size: .66rem; font-weight: 700; letter-spacing: .15em; text-transform: uppercase; }
.tool-rail__label { margin-bottom: .8rem; }
.tool-tabs { display: grid; gap: .35rem; }
.tool-tab { display: grid; width: 100%; border: 0; border-radius: .8rem; padding: .75rem; align-items: center; background: transparent; gap: .72rem; grid-template-columns: 2.25rem minmax(0, 1fr); text-align: left; transition: background 160ms ease, transform 160ms ease; }
.tool-tab:hover { background: rgba(255, 255, 255, .7); transform: translateX(2px); }
.tool-tab.is-active { background: var(--surface); box-shadow: 0 6px 22px rgba(49, 42, 34, .07); }
.tool-tab__icon { display: grid; width: 2.25rem; height: 2.25rem; place-items: center; border: 1px solid var(--line); border-radius: .62rem; background: var(--paper); color: var(--muted); }
.tool-tab__icon svg { width: 1.15rem; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }
.tool-tab.is-active .tool-tab__icon { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.tool-tab strong, .tool-tab small { display: block; }
.tool-tab strong { font-size: .81rem; font-weight: 700; }
.tool-tab small { margin-top: .08rem; color: var(--faint); font-size: .66rem; }

.engine-note { display: flex; margin-top: 2rem; padding: 1rem .7rem; align-items: flex-start; border-top: 1px solid var(--line); color: var(--muted); gap: .65rem; }
.engine-note__icon { display: grid; width: 1.8rem; height: 1.8rem; flex: 0 0 auto; place-items: center; border-radius: 50%; background: #e8e5dc; color: #4f5358; font-family: var(--serif); font-size: .7rem; font-weight: 700; }
.engine-note p { margin: 0; font-size: .65rem; line-height: 1.55; }
.engine-note strong { color: var(--ink); }

.workspace { min-width: 0; }
.workspace__heading { display: flex; margin-bottom: 1.8rem; align-items: flex-start; justify-content: space-between; gap: 2rem; }
.workspace h1 { max-width: 15ch; margin: .38rem 0 .65rem; font-family: var(--serif); font-size: clamp(2.45rem, 5vw, 4rem); font-weight: 600; letter-spacing: -.035em; line-height: .98; }
.workspace__intro { max-width: 42rem; margin: 0; color: var(--muted); font-size: .93rem; line-height: 1.7; }
.step-pill { flex: 0 0 auto; margin-top: .25rem; border: 1px solid var(--line); border-radius: 999px; padding: .42rem .7rem; background: rgba(255, 255, 255, .48); color: var(--muted); font-size: .64rem; font-weight: 650; }
.operation-explainer { display: grid; margin: -0.5rem 0 1.2rem; padding: 1rem 1.05rem; border: 1px solid #d8d4c9; border-radius: .9rem; background: rgba(255, 254, 251, .88); gap: .8rem; grid-template-columns: auto minmax(0, 1fr); }
.operation-explainer__icon { display: grid; width: 1.8rem; height: 1.8rem; place-items: center; border-radius: 50%; background: var(--accent-soft); color: var(--accent-dark); font-family: var(--serif); font-size: .9rem; font-weight: 800; }
.operation-explainer h2 { margin: .02rem 0 .25rem; font-family: var(--serif); font-size: 1rem; }
.operation-explainer p { margin: 0; color: var(--muted); font-size: .7rem; line-height: 1.6; }
.operation-explainer ul { display: grid; margin: .6rem 0 0; padding-left: 1.05rem; color: var(--muted); font-size: .66rem; gap: .25rem; }

.drop-zone { position: relative; display: grid; min-height: 20.5rem; padding: 2.2rem; place-items: center; align-content: center; overflow: hidden; border: 1.5px dashed var(--line-strong); border-radius: 1.25rem; background: rgba(255, 254, 251, .72); text-align: center; transition: border-color 180ms ease, background 180ms ease, transform 180ms ease; }
.drop-zone::before { position: absolute; width: 15rem; height: 15rem; border-radius: 50%; background: rgba(231, 99, 61, .055); content: ""; filter: blur(2px); }
.drop-zone:hover, .drop-zone:focus-visible, .drop-zone.is-dragging { border-color: var(--accent); outline: none; background: var(--surface); transform: translateY(-2px); }
.drop-zone > * { position: relative; }
.drop-zone__art { width: 5.2rem; margin-bottom: .8rem; color: var(--accent); }
.drop-zone__art svg { width: 100%; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2; }
.drop-zone__art .drop-zone__page { fill: var(--accent-soft); stroke-width: 1.5; }
.drop-zone__title { margin: 0; font-family: var(--serif); font-size: 1.42rem; font-weight: 700; }
.drop-zone__copy { margin: .32rem 0 1rem; color: var(--muted); font-size: .78rem; }
.choose-button { border: 1px solid var(--ink); border-radius: .68rem; padding: .66rem 1rem; background: var(--ink); color: white; font-size: .76rem; font-weight: 700; box-shadow: 0 7px 17px rgba(30, 32, 37, .14); }
.choose-button:hover { background: #383a40; }
.drop-zone__limits { margin: 1rem 0 0; color: var(--faint); font-size: .63rem; }
.drop-zone__hosted-note { max-width: 25rem; margin: .45rem 0 0; color: var(--muted); font-size: .6rem; }

.file-section, .options-card { margin-top: 1.2rem; border: 1px solid var(--line); border-radius: 1rem; padding: 1.25rem; background: var(--surface); box-shadow: 0 8px 28px rgba(49, 42, 34, .045); }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.section-heading h2, .result-card h2 { margin: .22rem 0 0; font-family: var(--serif); font-size: 1.3rem; }
.text-button { border: 0; padding: .4rem; background: transparent; color: var(--accent-dark); font-size: .72rem; font-weight: 700; }
.reorder-hint { margin: .7rem 0; color: var(--faint); font-size: .67rem; }
.file-list { display: grid; margin: 0; padding: 0; gap: .5rem; list-style: none; }
.file-item { display: grid; min-width: 0; padding: .7rem .75rem; align-items: center; border: 1px solid var(--line); border-radius: .7rem; background: #faf9f5; gap: .68rem; grid-template-columns: auto minmax(0, 1fr) auto; }
.file-item.is-dragging { opacity: .45; }
.file-item__type { display: grid; width: 2rem; height: 2.35rem; place-items: center; border: 1px solid #efd3c9; border-radius: .3rem; background: var(--accent-soft); color: var(--accent-dark); font-size: .52rem; font-weight: 800; text-transform: uppercase; }
.file-item__copy { min-width: 0; }
.file-item__copy strong, .file-item__copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item__copy strong { font-size: .75rem; }
.file-item__copy small { margin-top: .1rem; color: var(--faint); font-size: .62rem; }
.file-item__actions { display: flex; gap: .2rem; }
.icon-button { display: grid; width: 1.85rem; height: 1.85rem; place-items: center; border: 0; border-radius: .42rem; background: transparent; color: var(--muted); font-size: .9rem; }
.icon-button:hover:not(:disabled) { background: #eceae4; color: var(--ink); }
.icon-button:disabled { cursor: default; opacity: .28; }

.options-card { padding: 1.4rem; }
.option-grid { display: grid; margin-top: 1.1rem; gap: 1rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field-group { display: grid; min-width: 0; margin: 0; gap: .45rem; }
.field-group--wide { grid-column: 1 / -1; }
.field-group > span, .field-group legend { color: #4e514f; font-size: .69rem; font-weight: 700; }
.field-group output { float: right; color: var(--accent-dark); font-size: .66rem; }
.field-group small { color: var(--faint); font-size: .63rem; }
.option-note { margin: 0; color: var(--faint); font-size: .63rem; }
.field-group input[type="text"], .field-group input[type="url"], .field-group input[type="number"], .field-group select, .filename-input { width: 100%; min-height: 2.8rem; border: 1px solid var(--line-strong); border-radius: .62rem; background: #fbfaf7; color: var(--ink); }
.field-group input[type="text"], .field-group input[type="url"], .field-group input[type="number"], .field-group select { padding: .68rem .78rem; }
.field-group input:focus, .field-group select:focus { border-color: var(--accent); outline: 3px solid rgba(231, 99, 61, .11); }
.field-group input[type="range"] { width: 100%; accent-color: var(--accent); }
.segmented-field, .choice-field { padding: 0; border: 0; }
.segmented-control { display: grid; border: 1px solid var(--line-strong); border-radius: .65rem; padding: .22rem; background: #f4f2ed; gap: .2rem; grid-template-columns: repeat(3, 1fr); }
.segmented-control input, .choice-field input { position: absolute; opacity: 0; pointer-events: none; }
.segmented-control span { display: block; border-radius: .46rem; padding: .58rem .45rem; color: var(--muted); font-size: .68rem; font-weight: 700; text-align: center; cursor: pointer; }
.segmented-control input:checked + span { background: var(--surface); color: var(--accent-dark); box-shadow: 0 2px 8px rgba(49, 42, 34, .08); }
.choice-field { display: grid; gap: .45rem; }
.choice-field legend { margin-bottom: .45rem; }
.choice-field label > span { display: flex; padding: .72rem .8rem; align-items: center; justify-content: space-between; border: 1px solid var(--line); border-radius: .6rem; cursor: pointer; gap: 1rem; }
.choice-field label > span strong, .choice-field label > span small { display: block; }
.choice-field label > span strong { font-size: .72rem; }
.choice-field label > span small { font-size: .61rem; }
.choice-field input:checked + span { border-color: var(--accent); background: var(--accent-soft); }
.output-name { margin-top: 1.15rem; }
.watermark-preview { margin-top: .25rem; }
.watermark-preview__heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.watermark-preview__heading > span { color: #4e514f; font-size: .69rem; font-weight: 700; }
.watermark-preview__heading small { color: var(--faint); font-size: .61rem; }
.watermark-preview__page { position: relative; display: grid; min-height: 11rem; place-items: center; overflow: hidden; border: 1px solid var(--line); border-radius: .72rem; background: linear-gradient(135deg, #ece9e2 25%, transparent 25%) -8px 0/16px 16px, linear-gradient(225deg, #ece9e2 25%, transparent 25%) -8px 0/16px 16px, linear-gradient(315deg, #ece9e2 25%, transparent 25%) 0 0/16px 16px, linear-gradient(45deg, #ece9e2 25%, #f7f5f0 25%) 0 0/16px 16px; }
.watermark-preview__page img { display: block; width: 100%; max-height: 30rem; object-fit: contain; }
.watermark-preview__text { position: absolute; top: 50%; left: 50%; width: 82%; overflow: hidden; color: #292d34; font-weight: 800; line-height: 1; text-align: center; text-overflow: ellipsis; white-space: nowrap; pointer-events: none; transform: translate(-50%, -50%) rotate(45deg); transform-origin: center; }
.standardize-note { padding: .85rem .9rem; border: 1px solid var(--line); border-radius: .68rem; background: #faf9f5; }
.standardize-note strong { display: block; color: var(--ink); font-size: .7rem; }
.standardize-note p { margin: .28rem 0 0; color: var(--muted); font-size: .64rem; line-height: 1.6; }
.tiff-size-note { margin: 0; border-left: 3px solid #e3a341; padding: .68rem .78rem; background: #fff8e9; color: var(--muted); font-size: .63rem; line-height: 1.6; }
.tiff-size-note strong { color: var(--ink); }
.tiff-codec-guide { display: grid; gap: .4rem; }
.tiff-codec-guide p { display: grid; margin: 0; padding: .65rem .72rem; border: 1px solid var(--line); border-radius: .58rem; background: #faf9f5; gap: .12rem; grid-template-columns: 4rem minmax(0, 1fr); }
.tiff-codec-guide strong { color: var(--ink); font-size: .66rem; }
.tiff-codec-guide span { color: var(--muted); font-size: .62rem; line-height: 1.5; }
.link-editor { min-width: 0; }
.link-editor__heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; }
.link-editor__heading strong, .link-editor__heading small { display: block; }
.link-editor__heading strong { color: var(--ink); font-size: .7rem; }
.link-editor__heading small, .link-editor__heading > span { margin-top: .12rem; color: var(--faint); font-size: .61rem; }
.link-editor__stage { display: grid; min-height: 12rem; padding: .8rem; place-items: center; overflow: auto; border: 1px solid var(--line); border-radius: .72rem; background: #e9e6df; }
.link-editor__canvas { position: relative; width: fit-content; max-width: 100%; touch-action: none; cursor: crosshair; line-height: 0; user-select: none; }
.link-editor__canvas img { display: block; width: auto; max-width: 100%; max-height: 34rem; pointer-events: none; }
.link-editor__selection { position: absolute; display: grid; min-width: 2px; min-height: 2px; place-items: center; border: 2px solid var(--accent); background: rgba(231, 99, 61, .18); color: #8f2e14; line-height: 1.2; pointer-events: none; }
.link-editor__selection span { overflow: hidden; padding: .2rem .3rem; border-radius: .3rem; background: rgba(255, 255, 255, .86); font-size: .55rem; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.link-editor__coordinates { margin: 0; color: var(--faint); font-size: .61rem; }
.link-editor__toolbar { display: flex; margin-top: .6rem; align-items: center; justify-content: space-between; gap: .8rem; }
.link-editor__add { flex: 0 0 auto; border: 1px solid var(--accent); border-radius: .55rem; padding: .55rem .7rem; background: var(--accent-soft); color: var(--accent-dark); font-size: .64rem; font-weight: 800; }
.link-editor__saved-area { position: absolute; z-index: 2; display: grid; min-width: 4px; min-height: 4px; padding: 0; place-items: center; border: 2px solid #2f8d6c; background: rgba(47, 141, 108, .18); color: #166248; cursor: pointer; line-height: 1; }
.link-editor__saved-area span { display: grid; width: 1.1rem; height: 1.1rem; place-items: center; border-radius: 50%; background: rgba(255, 255, 255, .92); font-size: .58rem; font-weight: 850; }
.link-areas { border: 1px solid var(--line); border-radius: .68rem; padding: .8rem; background: #faf9f5; }
.link-areas__heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.link-areas__heading strong { color: var(--ink); font-size: .68rem; }
.link-areas__heading span, .link-areas__empty { color: var(--faint); font-size: .61rem; }
.link-areas__empty { margin: .5rem 0 0; }
.link-areas__list { display: grid; margin: .55rem 0 0; padding: 0; gap: .42rem; list-style: none; }
.link-area-item { display: grid; padding: .55rem .62rem; align-items: center; border: 1px solid var(--line); border-radius: .52rem; background: white; gap: .55rem; grid-template-columns: auto minmax(0, 1fr) auto; }
.link-area-item__number { display: grid; width: 1.45rem; height: 1.45rem; place-items: center; border-radius: 50%; background: #dff3eb; color: #166248; font-size: .6rem; font-weight: 850; }
.link-area-item__copy { min-width: 0; }
.link-area-item__copy strong, .link-area-item__copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-area-item__copy strong { color: var(--ink); font-size: .63rem; }
.link-area-item__copy small { margin-top: .12rem; color: var(--faint); font-size: .58rem; }
.link-area-item__actions { display: flex; gap: .3rem; }
.link-area-item__actions button { border: 1px solid var(--line); border-radius: .42rem; padding: .35rem .48rem; background: #faf9f5; color: var(--muted); font-size: .58rem; font-weight: 750; }
.filename-input { display: flex; align-items: center; overflow: hidden; }
.filename-input input { min-width: 0; flex: 1; border: 0 !important; outline: 0 !important; background: transparent !important; }
.filename-input span { padding-right: .78rem; color: var(--faint); font-size: .72rem; }

.form-status { min-height: 1.4rem; padding-top: .75rem; color: var(--accent-dark); font-size: .72rem; }
.form-actions { display: flex; margin-top: .25rem; align-items: center; justify-content: flex-end; gap: .7rem; }
.reset-button, .process-button, .download-button { min-height: 2.9rem; border-radius: .66rem; padding: .72rem 1rem; font-size: .74rem; font-weight: 750; text-decoration: none; }
.reset-button { border: 1px solid var(--line-strong); background: transparent; color: var(--muted); }
.process-button { display: inline-flex; min-width: 9rem; align-items: center; justify-content: center; border: 1px solid var(--accent); background: var(--accent); color: white; gap: .55rem; box-shadow: 0 8px 20px rgba(200, 71, 37, .18); }
.process-button:hover:not(:disabled) { background: var(--accent-dark); }
.process-button:disabled { cursor: wait; opacity: .62; }
.process-button svg { width: 1rem; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2; }
.process-button.is-processing svg { animation: pulse-arrow .8s ease-in-out infinite alternate; }

.result-card { display: grid; margin-top: 1rem; padding: 1.15rem 1.25rem; align-items: center; border: 1px solid rgba(50, 141, 107, .28); border-radius: 1rem; background: #f1faf5; gap: .9rem; grid-template-columns: auto minmax(0, 1fr) auto; }
.result-card__check { display: grid; width: 2.5rem; height: 2.5rem; place-items: center; border-radius: 50%; background: var(--green); color: white; }
.result-card__check svg { width: 1.3rem; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2.4; }
.result-card__copy p:last-child { margin: .2rem 0 0; color: var(--muted); font-size: .68rem; }
.download-button { display: inline-grid; min-width: 7rem; place-items: center; background: var(--green); color: white; }

.studio-footer { display: flex; width: calc(100% - 2 * clamp(1rem, 3vw, 4rem)); margin: 0 auto; padding: 1.5rem 0 2.5rem; justify-content: space-between; border-top: 1px solid var(--line); color: var(--faint); font-size: .65rem; gap: 1rem; }
.studio-footer p { margin: 0; }
.studio-footer a { color: var(--muted); text-underline-offset: .18em; }

[hidden] { display: none !important; }
@keyframes pulse-arrow { to { transform: translateX(3px); } }

@media (max-width: 820px) {
  .studio-main { grid-template-columns: minmax(0, 1fr); }
  .tool-rail { position: static; }
  .tool-tabs { display: flex; margin: 0; padding: 0 0 .8rem; overflow-x: auto; scroll-snap-type: x mandatory; }
  .tool-tab { min-width: 12rem; scroll-snap-align: start; }
  .engine-note { display: none; }
}

@media (max-width: 560px) {
  .studio-header, .studio-main, .studio-footer { width: min(100% - 2rem, 82rem); }
  .studio-header { min-height: 4.7rem; }
  .studio-brand__by, .privacy-note { display: none; }
  .studio-main { padding: 2rem 0 3rem; gap: 2rem; }
  .workspace__heading { display: block; }
  .step-pill { display: inline-block; margin-top: 1rem; }
  .drop-zone { min-height: 17rem; padding: 1.4rem; }
  .file-item { grid-template-columns: auto minmax(0, 1fr); }
  .file-item__actions { grid-column: 2; }
  .option-grid { grid-template-columns: 1fr; }
  .field-group--wide { grid-column: auto; }
  .form-actions { align-items: stretch; flex-direction: column-reverse; }
  .process-button, .reset-button { width: 100%; }
  .result-card { grid-template-columns: auto minmax(0, 1fr); }
  .download-button { grid-column: 1 / -1; }
  .studio-footer { align-items: flex-start; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
