/* ===== Desktop / Tablet (mặc định) ===== */
.af-wrap {
  max-width: 720px;
  margin: 16px auto;
  padding: 0 12px;
  font-family: system-ui, Arial;
  position: relative;
}

/* Toolbar dùng Grid tự co giãn */
.af-toolbar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  align-items: stretch;
  margin-bottom: 12px;
  position: relative;
  z-index: 50;
}
.af-title {
  grid-column: 1 / -1;
  font-weight: 600;
  color: #333;
}

/* Nút & input file */
.af-btn,
.af-input-file {
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
  text-align: center;
}
.af-btn:hover { background: #f7f7f7; }
.af-input-file { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* Canvas 1:1 */
.af-canvas-wrap {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #f3f3f3;
  border-radius: 14px;
  overflow: hidden;
  position: relative;
}
.af-canvas-wrap canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.af-hint { color:#666; font-size: 12px; margin-top: 10px; }

/* ===== Mobile full-bleed (<= 768px) ===== */
@media (max-width: 768px) {
  /* Bẻ ra khỏi container của theme để tràn full màn hình */
  .af-wrap {
    max-width: none;
    width: 100vw;
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    padding: 0;
  }
  .af-toolbar { padding: 8px 12px; gap: 8px; }
  .af-btn, .af-input-file { padding: 9px 10px; border-radius: 10px; }

  /* Canvas full chiều ngang màn hình, bỏ bo góc cho cảm giác liền viền */
  .af-canvas-wrap {
    width: 100vw;
    border-radius: 0;
  }

  /* Hint giữ lề cho dễ đọc */
  .af-hint { padding: 0 12px; }
}

/* Màn hình rất nhỏ */
@media (max-width: 400px) {
  .af-toolbar { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
}
