/* Image tools (social image resizer, Instagram grid maker). Needs _social-kit.css. */
.ir, .gm { container-type: inline-size; }
.ir [hidden], .gm [hidden] { display: none !important; }

/* ---- Picker: drop zone + sample button ---- */
.img-pick { display: grid; gap: 10px; }
.img-drop { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 230px; padding: 34px 18px; border: 2px dashed var(--sk-edge); border-radius: var(--radius); text-align: center; cursor: pointer; transition: border-color .2s, background .2s, box-shadow .2s;
  background: radial-gradient(120% 90% at 50% 0%, var(--soft) 0%, var(--soft) 55%, var(--bg) 100%); }
.img-drop:hover, .img-drop.is-over, .img-drop:focus-within { border-color: var(--brand); background: var(--sk-tint); }
.img-drop:focus-within { box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 14%, transparent); }
.img-drop.is-over { transform: scale(1.005); box-shadow: 0 0 0 6px color-mix(in srgb, var(--brand) 12%, transparent); }
.img-drop strong { font-size: 19px; letter-spacing: -.01em; }
.img-drop-small { display: none; }
.img-drop-sub { color: var(--ink); font-size: 15px; }
.img-drop-btn { color: var(--brand); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.img-drop-fmt { color: var(--muted); font-size: 13px; max-width: 420px; }
.img-drop-ico { display: grid; place-items: center; width: 56px; height: 56px; margin-bottom: 6px; border-radius: 16px; background: var(--sk-grad); color: #fff; box-shadow: 0 12px 26px -12px color-mix(in srgb, var(--brand) 70%, transparent); transition: transform .25s var(--sk-ease); }
.img-drop:hover .img-drop-ico, .img-drop.is-over .img-drop-ico { transform: translateY(-3px); }
.img-drop-ico .i { width: 26px; height: 26px; transform: rotate(180deg); }
.img-sample { justify-self: center; display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg); font: inherit; font-size: 14px; font-weight: 600; color: var(--ink); cursor: pointer; box-shadow: 0 1px 2px rgba(0, 0, 0, .06); transition: border-color .2s, color .2s; }
.img-sample:hover { border-color: var(--brand); color: var(--brand); }
.img-sample:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 35%, transparent); outline-offset: 2px; }
.img-sample .i { width: 16px; height: 16px; color: var(--brand); }
@media (pointer: coarse) { .img-paste-hint { display: none; } }

/* Compact picker once an image is open */
.img-pick.is-small { grid-template-columns: minmax(0, 1fr) auto; align-items: stretch; }
.img-drop.is-small { flex-direction: row; min-height: 0; padding: 10px 14px; gap: 10px; justify-content: flex-start; text-align: left; }
.img-drop.is-small .img-drop-ico { width: 34px; height: 34px; margin: 0; border-radius: 10px; box-shadow: none; }
.img-drop.is-small .img-drop-ico .i { width: 18px; height: 18px; }
.img-drop.is-small strong { font-size: 15px; }
.img-drop.is-small .img-drop-big, .img-drop.is-small .img-drop-sub, .img-drop.is-small .img-drop-fmt { display: none; }
.img-drop.is-small .img-drop-small { display: inline; }
.img-pick.is-small .img-sample { align-self: center; }
@container (max-width: 480px) {
  .img-pick.is-small { grid-template-columns: 1fr; }
  .img-pick.is-small .img-sample { justify-self: stretch; justify-content: center; }
}
.img-drop.is-busy { opacity: .6; pointer-events: none; }
.img-file { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; clip: rect(0 0 0 0); }
.img-link { padding: 0; border: 0; background: none; font: inherit; color: var(--brand); text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.img-check { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 600; cursor: pointer; }
.img-check input { width: 18px; height: 18px; accent-color: var(--brand); }
.ir-tabs { margin-bottom: 0; }
.ir-bg { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.ir-bg input[type=color] { width: 44px; height: 36px; padding: 2px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); cursor: pointer; }
[data-tool-root] .ir input[type=range], [data-tool-root] .gm input[type=range] { width: 100%; accent-color: var(--brand); }

/* ---- Work area: controls left, preview right (stacked, preview first, in narrow columns) ---- */
.ir-work, .gm-work { display: grid; grid-template-columns: 1fr; gap: 22px; margin-top: 18px; align-items: start; }
.ir-stage, .gm-stage { order: -1; min-width: 0; display: flex; flex-direction: column; align-items: center; padding: 18px 12px; border-radius: var(--radius); background: linear-gradient(180deg, var(--soft) 0%, var(--soft) 100%); border: 1px solid var(--line); }
@container (min-width: 640px) {
  .ir-work, .gm-work { grid-template-columns: minmax(0, 270px) minmax(0, 1fr); gap: 24px; }
  .ir-stage, .gm-stage { order: 0; position: sticky; top: 90px; }
}
.ir-controls, .gm-controls { display: grid; gap: 16px; min-width: 0; }
.ir-custom { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ir-info { text-align: center; }
.img-view { margin: 0 0 14px; }
.img-view button { padding: 6px 12px; font-size: 13px; }

/* ---- Downloads ---- */
.img-dl { display: grid; gap: 8px; padding: 14px; border-radius: 16px; background: var(--soft); border: 1px solid var(--line); }
.img-dl-btns { display: grid; gap: 8px; }
.img-dl-btn { white-space: normal; display: flex; align-items: center; justify-content: flex-start; gap: 10px; width: 100%; padding: 11px 14px; text-align: left; }
.img-dl-btn .i { width: 18px; height: 18px; flex: none; }
.img-dl-btn > span { flex: 1; min-width: 0; font-weight: 700; }
.img-dl-btn small { font-weight: 500; opacity: .75; font-size: 12.5px; }
.img-dl-btn em { flex: none; white-space: nowrap; font-style: normal; font-size: 12.5px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: rgba(255, 255, 255, .22); font-variant-numeric: tabular-nums; }
.img-dl-btn.btn-ghost em { background: var(--sk-tint); color: var(--brand); }
.img-dl-btn em:empty { display: none; }
.img-dl-btn em.is-busy::after { content: "…"; }
.img-dl-btn.is-done { box-shadow: 0 0 0 3px rgba(22, 163, 74, .3); }
.img-share { width: 100%; justify-content: center; }
.img-limit { margin: 0; }
.img-again { margin: 0; text-align: center; }

/* ---- Preview frame with checkerboard (shows the real edge of the output) ---- */
.img-frame { position: relative; line-height: 0; max-width: 100%; border-radius: 6px; overflow: hidden; box-shadow: 0 0 0 1px var(--line), 0 18px 40px -24px color-mix(in srgb, var(--brand) 40%, transparent);
  background: repeating-conic-gradient(#efedf5 0 25%, #fff 0 50%) 0 0 / 20px 20px; }
.img-frame canvas { display: block; max-width: 100%; }
.img-frame.is-drag { cursor: grab; touch-action: none; }
.img-frame.is-drag:active { cursor: grabbing; }

/* ---- App mockups around the preview ---- */
.img-dev { max-width: 100%; }
.img-dev-top, .img-dev-bot, .img-dev-time { display: none; }
/* Phone (9:16) */
.img-dev[data-dev=phone] { position: relative; padding: 12px; border-radius: 38px; background: #111118; box-shadow: 0 0 0 2px #2b2b36 inset, 0 30px 60px -30px rgba(20, 12, 50, .6); }
.img-dev[data-dev=phone]::before { content: ""; position: absolute; z-index: 2; top: 20px; left: 50%; width: 30%; height: 18px; transform: translateX(-50%); border-radius: 99px; background: #111118; }
.img-dev[data-dev=phone] .img-frame { border-radius: 27px; box-shadow: none; }
/* Feed post */
.img-dev[data-dev=post] { overflow: hidden; border-radius: 14px; background: var(--bg); border: 1px solid var(--line); box-shadow: 0 24px 50px -32px rgba(20, 12, 50, .45); }
.img-dev[data-dev=post] .img-frame { border-radius: 0; box-shadow: none; }
.img-dev[data-dev=post] .img-dev-top { display: flex; align-items: center; gap: 10px; height: 50px; padding: 0 12px; }
.img-dev-av { flex: none; width: 30px; height: 30px; border-radius: 50%; background: var(--sk-grad); box-shadow: 0 0 0 2px #fff inset, 0 0 0 2px #fff; position: relative; }
.img-dev-top span { display: grid; gap: 5px; }
.img-dev-top b, .img-dev-bot b { display: block; height: 7px; border-radius: 99px; background: var(--soft); }
.img-dev-top b:first-child { width: 96px; background: var(--line); }
.img-dev-top b:last-child { width: 60px; }
.img-dev[data-dev=post] .img-dev-bot { display: grid; padding: 10px 12px 14px; gap: 7px; }
.img-dev-icons { display: flex; gap: 12px; margin-bottom: 3px; }
.img-dev-icons i { width: 20px; height: 20px; border-radius: 6px; border: 2px solid #2b2b36; }
.img-dev-icons i { border-radius: 50%; }
.img-dev-icons i:last-child { margin-left: auto; border-radius: 4px; }
.img-dev-icons { width: 100%; }
.img-dev.has-zones .img-dev-time { display: none !important; }
.img-dev-bot b:nth-of-type(1) { width: 70%; }
.img-dev-bot b:nth-of-type(2) { width: 45%; }
/* YouTube video card */
.img-dev[data-dev=video] .img-frame { border-radius: 12px; }
.img-dev[data-dev=video] .img-dev-time { display: block; position: absolute; right: 2.2%; bottom: 3.2%; padding: 3px 5px; border-radius: 4px; background: rgba(0, 0, 0, .8); color: #fff; font-size: 11px; font-weight: 600; line-height: 1.1; letter-spacing: .02em; }
.img-dev[data-dev=video] .img-dev-bot { display: grid; grid-template-columns: 34px 1fr; grid-template-rows: auto auto; column-gap: 10px; row-gap: 7px; padding: 12px 2px 0; }
.img-dev[data-dev=video] .img-dev-bot::before { content: ""; grid-row: 1 / 3; width: 34px; height: 34px; border-radius: 50%; background: var(--sk-grad); }
.img-dev[data-dev=video] .img-dev-icons { display: none; }
.img-dev[data-dev=video] .img-dev-bot b:nth-of-type(1) { width: 85%; height: 9px; background: var(--line); }
.img-dev[data-dev=video] .img-dev-bot b:nth-of-type(2) { width: 50%; }

/* ---- Safe zones ---- */
.img-zones { position: absolute; inset: 0; pointer-events: none; line-height: 1.3; }
.img-zone { position: absolute; display: flex; align-items: center; justify-content: center; padding: 4px; background: rgba(236, 72, 153, .28); outline: 1px dashed rgba(255, 255, 255, .9); outline-offset: -1px; }
.img-zone span { padding: 3px 7px; border-radius: 6px; background: rgba(11, 11, 15, .7); color: #fff; font-size: 11px; font-weight: 600; text-align: center; }
.img-zone.is-side { background: rgba(11, 11, 15, .45); outline: 0; }
.img-zone-note { position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); width: max-content; max-width: 86%; padding: 4px 8px; border-radius: 6px; background: rgba(11, 11, 15, .7); color: #fff; font-size: 11px; font-weight: 600; text-align: center; }
.img-zone-circle { position: absolute; inset: 0; border-radius: 50%; box-shadow: 0 0 0 999px rgba(11, 11, 15, .5); outline: 1px dashed rgba(255, 255, 255, .9); }
.img-dev[data-dev=phone] .img-zone:first-child { padding-top: 26px; }

/* ---- Grid maker: tiles + profile preview ---- */
.gm [data-gm-layout] { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.gm [data-gm-layout] button { padding: 8px 8px; font-size: 13px; line-height: 1.25; }
.gm-tiles-wrap { margin-top: 24px; padding-top: 22px; border-top: 1px solid var(--line); }
.gm-out { display: grid; gap: 24px; }
@container (min-width: 640px) { .gm-out.has-prof { grid-template-columns: minmax(0, 1fr) minmax(0, 260px); align-items: start; } }
.gm-h { font-size: 19px; margin: 0; }
.gm-tiles { display: grid; gap: 10px; margin-top: 14px; }
.gm-tile { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.gm-tile canvas { display: block; width: 100%; height: auto; border-radius: 6px; box-shadow: 0 0 0 1px var(--line); }
.gm-cap { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px; font-size: 13.5px; font-weight: 600; }
.gm-cap .sk-copy { padding: 5px 10px; font-size: 12px; }
.gm-prof { justify-self: center; width: 100%; max-width: 260px; padding: 10px; border-radius: 30px; background: #111118; box-shadow: 0 30px 60px -30px rgba(20, 12, 50, .6); }
.gm-prof-in { overflow: hidden; border-radius: 21px; background: var(--bg); }
.gm-prof-head { display: grid; grid-template-columns: 46px 1fr; gap: 6px 12px; align-items: center; padding: 18px 12px 12px; }
.gm-prof-head i { grid-row: 1 / 3; width: 46px; height: 46px; border-radius: 50%; background: var(--sk-grad); box-shadow: 0 0 0 2px #fff inset; }
.gm-prof-head b { display: block; height: 7px; border-radius: 99px; background: #e2dfea; }
.gm-prof-head b:nth-of-type(2) { width: 70%; background: #eeecf3; }
.gm-prof-tabs { display: flex; justify-content: space-around; padding: 6px 0; border-top: 1px solid var(--line); }
.gm-prof-tabs span { width: 14px; height: 14px; border-radius: 3px; border: 2px solid #c9c6d4; }
.gm-prof-tabs span:first-child { border-color: #111118; }
.gm-prof-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; }
.gm-prof-grid canvas, .gm-prof-grid span { display: block; width: 100%; aspect-ratio: 3 / 4; object-fit: cover; background: #ecebf1; }
.gm-prof-cap { margin: 10px 0 0; text-align: center; font-size: 12.5px; color: var(--muted); }

@media (max-width: 480px) {
  .gm-cap { flex-direction: column; align-items: stretch; text-align: center; }
  .gm-cap .sk-copy { align-self: stretch; justify-content: center; }
  .img-zone span, .img-zone-note { font-size: 10px; }
  .img-drop { min-height: 190px; padding: 26px 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .img-drop, .img-drop-ico { transition: none; }
  .img-drop.is-over, .img-drop:hover .img-drop-ico { transform: none; }
}
