/* ===== TEXT TO IMAGE MAKER ===== */

/* Root — constrained card, centered */
.ttim-root {
  --accent: #6557ff;
  --accent2: #aa3fff;
  --bg: #F5F7FF;
  --surface: #ffffff;
  --surface2: #EEF0FB;
  --border: #DDE4F5;
  --border2: #C4CEE8;
  --text: #1B1D2C;
  --muted: #8893AA;
  --hover: #F0F3FF;
  --act: rgba(101,87,255,0.09);
  --shadow-sm: 0 1px 3px rgba(27,29,44,0.07);
  --shadow-md: 0 4px 20px rgba(27,29,44,0.1);

  font-family: 'Inter', system-ui, sans-serif;
  color: var(--text);
  background: var(--surface);
  /* Max width + center + visible margin from page edges */
  max-width: 1200px;
  margin: 0 auto 56px;
  border-radius: 18px;
  overflow: hidden;
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow-md), 0 1px 0 rgba(255,255,255,0.8) inset;
  /* Thin brand gradient stripe at top */
  outline: 3px solid transparent;
  position: relative;
}
.ttim-root::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent2) 100%);
  z-index: 10;
}

/* ===== PRESET BAR ===== */
.ttim-preset-wrap {
  position: relative;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.ttim-preset-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 44px;
  background: var(--bg);
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.ttim-preset-bar::-webkit-scrollbar { display: none; }
.ttim-preset-arrow {
  position: absolute; top: 50%; transform: translateY(-50%);
  z-index: 2; width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: 50%; cursor: pointer; color: var(--text);
  box-shadow: 0 2px 8px rgba(0,0,0,0.10);
  transition: opacity 0.15s, background 0.13s, border-color 0.13s;
}
.ttim-preset-arrow:hover { background: var(--hover); border-color: var(--border2); }
.ttim-preset-arrow-l { left: 6px; }
.ttim-preset-arrow-r { right: 6px; }
.ttim-preset-arrow.is-hidden { opacity: 0; pointer-events: none; }

.ttim-preset-btn {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 0;
  cursor: pointer;
  transition: border-color 0.17s, box-shadow 0.17s, transform 0.14s;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.ttim-preset-btn:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(101,87,255,0.2);
}
.ttim-preset-btn.ttim-preset-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(101,87,255,0.22);
}
.ttim-preset-thumb {
  width: 92px;
  height: 58px;
  display: block;
  border-radius: 10px 10px 0 0;
}
.ttim-preset-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
  padding: 5px 10px 7px;
  white-space: nowrap;
}

/* ===== WORKSPACE ===== */
.ttim-workspace {
  display: flex;
  flex-direction: row;
  /* Fixed height so canvas area has a defined container */
  height: 580px;
  min-height: 480px;
}

/*
 * Layout order on desktop (left → right):
 *   sidenav (order 1) | panel-wrap (order 2) | canvas-area (order 3)
 *
 * On mobile (column, natural DOM order):
 *   canvas-area (first in DOM) | sidenav | panel-wrap
 */
.ttim-sidenav    { order: 1; }
.ttim-panel-wrap { order: 2; }
.ttim-canvas-area{ order: 3; }

/* ===== SIDE NAV ===== */
.ttim-sidenav {
  width: 62px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 10px 0;
  gap: 2px;
}

.ttim-nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  width: 50px;
  padding: 9px 4px;
  border: none;
  border-radius: 10px;
  background: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  transition: background 0.13s, color 0.13s;
  position: relative;
}
.ttim-nav-btn svg { width: 19px; height: 19px; }
.ttim-nav-btn:hover { background: var(--hover); color: var(--text); }
.ttim-nav-btn.ttim-nav-active {
  background: var(--act);
  color: var(--accent);
}
/* Purple left-edge indicator */
.ttim-nav-btn.ttim-nav-active::after {
  content: '';
  position: absolute;
  left: -6px;
  top: 25%;
  bottom: 25%;
  width: 3px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}

/* ===== PANEL WRAP ===== */
.ttim-panel-wrap {
  width: 268px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border2) transparent;
}
.ttim-panel-wrap::-webkit-scrollbar { width: 3px; }
.ttim-panel-wrap::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

.ttim-panel { padding: 14px 13px 24px; }
.ttim-panel[hidden] { display: none; }

.ttim-panel-title {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 13px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.ttim-section-label {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--muted);
  margin-top: 14px;
  margin-bottom: 7px;
  display: block;
  letter-spacing: 0.03em;
}

/* ===== FIELDS ===== */
.ttim-field { margin-bottom: 13px; }
.ttim-field-row { display: flex; gap: 8px; }
.ttim-field-half { flex: 1; min-width: 0; }

.ttim-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 5px;
}

.ttim-val-badge {
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  background: var(--act);
  padding: 1px 7px;
  border-radius: 20px;
}

.ttim-textarea {
  width: 100%;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  padding: 9px 11px;
  resize: vertical;
  min-height: 68px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.14s, box-shadow 0.14s;
}
.ttim-textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(101,87,255,0.1); }

.ttim-select-wrap { position: relative; }
.ttim-select-wrap::after {
  content: '▾';
  position: absolute; right: 9px; top: 50%; transform: translateY(-50%);
  pointer-events: none; color: var(--muted); font-size: 11px;
}
.ttim-select {
  width: 100%; appearance: none;
  background: var(--surface2); border: 1.5px solid var(--border); border-radius: 8px;
  color: var(--text); font-size: 12px; font-weight: 600;
  padding: 7px 26px 7px 9px; cursor: pointer; outline: none;
  transition: border-color 0.14s;
}
.ttim-select:focus { border-color: var(--accent); }

.ttim-input-num {
  width: 100%; background: var(--surface2); border: 1.5px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 14px; font-weight: 700;
  padding: 7px 9px; outline: none; transition: border-color 0.14s; text-align: center;
}
.ttim-input-num:focus { border-color: var(--accent); }

/* ===== RANGE ===== */
.ttim-range {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 4px; border-radius: 4px;
  background: var(--border); outline: none; cursor: pointer;
}
.ttim-range::-webkit-slider-thumb {
  -webkit-appearance: none; width: 15px; height: 15px; border-radius: 50%;
  background: var(--accent); cursor: pointer; border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(101,87,255,0.4); transition: box-shadow 0.13s;
}
.ttim-range::-webkit-slider-thumb:hover { box-shadow: 0 1px 8px rgba(101,87,255,0.55); }
.ttim-range::-moz-range-thumb {
  width: 15px; height: 15px; border-radius: 50%; background: var(--accent);
  cursor: pointer; border: 2px solid #fff;
}

/* ===== ALIGNMENT ===== */
.ttim-align-btns { display: flex; gap: 5px; }
.ttim-align-btn {
  flex: 1; padding: 7px; background: var(--surface2); border: 1.5px solid var(--border);
  border-radius: 7px; color: var(--muted); cursor: pointer; display: flex;
  align-items: center; justify-content: center;
  transition: background 0.13s, color 0.13s, border-color 0.13s;
}
.ttim-align-btn:hover { background: var(--hover); color: var(--text); }
.ttim-align-btn.ttim-align-active { background: var(--act); border-color: var(--accent); color: var(--accent); }
.ttim-align-btn svg { width: 16px; height: 16px; }

/* ===== MODE TABS ===== */
.ttim-mode-tabs {
  display: flex; gap: 3px; background: var(--surface2);
  border-radius: 10px; padding: 3px; margin-bottom: 14px; flex-wrap: wrap;
}
.ttim-mode-tab {
  flex: 1; min-width: 48px; padding: 6px 3px; font-size: 11px; font-weight: 700;
  background: none; border: none; border-radius: 7px; color: var(--muted);
  cursor: pointer; transition: background 0.13s, color 0.13s; white-space: nowrap;
}
.ttim-mode-tab:hover { color: var(--text); background: rgba(255,255,255,0.65); }
.ttim-mode-tab.ttim-mode-active { background: var(--accent); color: #fff; box-shadow: 0 1px 6px rgba(101,87,255,0.3); }
.ttim-mode-panel[hidden] { display: none; }

/* ===== COLOR INPUTS ===== */
.ttim-color-pick-row { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; }
.ttim-color-input {
  width: 38px; height: 32px; border: 1.5px solid var(--border); border-radius: 7px;
  padding: 2px; background: var(--surface2); cursor: pointer; flex-shrink: 0;
}
.ttim-hex-input {
  flex: 1; background: var(--surface2); border: 1.5px solid var(--border);
  border-radius: 7px; color: var(--text); font-size: 12px; font-weight: 700;
  font-family: 'Space Grotesk', monospace; padding: 6px 9px; outline: none;
  text-transform: uppercase; transition: border-color 0.13s;
}
.ttim-hex-input:focus { border-color: var(--accent); }

/* ===== SWATCHES ===== */
.ttim-swatch-grid { display: grid; grid-template-columns: repeat(8,1fr); gap: 5px; margin-bottom: 3px; }
.ttim-swatch {
  aspect-ratio: 1; border-radius: 6px; cursor: pointer;
  border: 1.5px solid transparent;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.07);
  transition: transform 0.13s, border-color 0.13s;
}
.ttim-swatch:hover { transform: scale(1.1); border-color: var(--border2); }
.ttim-swatch.ttim-swatch-active { border-color: var(--accent); transform: scale(1.1); box-shadow: 0 0 0 2px rgba(101,87,255,0.18); }

/* ===== GRADIENT STOPS ===== */
.ttim-grad-stops { display: flex; flex-direction: column; gap: 7px; margin-bottom: 7px; }
.ttim-grad-stop-row { display: flex; align-items: center; gap: 7px; }
.ttim-grad-stop-color {
  width: 32px; height: 28px; border: 1.5px solid var(--border); border-radius: 6px;
  padding: 2px; background: var(--surface2); cursor: pointer; flex-shrink: 0;
}
.ttim-grad-stop-hex {
  flex: 1; background: var(--surface2); border: 1.5px solid var(--border);
  border-radius: 6px; color: var(--text); font-size: 11.5px; font-weight: 700;
  font-family: monospace; padding: 5px 7px; outline: none; text-transform: uppercase;
  transition: border-color 0.13s;
}
.ttim-grad-stop-hex:focus { border-color: var(--accent); }
.ttim-grad-stop-remove {
  background: none; border: none; color: var(--muted); cursor: pointer;
  padding: 4px; border-radius: 5px; display: flex; transition: color 0.13s, background 0.13s;
}
.ttim-grad-stop-remove:hover { color: #ef4444; background: #fef2f2; }

.ttim-add-stop-btn {
  width: 100%; padding: 7px; font-size: 11.5px; font-weight: 700;
  background: var(--surface2); border: 1.5px dashed var(--border2);
  border-radius: 8px; color: var(--muted); cursor: pointer;
  transition: border-color 0.13s, color 0.13s, background 0.13s;
}
.ttim-add-stop-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--act); }

/* ===== GRADIENT PRESETS ===== */
.ttim-grad-presets { display: grid; grid-template-columns: repeat(4,1fr); gap: 6px; }
.ttim-grad-preset-swatch {
  aspect-ratio: 2/1; border-radius: 7px; cursor: pointer;
  border: 1.5px solid transparent; box-shadow: var(--shadow-sm);
  transition: transform 0.13s, border-color 0.13s;
}
.ttim-grad-preset-swatch:hover { transform: scale(1.06); border-color: var(--border2); }
.ttim-grad-preset-swatch.ttim-swatch-active { border-color: var(--accent); }

/* ===== RAINBOW PREVIEW ===== */
.ttim-rainbow-preview {
  font-size: 24px; font-weight: 900; letter-spacing: 4px; text-align: center;
  padding: 14px 8px; background: var(--surface2); border-radius: 10px;
  margin-top: 10px; border: 1.5px solid var(--border);
}

/* ===== CUSTOM CHAR COLORS ===== */
.ttim-char-colors { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 9px; }
.ttim-char-color-swatch {
  width: 32px; height: 32px; border-radius: 7px; border: 1.5px solid var(--border);
  cursor: pointer; position: relative; transition: transform 0.13s; box-shadow: var(--shadow-sm);
}
.ttim-char-color-swatch:hover { transform: scale(1.1); }
.ttim-char-color-swatch input[type=color] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%;
}
.ttim-char-color-remove {
  position: absolute; top: -6px; right: -6px; width: 15px; height: 15px;
  background: #ef4444; border: none; border-radius: 50%; color: #fff;
  font-size: 9px; cursor: pointer; display: flex; align-items: center;
  justify-content: center; font-weight: 800; opacity: 0; transition: opacity 0.13s;
}
.ttim-char-color-swatch:hover .ttim-char-color-remove { opacity: 1; }

/* ===== EFFECTS ===== */
.ttim-effect-block {
  background: var(--surface); border-radius: 10px; overflow: hidden;
  margin-bottom: 9px; border: 1.5px solid var(--border); transition: border-color 0.15s;
}
.ttim-effect-block:has(input:checked) {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(101,87,255,0.09);
}
.ttim-effect-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; background: var(--surface2);
}
.ttim-effect-name {
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 700; color: var(--text);
}
.ttim-effect-body { padding: 11px 12px 13px; }
.ttim-effect-body-hidden { display: none; }

/* Toggle */
.ttim-toggle { position: relative; display: inline-block; width: 36px; height: 20px; flex-shrink: 0; }
.ttim-toggle input { opacity: 0; width: 0; height: 0; }
.ttim-toggle-track {
  position: absolute; inset: 0; background: var(--border2); border-radius: 20px;
  transition: background 0.18s; cursor: pointer;
}
.ttim-toggle-track::before {
  content: ''; position: absolute; height: 14px; width: 14px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: transform 0.18s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.ttim-toggle input:checked + .ttim-toggle-track { background: var(--accent); }
.ttim-toggle input:checked + .ttim-toggle-track::before { transform: translateX(16px); }

/* Info box */
.ttim-info-box {
  display: flex; align-items: flex-start; gap: 7px; font-size: 11.5px; color: var(--muted);
  background: var(--surface2); border-radius: 8px; padding: 9px 11px; margin-bottom: 11px;
  line-height: 1.5; border: 1px solid var(--border);
}

/* ===== BG PANEL ===== */
.ttim-upload-area {
  display: flex; flex-direction: column; align-items: center; gap: 7px; padding: 18px;
  background: var(--surface2); border: 2px dashed var(--border2); border-radius: 10px;
  cursor: pointer; color: var(--muted); font-size: 12px; font-weight: 600;
  position: relative; transition: border-color 0.13s, color 0.13s, background 0.13s; margin-bottom: 11px;
}
.ttim-upload-area:hover { border-color: var(--accent); color: var(--accent); background: var(--act); }
.ttim-upload-input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }

.ttim-bg-image-preview { position: relative; margin-bottom: 11px; }
.ttim-bg-image-preview img { width: 100%; height: 76px; object-fit: cover; border-radius: 8px; border: 1.5px solid var(--border); }
.ttim-remove-bg-img {
  position: absolute; top: 6px; right: 6px; padding: 3px 10px; font-size: 10.5px; font-weight: 700;
  background: rgba(255,255,255,0.9); color: var(--text); border: 1px solid var(--border2);
  border-radius: 20px; cursor: pointer; transition: background 0.13s, color 0.13s; backdrop-filter: blur(4px);
}
.ttim-remove-bg-img:hover { background: #ef4444; color: #fff; border-color: #ef4444; }

/* ===== SIZE PANEL ===== */
.ttim-size-presets { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-bottom: 3px; }
.ttim-size-preset-btn {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 10px 7px; background: var(--surface2); border: 1.5px solid var(--border);
  border-radius: 10px; cursor: pointer; color: var(--muted); font-size: 10px;
  font-weight: 700; text-align: center; line-height: 1.3;
  transition: border-color 0.13s, color 0.13s, background 0.13s;
}
.ttim-size-preset-btn:hover { border-color: var(--border2); color: var(--text); }
.ttim-size-preset-btn.ttim-size-active { border-color: var(--accent); background: var(--act); color: var(--accent); }
.ttim-size-preset-icon { display: block; background: var(--muted); opacity: 0.4; border-radius: 2px; margin-bottom: 1px; }
.ttim-size-preset-btn.ttim-size-active .ttim-size-preset-icon { opacity: 1; background: var(--accent); }

.ttim-apply-size-btn {
  width: 100%; padding: 10px; font-size: 12px; font-weight: 700;
  background: var(--accent); border: none; border-radius: 10px; color: #fff;
  cursor: pointer; margin-top: 10px; transition: opacity 0.13s, box-shadow 0.13s;
  box-shadow: 0 2px 10px rgba(101,87,255,0.3);
}
.ttim-apply-size-btn:hover { opacity: 0.9; box-shadow: 0 4px 16px rgba(101,87,255,0.4); }

/* ===== CANVAS AREA ===== */
.ttim-canvas-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.ttim-canvas-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow: hidden;
  position: relative;
  /* Dot-grid workspace */
  background-color: #E9EDF8;
  background-image: radial-gradient(circle, #BFC9E6 1px, transparent 1px);
  background-size: 22px 22px;
}
/* Vignette frame */
.ttim-canvas-wrapper::after {
  content: '';
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 50%, rgba(210,218,240,0.55) 100%);
}

#ttimCanvas {
  display: block;
  max-width: calc(100% - 24px);
  max-height: calc(100% - 24px);
  border-radius: 5px;
  box-shadow: 0 0 0 1px rgba(100,116,180,0.14), 0 8px 36px rgba(27,29,44,0.2), 0 2px 8px rgba(27,29,44,0.1);
  position: relative;
  z-index: 1;
}

/* ===== DOWNLOAD BAR ===== */
.ttim-dl-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  gap: 10px;
}
.ttim-dl-info {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; font-weight: 700; color: var(--muted);
  font-family: 'Space Grotesk', monospace;
  background: var(--surface2); padding: 4px 10px; border-radius: 20px;
  border: 1px solid var(--border); white-space: nowrap; flex-shrink: 0;
}
.ttim-reset-pos-btn {
  display: flex; align-items: center; gap: 3px;
  font-size: 10px; font-weight: 700; color: var(--muted);
  background: none; border: 1px solid var(--border); border-radius: 10px;
  padding: 2px 7px; cursor: pointer; transition: color 0.13s, border-color 0.13s;
  line-height: 1;
}
.ttim-reset-pos-btn:hover { color: var(--accent); border-color: var(--accent); }
.ttim-dl-btns { display: flex; gap: 8px; align-items: center; }
.ttim-fmt-pills {
  display: flex; gap: 4px; align-items: center;
  background: var(--surface2); border: 1.5px solid var(--border);
  border-radius: 20px; padding: 3px;
}
.ttim-fmt-pill {
  padding: 4px 10px; font-size: 11px; font-weight: 700;
  background: none; border: none; border-radius: 14px;
  color: var(--muted); cursor: pointer;
  transition: background 0.13s, color 0.13s;
  letter-spacing: 0.01em; white-space: nowrap;
}
.ttim-fmt-pill:hover { color: var(--text); background: var(--hover); }
.ttim-fmt-pill.is-active {
  background: var(--surface); color: var(--accent);
  box-shadow: 0 1px 4px rgba(0,0,0,0.10);
}
.ttim-dl-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 7px 14px; font-size: 12px; font-weight: 700;
  background: var(--surface2); border: 1.5px solid var(--border);
  border-radius: 20px; color: var(--text); cursor: pointer;
  transition: border-color 0.13s, background 0.13s, transform 0.1s;
  letter-spacing: 0.01em;
}
.ttim-dl-btn:hover { border-color: var(--border2); background: var(--hover); }
.ttim-dl-btn:active { transform: scale(0.97); }
.ttim-dl-btn.ttim-dl-primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%);
  border-color: transparent; color: #fff;
  box-shadow: 0 2px 12px rgba(101,87,255,0.35);
  padding: 7px 20px;
}
.ttim-dl-btn.ttim-dl-primary:hover {
  opacity: 0.91; border-color: transparent;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent2) 100%);
}

/* =============================================
   RESPONSIVE — Mobile-first stacking
   ============================================= */

/* Tablet: panels get a bit narrower */
@media (max-width: 1024px) {
  .ttim-root { max-width: 100%; border-radius: 0; border-left: none; border-right: none; margin: 0 0 48px; }
  .ttim-root::before { border-radius: 0; }
}

/* Mobile: app-style — controls at top, canvas preview at bottom */
@media (max-width: 767px) {
  .ttim-workspace {
    flex-direction: column;
    height: auto;
  }
  /* Controls first (tabs → panel), canvas at bottom */
  .ttim-sidenav    { order: 1; }
  .ttim-panel-wrap { order: 2; }
  .ttim-canvas-area { order: 3; }

  /* Sidenav: horizontal tab strip at top of workspace */
  .ttim-sidenav {
    width: 100%;
    flex-direction: row;
    justify-content: flex-start;
    padding: 0 10px;
    overflow-x: auto;
    scrollbar-width: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    gap: 2px;
    min-height: 50px;
  }
  .ttim-sidenav::-webkit-scrollbar { display: none; }
  .ttim-nav-btn {
    flex-direction: row;
    gap: 5px;
    padding: 8px 12px;
    white-space: nowrap;
    font-size: 11px;
    width: auto;
    border-radius: 8px;
    flex-shrink: 0;
  }
  .ttim-nav-btn svg { width: 16px; height: 16px; }
  /* Active tab: bottom border indicator */
  .ttim-nav-btn.ttim-nav-active::after {
    left: 20%; right: 20%; top: auto; bottom: -1px;
    width: auto; height: 2px;
    border-radius: 2px 2px 0 0;
  }

  /* Panel: taller scrollable area */
  .ttim-panel-wrap {
    width: 100%;
    max-height: 320px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  /* Canvas: compact preview at bottom */
  .ttim-canvas-wrapper {
    height: min(50vw, 280px);
    min-height: 180px;
    flex: none;
    padding: 10px;
  }

  /* Download bar */
  .ttim-dl-bar { padding: 8px 12px; gap: 7px; }
  .ttim-dl-info { font-size: 10px; }
  .ttim-dl-btn { font-size: 11px; padding: 6px 10px; }
  .ttim-dl-btn.ttim-dl-primary { padding: 6px 14px; }
  .ttim-fmt-pill { padding: 3px 8px; font-size: 10px; }

  /* Preset bar: smaller cards */
  .ttim-preset-bar { padding: 10px 12px; gap: 8px; }
  .ttim-preset-thumb { width: 76px; height: 48px; }
  .ttim-preset-label { font-size: 10px; padding: 4px 8px 6px; }

  /* Swatches: 6 columns on small screens */
  .ttim-swatch-grid { grid-template-columns: repeat(6,1fr); }
  .ttim-grad-presets { grid-template-columns: repeat(3,1fr); }
}

/* Very small phones */
@media (max-width: 400px) {
  .ttim-dl-btn { font-size: 11px; padding: 6px 12px; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .ttim-preset-btn, .ttim-nav-btn, .ttim-dl-btn, .ttim-swatch { transition: none; }
}
