:root {
  --paper: #f7f8fa;
  --sheet: #ffffff;
  --sheet-soft: #fbfcfd;

  --ink: #17191c;
  --ink-soft: #5f6670;
  --ink-faint: #8b929b;

  --line: #e5e7eb;
  --line-strong: #cfd4da;

  --accent: blue;
  --accent-hover: #991b1b;
  --accent-soft: #fef2f2;
  --accent-border: #fecaca;
  --accent-ink: #ffffff;

  --good: #237044;
  --good-soft: #ecfdf3;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-md: 0 8px 24px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 16px 40px rgba(16, 24, 40, 0.08);

  --radius: 8px;
  --radius-lg: 12px;
}


/* =========================================================
   BASE
========================================================= */

* {
  box-sizing: border-box;
}

.mono {
  font-family: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

.wrap {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 44px 22px 80px;
}


/* =========================================================
   DECORATIVE CORNER TICKS
========================================================= */

.ticked {
  position: relative;
}

.tick {
  position: absolute;
  width: 12px;
  height: 12px;
  pointer-events: none;
  opacity: 0.7;
}

.tick::before,
.tick::after {
  content: "";
  position: absolute;
  background: var(--line-strong);
}

.tick::before {
  width: 12px;
  height: 1px;
  top: 0;
  left: 0;
}

.tick::after {
  width: 1px;
  height: 12px;
  top: 0;
  left: 0;
}

.tick-tl {
  top: -6px;
  left: -6px;
}

.tick-tr {
  top: -6px;
  right: -6px;
  transform: scaleX(-1);
}

.tick-bl {
  bottom: -6px;
  left: -6px;
  transform: scaleY(-1);
}

.tick-br {
  bottom: -6px;
  right: -6px;
  transform: scale(-1, -1);
}


/* =========================================================
   HEADER
========================================================= */

header {
  position: relative;
  margin-bottom: 30px;
  padding: 0 0 24px;
  border-bottom: 1px solid var(--line);
}

header h1 {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 24px;
  line-height: 1.2;
  font-weight: 650;
  letter-spacing: -0.025em;
}

header p {
  max-width: 54ch;
  margin: 0;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.6;
}


/* =========================================================
   PANELS
========================================================= */

.panel {
  display: none;
  margin-bottom: 16px;
  padding: 22px;
  background: var(--sheet);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.panel h2 {
  margin: 0 0 5px;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.4;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.panel .hint {
  margin: 0 0 18px;
  color: var(--ink-faint);
  font-size: 12.5px;
  line-height: 1.5;
}


/* =========================================================
   UPLOAD AREA
========================================================= */

.drop {
  position: relative;
  padding: 34px 22px;
  text-align: center;

  background:
    linear-gradient(
      180deg,
      #ffffff 0%,
      #fcfcfd 100%
    );

  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius-lg);

  cursor: pointer;

  transition:
    border-color 0.18s ease,
    background 0.18s ease,
    box-shadow 0.18s ease,
    transform 0.18s ease;
}

.drop:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 4px rgba(185, 28, 28, 0.05);
}

.drop.drag {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 4px rgba(185, 28, 28, 0.07);
  transform: translateY(-1px);
}

.drop svg {
  display: block;
  width: 44px;
  height: 44px;
  margin: 0 auto 13px;
  color: var(--accent);
}

.drop .primary-text {
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}

.drop .primary-text b {
  color: var(--accent);
  font-weight: 650;
}

.drop .secondary-text {
  margin-top: 6px;
  color: var(--ink-faint);
  font-size: 12px;
  line-height: 1.5;
}


/* =========================================================
   FILE BAR
========================================================= */

#fileBar {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 14px;

  margin-top: 12px;
  padding: 11px 13px;

  background: var(--sheet-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);

  font-size: 12.5px;

  box-shadow: var(--shadow-sm);
}

#fileBar .name {
  overflow: hidden;
  color: var(--ink);
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#fileBar .meta {
  color: var(--ink-faint);
  white-space: nowrap;
}

#fileBar button {
  flex-shrink: 0;

  padding: 4px 7px;

  border: 0;
  background: transparent;

  color: var(--ink-faint);

  font-family: inherit;
  font-size: 12px;

  cursor: pointer;
  text-decoration: none;

  border-radius: 4px;

  transition:
    color 0.15s ease,
    background 0.15s ease;
}

#fileBar button:hover {
  color: var(--accent);
  background: var(--accent-soft);
}


/* =========================================================
   SIZE TABLE
========================================================= */

table.sizes {
  width: 100%;
  margin-top: 16px;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;

  font-size: 13px;

  border: 1px solid var(--line);
  border-radius: var(--radius);
}

table.sizes th {
  padding: 10px 12px;

  text-align: left;

  color: var(--ink-faint);
  background: #fafafa;

  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;

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

table.sizes td {
  padding: 11px 12px;

  color: var(--ink);

  vertical-align: top;

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

table.sizes tr:last-child td {
  border-bottom: none;
}

table.sizes tbody tr {
  transition: background 0.15s ease;
}

table.sizes tbody tr:hover {
  background: #fafafa;
}

table.sizes .dim {
  white-space: nowrap;
  color: var(--ink-soft);
}

table.sizes .name-tag {
  display: inline-flex;
  align-items: center;

  margin-left: 7px;
  padding: 2px 7px;

  color: var(--good);
  background: var(--good-soft);

  border-radius: 999px;

  font-size: 10px;
  font-weight: 600;
}

table.sizes .pages-col {
  color: var(--ink-soft);
}

.uniform-note {
  display: flex;
  align-items: center;
  gap: 7px;

  margin-top: 12px;

  color: var(--good);
  font-size: 12px;
  line-height: 1.5;
}


/* =========================================================
   TARGET SIZE SWATCHES
========================================================= */

.swatch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 10px;
}

.swatch {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;

  min-height: 92px;
  width: 100%;
  padding: 10px 7px;

  background: var(--sheet);

  border: 1px solid var(--line);
  border-radius: var(--radius);

  cursor: pointer;

  transition:
    border-color 0.16s ease,
    background 0.16s ease,
    box-shadow 0.16s ease,
    transform 0.16s ease;
}

.swatch:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.swatch.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.06);
}

.swatch .icon-box {
  display: flex;
  align-items: center;
  justify-content: center;

  width: 100%;
  height: 34px;
}

.swatch .icon-box .rect {
  background: var(--ink-faint);
  border-radius: 1px;
  transition: background 0.16s ease;
}

.swatch.active .icon-box .rect {
  background: var(--accent);
}

.swatch .icon-box .rect.dashed {
  background: transparent;
  border: 1.5px dashed var(--ink-faint);
}

.swatch.active .icon-box .rect.dashed {
  border-color: var(--accent);
}

.swatch .label {
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
}

.swatch .dims {
  color: var(--ink-faint);
  font-size: 10.5px;
}


/* =========================================================
   CUSTOM SIZE
========================================================= */

.custom-size {
  display: none;
  gap: 12px;
  margin-top: 14px;
}

.custom-size.show {
  display: flex;
}

.field {
  flex: 1;
  min-width: 120px;
}

.field label {
  display: block;

  margin-bottom: 6px;

  color: var(--ink-soft);

  font-size: 11.5px;
  font-weight: 600;
}


/* =========================================================
   INPUTS
========================================================= */

select,
input[type="number"] {
  width: 100%;
  height: 40px;

  padding: 0 11px;

  color: var(--ink);
  background: #fff;

  border: 1px solid var(--line-strong);
  border-radius: 6px;

  outline: none;

  font-family: inherit;
  font-size: 13px;

  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease;
}

select:hover,
input[type="number"]:hover {
  border-color: #aeb4bb;
}

input[type="number"]:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.08);
}


/* =========================================================
   METHOD CARDS
========================================================= */

.method-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.method-card {
  position: relative;

  min-width: 0;
  padding: 14px;

  background: var(--sheet);

  border: 1px solid var(--line);
  border-radius: var(--radius);

  cursor: pointer;

  transition:
    border-color 0.16s ease,
    background 0.16s ease,
    box-shadow 0.16s ease,
    transform 0.16s ease;
}

.method-card:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.method-card.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.05);
}

.method-card .icon-row {
  display: flex;
  align-items: center;

  height: 30px;
  margin-bottom: 9px;

  color: var(--accent);
}

.method-card .m-title {
  margin-bottom: 4px;

  color: var(--ink);

  font-size: 13px;
  font-weight: 650;
}

.method-card .m-desc {
  color: var(--ink-soft);

  font-size: 11.5px;
  line-height: 1.5;
}


/* =========================================================
   ALIGNMENT
========================================================= */

.align-row {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 28px;

  margin-top: 20px;
  padding-top: 18px;

  border-top: 1px solid var(--line);
}

.align-grid {
  display: grid;

  grid-template-columns: repeat(3, 24px);
  grid-template-rows: repeat(3, 24px);

  gap: 5px;
}

.align-grid button {
  position: relative;

  width: 24px;
  height: 24px;
  padding: 0;

  background: #fff;

  border: 1px solid var(--line-strong);
  border-radius: 4px;

  cursor: pointer;

  transition:
    border-color 0.15s ease,
    background 0.15s ease;
}

.align-grid button:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.align-grid button::after {
  content: "";

  position: absolute;

  width: 5px;
  height: 5px;

  top: 50%;
  left: 50%;

  border-radius: 50%;

  background: var(--ink-faint);

  transform: translate(-50%, -50%);

  transition: background 0.15s ease;
}

.align-grid button.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.align-grid button.active::after {
  background: var(--accent);
}

.align-label {
  margin-top: 8px;

  color: var(--ink-faint);

  font-size: 11.5px;
  line-height: 1.4;
}


/* =========================================================
   PREVIEW
========================================================= */

.preview-frame {
  flex: 1;
  min-width: 200px;
}

.preview-frame svg {
  display: block;

  width: 100%;
  max-width: 230px;
  height: auto;

  padding: 10px;

  background: #fafafa;

  border: 1px solid var(--line);
  border-radius: 8px;
}

.preview-caption {
  max-width: 36ch;

  margin-top: 8px;

  color: var(--ink-faint);

  font-size: 11.5px;
  line-height: 1.5;
}


/* =========================================================
   PRIMARY BUTTON
========================================================= */

button.primary {
  width: 100%;

  margin-top: 20px;
  padding: 12px 16px;

  color: #fff;
  background: var(--ink);

  border: none;
  border-radius: 7px;

  font-family: inherit;
  font-size: 13.5px;
  font-weight: 650;

  cursor: pointer;

  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);

  transition:
    background 0.16s ease,
    transform 0.16s ease,
    box-shadow 0.16s ease;
}

button.primary:hover:not(:disabled) {
  background: var(--accent);
  box-shadow: 0 5px 14px rgba(185, 28, 28, 0.18);
  transform: translateY(-1px);
}

button.primary:active:not(:disabled) {
  transform: translateY(0);
}

button.primary:disabled {
  color: #fff;
  background: var(--line-strong);
  cursor: not-allowed;
  box-shadow: none;
}


/* =========================================================
   STATUS
========================================================= */

#status {
  min-height: 20px;

  margin-top: 12px;

  color: var(--ink-soft);

  font-size: 12.5px;
  line-height: 1.5;

  text-align: center;
}

#status.ok {
  color: var(--good);
}

#status.err {
  color: var(--accent);
}


/* =========================================================
   DOWNLOAD BUTTON
========================================================= */

a#dl {
  display: flex;
  align-items: center;
  justify-content: center;

  width: 100%;

  margin-top: 10px;
  padding: 11px 14px;

  color: #fff;
  background: var(--good);

  border-radius: 7px;

  font-size: 13px;
  font-weight: 650;

  text-decoration: none;

  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);

  transition:
    background 0.16s ease,
    transform 0.16s ease,
    box-shadow 0.16s ease;
}

a#dl:hover {
  background: #1d5f39;
  box-shadow: 0 5px 14px rgba(35, 112, 68, 0.16);
  transform: translateY(-1px);
}


/* =========================================================
   HIDDEN
========================================================= */

.hidden {
  display: none !important;
}

#options {
  display: none;
}


/* =========================================================
   RESPONSIVE
========================================================= */

@media (max-width: 640px) {

  .wrap {
    padding: 30px 15px 60px;
  }

  header {
    margin-bottom: 22px;
    padding-bottom: 20px;
  }

  header h1 {
    font-size: 21px;
  }

  header p {
    font-size: 13px;
  }

  .panel {
    padding: 17px;
    border-radius: 9px;
  }

  .drop {
    padding: 28px 16px;
  }

  .swatch-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .method-grid {
    grid-template-columns: 1fr;
  }

  .custom-size {
    flex-direction: column;
  }

  .align-row {
    gap: 20px;
  }
}


@media (max-width: 420px) {

  .wrap {
    padding-left: 12px;
    padding-right: 12px;
  }

  .panel {
    padding: 15px;
  }

  .swatch-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  table.sizes {
    font-size: 12px;
  }

  table.sizes th,
  table.sizes td {
    padding-left: 9px;
    padding-right: 9px;
  }

  #fileBar {
    align-items: flex-start;
  }
}


/* =========================================================
   REDUCED MOTION
========================================================= */

@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
    animation: none !important;
  }
}