/* ============================================================
   Image Tool – shared stylesheet
   Design reference: Pi7 Image Tool (resize image pixel page)
   ============================================================ */

:root {
  --nav: #403a8f;
  --nav-dark: #342f7a;
  --nav-line: rgba(255, 255, 255, 0.18);
  --teal: #00796b;
  --teal-dark: #00695c;
  --btn: #4a4fa3;
  --btn-dark: #3d4190;
  --ink: #191923;
  --muted: #5d5e70;
  --line: #e2e2ec;
  --line-strong: #cfcfdd;
  --soft: #f7f7fc;
  --sidebar-line: #dcdcea;
  --link: #2c3a92;
  --danger: #c62828;
  --ok: #1b7f4c;
  --radius: 3px;
  --shadow: 0 3px 10px rgba(20, 20, 45, 0.08);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Arial, Helvetica, sans-serif;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: #fff;
  font-size: 15px;
  line-height: 1.45;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; }
button { font-family: inherit; }

/* ---------- Header ---------- */
.site-header {
  background: var(--nav);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.12);
}

.header-inner {
  max-width: 1320px;
  margin: 0 auto;
  min-height: 62px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-shrink: 0;
}

.brand-photo {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.9);
  background: #fff;
  flex-shrink: 0;
  display: block;
}

.brand-name {
  font-size: 23px;
  font-weight: 800;
  letter-spacing: 0.2px;
  white-space: nowrap;
  margin-left: 4px;
}

.main-nav {
  display: flex;
  align-items: stretch;
  margin-left: auto;
  min-height: 62px;
}

.main-nav > a,
.nav-drop {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 13px;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  background: transparent;
  border: 0;
  border-left: 1px solid var(--nav-line);
  cursor: pointer;
  white-space: nowrap;
  line-height: 1.15;
}

.main-nav > a:last-child { border-right: 1px solid var(--nav-line); }

.main-nav > a:hover,
.nav-drop:hover,
.nav-drop:focus-visible {
  background: rgba(255, 255, 255, 0.08);
}

.main-nav > a.active { background: rgba(0, 0, 0, 0.13); }

.nav-dropdown { position: relative; display: flex; }

.caret { font-size: 11px; margin-left: 3px; transform: translateY(-1px); }

.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 190px;
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 0 0 4px 4px;
  box-shadow: var(--shadow);
  padding: 5px 0;
  display: none;
  z-index: 70;
}

.dropdown-menu a {
  display: block;
  padding: 9px 15px;
  font-size: 14.5px;
  font-weight: 600;
  color: #313150;
}

.dropdown-menu a:hover { background: #f1f1fa; color: var(--link); }

.nav-dropdown:hover .dropdown-menu,
.nav-dropdown:focus-within .dropdown-menu,
.nav-dropdown.open .dropdown-menu { display: block; }

.nav-toggle {
  display: none;
  margin-left: auto;
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 3px;
  font-size: 20px;
  line-height: 1;
  padding: 5px 9px;
  cursor: pointer;
}

/* ---------- Page frame ---------- */
.page {
  max-width: 1320px;
  margin: 0 auto;
  border: 1px solid #dedee9;
  border-top: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 336px;
  background: #fff;
  min-height: calc(100vh - 62px);
}

.main {
  padding: 34px 40px 64px;
  min-width: 0;
}

/* ---------- Sidebar ---------- */
.sidebar {
  border-left: 1px solid var(--line);
  background: #fbfbfe;
  padding: 12px 10px 24px;
  font-size: 15px;
}

.side-card {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 10px;
  background: #fff;
  border: 1px solid var(--sidebar-line);
  color: #22223a;
  font-weight: 600;
  text-align: center;
  margin-bottom: 10px;
}

.side-card:hover { background: #f4f4ff; color: var(--link); }

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #d5355b;
  flex-shrink: 0;
}

.side-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--sidebar-line);
  background: #fff;
  margin-bottom: 10px;
}

.side-grid a {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 40px;
  padding: 7px 6px;
  color: var(--link);
  font-size: 15px;
  border-right: 1px solid var(--sidebar-line);
  border-bottom: 1px solid var(--sidebar-line);
}

.side-grid a:nth-child(2n) { border-right: 0; }
.side-grid a:nth-last-child(-n + 2) { border-bottom: 0; }
.side-grid a:hover { background: #f2f2fd; text-decoration: underline; }

.ad-label {
  text-align: right;
  font-size: 11px;
  color: #6a6a80;
  margin: 12px 2px 5px;
  letter-spacing: 0.2px;
}

.ad-slot {
  border: 1px dashed #d7d7e6;
  background: #fff;
  color: #6a6a80;
  min-height: 250px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  text-align: center;
}

/* ---------- Generic typography ---------- */
h1 {
  font-size: 30px;
  line-height: 1.25;
  font-weight: 800;
  margin: 0 0 18px;
  text-align: center;
  letter-spacing: -0.2px;
  color: #3b3590;
}

h1::after {
  content: "";
  display: block;
  width: 68px;
  height: 3px;
  margin: 10px auto 0;
  border-radius: 2px;
  background: linear-gradient(90deg, #4a4fa3, #00796b);
}

h2 { font-size: 21px; margin: 0 0 10px; color: #3b3590; }
h3 { font-size: 17px; margin: 0 0 8px; color: #2f2b73; }

.sub {
  text-align: center;
  color: var(--muted);
  margin: -12px auto 26px;
  max-width: 720px;
  font-size: 15px;
}

.tool { max-width: 820px; margin: 0 auto; }

.note {
  text-align: center;
  margin: 22px auto 0;
  font-size: 14.5px;
  font-weight: 600;
  color: #2c2c3c;
}

.note.soft { font-weight: 400; color: var(--muted); font-size: 13.5px; }

/* ---------- Dropzone ---------- */
.dropzone {
  max-width: 560px;
  margin: 0 auto;
  border: 2px dashed #7b7bb0;
  border-radius: var(--radius);
  padding: 36px 20px 32px;
  text-align: center;
  background: #fff;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
  outline: none;
}

.dropzone:hover,
.dropzone:focus-visible { background: #f8f8ff; border-color: var(--nav); }

.dropzone.dragover {
  background: #eef0ff;
  border-color: var(--btn);
}

.dropzone p {
  margin: 0 0 16px;
  font-size: 17px;
  color: #565669;
}

.dropzone .hint {
  font-size: 13px;
  color: #85859a;
  margin: 12px 0 0;
}

.dropzone.compact { padding: 26px 16px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 0;
  border-radius: var(--radius);
  padding: 10px 20px;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  background: var(--btn);
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease, transform 0.05s ease;
  box-shadow: 0 2px 4px rgba(20, 20, 45, 0.18);
  line-height: 1.2;
}

.btn:hover { background: var(--btn-dark); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; box-shadow: none; }

.btn-green { background: var(--teal); }
.btn-green:hover { background: var(--teal-dark); }

.btn-outline {
  background: #fff;
  color: var(--link);
  border: 1px solid var(--line-strong);
  box-shadow: none;
}
.btn-outline:hover { background: #f2f2fd; }

.btn-sm { padding: 6px 12px; font-size: 13.5px; box-shadow: none; }
.btn-lg { padding: 12px 28px; font-size: 16px; }
.btn[hidden] { display: none; }

.btn .spinner {
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: none;
}

.btn.busy .spinner { display: inline-block; }
.btn.busy { pointer-events: none; opacity: 0.85; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Form controls ---------- */
input[type="number"],
input[type="text"],
input[type="email"],
select {
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 8px 10px;
  background: #fff;
  outline: none;
}

input[type="number"]:focus,
input[type="text"]:focus,
select:focus { border-color: var(--btn); box-shadow: 0 0 0 3px rgba(74, 79, 163, 0.12); }

input[type="number"] { -moz-appearance: textfield; }
input::placeholder { color: #4f4f61; opacity: 1; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.check,
.radio {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  font-size: 15px;
  color: #3f3f52;
  user-select: none;
}

input[type="checkbox"],
input[type="radio"] {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--btn);
  cursor: pointer;
  flex-shrink: 0;
}

.control-row {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 17px;
  text-align: center;
}

.dim-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}

.dim-row input {
  width: 92px;
  height: 38px;
  text-align: center;
  padding: 0 8px;
}

.dim-row .x { color: #3d3d4e; font-size: 15px; }

.size-input {
  width: 78px;
  height: 32px;
  padding: 0 7px;
  font-size: 14px;
  text-align: center;
}

.output-row {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 17px;
}

.group-label { font-weight: 600; color: #2f2f40; }

.field { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.field > span { font-size: 13.5px; font-weight: 600; color: #4a4a5e; }
.field.full { grid-column: 1 / -1; }
.field-row { display: flex; gap: 12px; flex-wrap: wrap; }
.field-row .field { flex: 1 1 150px; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px 18px;
  max-width: 620px;
  margin: 24px auto 0;
  text-align: left;
}

.form-grid .field select { width: 100%; }

.target-row { display: flex; align-items: center; gap: 8px; }
.target-row input[type="number"] { flex: 1 1 auto; min-width: 0; }
.form-grid .field .target-row select { width: auto; flex: 0 0 92px; font-weight: 700; cursor: pointer; }

input[type="range"] {
  accent-color: var(--btn);
  width: 100%;
  max-width: 220px;
  cursor: pointer;
}

.range-val {
  display: inline-block;
  min-width: 46px;
  text-align: right;
  font-weight: 700;
  color: var(--link);
  font-size: 14px;
}

.inline-fields {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.inline-fields select { height: 40px; }

.section-label {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  color: #4a4a5e;
  margin-bottom: 6px;
}

.hint-inline {
  font-size: 12.5px;
  color: #6a6a80;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 7px;
  margin-top: 14px;
}

.chip {
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: 99px;
  padding: 5px 12px;
  font-size: 12.5px;
  font-weight: 600;
  color: #3f3f55;
  cursor: pointer;
}

.chip:hover { border-color: var(--btn); color: var(--link); }
.chip.active { background: var(--btn); border-color: var(--btn); color: #fff; }

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  max-width: 760px;
  margin: 22px auto 0;
  text-align: left;
}

@media (max-width: 640px) {
  .two-col { grid-template-columns: 1fr; }
}

/* ---------- File previews ---------- */
.file-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin: 24px auto 0;
  max-width: 760px;
}

.file-card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fbfbfe;
  padding: 8px;
  text-align: center;
  min-width: 0;
}

.file-card .thumb {
  width: 100%;
  height: 84px;
  object-fit: contain;
  background: repeating-conic-gradient(#f0f0f5 0% 25%, #fff 0% 50%) 50% / 14px 14px;
  border-radius: 2px;
  display: block;
}

.file-card .fname {
  font-size: 12px;
  margin-top: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #3c3c50;
}

.file-card .fmeta { font-size: 11.5px; color: #6a6a80; margin-top: 1px; }

.file-card .remove {
  position: absolute;
  top: -7px;
  right: -7px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #3b3b4d;
  color: #fff;
  border: 2px solid #fff;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.file-card .remove:hover { background: var(--danger); }

.file-summary {
  text-align: center;
  font-size: 13.5px;
  color: var(--muted);
  margin-top: 12px;
}

/* ---------- Panels / results ---------- */
.panel {
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  padding: 18px;
  margin-top: 26px;
  scroll-margin-top: 80px;
  box-shadow: 0 1px 4px rgba(20, 20, 45, 0.04);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.panel-head h2 { margin: 0; font-size: 16px; }

.result-list { display: flex; flex-direction: column; gap: 10px; }

.result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 9px 10px;
  background: #fdfdff;
  min-width: 0;
}

.result-item .thumb {
  width: 44px;
  height: 44px;
  object-fit: contain;
  border: 1px solid #ececf4;
  background: repeating-conic-gradient(#f1f1f6 0% 25%, #fff 0% 50%) 50% / 10px 10px;
  flex-shrink: 0;
  border-radius: 2px;
}

.result-item .info { flex: 1; min-width: 0; text-align: left; }
.result-item .info .name {
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.result-item .info .meta { font-size: 12.5px; color: #666678; margin-top: 1px; }
.result-item .info .meta .saved { color: var(--ok); font-weight: 600; }

.progress-wrap { display: flex; align-items: center; gap: 10px; margin-top: 18px; }
.progress {
  flex: 1;
  height: 9px;
  border-radius: 99px;
  background: #ececf5;
  overflow: hidden;
}
.progress > span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #5b63c4, #3f47a0);
  transition: width 0.18s ease;
}
.progress-text { font-size: 12.5px; color: var(--muted); min-width: 42px; text-align: right; }

/* ---------- Alerts / toast ---------- */
.alert {
  max-width: 760px;
  margin: 18px auto 0;
  border: 1px solid #f0c9c9;
  background: #fdf3f3;
  color: #8f2424;
  border-radius: 4px;
  padding: 10px 13px;
  font-size: 13.5px;
  text-align: left;
}
.alert.info { border-color: #c9d2f0; background: #f3f5fd; color: #2c3a92; }
.alert[hidden] { display: none; }

.toast-wrap {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(360px, calc(100vw - 32px));
}

.toast {
  background: #262638;
  color: #fff;
  padding: 11px 14px;
  border-radius: 4px;
  font-size: 13.5px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
  animation: toastIn 0.18s ease;
  border-left: 4px solid #7c83d8;
}

.toast.ok { border-left-color: #38b06b; }
.toast.err { border-left-color: #e05757; }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Crop tool ---------- */
.crop-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 250px;
  gap: 22px;
  align-items: start;
  margin-top: 24px;
}

.crop-stage {
  border: 1px solid var(--line);
  background: #222230;
  border-radius: 4px;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 320px;
  overflow: hidden;
  position: relative;
}

.crop-stage canvas { max-width: 100%; height: auto; display: block; cursor: crosshair; touch-action: none; }
.passport-stage {
  background: repeating-conic-gradient(#e9e9f2 0% 25%, #ffffff 0% 50%) 50% / 18px 18px;
}

.crop-side { text-align: left; display: flex; flex-direction: column; gap: 13px; }
.crop-side .field input,
.crop-side .field select { width: 100%; }
.crop-side .field-row { display: flex; gap: 9px; }
.crop-side .field-row .field { flex: 1 1 0; min-width: 0; }
.crop-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.preview-img {
  max-width: 100%;
  max-height: 340px;
  display: block;
  margin: 0 auto;
  background: repeating-conic-gradient(#f0f0f5 0% 25%, #fff 0% 50%) 50% / 16px 16px;
  border: 1px solid var(--line);
  border-radius: 3px;
}
.crop-side .preview-box {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fbfbfe;
  padding: 8px;
  text-align: center;
}
.crop-side .preview-box canvas { max-width: 100%; max-height: 150px; }
.crop-side .preview-box span { display: block; font-size: 12px; color: var(--muted); margin-top: 4px; }

.crop-readout {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  margin-top: 10px;
}

.empty-stage {
  color: #b9b9cc;
  font-size: 14px;
  text-align: center;
  padding: 40px 20px;
}

/* ---------- PDF tool lists ---------- */
.pdf-list { display: flex; flex-direction: column; gap: 9px; margin-top: 22px; }

.pdf-item {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 10px 12px;
  background: #fdfdff;
}

.pdf-item .pdf-icon {
  width: 34px;
  height: 40px;
  border-radius: 3px;
  background: #fdecec;
  color: #c0392b;
  font-size: 10px;
  font-weight: 800;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 5px;
  flex-shrink: 0;
  border: 1px solid #f4cccc;
}

.pdf-item .info { flex: 1; min-width: 0; text-align: left; }
.pdf-item .info .name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pdf-item .info .meta { font-size: 12px; color: #7a7a8c; }
.pdf-item .actions { display: flex; gap: 4px; flex-shrink: 0; }

.icon-btn {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line-strong);
  background: #fff;
  border-radius: 3px;
  cursor: pointer;
  color: #44445a;
  font-size: 14px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.icon-btn:hover { background: #f0f0fa; border-color: #b9b9d2; }
.icon-btn.danger:hover { background: #fdeeee; border-color: #e3b0b0; color: var(--danger); }

/* ---------- Signature maker ---------- */
.sig-tabs { display: flex; gap: 8px; justify-content: center; margin: 0 0 16px; }
.sig-stage {
  background: repeating-conic-gradient(#f0f0f5 0% 25%, #fff 0% 50%) 50% / 16px 16px;
  min-height: 300px;
}
.sig-stage canvas { background: transparent; cursor: crosshair; touch-action: none; }
.sig-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 16px;
}
.sig-toolbar label { display: inline-flex; align-items: center; gap: 7px; font-size: 14px; color: #3f3f55; }
.sig-toolbar input[type="color"] { width: 38px; height: 30px; padding: 2px; border: 1px solid var(--line-strong); border-radius: 3px; background: #fff; cursor: pointer; }
.sig-toolbar input[type="range"] { width: 130px; }

/* ---------- Misc ---------- */
.stat-row {
  display: flex;
  justify-content: center;
  gap: 22px;
  flex-wrap: wrap;
  margin-top: 16px;
  font-size: 13.5px;
  color: var(--muted);
}

.stat-row b { color: var(--ink); }

.center { text-align: center; }
.mt-0 { margin-top: 0 !important; }
.mt-10 { margin-top: 10px; }
.mt-18 { margin-top: 18px; }
.mt-24 { margin-top: 24px; }
.mb-0 { margin-bottom: 0 !important; }
.hidden { display: none !important; }

.tool-footer {
  border-top: 1px solid var(--line);
  margin-top: 46px;
  padding-top: 18px;
  font-size: 12.5px;
  color: #6a6a80;
  text-align: center;
}

.tool-footer a { color: #55556f; text-decoration: underline; }

/* ---------- Responsive ---------- */
@media (max-width: 1400px) {
  .main-nav > a, .nav-drop { padding: 0 9px; font-size: 14px; }
  .brand-name { font-size: 19px; letter-spacing: 0; }
  .header-inner { gap: 8px; }
}

@media (max-width: 1180px) {
  .main-nav > a, .nav-drop { padding: 0 9px; font-size: 14px; }
  .brand-name { font-size: 20px; }
  .main { padding: 28px 26px 52px; }
}

@media (max-width: 1040px) {
  .page { grid-template-columns: minmax(0, 1fr); }
  .sidebar { border-left: 0; border-top: 1px solid var(--line); }
  .side-grid, .side-card { max-width: 520px; margin-left: auto; margin-right: auto; }
  .side-card { margin-bottom: 10px; }
  .ad-slot { max-width: 520px; margin: 0 auto; }
  .ad-label { max-width: 520px; margin-left: auto; margin-right: auto; }
}

@media (max-width: 1220px) {
  .nav-toggle { display: inline-block; }
  .main-nav {
    position: absolute;
    top: 62px;
    left: 0;
    right: 0;
    background: var(--nav);
    display: none;
    flex-direction: column;
    min-height: 0;
    border-top: 1px solid var(--nav-line);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
    max-height: calc(100vh - 62px);
    overflow-y: auto;
  }
  .main-nav.open { display: flex; }
  .main-nav > a, .nav-drop {
    padding: 13px 18px;
    border-left: 0;
    border-bottom: 1px solid var(--nav-line);
    justify-content: flex-start;
    font-size: 15px;
  }
  .main-nav > a:last-child { border-right: 0; }
  .nav-dropdown { display: block; }
  .nav-drop { width: 100%; }
  .dropdown-menu {
    position: static;
    display: none;
    box-shadow: none;
    border: 0;
    background: rgba(0, 0, 0, 0.15);
    padding: 4px 0 8px;
  }
  .dropdown-menu a { color: #fff; padding: 10px 34px; }
  .dropdown-menu a:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
  .nav-dropdown.open .dropdown-menu { display: block; }
  .nav-dropdown:hover .dropdown-menu { display: none; }
  .nav-dropdown.open:hover .dropdown-menu { display: block; }
  h1 { font-size: 26px; }
  .main { padding: 24px 16px 44px; }
}

@media (max-width: 640px) {
  .brand-name { font-size: 17px; }
  .brand-logo, .brand-help { height: 30px; }
  .dropzone { padding: 28px 14px; }
  .dropzone p { font-size: 15.5px; }
  .form-grid { grid-template-columns: 1fr; }
  .crop-layout { grid-template-columns: 1fr; }
  .file-strip { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .result-item { flex-wrap: wrap; }
  .result-item .btn { margin-left: 56px; }
  .output-row { gap: 10px; }
}

/* ---------- Section titles ---------- */
.section-title {
  font-size: 16px;
  color: #3b3590;
  margin: 24px 0 10px;
  padding-left: 10px;
  border-left: 4px solid #4a4fa3;
  line-height: 1.2;
}
.muted { color: #6a6a80; }
.soon-links { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }

/* ---------- Colour picker ---------- */
.color-stage {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  background: repeating-conic-gradient(#f0f0f5 0% 25%, #fff 0% 50%) 50% / 16px 16px;
  min-height: 200px;
}
.color-stage canvas { max-width: 100%; cursor: crosshair; touch-action: none; }
.color-picked {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin: 18px 0 4px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fafaff;
}
.color-preview {
  width: 56px;
  height: 56px;
  border-radius: 6px;
  border: 1px solid var(--line-strong);
  background: #fff;
  flex-shrink: 0;
}
.color-values {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13.5px;
  color: #3f3f55;
  flex: 1;
  min-width: 180px;
}
.color-values b { display: inline-block; width: 34px; color: #4a4a63; }
.color-values code {
  font-family: Consolas, "Courier New", monospace;
  background: #eef0f8;
  padding: 2px 6px;
  border-radius: 3px;
}
.palette {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(86px, 1fr));
  gap: 10px;
}
.swatch {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 5px;
  overflow: hidden;
  background: #fff;
  cursor: pointer;
  padding: 0;
}
.swatch:hover { border-color: #b9b6e0; }
.swatch-color { display: block; height: 46px; }
.swatch-hex {
  font: 600 11.5px/1 Consolas, monospace;
  padding: 7px 4px;
  color: #3f3f55;
  text-align: center;
}

/* ---------- Image info ---------- */
.info-layout {
  display: grid;
  grid-template-columns: minmax(200px, 320px) 1fr;
  gap: 26px;
  align-items: start;
}
.info-preview {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #fafaff;
  text-align: center;
}
.info-preview img {
  max-width: 100%;
  max-height: 340px;
  display: block;
  margin: 0 auto;
  border-radius: 3px;
}
.info-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.info-table th {
  text-align: left;
  font-weight: 600;
  color: #4a4a63;
  padding: 7px 10px;
  background: #f5f6fb;
  border: 1px solid var(--line);
  width: 38%;
  vertical-align: top;
}
.info-table td {
  padding: 7px 10px;
  border: 1px solid var(--line);
  color: #2f2f45;
  word-break: break-word;
}

/* ---------- Tools hub ---------- */
.tools-search {
  display: flex;
  gap: 10px;
  margin: 0 0 6px;
}
.tools-search input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 11px 13px;
  font: 400 14.5px/1.2 Inter, "Segoe UI", Arial, sans-serif;
  color: #2f2f45;
  background: #fff;
}
.tools-search input:focus {
  outline: none;
  border-color: #7d79c9;
  box-shadow: 0 0 0 3px rgba(74, 79, 163, 0.12);
}
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 10px;
}
.tool-tile {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: #33334d;
  text-decoration: none;
  font-size: 13.5px;
  line-height: 1.3;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.tool-tile:hover { border-color: #b9b6e0; background: #f7f7ff; color: #3b3590; }
.tool-tile .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4a4fa3;
  flex-shrink: 0;
}
.tool-tile.soon .dot { background: #c3c3d6; }
.tools-group { margin-top: 26px; }
.tools-group h2 {
  font-size: 17px;
  color: #3b3590;
  border-left: 4px solid #4a4fa3;
  padding-left: 10px;
  margin: 0 0 12px;
  line-height: 1.2;
}
.tools-empty { padding: 24px; text-align: center; color: #6a6a80; }

@media (max-width: 760px) {
  .info-layout { grid-template-columns: 1fr; }
}

/* ---------- Site-wide footer (About / Privacy / Terms / Disclaimer / Contact) ---------- */
.site-footer {
  background: var(--nav-dark);
  color: #dcdcf2;
  margin-top: 0;
}

.site-footer-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 34px 22px 8px;
  display: grid;
  grid-template-columns: 1.5fr 1fr 1fr 1fr;
  gap: 30px;
}

.site-footer h2 {
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin: 0 0 10px;
}

.site-footer a {
  display: block;
  color: #d2d2ee;
  font-size: 14px;
  padding: 3px 0;
}

.site-footer a:hover { color: #fff; text-decoration: underline; }

.site-footer p {
  color: #c4c4e2;
  font-size: 13.5px;
  line-height: 1.65;
  margin: 0 0 10px;
  max-width: 340px;
}

.footer-brand {
  color: #fff;
  font-size: 21px;
  font-weight: 800;
  letter-spacing: 0.3px;
  margin-bottom: 8px;
}

.footer-bottom {
  max-width: 1320px;
  margin: 22px auto 0;
  padding: 15px 22px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
  font-size: 12.5px;
  color: #b9b9d8;
  text-align: center;
  line-height: 1.7;
}

.footer-bottom a {
  display: inline;
  padding: 0;
  font-size: 12.5px;
  color: #d2d2ee;
  text-decoration: underline;
}

.footer-plans {
  max-width: 1320px;
  margin: 4px auto 0;
  padding: 0 22px;
}

.footer-plans a {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 7px 12px;
  padding: 14px 18px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  text-align: center;
}

.footer-plans a:hover {
  background: rgba(255, 255, 255, 0.09);
  text-decoration: none;
}

.footer-plans .fp-label {
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #b9b9d8;
}

.footer-plans .fp-plan { white-space: nowrap; }

.footer-plans .fp-plan strong {
  color: #fff;
  font-weight: 800;
}

.footer-plans .fp-dot { color: #8f8fbe; }

.footer-plans .fp-cta {
  margin-left: 4px;
  padding-left: 14px;
  border-left: 1px solid rgba(255, 255, 255, 0.28);
  text-decoration: underline;
  text-underline-offset: 3px;
}

@media (max-width: 900px) {
  .site-footer-inner { grid-template-columns: 1fr 1fr; gap: 24px; }
}

@media (max-width: 520px) {
  .site-footer-inner { grid-template-columns: 1fr; gap: 20px; padding-top: 26px; }
  .site-footer p { max-width: none; }
  .footer-plans { padding: 0 18px; }
  .footer-plans a { gap: 6px 9px; padding: 13px 12px; font-size: 13.5px; }
  .footer-plans .fp-cta {
    width: 100%;
    margin-left: 0;
    padding-left: 0;
    border-left: 0;
  }
}

/* ---------- Legal / content pages ---------- */
.legal {
  max-width: 860px;
  margin: 0 auto;
  font-size: 15.5px;
  line-height: 1.75;
  color: #2b2b3c;
}

.legal h2 {
  font-size: 20px;
  margin: 30px 0 10px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.legal h2:first-child { margin-top: 0; padding-top: 0; border-top: 0; }

.legal h3 { margin: 18px 0 6px; }

.legal p { margin: 0 0 12px; }

.legal ul,
.legal ol { margin: 0 0 14px; padding-left: 24px; }

.legal li { margin: 0 0 7px; }

.legal a { color: var(--link); text-decoration: underline; }

.legal .updated {
  font-size: 13.5px;
  color: var(--muted);
  margin-bottom: 24px;
}

.legal .callout {
  background: #f5f5ff;
  border: 1px solid #dedef0;
  border-left: 4px solid var(--nav);
  padding: 14px 16px;
  margin: 18px 0;
  border-radius: 3px;
}

.legal .callout p:last-child { margin-bottom: 0; }

.legal table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0 18px;
  font-size: 14.5px;
}

.legal th,
.legal td {
  border: 1px solid var(--line);
  padding: 8px 10px;
  text-align: left;
  vertical-align: top;
}

.legal th { background: #f4f4fb; color: #2f2b73; }

.contact-card {
  max-width: 560px;
  margin: 0 auto 8px;
  border: 1px solid var(--line);
  background: #fafaff;
  border-radius: 4px;
  padding: 20px 22px;
  text-align: center;
}

.contact-card .mail {
  display: inline-block;
  margin: 6px 0 4px;
  font-size: 19px;
  font-weight: 800;
  color: var(--link);
  text-decoration: underline;
  word-break: break-word;
}

/* ---------- Cookie consent banner ---------- */
.cookie-banner {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 120;
  background: #1f1c4d;
  color: #eeeeff;
  padding: 14px 18px;
  box-shadow: 0 -4px 18px rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 13.5px;
}

.cookie-banner p { margin: 0; max-width: 760px; line-height: 1.55; }

.cookie-banner a { color: #cfcdf5; text-decoration: underline; }

.cookie-actions { display: flex; gap: 8px; flex-shrink: 0; }

.cookie-banner button {
  font: inherit;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 3px;
  border: 1px solid transparent;
  cursor: pointer;
}

.cookie-banner .accept { background: #4a4fa3; color: #fff; }
.cookie-banner .accept:hover { background: #5a5fb8; }

.cookie-banner .reject {
  background: transparent;
  color: #fff;
  border-color: rgba(255, 255, 255, 0.45);
}

.cookie-banner .reject:hover { border-color: #fff; }

@media (max-width: 640px) {
  .cookie-banner { padding: 12px 14px; gap: 10px; font-size: 13px; }
  .cookie-actions { width: 100%; }
  .cookie-actions button { flex: 1; }
}
