/* ============================================================
   Icon Maker - item styles
   Phone first: one column, in this order:
     drop, icons, settings, snippets.
   From 900px: drop, icons and snippets on the left; settings
   in a sticky column on the right.
   ============================================================ */

.im {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  padding-block: 1.1rem 0;
}
/* On phones the columns melt away, so `order` can mix them. */
.im-col { display: contents; }
.im-drop     { order: 1; }
.im-icons    { order: 2; }
.im-settings { order: 3; }
.im-snips    { order: 4; }

@media (min-width: 900px) {
  .im {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    align-items: start;
    gap: 1.4rem;
    padding-top: 1.6rem;
  }
  .im-col { display: flex; flex-direction: column; gap: 1.4rem; min-width: 0; }
  .im-col-side { position: sticky; top: calc(var(--bar-h) + 1rem); }
}

.im section { padding-block: 0; }
.im h2 { font-size: 1.2rem; margin: 0 0 .8rem; }
.im h3 {
  font-family: var(--font-mono);
  font-size: .72rem;
  font-weight: 500;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 0;
}

.im-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-width: 0;
}
.im .im-card { padding: 1.1rem 1.1rem 1.2rem; }

.im-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: .2rem 1rem;
  margin-bottom: .8rem;
}
.im-head h2 { margin: 0; }
.im-count { margin: 0; font-family: var(--font-mono); font-size: .85rem; color: var(--accent); }

.im-hint {
  font-size: .85rem;
  color: var(--text-faint);
  margin: -.3rem 0 1rem;
  line-height: 1.45;
}
.im-hint:empty, .im-hint[hidden] { display: none; }
.im-hint code { font-size: .8rem; }
.im-warn { color: var(--amber); margin: .2rem 0 0; }

/* ============================================================
   1. DROP
   ============================================================ */
.im .im-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: .3rem;
  padding: 1.8rem 1.1rem 1.3rem;
  border: 2px dashed var(--accent-line);
  border-radius: var(--radius);
  background: var(--accent-dim);
}
.im-drop h2 { font-size: clamp(1.5rem, 6vw, 2.1rem); margin: 0; }
.im-drop-sub { color: var(--text-dim); margin: 0 0 .7rem; overflow-wrap: anywhere; }
.im-drop.is-over { border-color: var(--accent); border-style: solid; background: var(--surface-2); }

.im .im-drop.is-loaded { padding: 1rem 1.1rem .9rem; }
.im-drop.is-loaded h2 { font-size: 1.25rem; }
.im-drop.is-loaded .im-drop-sub { font-family: var(--font-mono); font-size: .85rem; margin-bottom: .5rem; }

.im-drop-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: .6rem; width: 100%; }
.im-pick { min-height: 56px; min-width: min(100%, 220px); font-size: 1.1rem; padding-inline: 1.6rem; }
.im-sample { min-height: 56px; }
.im-drop.is-loaded .im-pick,
.im-drop.is-loaded .im-sample { min-height: var(--tap); font-size: 1rem; }
.im-drop:has(#file:focus-visible) .im-pick { outline: 2px solid var(--cyan); outline-offset: 3px; }

.im-private { margin: .9rem 0 0; color: var(--text-dim); font-size: .92rem; }
.im-private strong { color: var(--green); font-weight: 600; }
.im-status { margin: .3rem 0 0; font-size: .9rem; color: var(--amber); }
.im-status:empty { display: none; }

/* ============================================================
   2. ICONS
   ============================================================ */
.im-hero { display: grid; place-items: center; margin-bottom: 1.1rem; }
.im-big {
  width: min(100%, 256px);
  aspect-ratio: 1;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--bg-2);
  border: 1px solid var(--line);
}
.im-big canvas { display: block; width: 100%; height: 100%; }

.im-tiles {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 9.5rem), 1fr));
  gap: .7rem;
}
.im-tile {
  margin: 0;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  gap: .5rem .4rem;
  align-items: center;
  padding: .7rem;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  min-width: 0;
}
.im-tile.is-ico { grid-column: 1 / -1; }
.im-frame {
  grid-column: 1 / -1;
  position: relative;
  display: grid;
  place-items: center;
  height: 96px;
}
.im-frame canvas { width: 80px; height: 80px; }
.im-tile.is-apple canvas { border-radius: 22.5%; }              /* how iOS shows it */
.im-tile.is-maskable canvas { border-radius: 50%; }             /* a round launcher */
.im-safe {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 64px;                                                  /* 80% of 80px */
  height: 64px;
  transform: translate(-50%, -50%);
  border: 2px dashed var(--cyan);
  border-radius: 50%;
  pointer-events: none;
}

/* favicon: the three sizes at real size, on a tab-like strip */
.im-tab {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .6rem;
  background: var(--surface-2);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  border-bottom: 2px solid var(--accent);
}
.im-tab canvas.im-fav-16 { width: 16px; height: 16px; }
.im-tab canvas.im-fav-32 { width: 32px; height: 32px; }
.im-tab canvas.im-fav-48 { width: 48px; height: 48px; }

.im-tile-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.3; }
.im-tile-text strong { font-family: var(--font-display); font-size: .95rem; overflow-wrap: anywhere; }
.im-tile-text span { font-family: var(--font-mono); font-size: .72rem; color: var(--text-faint); }
.im-dl { min-height: 44px; min-width: 44px; padding: 0; font-size: 1.1rem; }

.im-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-bottom: .8rem; }
.im-actions .btn { min-height: 52px; flex: 1 1 14rem; font-size: 1.05rem; }

/* ============================================================
   3. SETTINGS
   ============================================================ */
.im-fs { border: 0; margin: 0 0 .9rem; padding: 0; min-width: 0; }
.im-fs legend {
  font-family: var(--font-mono);
  font-size: .72rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: .45rem;
  padding: 0;
}
.im-seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--line-field);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.im-seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.im-seg label {
  display: grid;
  place-items: center;
  min-height: var(--tap);
  padding: 0 .3rem;
  text-align: center;
  font-family: var(--font-display);
  font-weight: 600;
  cursor: pointer;
  color: var(--text-dim);
  border-left: 1px solid var(--line-field);
  -webkit-user-select: none;
          user-select: none;
}
.im-seg label:first-of-type { border-left: 0; }
.im-seg label:hover { color: var(--text); background: var(--surface-2); }
.im-seg input:checked + label { background: var(--accent); color: var(--bg); }
.im-seg input:focus-visible + label { outline: 2px solid var(--cyan); outline-offset: -4px; border-radius: 6px; }

.im-range { margin-bottom: .4rem; }
.im-range label { display: flex; justify-content: space-between; align-items: baseline; }
.im-range output {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0;
  text-transform: none;
}
.field input[type="range"] {
  -webkit-appearance: none;
          appearance: none;
  height: var(--tap);
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.field input[type="range"]:focus { background: transparent; }
.field input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: var(--line-bright); }
.field input[type="range"]::-moz-range-track { height: 6px; border-radius: 3px; background: var(--line-bright); }
.field input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 28px; height: 28px; margin-top: -11px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--bg);
}
.field input[type="range"]::-moz-range-thumb {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--bg);
}
.field input[type="range"]:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

.im-colour-row { display: flex; gap: .6rem; align-items: stretch; }
.im-colour-row input[type="color"] {
  flex: 0 0 var(--tap);
  width: var(--tap);
  min-height: var(--tap);
  padding: 4px;
  cursor: pointer;
}
.im-colour-row input[type="text"] { flex: 1 1 auto; min-width: 0; font-family: var(--font-mono); }
.im-colour-row input.is-bad { border-color: var(--hot); }

.im-check {
  display: flex;
  align-items: center;
  gap: .6rem;
  min-height: var(--tap);
  margin: -.4rem 0 .6rem;
  cursor: pointer;
  color: var(--text);
  font-size: .95rem;
}
.im-check input { width: 22px; height: 22px; accent-color: var(--accent); margin: 0; cursor: pointer; }

.im-pair { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; margin-top: .4rem; }
.im-pair .field { margin-bottom: .8rem; min-width: 0; }

/* ============================================================
   4. SNIPPETS
   ============================================================ */
.im-snip { margin-bottom: 1rem; }
.im-snip-head { display: flex; justify-content: space-between; align-items: center; gap: .6rem; margin-bottom: .4rem; }
.im-snip-head .btn { min-height: 44px; min-width: 5rem; }
.im-code {
  margin: 0;
  padding: .8rem .9rem;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: .78rem;
  line-height: 1.55;
  color: var(--text-dim);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 16rem;
  overflow-y: auto;
}
.im-code:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.im-copied { margin: 0; font-size: .9rem; color: var(--green); }
.im-copied:empty { display: none; }
