.thumbnail-maker {
    --tm-blue: #3667c0;
    --tm-dark: #172033;
    color: #1f2937;
}
.thumbnail-maker label,
.thumbnail-maker input,
.thumbnail-maker select { margin-bottom: 0; }

.tm-privacy {
    margin: 0 0 18px;
    padding: 12px 14px;
    color: #14532d;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 10px;
    font-size: 14px;
}

.tm-workspace { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-items: start; }
.tm-controls { grid-row: 3; min-width: 0; }
.tm-tabs { grid-row: 2; display: flex; gap: 4px; padding: 4px; background: #e9eef7; border-radius: 10px; }
.tm-tab { flex: 1 1 0; width: auto; min-width: 0; min-height: 36px; padding: 6px 4px; color: #475569; background: transparent; border: 0; border-radius: 7px; font: inherit; font-size: 12px; font-weight: 700; white-space: nowrap; cursor: pointer; }
.tm-tab:hover { color: #172033; background: #f8fafc; }
.tm-tab[aria-selected="true"] { color: #fff; background: var(--tm-blue); box-shadow: 0 2px 6px rgba(54, 103, 192, 0.22); }
.tm-tab-panel[hidden] { display: none; }
.tm-tab-panel .tm-panel { width: 100%; }
.tm-panel { min-width: 0; padding: 14px; border: 1px solid #dfe5ef; border-radius: 12px; background: #fff; }
.tm-panel legend { padding: 0 7px; font-weight: 700; color: var(--tm-dark); }
.tm-field { display: grid; gap: 6px; min-width: 0; font-size: 13px; font-weight: 600; line-height: 1.25; }
.tm-field > span { display: block; min-height: 17px; line-height: 17px; }
.tm-field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: stretch; }
.tm-field-row > .tm-field { width: 100%; margin: 0; align-self: stretch; }
.tm-field-row + .tm-field-row, .tm-field + .tm-field, .tm-field-row + .tm-field, .tm-field + .tm-field-row { margin-top: 10px; }
.tm-field input, .tm-field select, .tm-panel select { width: 100%; height: 42px; min-height: 42px; padding: 7px 9px; color: #111827; background: #fff; border: 1px solid #cbd5e1; border-radius: 8px; font: inherit; line-height: 1.2; }
.tm-field input[type="color"] { padding: 4px; cursor: pointer; }
.tm-field input[type="range"] { min-height: 28px; padding: 0; accent-color: var(--tm-blue); }
.tm-field output { justify-self: end; margin-top: -5px; color: #64748b; font-size: 12px; }
.tm-size-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 10px; }
.tm-check { display: flex; gap: 8px; align-items: center; margin-top: 14px; font-size: 13px; line-height: 18px; cursor: pointer; }
.tm-check input { flex: 0 0 18px; width: 18px; height: 18px; margin: 0; accent-color: var(--tm-blue); }
.tm-template-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tm-template { min-height: 42px; padding: 7px; border: 1px solid #cbd5e1; border-radius: 8px; background: #f8fafc; color: #172033; font-weight: 700; cursor: pointer; }
.tm-template:hover, .tm-template:focus-visible { color: #172033; border-color: var(--tm-blue); background: #eff6ff; }
.tm-file-button { display: block; margin: 10px 0; padding: 9px 12px; text-align: center; color: #fff; background: var(--tm-blue); border-radius: 8px; font-weight: 700; cursor: pointer; }
.tm-help { margin: 6px 0 10px; color: #64748b; font-size: 12px; overflow-wrap: anywhere; }
.tm-visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.tm-layers { display: grid; gap: 8px; }
.tm-layer { border: 1px solid #dfe5ef; border-radius: 9px; background: #f8fafc; }
.tm-layer summary { display: flex; justify-content: space-between; gap: 8px; padding: 9px 10px; font-weight: 700; cursor: pointer; }
.tm-layer-preview { max-width: 120px; color: #64748b; font-size: 11px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tm-layer-controls { padding: 4px 10px 12px; }
.tm-preview-panel { grid-row: 1; min-width: 0; padding: 16px; border: 1px solid #dfe5ef; border-radius: 14px; background: #f8fafc; }
.tm-preview-toolbar { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.tm-export { display: flex; justify-content: space-between; gap: 12px; align-items: flex-end; }
.tm-preview-toolbar p { margin: 0; color: #475569; font-size: 14px; font-weight: 700; }
.tm-canvas-shell { display: block; width: 100%; margin: 14px 0; overflow: hidden; background: repeating-conic-gradient(#e5e7eb 0 25%, #f8fafc 0 50%) 50% / 20px 20px; border-radius: 10px; box-shadow: inset 0 0 0 1px #cbd5e1; }
.tm-canvas-shell canvas { display: block; width: 100%; max-width: none; height: auto; }
.tm-button { min-height: 42px; padding: 9px 14px; border-radius: 8px; font: inherit; font-weight: 700; cursor: pointer; }
.tm-button-primary { color: #fff; background: var(--tm-blue); border: 1px solid var(--tm-blue); }
.tm-button-primary:hover { background: #2d56a1; }
.tm-button-secondary { color: #334155; background: #fff; border: 1px solid #cbd5e1; }
.tm-export-format { display: flex; grid-template-columns: none; align-items: center; gap: 10px; }
.tm-export-format > span { min-height: 0; line-height: 1.2; white-space: nowrap; }
.tm-export-format select { flex: 0 0 100px; width: 100px; }
.tm-status { min-height: 24px; margin: 8px 0 0; color: #14532d; font-size: 13px; }
.thumbnail-maker :focus-visible { outline: 3px solid rgba(54, 103, 192, 0.35); outline-offset: 2px; }

@media (max-width: 520px) {
    .tm-field-row { grid-template-columns: 1fr; }
    .tm-size-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .tm-preview-toolbar, .tm-export { align-items: stretch; flex-direction: column; }
    .tm-export-format { display: grid; grid-template-columns: 1fr; }
    .tm-export-format select { width: 100%; }
    .tm-template-list { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
    .thumbnail-maker * { scroll-behavior: auto !important; transition: none !important; }
}
