/* Image Compress tool — /tools/compress/ */

.ic-workspace.has-images ~ .ic-status,
.ic-app:has(.ic-workspace.has-images) .ic-hero-actions { display: none; }
.ic-app:has(.ic-workspace.has-images) .ic-hero {
  padding-bottom: 4px;
}
.ic-app:has(.ic-workspace.has-images) .ic-hero .section-head p {
  display: none;
}
.ic-app:has(.ic-workspace.has-images) .ic-hero h1 {
  font-size: clamp(22px, 4vw, 32px);
  margin-bottom: 0;
}
.ic-hero .section-head { margin-bottom: 0; }
.ic-hero-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 20px;
}
.ic-app { padding-top: 0; }

.ic-workspace {
  padding: clamp(16px, 3vw, 24px);
  border-radius: var(--radius-xl);
  min-height: 320px;
}
.ic-workspace.has-images .ic-empty { display: none; }
.ic-workspace:not(.has-images) #icLayoutInner { display: none; }
.ic-workspace.has-images #icLayoutInner { display: grid; }

.ic-empty { padding: 8px 0; }
.ic-drop {
  border: 2px dashed var(--glass-border, rgba(255,255,255,.45));
  border-radius: var(--radius-lg);
  padding: clamp(32px, 6vw, 48px) 24px;
  text-align: center;
  cursor: pointer;
  color: var(--text-soft);
  transition: border-color .2s, background .2s;
}
.ic-drop:hover, .ic-drop.is-drag, .ic-drop:focus-visible {
  border-color: var(--accent);
  background: var(--accent-grad-soft);
  outline: none;
}
.ic-drop svg { opacity: .55; margin-bottom: 12px; }
.ic-drop p { margin: 0 0 6px; color: var(--text); }
.ic-muted { font-size: 13px; color: var(--text-soft); margin: 0; }

.ic-layout {
  grid-template-columns: 88px 1fr minmax(240px, 300px);
  gap: 16px;
  align-items: start;
}

.ic-rail-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-soft);
  margin-bottom: 8px;
}
.ic-link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
  padding: 0;
}
.ic-thumbs {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 420px;
  overflow-y: auto;
}
.ic-thumb {
  position: relative;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 10px;
  background: var(--glass-fill-soft);
  cursor: pointer;
  overflow: hidden;
}
.ic-thumb.is-active { border-color: var(--accent); }
.ic-thumb img {
  display: block;
  width: 72px;
  height: 72px;
  object-fit: cover;
}
.ic-thumb-x {
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 16px;
  line-height: 1;
  color: var(--text);
  opacity: .7;
  padding: 2px 4px;
}
.ic-thumb-x:hover { opacity: 1; color: #e03; }

.ic-preview-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}
.ic-preview-box {
  margin: 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--glass-fill-soft);
  border: 1px solid var(--glass-border);
}
.ic-preview-box figcaption {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 8px 10px 0;
  color: var(--text-soft);
}
.ic-output-box img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 160px;
  object-fit: contain;
  padding: 8px;
  box-sizing: border-box;
}

.ic-crop-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 12px 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  border-top: 1px solid var(--glass-border);
  background: var(--glass-fill-soft);
}
.ic-crop-toolbar .btn { margin: 0; }
.ic-crop-stage {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.ic-crop-wrap {
  position: relative;
  width: calc(100% - 16px);
  height: min(48vh, 380px);
  min-height: 200px;
  margin: 8px;
  box-sizing: border-box;
  user-select: none;
  touch-action: none;
  overflow: hidden;
  cursor: grab;
  background:
    linear-gradient(45deg, rgba(127,127,127,.12) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(127,127,127,.12) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(127,127,127,.12) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(127,127,127,.12) 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  border-radius: 8px;
}
.ic-crop-wrap img {
  position: absolute;
  display: block;
  max-width: none;
  max-height: none;
  padding: 0;
  pointer-events: none;
  z-index: 0;
}
.ic-crop-box {
  position: absolute;
  box-sizing: border-box;
  border: 2px solid #fff;
  box-shadow: 0 0 0 9999px rgba(8, 12, 28, .52);
  cursor: move;
  touch-action: none;
  z-index: 1;
}
.ic-crop-box::after {
  content: "";
  position: absolute;
  inset: 0;
  border: 1px dashed rgba(10, 132, 255, .55);
  pointer-events: none;
}
.ic-crop-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  background: #fff;
  border: 2px solid #0a84ff;
  border-radius: 2px;
  box-sizing: border-box;
  z-index: 2;
}
.ic-crop-handle[data-h="nw"] { left: -6px; top: -6px; cursor: nwse-resize; }
.ic-crop-handle[data-h="ne"] { right: -6px; top: -6px; cursor: nesw-resize; }
.ic-crop-handle[data-h="sw"] { left: -6px; bottom: -6px; cursor: nesw-resize; }
.ic-crop-handle[data-h="se"] { right: -6px; bottom: -6px; cursor: nwse-resize; }
.ic-crop-handle[data-h="n"] { left: 50%; top: -6px; margin-left: -6px; cursor: ns-resize; }
.ic-crop-handle[data-h="s"] { left: 50%; bottom: -6px; margin-left: -6px; cursor: ns-resize; }
.ic-crop-handle[data-h="e"] { right: -6px; top: 50%; margin-top: -6px; cursor: ew-resize; }
.ic-crop-handle[data-h="w"] { left: -6px; top: 50%; margin-top: -6px; cursor: ew-resize; }
.ic-crop-stage.is-locked .ic-crop-edge { display: none; }

.ic-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 14px 0 0;
  padding: 0;
}
.ic-stats div {
  margin: 0;
  padding: 10px;
  border-radius: 10px;
  background: var(--glass-fill-soft);
  border: 1px solid var(--glass-border);
}
.ic-stats dt {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-soft);
  margin: 0 0 4px;
}
.ic-stats dd {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
}

.ic-controls { display: flex; flex-direction: column; gap: 14px; }
.ic-field {
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin: 0;
}
.ic-field legend {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 0 4px;
}
.ic-field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin: 10px 0 4px;
  color: var(--text-soft);
}
.ic-field input[type="text"],
.ic-field input[type="number"],
.ic-field select {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--glass-border);
  background: var(--glass-fill-soft);
  color: var(--text);
  font: inherit;
  box-sizing: border-box;
}
.ic-field input[type="range"] { width: 100%; margin-top: 4px; }
.ic-mode-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  margin-top: 8px;
}
.ic-mode-row label { display: flex; align-items: center; gap: 8px; margin: 0; font-weight: 500; color: var(--text); }
.is-disabled { opacity: .45; pointer-events: none; }
.ic-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 8px;
}
.ic-row-3 label { margin-top: 0; font-size: 12px; }
.ic-full { width: 100%; justify-content: center; margin-top: 8px; }
.ic-actions { display: flex; flex-direction: column; gap: 4px; }
.ic-check {
  font-size: 13px;
  color: var(--text-soft);
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0;
}
.ic-muted-btn { opacity: .85; }

.ic-status {
  margin: 14px 0 0;
  font-size: 14px;
  color: var(--text-soft);
  min-height: 1.4em;
}
.ic-status[data-kind="err"] { color: #c0392b; }
html.dark .ic-status[data-kind="err"] { color: #ff6b6b; }
.ic-status[data-kind="ok"] { color: #1a7f37; }

.ic-transform-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}
.ic-transform-row .btn {
  width: 100%;
  justify-content: center;
  margin-top: 0;
  font-size: 13px;
  padding: 8px 10px;
}
.ic-transform-row .btn.is-active {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.ic-help-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 80;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  background: rgba(20, 24, 40, .48);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.ic-help-overlay.active { display: flex; }
.ic-help-modal {
  width: min(520px, 100%);
  max-height: min(78vh, 640px);
  display: flex;
  flex-direction: column;
  border-radius: 20px;
  padding: 0;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(20, 24, 40, .28);
}
.ic-help-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0;
  padding: 16px 18px;
  border-bottom: 1px solid var(--divider, rgba(60, 60, 67, .12));
  flex-shrink: 0;
}
.ic-help-head h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -.01em;
}
.ic-help-head .btn {
  flex-shrink: 0;
  min-height: 36px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
}
.ic-help-body {
  padding: 8px 18px 20px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: rgba(120, 120, 128, .45) transparent;
}
.ic-help-body::-webkit-scrollbar { width: 8px; }
.ic-help-body::-webkit-scrollbar-thumb {
  background: rgba(120, 120, 128, .35);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
.ic-help-body section {
  margin: 0;
  padding: 14px 0;
  border-bottom: 1px solid var(--divider, rgba(60, 60, 67, .1));
}
.ic-help-body section:last-child { border-bottom: none; padding-bottom: 6px; }
.ic-help-body h3 {
  margin: 0 0 6px;
  font-size: .9rem;
  font-weight: 750;
  letter-spacing: -.01em;
}
.ic-help-body p {
  margin: 0;
  color: var(--text-soft);
  font-size: .9rem;
  line-height: 1.55;
}

.ic-note {
  margin-top: 24px;
  padding: clamp(20px, 4vw, 28px);
  border-radius: var(--radius-xl);
}

body.ic-cropping { cursor: grabbing; user-select: none; }
body.ic-cropping * { cursor: grabbing !important; }
.ic-crop-wrap.is-zoomed { cursor: grab; }
.ic-crop-wrap.is-panning { cursor: grabbing; }

@media (max-width: 960px) {
  .ic-layout {
    grid-template-columns: 1fr;
  }
  .ic-thumbs {
    flex-direction: row;
    max-height: none;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 4px;
  }
  .ic-stats { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 520px) {
  .ic-crop-wrap { height: min(46vh, 320px); min-height: 200px; }
}

@media (prefers-reduced-motion: reduce) {
  .ic-drop { transition: none; }
}
