/* YouTube Thumbnail Maker — tool-specific styles (site design tokens only). */

@media (min-width: 1024px) {
  .tool-shell.tm-shell { grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); }
}
/* The sticky preview column can be taller than a laptop screen: let it scroll on its own
   so the download buttons are always reachable. */
@media (min-width: 1024px) {
  .tm-preview-col {
    max-height: calc(100vh - var(--header-h) - 32px); overflow-y: auto; overscroll-behavior: contain;
    padding: 4px; margin: -4px; scrollbar-width: thin;
  }
}

.tm-jump-wrap { margin-top: 14px; display: none; }
@media (max-width: 1023px) { .tm-jump-wrap { display: block; } }

/* ---------- Preview ---------- */
.tm-stage { padding: 16px; }
.tm-canvas-wrap { position: relative; width: 100%; }
#tm-canvas {
  display: block; width: 100%; height: auto; aspect-ratio: 16 / 9;
  border-radius: var(--radius-sm); box-shadow: var(--shadow); background: #0f172a;
  touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
#tm-canvas.is-dragging { cursor: grabbing !important; }
#tm-canvas:focus { outline: none; }
#tm-canvas:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.tm-stage .hint { margin-top: 10px; }

.tm-actions { padding: 0; }
.tm-toolbar { border-bottom: 1px solid var(--border); }
.tm-glyph { font-size: 1.1rem; line-height: 1; }
.tm-guide-row { padding: 10px 16px 14px; }
.tm-guide-row .hint { margin-top: 2px; }

.tm-export { padding: 18px 20px; }
.tm-export h2 { font-size: 1.05rem; margin-bottom: 12px; }
.tm-export .field { margin-bottom: 12px; }
.tm-export-buttons { display: flex; flex-wrap: wrap; gap: 10px; }
.tm-export-buttons .btn { flex: 1 1 200px; justify-content: center; white-space: normal; text-align: center; }
.tm-attn { border-color: var(--warning) !important; box-shadow: 0 0 0 3px color-mix(in srgb, var(--warning) 30%, transparent); }
.tm-gap { margin-top: 12px; }
.tm-copyright { border-left: 3px solid var(--warning); padding-left: 10px; }

/* ---------- Layout cards ---------- */
.tm-layouts { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 10px; margin-bottom: 4px; }
.tm-layout {
  display: flex; flex-direction: column; align-items: stretch; gap: 6px; padding: 6px 6px 8px;
  border: 2px solid var(--border); border-radius: var(--radius); background: var(--surface);
  color: var(--text-2); font: inherit; font-size: .85rem; font-weight: 600; text-align: center; cursor: pointer;
}
.tm-layout canvas { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; border-radius: 6px; }
.tm-layout:hover { border-color: var(--border-strong); background: var(--surface-2); }
.tm-layout[aria-pressed="true"] { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-text); }
.tm-layout:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* ---------- Background ---------- */
.tm-drop { margin-bottom: 4px; justify-content: flex-start; text-align: left; gap: 12px; }
.tm-drop .dz-icon { width: 44px; height: 44px; border-radius: 12px; }
.tm-drop .dz-icon .icon { width: 22px; height: 22px; }
.tm-drop-text { flex: 1 1 180px; min-width: 0; }
.tm-drop-text strong { display: block; font-size: .95rem; overflow-wrap: anywhere; }
.tm-bg-image-controls { margin-top: 14px; }
.tm-bg-image-controls > p:last-child { margin: 8px 0 14px; }

/* ---------- Layers ---------- */
.tm-add-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.tm-add-shape { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; }
.tm-add-shape .field { flex: 1 1 180px; margin-bottom: 0; }
.tm-add-shape .btn { min-height: 44px; }
.tm-file-btn { position: relative; display: inline-flex; }
.tm-file-btn input[type="file"] { position: absolute; opacity: 0; width: 1px; height: 1px; overflow: hidden; }
.tm-file-btn input[type="file"]:focus-visible + label { outline: 3px solid var(--focus); outline-offset: 2px; }
.tm-file-btn label.btn { margin: 0; }
.tm-replace { margin: 4px 0 2px; }

.tm-sub { font-size: .95rem; margin: 20px 0 8px; }
.tm-layer-list { list-style: none; margin: 0 0 16px; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.tm-layer-list:empty { display: none; }
.tm-layer { display: flex; align-items: center; gap: 4px; padding: 4px 6px; border-bottom: 1px solid var(--border); background: var(--surface); }
.tm-layer:last-child { border-bottom: 0; }
.tm-layer.is-selected { background: var(--primary-soft); }
.tm-layer.is-hidden .tm-layer-text { opacity: .55; text-decoration: line-through; }
.tm-layer-name {
  flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 6px 8px;
  border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text); font: inherit; font-size: .9rem; text-align: left; cursor: pointer;
}
.tm-layer-name:hover { background: var(--surface-2); }
.tm-layer.is-selected .tm-layer-name { color: var(--primary-text); font-weight: 650; }
.tm-layer-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tm-kind { flex: 0 0 auto; display: grid; place-items: center; color: var(--muted); }
.tm-kind .icon { width: 16px; height: 16px; }
.tm-layer-acts { flex: 0 0 auto; display: flex; gap: 2px; }
.tm-icon-btn {
  position: relative; display: grid; place-items: center; width: 34px; height: 34px; padding: 0;
  border: 1px solid transparent; border-radius: var(--radius-sm); background: transparent; color: var(--text-2);
  font: inherit; font-size: 1rem; font-weight: 700; cursor: pointer;
}
.tm-icon-btn .icon { width: 16px; height: 16px; }
.tm-icon-btn:hover:not(:disabled) { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.tm-icon-btn:disabled { opacity: .35; cursor: default; }
.tm-icon-btn[data-act="del"]:hover:not(:disabled) { color: var(--danger); }
.tm-icon-btn .tm-slash { position: absolute; left: 7px; right: 7px; top: 50%; height: 2px; background: currentColor; transform: rotate(-40deg); border-radius: 2px; }
.tm-layer-name:focus-visible, .tm-icon-btn:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
.tm-layer-empty { margin: 0 0 16px; }

/* ---------- Selected-layer properties ---------- */
#tm-props [hidden], .tm-shell [hidden] { display: none !important; }
#tm-props textarea { min-height: 70px; }
.tm-align { grid-column: 1 / -1; margin-bottom: 12px; }
.tm-align span { min-height: 36px; padding: 6px 12px; }
.tm-checks { display: flex; flex-wrap: wrap; gap: 4px 20px; margin-bottom: 10px; }
.tm-common { margin-top: 6px; padding-top: 14px; border-top: 1px dashed var(--border); }
.tm-prop-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 18px; }

/* ---------- Content ---------- */
.tm-lead { color: var(--text-2); max-width: 820px; }
.tm-h2 { margin-top: 32px; }
.tm-gap-lg { margin-top: 24px; }
.tm-features { margin: 0; padding-left: 20px; color: var(--text-2); display: grid; gap: 6px; }

@media (prefers-reduced-motion: no-preference) {
  .tm-layout, .tm-icon-btn, .tm-layer-name { transition: border-color .15s, background .15s, color .15s; }
}

@media (max-width: 640px) {
  .tm-stage { padding: 8px; }
  .tm-layouts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tm-icon-btn { width: 36px; height: 36px; }
  .tm-layer { flex-wrap: wrap; }
  .tm-layer-name { flex-basis: 100%; }
  .tm-layer-acts { margin-left: auto; }
  .tm-export-buttons .btn { flex-basis: 100%; }
}
