:root {
  --bg: #f5f7f8;
  --panel: #ffffff;
  --text: #172026;
  --muted: #64717a;
  --line: #d9e0e4;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --danger: #b42318;
  --warning-bg: #fff7ed;
  --warning-line: #fed7aa;
  --shadow: 0 18px 45px rgba(23, 32, 38, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(245, 247, 248, 0.9)),
    var(--bg);
}

button,
input,
a {
  font: inherit;
}

.shell {
  width: min(1160px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(30px, 5vw, 52px);
  line-height: 1.02;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 6px;
  font-size: 20px;
  line-height: 1.2;
}

.status-pill {
  min-width: 98px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  text-align: center;
  font-size: 13px;
  font-weight: 700;
}

.status-pill.busy {
  color: #8a4b0f;
  background: #fff8eb;
  border-color: #f1d49a;
}

.status-pill.done {
  color: var(--accent-strong);
  background: #edfdf9;
  border-color: #9fe8d8;
}

.status-pill.error {
  color: var(--danger);
  background: #fff1f0;
  border-color: #ffb4ad;
}

.workspace {
  display: grid;
  gap: 16px;
}

.panel,
.size-card,
.progress-panel,
.folder-task-panel,
.result-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.upload-panel {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) auto auto;
  align-items: end;
  gap: 18px;
  padding: 18px;
}

.source-tabs {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.source-tab {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--muted);
  font-weight: 800;
  cursor: pointer;
}

.source-tab.active {
  border-color: var(--accent);
  background: #edfdf9;
  color: var(--accent-strong);
}

.source-tab:disabled {
  border-color: #d7dde2;
  background: #f3f5f6;
  color: #9aa3aa;
  cursor: not-allowed;
  opacity: 0.75;
}

.gif-mode-notice {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid #99d8cc;
  border-radius: 8px;
  background: #f0fdfa;
  color: #345b55;
  font-size: 13px;
}

.gif-mode-notice strong {
  color: var(--accent-strong);
  white-space: nowrap;
}

.source-panel {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: end;
}

.source-toolbar {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 1fr);
  align-items: stretch;
  gap: 16px;
}

#demandGenSourcePanel {
  grid-template-columns: minmax(280px, 1fr);
}

#standardSourcePanel {
  grid-template-columns: 1fr;
}

.standard-source-choice {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  min-height: 70px;
}

.standard-source-choice legend {
  padding: 0 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.standard-source-choice label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.standard-source-choice input {
  accent-color: var(--accent);
}

.source-or {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.demand-mode-label {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 7px;
  min-height: 70px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--text);
  font-size: 13px;
}

.background-control {
  min-height: 70px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.standard-method-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: end;
}

#sheetSourcePanel {
  grid-template-columns: minmax(280px, 1fr);
}

.field-label,
.size-card label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input[type="file"],
input[type="number"],
input[type="text"],
input[type="password"],
input[type="url"] {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--text);
}

input[type="file"] {
  padding: 9px;
}

input[type="number"] {
  max-width: 112px;
  padding: 8px 10px;
}

input[type="text"],
input[type="password"],
input[type="url"] {
  padding: 8px 10px;
}

.folder-upload-field small {
  min-height: 17px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.drop-zone {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 78px;
  padding: 14px;
  border: 2px dashed var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
  cursor: pointer;
}

.drop-zone.drag-over {
  border-color: var(--accent);
  background: #edfdf9;
  color: var(--accent-strong);
}

.drop-zone input {
  display: none;
}

input[type="color"] {
  width: 54px;
  height: 42px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.control-row {
  display: grid;
  grid-template-columns: auto auto auto;
  align-items: end;
  gap: 10px;
}

.control-row .field-label {
  grid-column: 1 / -1;
}

#backgroundText {
  min-width: 82px;
  padding-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.check-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.website-control {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 42px;
  margin: 0;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
}

.website-control legend {
  padding: 0 4px;
  font-size: 12px;
  font-weight: 700;
}

.website-control label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.website-control input {
  accent-color: var(--accent);
}

#websiteNameField {
  min-width: 210px;
}

.sizes-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.common-count-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.common-count-bar > div {
  display: grid;
  gap: 3px;
}

.common-count-bar strong {
  font-size: 15px;
}

.common-count-bar span,
.common-count-bar label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.common-count-bar label {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.common-count-bar input[type="number"] {
  width: 90px;
  min-height: 38px;
}

.size-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 126px;
  padding: 17px;
}

.pattern-size-card {
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 14px;
}

.size-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.pattern-picker {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  margin: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.scrollable-pattern-picker {
  max-height: 230px;
  overflow-x: hidden;
  overflow-y: auto;
  padding-right: 6px;
  scrollbar-color: #9fb0b8 #edf2f4;
  scrollbar-width: thin;
}

.scrollable-pattern-picker::-webkit-scrollbar {
  width: 7px;
}

.scrollable-pattern-picker::-webkit-scrollbar-track {
  border-radius: 999px;
  background: #edf2f4;
}

.scrollable-pattern-picker::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: #9fb0b8;
}

.pattern-picker legend {
  padding: 0 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.pattern-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 58px;
  align-items: center;
  gap: 7px;
  padding: 6px 7px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: var(--muted);
}

.pattern-row.active {
  border-color: var(--accent);
  background: #edfdf9;
  color: var(--accent-strong);
}

.pattern-selection {
  display: grid;
  grid-template-columns: 16px minmax(62px, 1fr) auto;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.pattern-selection input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.pattern-canvas {
  display: flex;
  align-items: center;
  justify-content: space-evenly;
  width: 100%;
  min-width: 62px;
  height: 16px;
  padding: 2px;
  border: 1px solid #aebbc2;
  background: #ffffff;
}

.pattern-canvas i {
  display: block;
  width: 7px;
  height: 10px;
  border: 1px solid #9aa8af;
  border-radius: 2px;
  background: #dfe6e9;
}

.pattern-4 i,
.pattern-6 i,
.pattern-8 i {
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 1px;
}

.pattern-8 i {
  width: 6px;
  height: 6px;
  flex-basis: 6px;
}

.pattern-grid-canvas {
  display: grid;
  justify-self: center;
  width: 38px;
  min-width: 38px;
  height: 38px;
  gap: 2px;
  padding: 3px;
}

.pattern-grid-canvas i {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  border-radius: 1px;
  background: #eef2f4;
}

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

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

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

.grid-4x3 {
  height: 30px;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(3, 1fr);
}

.grid-6x4 {
  height: 30px;
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 1px;
}

.grid-8x2 {
  width: 64px;
  min-width: 64px;
  height: 22px;
  grid-template-columns: repeat(8, 6px);
  grid-template-rows: repeat(2, 6px);
  gap: 1px;
  padding: 2px;
  place-content: center;
}

.mosaic-970-preview {
  display: grid;
  grid-auto-flow: row dense;
  grid-template-columns: repeat(8, 6px);
  grid-template-rows: repeat(2, 6px);
  justify-self: center;
  width: 64px;
  min-width: 64px;
  height: 22px;
  gap: 1px;
  padding: 2px;
  place-content: center;
}

.mosaic-970-preview i {
  width: 6px;
  height: 6px;
  min-width: 0;
  min-height: 0;
  border-radius: 1px;
  background: #eef2f4;
}

.mosaic-970-preview .large-left {
  grid-column: 1 / span 2;
  grid-row: 1 / span 2;
  width: 13px;
  height: 13px;
  background: #ffffff;
}

.mosaic-970-preview .large-right {
  grid-column: 7 / span 2;
  grid-row: 1 / span 2;
  width: 13px;
  height: 13px;
  background: #ffffff;
}

.mosaic-970-preview .large-center {
  grid-column: 4 / span 2;
  grid-row: 1 / span 2;
  width: 13px;
  height: 13px;
  background: #ffffff;
}

.mosaic-970-preview .large-col-2 {
  grid-column: 2 / span 2;
  grid-row: 1 / span 2;
  width: 13px;
  height: 13px;
  background: #ffffff;
}

.mosaic-970-preview .large-col-6 {
  grid-column: 6 / span 2;
  grid-row: 1 / span 2;
  width: 13px;
  height: 13px;
  background: #ffffff;
}

.mosaic-600-preview {
  position: relative;
  display: block;
  justify-self: center;
  width: 46px;
  min-width: 46px;
  height: 40px;
  padding: 0;
}

.mosaic-600-preview i {
  position: absolute;
  width: auto;
  height: auto;
  border-radius: 1px;
  background: #f7fafb;
}

.mosaic-600-preview .photo-slot {
  border-color: #607d88;
  background: #d5e2e7;
}

.mosaic-600-a i:nth-child(1), .mosaic-600-a i:nth-child(6),
.mosaic-600-c i:nth-child(1) { left: 2px; }
.mosaic-600-a i:nth-child(2), .mosaic-600-a i:nth-child(7),
.mosaic-600-c i:nth-child(2) { left: 13px; }
.mosaic-600-a i:nth-child(3), .mosaic-600-a i:nth-child(8),
.mosaic-600-c i:nth-child(3) { left: 24px; }
.mosaic-600-a i:nth-child(4), .mosaic-600-a i:nth-child(9),
.mosaic-600-c i:nth-child(4) { left: 35px; }
.mosaic-600-a i:nth-child(-n+4), .mosaic-600-c i:nth-child(-n+4) { top: 2px; width: 8px; height: 8px; }
.mosaic-600-a i:nth-child(5) { left: 2px; top: 13px; width: 41px; height: 11px; }
.mosaic-600-a i:nth-child(n+6) { top: 27px; width: 8px; height: 8px; }

.mosaic-600-b i:nth-child(1) { left: 2px; top: 2px; width: 19px; height: 19px; }
.mosaic-600-b i:nth-child(2) { left: 24px; top: 2px; width: 19px; height: 19px; }
.mosaic-600-b i:nth-child(3) { left: 2px; top: 25px; width: 11px; height: 11px; }
.mosaic-600-b i:nth-child(4) { left: 17px; top: 25px; width: 11px; height: 11px; }
.mosaic-600-b i:nth-child(5) { left: 32px; top: 25px; width: 11px; height: 11px; }

.mosaic-600-c i:nth-child(5) { left: 2px; top: 13px; width: 41px; height: 23px; }

.mosaic-600-d i:nth-child(1) { left: 2px; top: 2px; width: 16px; height: 16px; }
.mosaic-600-d i:nth-child(2) { left: 2px; top: 21px; width: 16px; height: 16px; }
.mosaic-600-d i:nth-child(3) { left: 21px; top: 2px; width: 22px; height: 35px; }

.mosaic-600-e i:nth-child(1) { left: 2px; top: 2px; width: 9px; height: 9px; }
.mosaic-600-e i:nth-child(2) { left: 13px; top: 2px; width: 9px; height: 9px; }
.mosaic-600-e i:nth-child(3) { left: 24px; top: 2px; width: 9px; height: 9px; }
.mosaic-600-e i:nth-child(4) { left: 35px; top: 2px; width: 9px; height: 9px; }
.mosaic-600-e i:nth-child(5) { left: 2px; top: 13px; width: 11px; height: 11px; }
.mosaic-600-e i:nth-child(6) { left: 2px; top: 26px; width: 11px; height: 11px; }
.mosaic-600-e i:nth-child(7) { left: 15px; top: 13px; width: 29px; height: 24px; }

.mosaic-600-f i:nth-child(1) { left: 2px; top: 2px; width: 29px; height: 24px; }
.mosaic-600-f i:nth-child(2) { left: 33px; top: 2px; width: 11px; height: 11px; }
.mosaic-600-f i:nth-child(3) { left: 33px; top: 15px; width: 11px; height: 11px; }
.mosaic-600-f i:nth-child(4) { left: 2px; top: 28px; width: 9px; height: 9px; }
.mosaic-600-f i:nth-child(5) { left: 13px; top: 28px; width: 9px; height: 9px; }
.mosaic-600-f i:nth-child(6) { left: 24px; top: 28px; width: 9px; height: 9px; }
.mosaic-600-f i:nth-child(7) { left: 35px; top: 28px; width: 9px; height: 9px; }

.portrait-grid-canvas {
  align-self: center;
  justify-self: center;
  align-content: center;
  justify-content: center;
}

.grid-2x4 {
  width: 22px;
  min-width: 22px;
  height: 38px;
  grid-template-columns: repeat(2, 6px);
  grid-template-rows: repeat(4, 6px);
}

.grid-3x6 {
  width: 24px;
  min-width: 24px;
  height: 42px;
  grid-template-columns: repeat(3, 4px);
  grid-template-rows: repeat(6, 4px);
}

.portrait-mosaic-preview {
  display: grid;
  width: 25px;
  min-width: 25px;
  height: 43px;
  grid-template-columns: repeat(3, 5px);
  grid-template-rows: repeat(6, 5px);
  gap: 1px;
  padding: 3px;
}

.portrait-mosaic-preview i {
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  border-radius: 1px;
  background: #eef2f4;
}

.portrait-large-tl i:first-child {
  grid-column: 1 / 3;
  grid-row: 1 / 3;
}

.portrait-center-photo i:first-child {
  grid-column: 2 / 4;
  grid-row: 3 / 5;
}

.portrait-photo-preview {
  position: relative;
  display: block;
  flex: none;
  width: 25px;
  min-width: 25px;
  height: 43px;
  padding: 0;
}

.portrait-photo-preview i {
  position: absolute;
  display: block;
  border: 1px solid #8da0a9;
  border-radius: 1px;
  background: #e5ecef;
}

.portrait-photo-preview i:not(.photo-slot) {
  background: #f7fafb;
}

.portrait-photo-preview .photo-slot {
  border-color: #607d88;
  background: #d5e2e7;
}

.portrait-photo-a i:nth-child(1) { left: 3px; top: 3px; width: 9px; height: 8px; }
.portrait-photo-a i:nth-child(2) { left: 14px; top: 3px; width: 9px; height: 8px; }
.portrait-photo-a i:nth-child(3) { left: 3px; top: 13px; width: 20px; height: 16px; }
.portrait-photo-a i:nth-child(4) { left: 3px; top: 32px; width: 9px; height: 8px; }
.portrait-photo-a i:nth-child(5) { left: 14px; top: 32px; width: 9px; height: 8px; }

.portrait-photo-b i:nth-child(1) { left: 3px; top: 3px; width: 20px; height: 19px; }
.portrait-photo-b i:nth-child(2) { left: 3px; top: 25px; width: 9px; height: 7px; }
.portrait-photo-b i:nth-child(3) { left: 14px; top: 25px; width: 9px; height: 7px; }
.portrait-photo-b i:nth-child(4) { left: 3px; top: 34px; width: 9px; height: 6px; }
.portrait-photo-b i:nth-child(5) { left: 14px; top: 34px; width: 9px; height: 6px; }

.portrait-photo-c i:nth-child(odd) { left: 3px; width: 9px; height: 8px; }
.portrait-photo-c i:nth-child(even) { left: 14px; width: 9px; height: 8px; }
.portrait-photo-c i:nth-child(1), .portrait-photo-c i:nth-child(2) { top: 3px; }
.portrait-photo-c i:nth-child(3), .portrait-photo-c i:nth-child(4) { top: 12px; }
.portrait-photo-c i:nth-child(5), .portrait-photo-c i:nth-child(6) { top: 21px; }
.portrait-photo-c i:nth-child(7), .portrait-photo-c i:nth-child(8) { top: 30px; }

.portrait-photo-d i:nth-child(1) { left: 3px; top: 3px; width: 9px; height: 8px; }
.portrait-photo-d i:nth-child(2) { left: 14px; top: 3px; width: 9px; height: 8px; }
.portrait-photo-d i:nth-child(3) { left: 3px; top: 13px; width: 20px; height: 27px; }

.portrait-photo-e i:nth-child(1) { left: 3px; top: 3px; width: 6px; height: 6px; }
.portrait-photo-e i:nth-child(2) { left: 3px; top: 10px; width: 6px; height: 6px; }
.portrait-photo-e i:nth-child(3) { left: 10px; top: 3px; width: 13px; height: 13px; }
.portrait-photo-e i:nth-child(4) { left: 3px; top: 18px; width: 20px; height: 10px; }
.portrait-photo-e i:nth-child(5) { left: 3px; top: 30px; width: 13px; height: 10px; }
.portrait-photo-e i:nth-child(6) { left: 18px; top: 30px; width: 5px; height: 4px; }
.portrait-photo-e i:nth-child(7) { left: 18px; top: 36px; width: 5px; height: 4px; }

.portrait-photo-f i:nth-child(1) { left: 3px; top: 3px; width: 20px; height: 28px; }
.portrait-photo-f i:nth-child(2) { left: 3px; top: 34px; width: 9px; height: 6px; }
.portrait-photo-f i:nth-child(3) { left: 14px; top: 34px; width: 9px; height: 6px; }

.grid-mosaic-3 {
  height: 26px;
  grid-template-columns: repeat(3, 8px);
  grid-template-rows: repeat(2, 8px);
  align-content: center;
  justify-content: center;
}

.grid-mosaic-3 i:first-child {
  grid-column: 1 / 3;
  grid-row: 1 / 3;
}

.grid-mosaic-3 i:nth-child(2) {
  grid-column: 3;
  grid-row: 1;
}

.grid-mosaic-3 i:nth-child(3) {
  grid-column: 3;
  grid-row: 2;
}

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

.grid-mosaic-6 i:nth-child(1) {
  grid-column: 1 / 3;
  grid-row: 1 / 3;
}

.grid-mosaic-6 i:nth-child(2) {
  grid-column: 3;
  grid-row: 1;
}

.grid-mosaic-6 i:nth-child(3) {
  grid-column: 3;
  grid-row: 2;
}

.grid-mosaic-6 i:nth-child(4) {
  grid-column: 1;
  grid-row: 3;
}

.grid-mosaic-6 i:nth-child(5) {
  grid-column: 2;
  grid-row: 3;
}

.grid-mosaic-6 i:nth-child(6) {
  grid-column: 3;
  grid-row: 3;
}

.photo-pattern-canvas {
  position: relative;
  display: block;
  flex: none;
  width: 38px;
  min-width: 38px;
  height: 32px;
  padding: 0;
}

.photo-pattern-canvas i {
  position: absolute;
  display: block;
  border: 1px solid #9aa8af;
  border-radius: 2px;
  background: #eef2f4;
}

.photo-pattern-canvas .photo-slot {
  border-color: #607d88;
  background: #d5e2e7;
}

.photo-v2 i:first-child { left: 3px; top: 3px; width: 18px; height: 26px; }
.photo-v2 i:nth-child(2) { left: 23px; top: 3px; width: 12px; height: 12px; }
.photo-v2 i:nth-child(3) { left: 23px; top: 17px; width: 12px; height: 12px; }

.photo-top3-wide i:nth-child(1) { left: 3px; top: 3px; width: 9px; height: 9px; }
.photo-top3-wide i:nth-child(2) { left: 14px; top: 3px; width: 9px; height: 9px; }
.photo-top3-wide i:nth-child(3) { left: 25px; top: 3px; width: 9px; height: 9px; }
.photo-top3-wide i:nth-child(4) { left: 3px; top: 14px; width: 31px; height: 15px; }

.photo-v3 i:first-child { left: 3px; top: 3px; width: 22px; height: 26px; }
.photo-v3 i:nth-child(2) { left: 27px; top: 3px; width: 8px; height: 8px; }
.photo-v3 i:nth-child(3) { left: 27px; top: 12px; width: 8px; height: 8px; }
.photo-v3 i:nth-child(4) { left: 27px; top: 21px; width: 8px; height: 8px; }

.photo-wide-bottom3 i:first-child { left: 3px; top: 3px; width: 31px; height: 15px; }
.photo-wide-bottom3 i:nth-child(2) { left: 3px; top: 20px; width: 9px; height: 9px; }
.photo-wide-bottom3 i:nth-child(3) { left: 14px; top: 20px; width: 9px; height: 9px; }
.photo-wide-bottom3 i:nth-child(4) { left: 25px; top: 20px; width: 9px; height: 9px; }

.photo-two-wide i:first-child { left: 3px; top: 3px; width: 31px; height: 12px; }
.photo-two-wide i:nth-child(2) { left: 3px; top: 17px; width: 31px; height: 12px; }

.logo-mosaic-preview {
  position: relative;
  display: block;
  flex: none;
  width: 38px;
  min-width: 38px;
  height: 28px;
  padding: 0;
}

.logo-mosaic-preview i {
  position: absolute;
  display: block;
  border: 1px solid #9aa8af;
  border-radius: 1px;
  background: #eef2f4;
}

.mosaic-480-a i:first-child { left: 3px; top: 3px; width: 12px; height: 12px; }
.mosaic-480-a i:nth-child(2) { left: 20px; top: 3px; width: 5px; height: 5px; }
.mosaic-480-a i:nth-child(3) { left: 28px; top: 3px; width: 5px; height: 5px; }
.mosaic-480-a i:nth-child(4) { left: 20px; top: 10px; width: 5px; height: 5px; }
.mosaic-480-a i:nth-child(5) { left: 28px; top: 10px; width: 5px; height: 5px; }
.mosaic-480-a i:nth-child(6) { left: 3px; top: 19px; width: 6px; height: 6px; }
.mosaic-480-a i:nth-child(7) { left: 11px; top: 19px; width: 6px; height: 6px; }
.mosaic-480-a i:nth-child(8) { left: 20px; top: 19px; width: 6px; height: 6px; }
.mosaic-480-a i:nth-child(9) { left: 29px; top: 19px; width: 6px; height: 6px; }

.mosaic-480-b i:nth-child(1) { left: 3px; top: 3px; width: 6px; height: 6px; }
.mosaic-480-b i:nth-child(2) { left: 11px; top: 3px; width: 6px; height: 6px; }
.mosaic-480-b i:nth-child(3) { left: 20px; top: 3px; width: 6px; height: 6px; }
.mosaic-480-b i:nth-child(4) { left: 29px; top: 3px; width: 6px; height: 6px; }
.mosaic-480-b i:nth-child(5) { left: 3px; top: 11px; width: 6px; height: 6px; }
.mosaic-480-b i:nth-child(6) { left: 11px; top: 11px; width: 6px; height: 6px; }
.mosaic-480-b i:nth-child(7) { left: 3px; top: 19px; width: 6px; height: 6px; }
.mosaic-480-b i:nth-child(8) { left: 11px; top: 19px; width: 6px; height: 6px; }
.mosaic-480-b i:nth-child(9) { left: 20px; top: 11px; width: 15px; height: 14px; }

.mosaic-480-c i:nth-child(1) { left: 3px; top: 3px; width: 7px; height: 7px; }
.mosaic-480-c i:nth-child(2) { left: 3px; top: 11px; width: 7px; height: 7px; }
.mosaic-480-c i:nth-child(3) { left: 3px; top: 19px; width: 7px; height: 7px; }
.mosaic-480-c i:nth-child(4) { left: 27px; top: 3px; width: 7px; height: 7px; }
.mosaic-480-c i:nth-child(5) { left: 27px; top: 11px; width: 7px; height: 7px; }
.mosaic-480-c i:nth-child(6) { left: 27px; top: 19px; width: 7px; height: 7px; }
.mosaic-480-c i:nth-child(7) { left: 11px; top: 3px; width: 7px; height: 7px; }
.mosaic-480-c i:nth-child(8) { left: 19px; top: 3px; width: 7px; height: 7px; }
.mosaic-480-c i:nth-child(9) { left: 11px; top: 11px; width: 15px; height: 15px; }

.mosaic-480-d i:nth-child(1) { left: 3px; top: 3px; width: 7px; height: 7px; }
.mosaic-480-d i:nth-child(2) { left: 3px; top: 11px; width: 7px; height: 7px; }
.mosaic-480-d i:nth-child(3) { left: 3px; top: 19px; width: 7px; height: 7px; }
.mosaic-480-d i:nth-child(4) { left: 27px; top: 3px; width: 7px; height: 7px; }
.mosaic-480-d i:nth-child(5) { left: 27px; top: 11px; width: 7px; height: 7px; }
.mosaic-480-d i:nth-child(6) { left: 27px; top: 19px; width: 7px; height: 7px; }
.mosaic-480-d i:nth-child(7) { left: 11px; top: 19px; width: 7px; height: 7px; }
.mosaic-480-d i:nth-child(8) { left: 19px; top: 19px; width: 7px; height: 7px; }
.mosaic-480-d i:nth-child(9) { left: 11px; top: 3px; width: 15px; height: 15px; }

.mixed-480-left .photo-slot,
.mixed-480-right .photo-slot {
  top: 3px;
  width: 17px;
  height: 22px;
  border-color: #748b96;
  background: #dfe8eb;
}

.mixed-480-left .photo-slot { left: 3px; }
.mixed-480-left i:nth-child(2) { left: 23px; top: 3px; width: 5px; height: 5px; }
.mixed-480-left i:nth-child(3) { left: 30px; top: 3px; width: 5px; height: 5px; }
.mixed-480-left i:nth-child(4) { left: 23px; top: 11px; width: 5px; height: 5px; }
.mixed-480-left i:nth-child(5) { left: 30px; top: 11px; width: 5px; height: 5px; }
.mixed-480-left i:nth-child(6) { left: 23px; top: 19px; width: 5px; height: 5px; }
.mixed-480-left i:nth-child(7) { left: 30px; top: 19px; width: 5px; height: 5px; }

.mixed-480-right .photo-slot { left: 18px; }
.mixed-480-right i:nth-child(2) { left: 3px; top: 3px; width: 5px; height: 5px; }
.mixed-480-right i:nth-child(3) { left: 10px; top: 3px; width: 5px; height: 5px; }
.mixed-480-right i:nth-child(4) { left: 3px; top: 11px; width: 5px; height: 5px; }
.mixed-480-right i:nth-child(5) { left: 10px; top: 11px; width: 5px; height: 5px; }
.mixed-480-right i:nth-child(6) { left: 3px; top: 19px; width: 5px; height: 5px; }
.mixed-480-right i:nth-child(7) { left: 10px; top: 19px; width: 5px; height: 5px; }

.pattern-selection strong {
  font-size: 10px;
  line-height: 1.1;
  white-space: nowrap;
}

.portrait-pattern-card .pattern-selection {
  grid-template-columns: 16px 32px minmax(0, 1fr);
}

.portrait-pattern-card .pattern-selection strong {
  min-width: 0;
  font-size: 9px;
  line-height: 1.15;
  white-space: normal;
  overflow-wrap: anywhere;
}

.pattern-count {
  display: grid;
  gap: 2px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
}

.pattern-count input[type="number"] {
  width: 58px;
  min-height: 30px;
  padding: 4px 5px;
  font-size: 11px;
}

.size-card p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.primary-button,
.danger-button,
.secondary-button,
.secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border-radius: 8px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.primary-button {
  min-width: 250px;
  padding: 0 20px;
  border: 1px solid var(--accent-strong);
  background: var(--accent);
  color: #ffffff;
}

.primary-button:hover {
  background: var(--accent-strong);
}

.danger-button {
  min-width: 116px;
  padding: 0 18px;
  border: 1px solid #8f1d16;
  background: var(--danger);
  color: #ffffff;
}

.danger-button:hover {
  background: #8f1d16;
}

.primary-button:disabled,
.danger-button:disabled,
.secondary-button:disabled,
.secondary-link.disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.secondary-button,
.secondary-link {
  min-width: 154px;
  padding: 0 15px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
}

.final-download-button {
  min-width: 230px;
  border-color: var(--accent);
  background: #edfdf9;
  color: var(--accent-strong);
}

.final-download-button:not(.disabled):hover {
  background: var(--accent);
  color: #ffffff;
}

.final-download-button.disabled {
  pointer-events: none;
}

.result-panel {
  margin-top: 18px;
  padding: 18px;
}

.progress-panel {
  margin-top: 18px;
  padding: 18px;
}

.folder-task-panel {
  margin-top: 18px;
  padding: 18px;
}

.folder-task-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
}

.folder-task-head h2 {
  margin-bottom: 0;
  font-size: 20px;
}

.folder-task-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  align-items: end;
  gap: 14px;
  margin-top: 16px;
}

.folder-task-form input[type="number"],
.folder-task-form input[type="text"] {
  max-width: none;
}

.folder-task-form small {
  min-height: 30px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.folder-task-form .primary-button {
  min-width: 190px;
}

.folder-task-result {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid #9fe8d8;
  border-radius: 8px;
  background: #edfdf9;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
}

.folder-task-result.error {
  border-color: #ffb4ad;
  background: #fff1f0;
  color: var(--danger);
}

.progress-head h2 {
  margin-bottom: 0;
  font-size: 18px;
}

.progress-list {
  display: grid;
  gap: 9px;
  margin-top: 14px;
}

.progress-step {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.progress-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: #e8eef1;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.progress-title {
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
}

.progress-detail {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.counter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  color: var(--text);
  font-size: 12px;
  font-weight: 900;
}

.counter-row span {
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
}

.progress-bar {
  width: min(420px, 100%);
  height: 8px;
  margin-top: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8eef1;
}

.progress-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.skip-list {
  margin: 8px 0 0;
  padding-left: 18px;
  color: #7c3d10;
  font-size: 12px;
  font-weight: 700;
}

.skip-list li + li {
  margin-top: 4px;
}

.progress-step.active {
  border-color: #f1d49a;
  background: #fff8eb;
}

.progress-step.active .progress-number {
  background: #f59e0b;
  color: #ffffff;
}

.progress-step.done {
  border-color: #9fe8d8;
  background: #edfdf9;
}

.progress-step.done .progress-number {
  background: var(--accent);
  color: #ffffff;
}

.progress-step.error,
.progress-step.stopped {
  border-color: #ffb4ad;
  background: #fff1f0;
}

.progress-step.error .progress-number,
.progress-step.stopped .progress-number {
  background: var(--danger);
  color: #ffffff;
}

.hidden {
  display: none;
}

.result-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
}

.result-head h2 {
  margin-bottom: 0;
}

.mini-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 8px;
}

.mini-stats span {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.output-path {
  margin: 14px 0;
  padding: 11px 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.warnings {
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--warning-line);
  border-radius: 8px;
  background: var(--warning-bg);
  color: #7c3d10;
  font-size: 13px;
}

.warnings ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.preview-item {
  display: grid;
  gap: 8px;
  align-content: start;
  min-height: 168px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.preview-item img {
  width: 100%;
  max-height: 180px;
  object-fit: contain;
  border: 1px solid #eef2f4;
  border-radius: 0;
  background: #ffffff;
}

.preview-item span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.user-badge,
.header-button {
  min-height: 38px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.user-badge {
  color: var(--accent-strong);
  background: #edfdf9;
  border-color: #9fe8d8;
}

.header-button {
  cursor: pointer;
}

.header-button:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.user-dialog {
  width: min(560px, calc(100% - 28px));
  max-height: min(760px, calc(100vh - 40px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 24px 80px rgba(23, 32, 38, 0.24);
}

.user-dialog::backdrop {
  background: rgba(23, 32, 38, 0.55);
  backdrop-filter: blur(3px);
}

.user-dialog-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
  padding: 20px 20px 14px;
  border-bottom: 1px solid var(--line);
}

.user-dialog-head h2 {
  margin-bottom: 0;
}

.dialog-close {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #ffffff;
  color: var(--muted);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.user-list-summary {
  padding: 14px 20px 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.user-list {
  display: grid;
  gap: 8px;
  max-height: 280px;
  padding: 0 20px 16px;
  overflow-y: auto;
}

.user-list-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 11px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.user-avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #e8eff2;
  color: var(--accent-strong);
  font-weight: 900;
}

.user-list-row div {
  display: grid;
  gap: 2px;
}

.user-list-row small {
  color: var(--muted);
}

.user-role {
  padding: 5px 8px;
  border-radius: 999px;
  background: #edfdf9;
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 800;
}

.user-role.admin {
  background: #fff8eb;
  color: #8a4b0f;
}

.add-user-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  align-items: end;
  gap: 12px;
  padding: 18px 20px 20px;
  border-top: 1px solid var(--line);
}

.add-user-form h3,
.add-user-form .form-message {
  grid-column: 1 / -1;
  margin: 0;
}

.add-user-form h3 {
  font-size: 16px;
}

.form-message {
  padding: 9px 10px;
  border: 1px solid #9fe8d8;
  border-radius: 8px;
  background: #edfdf9;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
}

.form-message.error {
  border-color: #ffb4ad;
  background: #fff1f0;
  color: var(--danger);
}

.login-page {
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-shell {
  width: min(460px, 100%);
}

.login-card {
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-card h1 {
  font-size: clamp(34px, 8vw, 48px);
}

.login-intro {
  margin: 14px 0 22px;
  color: var(--muted);
  line-height: 1.55;
}

.login-form {
  display: grid;
  gap: 16px;
}

.login-form .primary-button {
  width: 100%;
  min-height: 46px;
}

@media (max-width: 900px) {
  .upload-panel,
  .sizes-grid,
  .folder-task-form {
    grid-template-columns: 1fr 1fr;
  }

  .add-user-form {
    grid-template-columns: 1fr 1fr;
  }

  .add-user-form .primary-button {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .shell {
    width: min(100% - 22px, 1160px);
    padding-top: 18px;
  }

  .topbar,
  .result-head,
  .folder-task-head {
    align-items: start;
    flex-direction: column;
  }

  .topbar-actions {
    justify-content: flex-start;
  }

  .upload-panel,
  .source-panel,
  .source-toolbar,
  .standard-method-panel,
  .sizes-grid,
  .folder-task-form {
    grid-template-columns: 1fr;
  }

  .add-user-form {
    grid-template-columns: 1fr;
  }

  .login-page {
    padding: 14px;
  }

  .login-card {
    padding: 24px 20px;
  }

  .size-card {
    min-height: 112px;
  }

  .primary-button,
  .danger-button,
  .secondary-button,
  .secondary-link {
    width: 100%;
  }
}
