/* The theme maker (/theme-maker). Phone first: the preview sits on top and sticks
   there while you pick; on a wide screen it moves to the right and stays in view. */

.tm { display: grid; gap: 18px; margin-top: 26px; }
.tm[hidden] { display: none; }
.tm-controls { display: grid; gap: 14px; order: 2; min-width: 0; }
.tm-preview { order: 1; position: sticky; top: 66px; z-index: 5; margin: 0 -20px; padding: 10px 20px 12px;
  background: rgba(7, 11, 10, 0.92); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line); }
@media (min-width: 980px) {
  .tm { grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr); gap: 26px; align-items: start; }
  .tm-controls { order: 1; }
  .tm-preview { order: 2; top: 84px; margin: 0; padding: 0; background: none; backdrop-filter: none;
    -webkit-backdrop-filter: none; border: 0; }
}

.tm-step { padding: 18px 18px 20px; }
.tm-h { display: flex; align-items: center; gap: 10px; margin: 0 0 6px; font-size: 19px; letter-spacing: -0.01em; }
.tm-n { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; flex: none;
  background: var(--accent-soft); color: var(--accent); font: 600 13px/1 var(--mono); }
.tm-note { color: var(--muted); font-size: 14px; line-height: 1.5; margin: 0 0 12px; }
.tm-note:last-child { margin-bottom: 0; }

/* ---- looks ---- */
.tm-looks { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
@media (min-width: 560px) { .tm-looks { grid-template-columns: repeat(4, 1fr); } }
.tm-look { display: grid; gap: 7px; padding: 9px; border-radius: 11px; cursor: pointer; text-align: left;
  background: var(--bg-2); border: 1px solid var(--line); color: var(--text); font: 600 14px/1.2 var(--sans); }
.tm-look:hover { border-color: var(--accent-dim); }
.tm-look[aria-checked="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; color: var(--heading); }
.tm-look canvas { width: 100%; height: auto; border-radius: 6px; display: block; image-rendering: pixelated; background: #000; }
.tm-look small { display: block; color: var(--muted); font: 400 12px/1.3 var(--sans); }

/* ---- colours ---- */
.tm-swatches { display: grid; gap: 6px; }
.tm-sw { display: grid; grid-template-columns: 46px minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding: 6px 10px 6px 6px; border-radius: 11px; border: 1px solid transparent; }
.tm-sw:hover, .tm-sw:focus-within { background: var(--bg-2); border-color: var(--line); }
.tm-sw input[type="color"] { width: 46px; height: 38px; padding: 0; border: 1px solid var(--line-2); border-radius: 9px;
  background: none; cursor: pointer; }
.tm-sw input[type="color"]::-webkit-color-swatch-wrapper { padding: 3px; }
.tm-sw input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 6px; }
.tm-sw input[type="color"]::-moz-color-swatch { border: 0; border-radius: 6px; }
.tm-sw-name { display: block; color: var(--heading); font-weight: 600; font-size: 15px; line-height: 1.25; }
.tm-sw-what { display: block; color: var(--muted); font-size: 13px; line-height: 1.3; }
.tm-sw-hex { font: 400 12.5px/1 var(--mono); color: var(--muted); width: 78px; box-sizing: border-box; padding: 7px 4px; text-align: center;
  background: var(--bg); border: 1px solid var(--line); border-radius: 7px; text-transform: lowercase; }
.tm-sw-hex:focus { color: var(--heading); border-color: var(--accent-dim); outline: none; }
.tm-sw-auto { display: inline-flex; align-items: center; gap: 5px; margin-right: 8px; color: var(--muted); font-size: 12.5px; cursor: pointer; }
.tm-sw-auto input { accent-color: var(--accent); width: 14px; height: 14px; cursor: pointer; }
.tm-sw-side { display: flex; align-items: center; }

.tm-presets { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin: 14px 0 0; padding-top: 14px; border-top: 1px solid var(--line); }
.tm-presets-label { color: var(--muted); font-size: 13.5px; }
.tm-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.tm-chip { display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px 0 8px; border-radius: 999px; cursor: pointer;
  background: var(--bg-2); border: 1px solid var(--line); color: var(--text); font: 500 13.5px/1 var(--sans); }
.tm-chip:hover { border-color: var(--accent-dim); color: var(--heading); }
.tm-chip i { display: block; width: 16px; height: 16px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, 0.18); }

.tm-warn { margin: 14px 0 0; padding: 10px 12px; border-radius: 10px; font-size: 13.5px; line-height: 1.45;
  color: var(--amber); background: rgba(240, 192, 96, 0.07); border: 1px solid #4a3a14; }
.tm-warn[hidden] { display: none; }

.tm-more { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.tm-more summary { cursor: pointer; color: var(--heading); font-weight: 600; font-size: 14.5px; padding: 4px 0; }
.tm-more[open] summary { margin-bottom: 8px; }

/* ---- name ---- */
.tm-name { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.tm-name input { flex: 1; min-width: 0; height: 46px; padding: 0 14px; border-radius: 11px; font: 600 17px/1 var(--sans);
  color: var(--heading); background: var(--bg); border: 1px solid var(--line-2); }
.tm-name input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.tm-count { color: var(--muted); font: 400 12.5px/1 var(--mono); }

/* ---- send ---- */
.tm-send { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.tm-send .btn[disabled] { opacity: 0.55; cursor: progress; }
.tm-unsupported { margin: 12px 0 0; font-size: 14px; color: var(--amber); }
.tm-status { margin-top: 14px; padding: 12px 14px; border-radius: 11px; background: var(--bg-2); border: 1px solid var(--line);
  font-size: 14.5px; line-height: 1.5; }
.tm-status[hidden] { display: none; }
.tm-status-head { display: block; font: 600 16px/1.3 var(--display); color: var(--heading); margin-bottom: 2px; }
.tm-status.ok { border-color: var(--accent-dim); }
.tm-status.ok .tm-status-head { color: var(--accent); }
.tm-status.bad { border-color: #4a3a14; }
.tm-status.bad .tm-status-head { color: var(--amber); }
.tm-status.busy .tm-status-head::after { content: ""; display: inline-block; width: 0.9em; height: 0.9em; margin-left: 9px; vertical-align: -1px;
  border: 2px solid var(--line-2); border-top-color: var(--accent); border-radius: 50%; animation: tm-spin 0.9s linear infinite; }
@keyframes tm-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .tm-status.busy .tm-status-head::after { animation: none; } }

.tm-device { margin-top: 14px; }
.tm-device h3 { font-size: 15px; margin: 0 0 8px; }
.tm-device-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.tm-device-list li { display: flex; align-items: center; gap: 10px; padding: 7px 8px 7px 10px; border-radius: 10px;
  background: var(--bg-2); border: 1px solid var(--line); font-size: 14.5px; }
.tm-device-list .tm-dots { display: flex; gap: 3px; flex: none; }
.tm-device-list .tm-dots i { width: 12px; height: 12px; border-radius: 3px; border: 1px solid rgba(255, 255, 255, 0.14); }
.tm-device-list .tm-dname { flex: 1; min-width: 0; color: var(--heading); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tm-device-list .tm-dname small { color: var(--muted); font-weight: 400; margin-left: 6px; }
.tm-device-list button { height: 30px; padding: 0 10px; border-radius: 8px; cursor: pointer; font: 500 13px/1 var(--sans);
  background: var(--panel); border: 1px solid var(--line-2); color: var(--text); }
.tm-device-list button:hover { border-color: var(--accent-dim); color: var(--heading); }
.tm-device-list button[disabled] { opacity: 0.5; cursor: progress; }
.tm-device-list .tm-empty { color: var(--muted); background: none; border-style: dashed; }

.tm-log { margin-top: 12px; }
.tm-log summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.tm-log pre { margin: 8px 0 0; padding: 10px; max-height: 200px; overflow: auto; white-space: pre-wrap; word-break: break-word;
  font: 12px/1.5 var(--mono); color: var(--muted); background: var(--bg); border: 1px solid var(--line); border-radius: 9px; }
.tm-need { margin-top: 14px; }

/* ---- preview ---- */
.tm-preview-inner { display: grid; gap: 10px; }
.tm-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.tm-tabs button { height: 34px; padding: 0 13px; border-radius: 999px; cursor: pointer; font: 600 13.5px/1 var(--sans);
  color: var(--muted); background: var(--panel); border: 1px solid var(--line); }
.tm-tabs button:hover { color: var(--heading); }
.tm-tabs button[aria-selected="true"] { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.tm-boards { justify-content: flex-start; }
.tm-screen-wrap { border-radius: 18px; padding: 10px; background: linear-gradient(160deg, #1a2420, #0c1210); border: 1px solid var(--line-2);
  box-shadow: var(--shadow); }
.tm-screen-wrap canvas { display: block; width: 100%; height: auto; border-radius: 8px; image-rendering: pixelated; background: #000;
  box-shadow: 0 0 0 1px #000; }
.tm-screen-wrap.tdeck { max-width: 520px; }
.tm-cap { color: var(--muted); font-size: 13px; line-height: 1.45; margin: 0; }
@media (max-width: 979px) {
  .tm-cap { display: none; }
  .tm-screen-wrap { padding: 6px; border-radius: 12px; max-width: 520px; margin: 0 auto; }
  .tm-screen-wrap.tdeck { max-width: 300px; }
  .tm-tabs { justify-content: center; }
  .tm-tabs button { height: 30px; padding: 0 11px; font-size: 13px; }
}
