/* ===================================================================
   ImageToolsFree — Tool page styles
   Reuses the existing class names so all tool JS keeps working.
   =================================================================== */

.tool-layout {
  max-width: var(--wrap); margin: 0 auto; padding: clamp(1.6rem,4vw,2.6rem) clamp(1.1rem,4vw,2rem) 0;
  display: grid; grid-template-columns: minmax(0,1fr) 312px; gap: 2rem; align-items: start;
}
@media (max-width: 900px){ .tool-layout { grid-template-columns: 1fr; } .sidebar { display: none; } }

/* ---- tool header ---- */
.tool-header { margin-bottom: 1.4rem; }
.tool-header .eyebrow { margin-bottom: .85rem; }
.tool-header h1 {
  font-family: 'Newsreader', Georgia, serif; font-weight: 500;
  font-size: clamp(2.1rem, 4.5vw, 3rem); letter-spacing: -.02em; line-height: 1.05;
}
.tool-header h1 span, .tool-header h1 em { font-style: italic; color: var(--green); }
.tool-header p { margin-top: .7rem; color: var(--muted); font-size: 1.05rem; max-width: 60ch; }

/* ---- card ---- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl);
  padding: clamp(1.2rem, 3vw, 1.9rem); box-shadow: var(--sh);
}

/* ---- mode toggle (segmented) ---- */
.mode-toggle, .mode-tabs {
  display: inline-flex; gap: .25rem; margin-bottom: 1.4rem; background: var(--sand);
  padding: .3rem; border-radius: var(--pill); border: 1px solid var(--line);
}
.mode-btn, .mode-tab {
  padding: .5rem 1.15rem; border-radius: var(--pill); border: none; background: transparent;
  font-family: inherit; font-size: .88rem; font-weight: 600; cursor: pointer; color: var(--muted);
  transition: all .15s;
}
.mode-btn.active, .mode-tab.active { background: var(--surface); color: var(--green-700); box-shadow: var(--sh-sm); }

/* ---- drop zone ---- */
#drop-zone {
  border: 2px dashed var(--line-strong); border-radius: var(--r-lg); padding: clamp(2.2rem,5vw,3.4rem) 1.5rem;
  text-align: center; cursor: pointer; background: linear-gradient(180deg, var(--surface-2), var(--bg));
  transition: border-color .2s, background .2s, transform .2s;
}
#drop-zone:hover { border-color: var(--green-200); }
#drop-zone.dragover { border-color: var(--green); background: var(--green-50); transform: scale(1.005); }
#drop-zone .icon {
  width: 64px; height: 64px; margin: 0 auto 1.1rem; border-radius: 18px; display: grid; place-items: center;
  background: var(--green-50); border: 1px solid var(--green-100); color: var(--green); font-size: 0;
}
#drop-zone .icon svg { width: 30px; height: 30px; }
#drop-zone h2 { font-size: 1.2rem; font-weight: 700; margin-bottom: .4rem; color: var(--ink); }
#drop-zone p { color: var(--muted); font-size: .92rem; margin-bottom: 1.3rem; max-width: 42ch; margin-inline: auto; }
#file-input, #file-input-bulk { display: none; }

/* ---- settings ---- */
.settings-section { margin-top: 1.5rem; }
.settings-section > label {
  display: block; font-size: .8rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--muted); margin-bottom: .65rem;
}
.quality-row, .percent-row { display: flex; align-items: center; gap: 1rem; }
input[type=range] {
  flex: 1; accent-color: var(--green); height: 6px;
}
.quality-badge, .percent-badge {
  background: var(--green-50); color: var(--green-700); font-weight: 700; font-size: .9rem;
  padding: .35rem .8rem; border-radius: var(--pill); min-width: 56px; text-align: center; border: 1px solid var(--green-100);
}

.format-row, .preset-row { display: flex; gap: .5rem; flex-wrap: wrap; }
.format-btn, .preset-btn {
  padding: .5rem 1.05rem; border-radius: var(--pill); border: 1.5px solid var(--line-strong);
  background: var(--surface); font-family: inherit; font-size: .82rem; font-weight: 600; cursor: pointer;
  color: var(--muted); transition: all .15s;
}
.format-btn:hover, .preset-btn:hover { border-color: var(--green-200); color: var(--green-700); }
.format-btn.active { border-color: var(--green); background: var(--green-50); color: var(--green-700); }

/* ---- dimension inputs ---- */
.dimensions-grid { display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; gap: .75rem; margin-bottom: 1rem; }
.dim-input-wrap { display: flex; flex-direction: column; gap: .45rem; }
.dim-input-wrap span { font-size: .72rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.dim-input-wrap input, input[type=number], input[type=text]:not(.bare) {
  width: 100%; padding: .7rem .9rem; border: 1.5px solid var(--line-strong); border-radius: var(--r-sm);
  font-family: inherit; font-size: 1rem; font-weight: 500; color: var(--ink); background: var(--surface-2);
  transition: border-color .15s, box-shadow .15s;
}
.dim-input-wrap input:focus, input[type=number]:focus { outline: none; border-color: var(--green); box-shadow: var(--ring); }
.lock-btn {
  width: 42px; height: 42px; border-radius: 12px; border: 1.5px solid var(--line-strong);
  background: var(--surface); cursor: pointer; display: grid; place-items: center; font-size: 1rem; transition: all .15s;
}
.lock-btn.locked { border-color: var(--green); background: var(--green-50); color: var(--green-700); }

/* ---- preview ---- */
#preview-section { display: none; margin-top: 1.6rem; }
.preview-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 540px){ .preview-grid { grid-template-columns: 1fr; } }
.preview-box { text-align: center; }
.preview-box > p {
  font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: .6rem;
}
.preview-box img, .preview-box canvas {
  width: 100%; border-radius: var(--r); border: 1px solid var(--line); display: block; object-fit: contain;
  max-height: 240px; background:
    linear-gradient(45deg, #ece7db 25%, transparent 25%, transparent 75%, #ece7db 75%) 0 0/20px 20px,
    linear-gradient(45deg, #ece7db 25%, #f4f0e8 25%, #f4f0e8 75%, #ece7db 75%) 10px 10px/20px 20px;
}
.size-tag { margin-top: .45rem; font-size: .82rem; color: var(--muted); }
.size-tag strong { color: var(--ink); }
.savings-bar, .info-bar, .bulk-summary {
  margin-top: 1.1rem; background: linear-gradient(100deg, var(--green-50), var(--green-100));
  border: 1px solid var(--green-100); border-radius: var(--r); padding: .9rem 1.15rem;
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
}
.savings-bar span, .info-bar span, .bulk-summary span { font-size: .9rem; color: var(--green-700); font-weight: 600; }
.savings-bar strong, .info-bar strong, .bulk-summary strong { font-size: 1.15rem; color: var(--green); font-family: 'Newsreader', serif; font-weight: 600; }
.action-row { display: flex; gap: .7rem; margin-top: 1.3rem; flex-wrap: wrap; }

/* ---- bulk list ---- */
#bulk-section { display: none; margin-top: 1.6rem; }
.bulk-list { display: flex; flex-direction: column; gap: .5rem; margin-bottom: 1.2rem; max-height: 400px; overflow-y: auto; }
.bulk-item {
  display: grid; grid-template-columns: 1fr auto auto auto; align-items: center; gap: .8rem;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: .65rem 1rem; font-size: .86rem;
}
.bulk-item-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; color: var(--ink); }
.bulk-item-original { color: var(--muted); font-size: .8rem; white-space: nowrap; }
.bulk-item-compressed, .bulk-item-result { font-weight: 700; color: var(--green-700); font-size: .8rem; white-space: nowrap; }
.bulk-item-status { font-size: .78rem; white-space: nowrap; }
.bulk-item.done .bulk-item-status { color: var(--green); }
.bulk-item.error .bulk-item-status { color: #c0392b; }

/* ---- step cards inside content ---- */
.howto-steps { display: flex; flex-direction: column; gap: .8rem; margin: 1.4rem 0 2rem; }
.howto-step {
  display: flex; gap: 1rem; align-items: flex-start; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r); padding: 1.15rem 1.25rem;
}
.howto-step .n {
  flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: var(--green-50); border: 1px solid var(--green-100); color: var(--green);
  font-family: 'Newsreader', serif; font-weight: 600; font-size: 1.05rem;
}
.howto-step strong { display: block; margin-bottom: .25rem; color: var(--ink); font-size: 1rem; }
.howto-step span { font-size: .92rem; color: var(--muted); line-height: 1.7; }

.content-section { max-width: var(--wrap); margin: 0 auto; padding: clamp(2rem,4vw,3rem) clamp(1.1rem,4vw,2rem); }
.content-section .prose { max-width: 100%; }

/* ---- sidebar ---- */
.sidebar { display: flex; flex-direction: column; gap: 1.1rem; position: sticky; top: 86px; }
.sidebar-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 1.3rem; box-shadow: var(--sh-sm); }
.sidebar-card h3 { font-size: .95rem; font-weight: 700; margin-bottom: .9rem; color: var(--ink); }
.tool-links { list-style: none; display: flex; flex-direction: column; gap: .2rem; }
.tool-links li a {
  text-decoration: none; color: var(--body); font-size: .9rem; display: flex; align-items: center; gap: .7rem;
  padding: .55rem .6rem; border-radius: var(--r-sm); transition: background .15s, color .15s;
}
.tool-links li a svg { width: 18px; height: 18px; color: var(--green); flex: none; }
.tool-links li a:hover { background: var(--green-50); color: var(--green-700); }
.tool-links li a.current { background: var(--green-50); color: var(--green-700); font-weight: 600; }
.feature-list { list-style: none; display: flex; flex-direction: column; }
.feature-list li {
  font-size: .88rem; color: var(--body); padding: .5rem 0; display: flex; gap: .6rem; align-items: flex-start;
  border-bottom: 1px solid var(--line-soft);
}
.feature-list li:last-child { border-bottom: none; }
.feature-list li::before {
  content: ''; flex: none; width: 18px; height: 18px; margin-top: 1px; border-radius: 50%;
  background: var(--green-50) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2316704b' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E") center/12px no-repeat;
  border: 1px solid var(--green-100);
}

/* warnings */
.warn-box {
  margin-top: .85rem; background: var(--clay-50); border: 1px solid #e8cdb8; border-radius: var(--r-sm);
  padding: .75rem 1rem; font-size: .85rem; color: #8a4e26; line-height: 1.6;
}

/* ---- convert: format cards ---- */
.format-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .7rem; margin-bottom: 1.2rem; }
@media (max-width: 480px){ .format-grid { grid-template-columns: repeat(2,1fr); } }
.format-card {
  border: 1.5px solid var(--line-strong); border-radius: var(--r); padding: 1rem .5rem; text-align: center;
  cursor: pointer; transition: all .15s; background: var(--surface-2);
}
.format-card:hover { border-color: var(--green-200); }
.format-card.active { border-color: var(--green); background: var(--green-50); box-shadow: var(--sh-sm); }
.format-card .fmt-name {
  font-family: 'Newsreader', serif; font-weight: 600; font-size: 1.25rem; color: var(--ink);
  display: block; margin-bottom: .2rem;
}
.format-card.active .fmt-name { color: var(--green-700); }
.format-card .fmt-desc { font-size: .72rem; color: var(--muted); line-height: 1.4; }
.conversion-display {
  display: flex; align-items: center; justify-content: center; gap: 1rem;
  background: var(--sand); border: 1px solid var(--line); border-radius: var(--r);
  padding: .8rem 1.25rem; margin-bottom: 1.2rem;
}
.conversion-display .from-fmt { font-family: 'Newsreader', serif; font-weight: 600; font-size: 1.2rem; color: var(--muted); }
.conversion-display .arrow { font-size: 1.2rem; color: var(--green); }
.conversion-display .to-fmt { font-family: 'Newsreader', serif; font-weight: 600; font-size: 1.2rem; color: var(--green-700); }

/* ---- remove-bg ---- */
#processing-state {
  display: none; text-align: center; padding: 2.2rem; margin-top: 1.6rem;
  background: var(--green-50); border: 1px solid var(--green-100); border-radius: var(--r-lg);
}
.spinner {
  width: 42px; height: 42px; border: 3px solid var(--green-100); border-top-color: var(--green);
  border-radius: 50%; animation: spin .8s linear infinite; margin: 0 auto 1rem;
}
@keyframes spin { to { transform: rotate(360deg); } }
#processing-state p { color: var(--green-700); font-weight: 600; }
#error-state {
  display: none; background: #fdf0ef; border: 1px solid #f0b8b4; border-radius: var(--r);
  padding: 1rem 1.25rem; margin-top: 1.6rem;
}
#error-state p { color: #8b2c26; font-size: .9rem; }
.preview-box img.transparent-bg, .transparent-bg {
  background:
    linear-gradient(45deg, #d9d3c6 25%, transparent 25%, transparent 75%, #d9d3c6 75%) 0 0/18px 18px,
    linear-gradient(45deg, #d9d3c6 25%, #eee8db 25%, #eee8db 75%, #d9d3c6 75%) 9px 9px/18px 18px !important;
}
.bg-options { margin-top: 1.4rem; }
.bg-options > label { display: block; font-size: .8rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin-bottom: .7rem; }
.bg-swatches { display: flex; gap: .55rem; flex-wrap: wrap; align-items: center; }
.bg-swatches .swatch {
  width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--line-strong); cursor: pointer;
  transition: transform .15s, border-color .15s, box-shadow .15s; flex-shrink: 0;
}
.bg-swatches .swatch:hover, .bg-swatches .swatch.active { transform: scale(1.12); border-color: var(--green); box-shadow: var(--sh-sm); }
.bg-swatches .swatch.transparent-swatch {
  background:
    linear-gradient(45deg, #ccc 25%, transparent 25%, transparent 75%, #ccc 75%) 0 0/10px 10px,
    linear-gradient(45deg, #ccc 25%, #fff 25%, #fff 75%, #ccc 75%) 5px 5px/10px 10px;
}
.custom-color-wrap { display: flex; align-items: center; gap: .45rem; }
.custom-color-wrap input[type="color"] {
  width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--line-strong); cursor: pointer; padding: 0; background: none;
}
.custom-color-wrap span { font-size: .8rem; color: var(--muted); }
.preview-box img { max-height: 260px; }

/* ---- palette ---- */
.count-row { display: flex; align-items: center; gap: .6rem; margin-top: 1.4rem; flex-wrap: wrap; }
.count-row label { font-size: .8rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.count-btn {
  padding: .42rem .95rem; border-radius: var(--pill); border: 1.5px solid var(--line-strong); background: var(--surface);
  font-family: inherit; font-size: .85rem; font-weight: 600; cursor: pointer; color: var(--muted); transition: all .15s;
}
.count-btn:hover { border-color: var(--green-200); color: var(--green-700); }
.count-btn.active { border-color: var(--green); background: var(--green-50); color: var(--green-700); }
#results { display: none; margin-top: 1.6rem; }
.result-image { width: 100%; border-radius: var(--r); border: 1px solid var(--line); display: block; object-fit: contain; max-height: 300px; background: var(--sand); margin-bottom: 1.5rem; }
.palette-strip { display: flex; border-radius: var(--r); overflow: hidden; height: 74px; margin-bottom: 1.5rem; border: 1px solid var(--line); box-shadow: var(--sh-sm); }
.palette-strip-block { flex: 1; transition: flex .3s; }
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px,1fr)); gap: .8rem; margin-bottom: 1.5rem; }
.swatches .swatch {
  width: auto; height: auto; border-radius: var(--r); overflow: hidden; border: 1px solid var(--line); cursor: pointer;
  transition: transform .15s, box-shadow .15s; box-shadow: var(--sh-sm);
}
.swatches .swatch:hover { transform: translateY(-3px); box-shadow: var(--sh-md); border-color: var(--green-200); }
.swatch-color { height: 88px; }
.swatch-info { padding: .65rem .8rem; background: var(--surface); }
.swatch-hex { font-family: 'Newsreader', serif; font-weight: 600; font-size: 1.05rem; color: var(--ink); display: block; letter-spacing: .01em; }
.swatch-rgb { font-size: .74rem; color: var(--muted); margin-top: .15rem; }
.swatch-copy { font-size: .7rem; color: var(--green); font-weight: 600; margin-top: .25rem; display: block; }
