/* imgly image tools: hub, tool shell, controls and the upload quick-edit dialog.
 * Uses the tokens from site.css. Loaded only on /tools pages, /upload and post pages. */

/* ---------- Hub ---------- */
.tools-hub { padding-top: 24px; padding-bottom: 20px; }
.hub-head { display: flex; gap: 20px; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; margin-bottom: 8px; }
.hub-head h1 { margin: 0 0 4px; font-size: 28px; letter-spacing: -.4px; }
.hub-head p { margin: 0; max-width: 640px; }
.hub-upload { display: inline-flex; gap: 8px; align-items: center; min-height: 40px; color: var(--text-2); }
.hub-upload svg { width: 18px; height: 18px; }
.hub-upload:hover { text-decoration: underline; }
.hub-group h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 26px 0 10px; }
.hub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.hub-grid.compact { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.hub-card {
  display: flex; gap: 12px; align-items: center; padding: 14px; border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--line); transition: background .15s, border-color .15s;
}
.hub-card:hover { background: var(--card-hover); border-color: var(--line-strong); }
.hub-card > span:last-child { display: flex; flex-direction: column; min-width: 0; }
.hub-grid.compact .hub-card { padding: 9px 12px; font-size: 14px; }
.hub-ico { width: 40px; height: 40px; border-radius: 10px; background: var(--elev); display: grid; place-items: center; flex: none; color: var(--text-2); }
.hub-grid.compact .hub-ico { width: 30px; height: 30px; border-radius: 8px; }
.hub-ico svg { width: 20px; height: 20px; }
.hub-grid.compact .hub-ico svg { width: 16px; height: 16px; }

/* ---------- Tool page ---------- */
.tool-page { padding-top: 14px; padding-bottom: 10px; }
.tool-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.tool-head h1 { margin: 0; font-size: 22px; letter-spacing: -.3px; }
.tool-head p { margin: 0; font-size: 14px; }
.crumbs { display: flex; gap: 8px; color: var(--muted); font-size: 14px; }
.crumbs a:hover { color: var(--text); }

.tool-drop {
  display: flex; align-items: center; gap: 16px; justify-content: center; text-align: left;
  min-height: 260px; padding: 28px; border: 2px dashed var(--line-strong); border-radius: var(--radius);
  background: var(--elev); cursor: pointer; transition: border-color .15s, background .15s;
}
.tool-drop > svg { width: 44px; height: 44px; color: var(--cta); flex: none; }
.tool-drop > div { display: flex; flex-direction: column; gap: 4px; max-width: 520px; }
.tool-drop u { color: var(--cta); text-decoration: none; }
.tool-drop:hover, .tool-drop.over { border-color: var(--cta); background: #20242c; }
.tool-drop.compact { min-height: 0; padding: 10px 14px; margin-bottom: 10px; justify-content: flex-start; }
.tool-drop.compact > svg { width: 22px; height: 22px; }
.tool-drop.compact .muted { display: none; }

.tool-work { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 14px; align-items: start; }
.tool-stage {
  position: relative; min-height: 300px; border-radius: var(--radius); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center; padding: 12px; overflow: hidden;
  background-color: #191b20;
  background-image: linear-gradient(45deg, #22252c 25%, transparent 25%), linear-gradient(-45deg, #22252c 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #22252c 75%), linear-gradient(-45deg, transparent 75%, #22252c 75%);
  background-size: 20px 20px; background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}
.tool-stage.plain { background-image: none; background-color: var(--bg-deep); display: block; }
.tv-canvas { max-width: 100%; max-height: calc(100vh - 200px); width: auto; height: auto; display: block; box-shadow: 0 4px 24px rgba(0, 0, 0, .35); }
.tool-panel {
  position: sticky; top: calc(var(--header-h) + 12px); background: var(--elev); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; max-height: calc(100vh - var(--header-h) - 24px); overflow: auto;
}
.tool-export { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.tool-export .btn svg { width: 16px; height: 16px; }
.tool-export .help { margin: 0; min-height: 1em; }
.tool-export .btn-ghost { align-self: flex-start; padding: 0 4px; }
.help.bad { color: var(--down); }

.tool-about { max-width: 860px; margin: 34px 0 10px; color: var(--text-2); font-size: 15px; }
.tool-about h2 { color: var(--text); font-size: 19px; margin: 26px 0 8px; }
.tool-about h2:first-child { margin-top: 0; }
.tool-about ul { padding-left: 20px; }
.tool-about li { margin: 3px 0; }
.tool-about b { color: var(--text); }
.privacy-note { padding: 12px 14px; border-left: 3px solid var(--cta); background: var(--elev); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.tool-more { margin: 30px 0 10px; }
.tool-more h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 0 0 10px; }

/* ---------- Controls ---------- */
.tc-sec { padding-bottom: 12px; margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.tc-sec:last-child { border-bottom: 0; margin-bottom: 0; padding-bottom: 0; }
.tc-sec h3 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.tc-field { margin: 0 0 10px; display: flex; flex-direction: column; gap: 4px; }
.tc-field > label, .tc-label { font-size: 13px; color: var(--text-2); font-weight: 600; margin: 0; }
.tc-range { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; }
.tc-range label { grid-column: 1; }
.tc-range output { grid-column: 2; grid-row: 1; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tc-range input { grid-column: 1 / -1; }
.tc-field input[type=range] { width: 100%; accent-color: var(--cta); padding: 0; height: 22px; background: none; border: 0; }
.tc-field select, .tc-field input[type=text], .tc-field input[type=number], .tc-field textarea { width: 100%; padding: 7px 9px; font-size: 14px; }
.tc-color { flex-direction: row; align-items: center; justify-content: space-between; }
.tc-color input[type=color] { width: 44px; height: 30px; padding: 2px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--field); cursor: pointer; }
.tc-check { display: flex; align-items: center; gap: 8px; font-size: 14px; margin: 0 0 10px; cursor: pointer; color: var(--text-2); }
.tc-check input { width: 16px; height: 16px; accent-color: var(--cta); margin: 0; }
.tc-seg { display: flex; flex-wrap: wrap; gap: 4px; }
.tc-seg button {
  flex: 1 1 auto; min-width: 36px; height: 32px; padding: 0 9px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
  background: var(--field); color: var(--text-2); cursor: pointer; font-size: 13px; display: inline-flex; align-items: center; justify-content: center; gap: 4px;
}
.tc-seg button:hover { color: var(--text); background: var(--card-hover); }
.tc-seg button[aria-pressed=true] { background: rgba(76, 141, 255, .18); border-color: var(--link); color: var(--text); }
.tc-seg button svg { width: 16px; height: 16px; }
.tc-btns { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.tc-btns .btn svg { width: 15px; height: 15px; }
.tc-grid9 { display: grid; grid-template-columns: repeat(3, 34px); gap: 4px; }
.tc-grid9 button { height: 34px; min-width: 0; }
.tc-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tc-row2 .tc-field { margin-bottom: 6px; }

/* Lists and outputs used by batch, palette, EXIF and Base64 tools */
.tl-list { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.tl-item { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 10px; align-items: center; background: var(--elev); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 6px; }
.tl-item img, .tl-item canvas { width: 56px; height: 56px; object-fit: cover; border-radius: 4px; background: var(--bg-deep); }
.tl-item .nm { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-item .meta { font-size: 12px; color: var(--muted); }
.tl-item .save { color: var(--cta); font-weight: 700; }
.tl-item .grow { color: var(--down); font-weight: 700; }
.tl-item button { width: 30px; height: 30px; padding: 0; justify-content: center; }
.split { position: relative; display: inline-block; max-width: 100%; user-select: none; touch-action: none; cursor: ew-resize; line-height: 0; }
.split img { display: block; max-width: 100%; max-height: calc(100vh - 300px); width: auto; height: auto; }
.split img.after { position: absolute; inset: 0; width: 100%; height: 100%; max-height: none; clip-path: inset(0 0 0 50%); }
.split .split-bar { position: absolute; top: 0; bottom: 0; left: 50%; width: 2px; margin-left: -1px; background: #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .4); }
.split .split-bar::after { content: '94'; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 30px; height: 30px; border-radius: 50%; background: #fff; color: #111; display: grid; place-items: center; font-size: 16px; line-height: 1; }
.split .lbl { position: absolute; top: 8px; padding: 2px 8px; border-radius: 4px; background: rgba(0, 0, 0, .65); font-size: 12px; font-weight: 700; line-height: 1.5; color: #fff; }
.stack { display: flex; flex-direction: column; gap: 12px; align-items: center; width: 100%; }
.loupe { position: absolute; width: 132px; height: 132px; border-radius: 50%; border: 3px solid #fff; box-shadow: var(--shadow); pointer-events: none; overflow: hidden; image-rendering: pixelated; }
.loupe canvas { width: 100%; height: 100%; image-rendering: pixelated; }
.loupe span { position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%); background: rgba(0, 0, 0, .75); padding: 1px 6px; border-radius: 4px; font: 11px var(--mono); }
.meta-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.meta-table th, .meta-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.meta-table th { color: var(--muted); font-weight: 600; width: 38%; }
.meta-table td { overflow-wrap: anywhere; }
.meta-warn { padding: 10px 12px; border-radius: var(--radius-sm); background: rgba(255, 90, 95, .12); border: 1px solid rgba(255, 90, 95, .4); color: var(--text); margin: 0 0 12px; }
.meta-ok { padding: 10px 12px; border-radius: var(--radius-sm); background: rgba(27, 183, 110, .12); border: 1px solid rgba(27, 183, 110, .4); margin: 0 0 12px; }
.code-out { width: 100%; font: 12px/1.45 var(--mono); min-height: 74px; resize: vertical; padding: 8px; }
.out-card { width: 100%; }
.out-card + .out-card { margin-top: 12px; }
.out-card .hd { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; font-size: 13px; font-weight: 700; color: var(--text-2); }
.progress { height: 6px; border-radius: 3px; background: var(--card); overflow: hidden; margin: 6px 0; }
.progress i { display: block; height: 100%; width: 0; background: var(--link); transition: width .2s; }

/* ---------- Upload quick edit ---------- */
.qe-dialog {
  width: min(1100px, calc(100vw - 24px)); max-height: calc(100vh - 24px); padding: 0; border: 1px solid var(--line-strong);
  border-radius: var(--radius); background: var(--elev); color: var(--text); box-shadow: var(--shadow);
}
.qe-dialog::backdrop { background: rgba(0, 0, 0, .7); }
.qe-dialog[open] { display: flex; flex-direction: column; }
.qe-head { display: flex; align-items: baseline; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.qe-head h2 { margin: 0; font-size: 17px; }
.qe-head span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qe-body { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 12px; padding: 12px; overflow: auto; min-height: 0; }
.qe-body .tool-stage { min-height: 240px; }
.qe-body .tv-canvas { max-height: calc(100vh - 220px); }
.qe-foot { display: flex; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
.qe-foot .spacer { flex: 1; }

@media (max-width: 1023px) {
  .tool-work { grid-template-columns: 1fr; }
  .tool-panel { position: static; max-height: none; }
  .qe-body { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .tool-drop { flex-direction: column; text-align: center; min-height: 200px; }
  .tool-drop > div { align-items: center; }
  .tool-stage { min-height: 200px; padding: 6px; }
  .tv-canvas { max-height: 62vh; }
  .hub-head h1 { font-size: 24px; }
  .hub-grid { grid-template-columns: 1fr; }
  .hub-grid.compact { grid-template-columns: 1fr 1fr; }
  .qe-dialog { width: 100vw; max-width: 100vw; max-height: 100dvh; height: 100dvh; border-radius: 0; margin: 0; }
}

.tools-hero {
  background: var(--elev);
  padding-block: 24px 16px;
  border-block-end: 1px solid var(--line);
}

.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.tool-card {
  display: grid;
  gap: 12px;
  padding: 18px;
  border-radius: var(--radius-md);
  background: var(--elev);
  border: 1px solid var(--line);
  transition: transform 0.16s ease, border-color 0.16s ease, background-color 0.16s ease, box-shadow 0.16s ease;
}

.tool-card:hover {
  transform: translateY(-2px);
  background: var(--elev-2);
  border-color: rgba(27, 183, 110, 0.45);
  box-shadow: var(--shadow-md);
}

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

.tool-icon-box {
  inline-size: 42px;
  block-size: 42px;
  border-radius: 10px;
  background: var(--tool-tint, rgba(27, 183, 110, 0.16));
  color: var(--tool-color, #5eeaa6);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.tool-card p {
  font-size: 0.84rem;
  color: var(--text-2);
  line-height: 1.45;
}

.studio-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.tools-hero .hub-head { align-items:center; }
.studio-feature { display:flex; align-items:center; flex-wrap:wrap; gap:0 16px; border-top:1px solid var(--line); padding-top:8px; margin-top:12px; }
.studio-feature span { color:var(--text-2); font-size:13px; }
.studio-feature a { display:inline-flex; align-items:center; min-height:36px; font-size:14px; text-decoration:underline; text-underline-offset:3px; }
.tool-card p { margin:0; color:var(--text-2); }
.eyebrow,.tool-category { font-size:12px; }
.tool-category { padding:2px 8px; background:#ffffff08; color:var(--text-2); border-radius:20px; }
.tool-icon-box svg { height:22px; width:22px; }
.tool-card h2 { font-size:16px; margin:0; }
.tool-card[data-category="optimize"] { --tool-color:#91bcff; --tool-tint:#5b9dff23; }
.tool-card[data-category="compose"] { --tool-color:#bca4ff; --tool-tint:#8b5cf625; }
.tool-filters { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:12px; margin-bottom:18px; }
.tool-filters input { width:min(100%,300px); }
.sort-options button { border:0; border-radius:6px; background:transparent; padding:8px 12px; color:var(--muted); cursor:pointer; }
.sort-options button[aria-pressed=true],.studio-tabs .on,.studio-sources [aria-pressed=true] { background:var(--card-hover); color:white; }
.studio-topbar { margin:8px 0 16px; }
.studio-topbar .tool-head { display:grid; gap:3px; margin:0; }
.studio-sources { padding-bottom:14px; margin-bottom:12px; border-bottom:1px solid var(--line); }
.studio-sources .row { margin-top:8px; gap:6px; }
.tool-work { gap:18px; }
.tool-work:has(.studio-sources) .tool-stage { background:radial-gradient(#ffffff15 1px,transparent 1px),var(--bg-deep); background-size:18px 18px; min-height:min(540px,55vh); border-radius:14px; }
.tool-work:has(.studio-sources) .tv-canvas { max-height:min(560px,65vh); border-radius:8px; }
@media(min-width:1024px){.tool-work { grid-template-columns:minmax(0,1fr) 340px; }}
@media (max-width: 640px) {
  .tools-hero { padding-block: 16px 8px; }
  .hub-head { gap: 0 12px; }
  .studio-feature { margin-top: 4px; gap: 0 12px; }
  .studio-feature span { width: 100%; }
  .tools-hub { padding-top: 16px; }
  .tools-grid { grid-template-columns: minmax(0,1fr); }
  .tool-panel { padding: 14px; }
  .tool-filters { flex-direction: column; align-items: stretch; gap: 8px; }
  .tool-filters input { width: 100%; }
  .sort-options button { min-height: 36px; padding: 4px 8px; font-size: 13px; }
  .tool-work:has(.studio-sources) .tool-stage { min-height: 250px; }
}
